Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • holic

    Scripter
    • Posts

      639
    • Joined

    • Last visited

    • Days Won

      20

    Reputation Activity

    1. Like
      holic got a reaction from Szarikov in Fightaholic - The scrappy AIO fightin' script - Interaction Before Fight Added   
      Fightaholic - The scrappy AIO fightin' script


       
       

      Bug Reports - READ THIS FIRST
      To submit a bug report, please do the following. Failing to do so may result in being ignored all together. These are simple requests
      Ensure you're on the latest version first Explain your problem as clearly and concise as possible Share the error Share what settings you are using by setting up the script, saving your config to a file and pasting it here or PM me.  
       
       
      Description
      Fights shit, like anything, eats, banks, loots, buries bones, switches combat styles, etc. Very easy to setup but a complex script nonetheless.
      Setup
      Selecting your NPC(s) is required. All other options are optional. Click Refresh to auto-fill the form and get available NPCs Click Start Troubleshooting
      StackoverflowError: Give more memory to DreamBot on launch (slider above "Launch" button) Images failed to download: Manually download them below this post and extract the files to "~/DreamBot/Scripts/Fightaholic" Chinese users will almost certainly need to download these Main features
      Extremely simple setup: simple GUI that auto-fills the fields for you as much as possible. Combat switching: supports all combat types (ie Melee, Range and Magic) Click on-screen "Switch" to switch styles whenever Right-click on-screen "Switch" to manually choose which style to use Buys missing items from GE: if any equipment, food, runes, arrows, potions or required items are missing, it will walk to the GE and attempt to buy them Script will end if you lack the resources to afford your items Script will buy equipment upgrades when specified. Sells loot at GE: select looted items to sell in the "Loot" tab. Will attempt to sell items first for cash before buying missing items Script will only show loot options in the list, to add custom items edit the .ini file manually. Level targets: stops training combat style when your desired level is reached Drinks potions: don't include the number of doses ("Strength potion", not "Strength potion(4)"), won't use Prayer potions until your prayer is almost drained Add antivenom potion to your inventory or required items and it will automatically cure you when necessary. Optional: Check drop vials to get rid of them Uses prayer: Select one or many prayers to use. Quick prayers and quick prayer setup supported Dungeons supported: Edgeville (with or without Brass key, add key to required items), Dwarven Mines, Asgarnian Ice Dungeon, Karamja Dungeon, Varrock Sewers Equipment switching: supports switching equipment when changing combat style Withdraws equipment if missing Upgrades equipment when specified (either have it in your bank or select "Buy upgradeable equipment"), use "^" as the upgrade wildcard. "^ scimitar" or "^ shortbow". DOESN'T WORK FOR ALL ITEMS. High Alch support: choose what to loot and in the opposite column choose which items to alch and the script will take care of the rest Multiple loot options: change the frequency of looting, style of looting and what to loot Supports options like loot by price and blacklist Ironman loot option: loot only what your NPC drops Features item blacklist to prevent looting the wrong items when looting by a price threshold Death walking / Grave looting: handles deaths by returning, collecting your grave, re-equipping equipment and continuing Still zero deaths to date with this script but will handle it once it happens Option to logout on death so you can handle it yourself Collects and equips arrows: makes sure you don't run out of arrows, checks your bank for more if needed. Safe spotting: set your "Target area" to below 3 and the script will automatically safe-spot Aggro support: check the "Aggro mode" checkbox when dealing with monster like Rock Crabs, who will become tame and impossible to fight after a certain amount of time. This will do its best to leave the area, rest and return to continue the fight. GIVE IT TIME TO DO ITS THING. This will not prefer AFK training over active training but will still allow for AFK training. Buries bones: all bones supported, you can also specify to bury only certain bones. Eats food: what kind of fighter would this be if it didn't eat when necessary, right? Bones to Peaches: experimental but should work. If it isn't, please screen record it or at least share the error from your console with me. Bones to Bananas: experimental but should work. If it isn't, please screen record it or at least share the error from your console with me. Customize bank locations: set the bank you'd like to use, or just set it to the closest and let the script handle it for you. Custom random-event handler: Talks to Genie, Old-Man, Drunken Dwarf , Frog, Freaky Forester and Rick Turpentine to collect their goodies and a delay for all other randoms to be more human-like Lamps will be used to increase your current combat skill Random handler will only fire if you have selected "Dismiss Randoms" in DreamBot's settings Anti-Ban: Bunch of features to keep your accounts safe Comprehensive obstacle handler:  meaning you can start this script just about anywhere and the script will navigate Gielinor to your specified area Quickstart support: Parameters: "path\to\config.ini" Example: Windows: java -jar C:\Users\USERNAME\DreamBot\BotData\client.jar -script Fightaholic -params "C:\Users\USERNAME\Desktop\CONFIG.ini" Linux:
      java -jar ~/BotData/client.jar -script Fightaholic -params "C:/Users/USERNAME/CONFIG.ini"  
      More to be included in this list that are already in the script.


      *Temporarily disabled Script information
      Click "Refresh" once logged in to see NPCs and auto-fill the script. Select the NPCs you want, and their potential drops will be listed below This is the only required setting. Select the loot you want. Click "Add" to add combat level targets, these skills will be trained until the specified target is reached. If you want to set a Magic level target, you can only do that with the first level target currently (because I'm lazy). If you want to use different equipment, fill out and select "Use" per equipment setup Arrows, bows, staves, melee weapons, shield and food should automatically be detected and filled out in their respective textfields Check "Use bank" to bank when inventory is full or out of food/arrows/runes Your target area will be set to the tile you are standing on when you click the "Start" button if no tile is set.
      OR you can set the tile in the "Optional" tab and have the script walk there next time on start (provided you save the info) Set your target area to below 3 and the script will automatically safe-spot All other setup options have explanatory tool-tips (if you hover over them) and aren't required.
        Item Support
      These are items that will be automatically recognized in your settings

      GUI
      As of version 0.941

      Progress Reports
      27 hours                                        3 days                                                  all using overnight+1hr breaks
        

        
       
        Changelog (For updates beyond version 1.0, please search this topic for "SDN Bot")
       




      Fightaholic images.zip
       
       

    2. Like
      holic got a reaction from btksurfjohn in Fightaholic - The scrappy AIO fightin' script - Interaction Before Fight Added   
      Fightaholic - The scrappy AIO fightin' script


       
       

      Bug Reports - READ THIS FIRST
      To submit a bug report, please do the following. Failing to do so may result in being ignored all together. These are simple requests
      Ensure you're on the latest version first Explain your problem as clearly and concise as possible Share the error Share what settings you are using by setting up the script, saving your config to a file and pasting it here or PM me.  
       
       
      Description
      Fights shit, like anything, eats, banks, loots, buries bones, switches combat styles, etc. Very easy to setup but a complex script nonetheless.
      Setup
      Selecting your NPC(s) is required. All other options are optional. Click Refresh to auto-fill the form and get available NPCs Click Start Troubleshooting
      StackoverflowError: Give more memory to DreamBot on launch (slider above "Launch" button) Images failed to download: Manually download them below this post and extract the files to "~/DreamBot/Scripts/Fightaholic" Chinese users will almost certainly need to download these Main features
      Extremely simple setup: simple GUI that auto-fills the fields for you as much as possible. Combat switching: supports all combat types (ie Melee, Range and Magic) Click on-screen "Switch" to switch styles whenever Right-click on-screen "Switch" to manually choose which style to use Buys missing items from GE: if any equipment, food, runes, arrows, potions or required items are missing, it will walk to the GE and attempt to buy them Script will end if you lack the resources to afford your items Script will buy equipment upgrades when specified. Sells loot at GE: select looted items to sell in the "Loot" tab. Will attempt to sell items first for cash before buying missing items Script will only show loot options in the list, to add custom items edit the .ini file manually. Level targets: stops training combat style when your desired level is reached Drinks potions: don't include the number of doses ("Strength potion", not "Strength potion(4)"), won't use Prayer potions until your prayer is almost drained Add antivenom potion to your inventory or required items and it will automatically cure you when necessary. Optional: Check drop vials to get rid of them Uses prayer: Select one or many prayers to use. Quick prayers and quick prayer setup supported Dungeons supported: Edgeville (with or without Brass key, add key to required items), Dwarven Mines, Asgarnian Ice Dungeon, Karamja Dungeon, Varrock Sewers Equipment switching: supports switching equipment when changing combat style Withdraws equipment if missing Upgrades equipment when specified (either have it in your bank or select "Buy upgradeable equipment"), use "^" as the upgrade wildcard. "^ scimitar" or "^ shortbow". DOESN'T WORK FOR ALL ITEMS. High Alch support: choose what to loot and in the opposite column choose which items to alch and the script will take care of the rest Multiple loot options: change the frequency of looting, style of looting and what to loot Supports options like loot by price and blacklist Ironman loot option: loot only what your NPC drops Features item blacklist to prevent looting the wrong items when looting by a price threshold Death walking / Grave looting: handles deaths by returning, collecting your grave, re-equipping equipment and continuing Still zero deaths to date with this script but will handle it once it happens Option to logout on death so you can handle it yourself Collects and equips arrows: makes sure you don't run out of arrows, checks your bank for more if needed. Safe spotting: set your "Target area" to below 3 and the script will automatically safe-spot Aggro support: check the "Aggro mode" checkbox when dealing with monster like Rock Crabs, who will become tame and impossible to fight after a certain amount of time. This will do its best to leave the area, rest and return to continue the fight. GIVE IT TIME TO DO ITS THING. This will not prefer AFK training over active training but will still allow for AFK training. Buries bones: all bones supported, you can also specify to bury only certain bones. Eats food: what kind of fighter would this be if it didn't eat when necessary, right? Bones to Peaches: experimental but should work. If it isn't, please screen record it or at least share the error from your console with me. Bones to Bananas: experimental but should work. If it isn't, please screen record it or at least share the error from your console with me. Customize bank locations: set the bank you'd like to use, or just set it to the closest and let the script handle it for you. Custom random-event handler: Talks to Genie, Old-Man, Drunken Dwarf , Frog, Freaky Forester and Rick Turpentine to collect their goodies and a delay for all other randoms to be more human-like Lamps will be used to increase your current combat skill Random handler will only fire if you have selected "Dismiss Randoms" in DreamBot's settings Anti-Ban: Bunch of features to keep your accounts safe Comprehensive obstacle handler:  meaning you can start this script just about anywhere and the script will navigate Gielinor to your specified area Quickstart support: Parameters: "path\to\config.ini" Example: Windows: java -jar C:\Users\USERNAME\DreamBot\BotData\client.jar -script Fightaholic -params "C:\Users\USERNAME\Desktop\CONFIG.ini" Linux:
      java -jar ~/BotData/client.jar -script Fightaholic -params "C:/Users/USERNAME/CONFIG.ini"  
      More to be included in this list that are already in the script.


      *Temporarily disabled Script information
      Click "Refresh" once logged in to see NPCs and auto-fill the script. Select the NPCs you want, and their potential drops will be listed below This is the only required setting. Select the loot you want. Click "Add" to add combat level targets, these skills will be trained until the specified target is reached. If you want to set a Magic level target, you can only do that with the first level target currently (because I'm lazy). If you want to use different equipment, fill out and select "Use" per equipment setup Arrows, bows, staves, melee weapons, shield and food should automatically be detected and filled out in their respective textfields Check "Use bank" to bank when inventory is full or out of food/arrows/runes Your target area will be set to the tile you are standing on when you click the "Start" button if no tile is set.
      OR you can set the tile in the "Optional" tab and have the script walk there next time on start (provided you save the info) Set your target area to below 3 and the script will automatically safe-spot All other setup options have explanatory tool-tips (if you hover over them) and aren't required.
        Item Support
      These are items that will be automatically recognized in your settings

      GUI
      As of version 0.941

      Progress Reports
      27 hours                                        3 days                                                  all using overnight+1hr breaks
        

        
       
        Changelog (For updates beyond version 1.0, please search this topic for "SDN Bot")
       




      Fightaholic images.zip
       
       

    3. Like
      holic got a reaction from alvarengas in Fightaholic - The scrappy AIO fightin' script - Interaction Before Fight Added   
      Fightaholic - The scrappy AIO fightin' script


       
       

      Bug Reports - READ THIS FIRST
      To submit a bug report, please do the following. Failing to do so may result in being ignored all together. These are simple requests
      Ensure you're on the latest version first Explain your problem as clearly and concise as possible Share the error Share what settings you are using by setting up the script, saving your config to a file and pasting it here or PM me.  
       
       
      Description
      Fights shit, like anything, eats, banks, loots, buries bones, switches combat styles, etc. Very easy to setup but a complex script nonetheless.
      Setup
      Selecting your NPC(s) is required. All other options are optional. Click Refresh to auto-fill the form and get available NPCs Click Start Troubleshooting
      StackoverflowError: Give more memory to DreamBot on launch (slider above "Launch" button) Images failed to download: Manually download them below this post and extract the files to "~/DreamBot/Scripts/Fightaholic" Chinese users will almost certainly need to download these Main features
      Extremely simple setup: simple GUI that auto-fills the fields for you as much as possible. Combat switching: supports all combat types (ie Melee, Range and Magic) Click on-screen "Switch" to switch styles whenever Right-click on-screen "Switch" to manually choose which style to use Buys missing items from GE: if any equipment, food, runes, arrows, potions or required items are missing, it will walk to the GE and attempt to buy them Script will end if you lack the resources to afford your items Script will buy equipment upgrades when specified. Sells loot at GE: select looted items to sell in the "Loot" tab. Will attempt to sell items first for cash before buying missing items Script will only show loot options in the list, to add custom items edit the .ini file manually. Level targets: stops training combat style when your desired level is reached Drinks potions: don't include the number of doses ("Strength potion", not "Strength potion(4)"), won't use Prayer potions until your prayer is almost drained Add antivenom potion to your inventory or required items and it will automatically cure you when necessary. Optional: Check drop vials to get rid of them Uses prayer: Select one or many prayers to use. Quick prayers and quick prayer setup supported Dungeons supported: Edgeville (with or without Brass key, add key to required items), Dwarven Mines, Asgarnian Ice Dungeon, Karamja Dungeon, Varrock Sewers Equipment switching: supports switching equipment when changing combat style Withdraws equipment if missing Upgrades equipment when specified (either have it in your bank or select "Buy upgradeable equipment"), use "^" as the upgrade wildcard. "^ scimitar" or "^ shortbow". DOESN'T WORK FOR ALL ITEMS. High Alch support: choose what to loot and in the opposite column choose which items to alch and the script will take care of the rest Multiple loot options: change the frequency of looting, style of looting and what to loot Supports options like loot by price and blacklist Ironman loot option: loot only what your NPC drops Features item blacklist to prevent looting the wrong items when looting by a price threshold Death walking / Grave looting: handles deaths by returning, collecting your grave, re-equipping equipment and continuing Still zero deaths to date with this script but will handle it once it happens Option to logout on death so you can handle it yourself Collects and equips arrows: makes sure you don't run out of arrows, checks your bank for more if needed. Safe spotting: set your "Target area" to below 3 and the script will automatically safe-spot Aggro support: check the "Aggro mode" checkbox when dealing with monster like Rock Crabs, who will become tame and impossible to fight after a certain amount of time. This will do its best to leave the area, rest and return to continue the fight. GIVE IT TIME TO DO ITS THING. This will not prefer AFK training over active training but will still allow for AFK training. Buries bones: all bones supported, you can also specify to bury only certain bones. Eats food: what kind of fighter would this be if it didn't eat when necessary, right? Bones to Peaches: experimental but should work. If it isn't, please screen record it or at least share the error from your console with me. Bones to Bananas: experimental but should work. If it isn't, please screen record it or at least share the error from your console with me. Customize bank locations: set the bank you'd like to use, or just set it to the closest and let the script handle it for you. Custom random-event handler: Talks to Genie, Old-Man, Drunken Dwarf , Frog, Freaky Forester and Rick Turpentine to collect their goodies and a delay for all other randoms to be more human-like Lamps will be used to increase your current combat skill Random handler will only fire if you have selected "Dismiss Randoms" in DreamBot's settings Anti-Ban: Bunch of features to keep your accounts safe Comprehensive obstacle handler:  meaning you can start this script just about anywhere and the script will navigate Gielinor to your specified area Quickstart support: Parameters: "path\to\config.ini" Example: Windows: java -jar C:\Users\USERNAME\DreamBot\BotData\client.jar -script Fightaholic -params "C:\Users\USERNAME\Desktop\CONFIG.ini" Linux:
      java -jar ~/BotData/client.jar -script Fightaholic -params "C:/Users/USERNAME/CONFIG.ini"  
      More to be included in this list that are already in the script.


      *Temporarily disabled Script information
      Click "Refresh" once logged in to see NPCs and auto-fill the script. Select the NPCs you want, and their potential drops will be listed below This is the only required setting. Select the loot you want. Click "Add" to add combat level targets, these skills will be trained until the specified target is reached. If you want to set a Magic level target, you can only do that with the first level target currently (because I'm lazy). If you want to use different equipment, fill out and select "Use" per equipment setup Arrows, bows, staves, melee weapons, shield and food should automatically be detected and filled out in their respective textfields Check "Use bank" to bank when inventory is full or out of food/arrows/runes Your target area will be set to the tile you are standing on when you click the "Start" button if no tile is set.
      OR you can set the tile in the "Optional" tab and have the script walk there next time on start (provided you save the info) Set your target area to below 3 and the script will automatically safe-spot All other setup options have explanatory tool-tips (if you hover over them) and aren't required.
        Item Support
      These are items that will be automatically recognized in your settings

      GUI
      As of version 0.941

      Progress Reports
      27 hours                                        3 days                                                  all using overnight+1hr breaks
        

        
       
        Changelog (For updates beyond version 1.0, please search this topic for "SDN Bot")
       




      Fightaholic images.zip
       
       

    4. Like
      holic reacted to mgiven95 in Alclueholic - A beginner clue scroll solver - Re-written!   
      Really good script so far, just a note off of one run:
       
      When doing hot/cold, it walks to location, but doesn't always click on strange device to verify before moving on.
      Once it found the correct location and dug, we received a new clue scroll.
      The bot continued to dig around it for a few moments before i manually had to stop it. (I only waited about 15 seconds as I was babysitting)
       
      A lot better than the other easy clue scroll script!
    5. Like
      holic got a reaction from tjet in Alclueholic - A beginner clue scroll solver - Re-written!   
      Version 1.08 should be available from the SDN now! Let me know anyone hits any bugs
    6. Like
      holic got a reaction from BeeMan42069 in Alclueholic - A beginner clue scroll solver - Re-written!   
      Alclueholic
      "It's like an alcoholic, but for clue scrolls"

       
      Description
      A simple beginner clue scroll solver. Completes scrolls in 2 to 10 minutes, depending on complexity.
       
      Setup
      Have a clue scroll either in your inventory or bank Meet all item and level requirements Click start
        Features
      Quick-start support - Requires no interaction to start the script, can even be executed from within another script. Optional quick-start parameters o, open: boolean; toggles the option to open your casket at the end of the script c, check: boolean; toggles the option to check your bank for a clue scroll if there isn't one in your inventory (ideal for running in tandem with other scripts) p, plugin: boolean; set to true if run in tandem with another script to move the paint's location on screen as to not overlap the other script's paint. Teleportation - If you meet the level & item requirements for a teleport the script will cast it when appropriate. Uses home teleport only when possible. Gathers missing items - See below for full list Custom mouse movement algorithm - A combination of the two algorithms I posted which builds a "profile" for each account to create a unique play-style for each bot Anti-ban - Randomized movements, actions and sleeps to add onto the unique play-style of each bot. Start anywhere - Custom walking utility lets you start the script anywhere you'd like, even places that don't have walk nodes!
        Skill requirements
      15 Smithing: To smith an iron dagger for Charlie 15 Mining: To mine some a iron ore for Charlie 18 Crafting: To craft a leather body/chaps for Charlie 20 Cooking: To cook a trout/pike for Charlie Will catch the required fish if not found in the bank (Note: level 25 fishing required to catch a pike) 20 Fishing: To catch a raw trout/herring for Charlie Will also be potentially required to cook Charlie a trout if you don't have any in the bank
        Item requirements - must be in bank or inventory
       
      Optional items - these items will be grabbed by the script if they aren't in your bank and the rest will be purchased
      Spade Strange device Bronze axe Bronze pickaxe
         
      Mining iron for Charlie, but first getting a pickaxe from a spawn, then fishing for a herring for Charlie, then withdrawing a Chef's hat and cheering at Iffie


       
      Changelog
       
       

    7. Like
      holic got a reaction from boomslap in WindMouse - Custom Mouse Movement Algorithm   
      Hey all,
      Since DB3 officially supports custom mouse algorithms I thought I would port over a classic one: WindMouse.
      WindMouse was written by BenLand100 for SCAR some years back (maybe 10 years?) and has been used on so many damn bots throughout the years because it functions really well so it only seemed right to bring it here.
      In the source code below, there are two implementations of WindMouse:
      Point windMouse(int x, int y) Which comes directly from the SMART github with minor adjustments to work with DB3.
      Better in fixed mode.
        void windMouse2(Point point) My tweaked version from years back that supports all screen sizes.
      I've added a random point between the original and the destination point if the distance between them is large to feel more human but has a 50% chance of happening. By default my implementation is the active algorithm (as it handles all sizes), swap the comments in handleMovement to change to the original.
       
      To use it, simply add the file WindMouse.java to your project and add the following to your onStart method:
      Client.getInstance().setMouseMovementAlgorithm(new WindMouse());  
      All credits go to Benjamin J. Land a.k.a. BenLand100
      WindMouse.java:
      /** * WindMouse from SMART by Benland100 * Copyright to Benland100, (Benjamin J. Land) * * Prepped for DreamBot 3 **/ import org.dreambot.api.Client; import org.dreambot.api.input.Mouse; import org.dreambot.api.input.mouse.algorithm.MouseMovementAlgorithm; import org.dreambot.api.input.mouse.destination.AbstractMouseDestination; import org.dreambot.api.methods.Calculations; import org.dreambot.api.methods.input.mouse.MouseSettings; import java.awt.*; import static java.lang.Thread.sleep; public class WindMouse implements MouseMovementAlgorithm { private int _mouseSpeed = MouseSettings.getSpeed() > 15 ? MouseSettings.getSpeed() - 10 : 15; private int _mouseSpeedLow = Math.round(_mouseSpeed / 2); private int _mouseGravity = Calculations.random(4, 20); private int _mouseWind = Calculations.random(1, 10); @Override public boolean handleMovement(AbstractMouseDestination abstractMouseDestination) { //Get a suitable point for the mouse's destination Point suitPos = abstractMouseDestination.getSuitablePoint(); // Select which implementation of WindMouse you'd like to use // by uncommenting out the line you want to use below: //windMouse(suitPos.x, suitPos.y); //Original implementation windMouse2(suitPos); //Tweaked implementation return distance(Client.getMousePosition(), suitPos) < 2; } public static void sleep(int min, int max) { try { Thread.sleep(Calculations.random(min,max)); } catch (InterruptedException e) { log(e.getMessage()); } } public static void sleep(int ms) { try { Thread.sleep(ms); } catch (InterruptedException e) { log(e.getMessage()); } } /** * Tweaked implementation of WindMouse * Moves to a mid point on longer moves to seem a little more human-like * Remove the if statement below if you'd rather straighter movement * @param point The destination point */ public void windMouse2(Point point) { Point curPos = Client.getMousePosition(); if (distance(point, curPos) > 250 && Calculations.random(1) == 2) { Point rp = randomPoint(point, curPos); windMouse2(curPos.x, curPos.y, rp.x, rp.y, _mouseGravity, _mouseWind, _mouseSpeed, Calculations.random(5, 25)); sleep(1, 150); } windMouse2(curPos.x, curPos.y, point.x, point.y, _mouseGravity, _mouseWind, _mouseSpeed, Calculations.random(5, 25)); _mouseGravity = Calculations.random(4, 20); _mouseWind = Calculations.random(1, 10); _mouseSpeed = Calculations.random(_mouseSpeedLow, MouseSettings.getSpeed()); } /** * Tweaked implementation of WindMouse by holic * All credit to Benjamin J. Land for the original. (see below) * * @param xs The x start * @param ys The y start * @param xe The x destination * @param ye The y destination * @param gravity Strength pulling the position towards the destination * @param wind Strength pulling the position in random directions * @param targetArea Radius of area around the destination that should * trigger slowing, prevents spiraling */ private void windMouse2(double xs, double ys, double xe, double ye, double gravity, double wind, double speed, double targetArea) { double dist, veloX = 0, veloY = 0, windX = 0, windY = 0; double sqrt2 = Math.sqrt(2); double sqrt3 = Math.sqrt(3); double sqrt5 = Math.sqrt(5); int tDist = (int) distance(xs, ys, xe, ye); long t = System.currentTimeMillis() + 10000; while (!(Math.hypot((xs - xe), (ys - ye)) < 1)) { if (System.currentTimeMillis() > t) break; dist = Math.hypot((xs - xe), (ys - ye)); wind = Math.min(wind, dist); if ((dist < 1)) { dist = 1; } long d = (Math.round((Math.round(((double) (tDist))) * 0.3)) / 7); if ((d > 25)) { d = 25; } if ((d < 5)) { d = 5; } double rCnc = Calculations.random(6); if ((rCnc == 1)) { d = 2; } double maxStep = (Math.min(d, Math.round(dist))) * 1.5; if ((dist >= targetArea)) { windX = (windX / sqrt3) + ((Calculations.random((int) ((Math.round(wind) * 2) + 1)) - wind) / sqrt5); windY = (windY / sqrt3) + ((Calculations.random((int) ((Math.round(wind) * 2) + 1)) - wind) / sqrt5); } else { windX = (windX / sqrt2); windY = (windY / sqrt2); } veloX += windX + gravity * (xe - xs) / dist; veloY += windY + gravity * (ye - ys) / dist; if ((Math.hypot(veloX, veloY) > maxStep)) { maxStep = ((maxStep / 2) < 1) ? 2 : maxStep; double randomDist = (maxStep / 2) + Calculations.random((int) (Math.round(maxStep) / 2)); double veloMag = Math.sqrt(((veloX * veloX) + (veloY * veloY))); veloX = (veloX / veloMag) * randomDist; veloY = (veloY / veloMag) * randomDist; } int lastX = ((int) (Math.round(xs))); int lastY = ((int) (Math.round(ys))); xs += veloX; ys += veloY; if ((lastX != Math.round(xs)) || (lastY != Math.round(ys))) { Mouse.hop(new Point((int) Math.round(xs), (int) Math.round(ys))); } int w = Calculations.random((int) (Math.round(100 / speed))) * 6; if ((w < 5)) { w = 5; } w = (int) Math.round(w * 0.9); sleep(w); } if (((Math.round(xe) != Math.round(xs)) || (Math.round(ye) != Math.round(ys)))) { Mouse.hop(new Point(((int) (Math.round(xe))), ((int) (Math.round(ye))))); } } /** * Internal mouse movement algorithm from SMART. Do not use this without credit to either * Benjamin J. Land or BenLand100. This was originally synchronized to prevent multiple * motions and bannage but functions poorly with DB3. * * BEST USED IN FIXED MODE * * @param xs The x start * @param ys The y start * @param xe The x destination * @param ye The y destination * @param gravity Strength pulling the position towards the destination * @param wind Strength pulling the position in random directions * @param minWait Minimum relative time per step * @param maxWait Maximum relative time per step * @param maxStep Maximum size of a step, prevents out of control motion * @param targetArea Radius of area around the destination that should * trigger slowing, prevents spiraling * @result The actual end point */ private Point windMouseImpl(double xs, double ys, double xe, double ye, double gravity, double wind, double minWait, double maxWait, double maxStep, double targetArea) { final double sqrt3 = Math.sqrt(3); final double sqrt5 = Math.sqrt(5); double dist, veloX = 0, veloY = 0, windX = 0, windY = 0; while ((dist = Math.hypot(xs - xe, ys - ye)) >= 1) { wind = Math.min(wind, dist); if (dist >= targetArea) { windX = windX / sqrt3 + (2D * Math.random() - 1D) * wind / sqrt5; windY = windY / sqrt3 + (2D * Math.random() - 1D) * wind / sqrt5; } else { windX /= sqrt3; windY /= sqrt3; if (maxStep < 3) { maxStep = Math.random() * 3D + 3D; } else { maxStep /= sqrt5; } } veloX += windX + gravity * (xe - xs) / dist; veloY += windY + gravity * (ye - ys) / dist; double veloMag = Math.hypot(veloX, veloY); if (veloMag > maxStep) { double randomDist = maxStep / 2D + Math.random() * maxStep / 2D; veloX = (veloX / veloMag) * randomDist; veloY = (veloY / veloMag) * randomDist; } int lastX = ((int) (Math.round(xs))); int lastY = ((int) (Math.round(ys))); xs += veloX; ys += veloY; if ((lastX != Math.round(xs)) || (lastY != Math.round(ys))) { setMousePosition(new Point((int) Math.round(xs), (int) Math.round(ys))); } double step = Math.hypot(xs - lastX, ys - lastY); sleep((int) Math.round((maxWait - minWait) * (step / maxStep) + minWait)); } return new Point((int) xs, (int) ys); } /** * Moves the mouse from the current position to the specified position. * Approximates human movement in a way where smoothness and accuracy are * relative to speed, as it should be. * * @param x The x destination * @param y The y destination * @result The actual end point */ public Point windMouse(int x, int y) { Point c = Client.getMousePosition(); double speed = (Math.random() * 15D + 15D) / 10D; return windMouseImpl(c.x, c.y, x, y, 9D, 3D, 5D / speed, 10D / speed, 10D * speed, 8D * speed); } private void setMousePosition(Point p) { Mouse.hop(p.x, p.y); } private static double distance(double x1, double y1, double x2, double y2) { return Math.sqrt((Math.pow((Math.round(x2) - Math.round(x1)), 2) + Math.pow((Math.round(y2) - Math.round(y1)), 2))); } public double distance(Point p1, Point p2) { return Math.sqrt((p2.y - p1.y) * (p2.y - p1.y) + (p2.x - p1.x) * (p2.x - p1.x)); } public static float randomPointBetween(float corner1, float corner2) { if (corner1 == corner2) { return corner1; } float delta = corner2 - corner1; float offset = Calculations.getRandom().nextFloat() * delta; return corner1 + offset; } public Point randomPoint(Point p1, Point p2) { int randomX = (int) randomPointBetween(p1.x, p2.x); int randomY = (int) randomPointBetween(p1.y, p2.y); return new Point(randomX, randomY); } }  
      Happy botting!
    8. Like
      holic reacted to Hashtag in Alclueholic - A beginner clue scroll solver - Re-written!   
      Released on SDN and promoted. Congratulations!
    9. Like
      holic got a reaction from tjet in Alclueholic - A beginner clue scroll solver - Re-written!   
      Thanks tjet! There is a small bug I haven't figured out that I thought I had fixed just fyi. Start with a clue scroll in your inventory and you should be good. Its getting stuck withdrawing the scroll ATM. I'll fix it this weekend. 
    10. Like
      holic reacted to tjet in Alclueholic - A beginner clue scroll solver - Re-written!   
      Another quality script from my boy @holic. 👌
      I'll be testing this over the next few days and give you a shout!  Nice dude.
    11. Like
      holic got a reaction from tjet in Alclueholic - A beginner clue scroll solver - Re-written!   
      Minor release: 1.07
      Fixed bug with clapping at Bob Fixed teleportation bug where it might interrupt a home teleport by walking Fixed another withdrawing issue Fixed mouse algorithm issue DOWNLOAD
    12. Upvote
      holic got a reaction from litintrovert in Alclueholic - A beginner clue scroll solver - Re-written!   
      Alclueholic
      "It's like an alcoholic, but for clue scrolls"

       
      Description
      A simple beginner clue scroll solver. Completes scrolls in 2 to 10 minutes, depending on complexity.
       
      Setup
      Have a clue scroll either in your inventory or bank Meet all item and level requirements Click start
        Features
      Quick-start support - Requires no interaction to start the script, can even be executed from within another script. Optional quick-start parameters o, open: boolean; toggles the option to open your casket at the end of the script c, check: boolean; toggles the option to check your bank for a clue scroll if there isn't one in your inventory (ideal for running in tandem with other scripts) p, plugin: boolean; set to true if run in tandem with another script to move the paint's location on screen as to not overlap the other script's paint. Teleportation - If you meet the level & item requirements for a teleport the script will cast it when appropriate. Uses home teleport only when possible. Gathers missing items - See below for full list Custom mouse movement algorithm - A combination of the two algorithms I posted which builds a "profile" for each account to create a unique play-style for each bot Anti-ban - Randomized movements, actions and sleeps to add onto the unique play-style of each bot. Start anywhere - Custom walking utility lets you start the script anywhere you'd like, even places that don't have walk nodes!
        Skill requirements
      15 Smithing: To smith an iron dagger for Charlie 15 Mining: To mine some a iron ore for Charlie 18 Crafting: To craft a leather body/chaps for Charlie 20 Cooking: To cook a trout/pike for Charlie Will catch the required fish if not found in the bank (Note: level 25 fishing required to catch a pike) 20 Fishing: To catch a raw trout/herring for Charlie Will also be potentially required to cook Charlie a trout if you don't have any in the bank
        Item requirements - must be in bank or inventory
       
      Optional items - these items will be grabbed by the script if they aren't in your bank and the rest will be purchased
      Spade Strange device Bronze axe Bronze pickaxe
         
      Mining iron for Charlie, but first getting a pickaxe from a spawn, then fishing for a herring for Charlie, then withdrawing a Chef's hat and cheering at Iffie


       
      Changelog
       
       

    13. Upvote
      holic got a reaction from UberJason in Alclueholic - A beginner clue scroll solver - Re-written!   
      Minor release: 1.05
      Fixed craft leather chaps bug Fixed teleportation bug DOWNLOAD
    14. Like
      holic got a reaction from Pseudo in Alclueholic - A beginner clue scroll solver - Re-written!   
      Minor release: 1.05
      Fixed craft leather chaps bug Fixed teleportation bug DOWNLOAD
    15. Like
      holic reacted to TheCloakdOne in Alclueholic - A beginner clue scroll solver - Re-written!   
      Awesome release dude! 
    16. Upvote
      holic got a reaction from josemiguelcal in Alclueholic - A beginner clue scroll solver - Re-written!   
      Alclueholic
      "It's like an alcoholic, but for clue scrolls"

       
      Description
      A simple beginner clue scroll solver. Completes scrolls in 2 to 10 minutes, depending on complexity.
       
      Setup
      Have a clue scroll either in your inventory or bank Meet all item and level requirements Click start
        Features
      Quick-start support - Requires no interaction to start the script, can even be executed from within another script. Optional quick-start parameters o, open: boolean; toggles the option to open your casket at the end of the script c, check: boolean; toggles the option to check your bank for a clue scroll if there isn't one in your inventory (ideal for running in tandem with other scripts) p, plugin: boolean; set to true if run in tandem with another script to move the paint's location on screen as to not overlap the other script's paint. Teleportation - If you meet the level & item requirements for a teleport the script will cast it when appropriate. Uses home teleport only when possible. Gathers missing items - See below for full list Custom mouse movement algorithm - A combination of the two algorithms I posted which builds a "profile" for each account to create a unique play-style for each bot Anti-ban - Randomized movements, actions and sleeps to add onto the unique play-style of each bot. Start anywhere - Custom walking utility lets you start the script anywhere you'd like, even places that don't have walk nodes!
        Skill requirements
      15 Smithing: To smith an iron dagger for Charlie 15 Mining: To mine some a iron ore for Charlie 18 Crafting: To craft a leather body/chaps for Charlie 20 Cooking: To cook a trout/pike for Charlie Will catch the required fish if not found in the bank (Note: level 25 fishing required to catch a pike) 20 Fishing: To catch a raw trout/herring for Charlie Will also be potentially required to cook Charlie a trout if you don't have any in the bank
        Item requirements - must be in bank or inventory
       
      Optional items - these items will be grabbed by the script if they aren't in your bank and the rest will be purchased
      Spade Strange device Bronze axe Bronze pickaxe
         
      Mining iron for Charlie, but first getting a pickaxe from a spawn, then fishing for a herring for Charlie, then withdrawing a Chef's hat and cheering at Iffie


       
      Changelog
       
       

    17. Like
      holic got a reaction from Hmm in Alclueholic - A beginner clue scroll solver - Re-written!   
      Alclueholic
      "It's like an alcoholic, but for clue scrolls"

       
      Description
      A simple beginner clue scroll solver. Completes scrolls in 2 to 10 minutes, depending on complexity.
       
      Setup
      Have a clue scroll either in your inventory or bank Meet all item and level requirements Click start
        Features
      Quick-start support - Requires no interaction to start the script, can even be executed from within another script. Optional quick-start parameters o, open: boolean; toggles the option to open your casket at the end of the script c, check: boolean; toggles the option to check your bank for a clue scroll if there isn't one in your inventory (ideal for running in tandem with other scripts) p, plugin: boolean; set to true if run in tandem with another script to move the paint's location on screen as to not overlap the other script's paint. Teleportation - If you meet the level & item requirements for a teleport the script will cast it when appropriate. Uses home teleport only when possible. Gathers missing items - See below for full list Custom mouse movement algorithm - A combination of the two algorithms I posted which builds a "profile" for each account to create a unique play-style for each bot Anti-ban - Randomized movements, actions and sleeps to add onto the unique play-style of each bot. Start anywhere - Custom walking utility lets you start the script anywhere you'd like, even places that don't have walk nodes!
        Skill requirements
      15 Smithing: To smith an iron dagger for Charlie 15 Mining: To mine some a iron ore for Charlie 18 Crafting: To craft a leather body/chaps for Charlie 20 Cooking: To cook a trout/pike for Charlie Will catch the required fish if not found in the bank (Note: level 25 fishing required to catch a pike) 20 Fishing: To catch a raw trout/herring for Charlie Will also be potentially required to cook Charlie a trout if you don't have any in the bank
        Item requirements - must be in bank or inventory
       
      Optional items - these items will be grabbed by the script if they aren't in your bank and the rest will be purchased
      Spade Strange device Bronze axe Bronze pickaxe
         
      Mining iron for Charlie, but first getting a pickaxe from a spawn, then fishing for a herring for Charlie, then withdrawing a Chef's hat and cheering at Iffie


       
      Changelog
       
       

    18. Like
      holic got a reaction from tjet in Alclueholic - A beginner clue scroll solver - Re-written!   
      Alclueholic
      "It's like an alcoholic, but for clue scrolls"

       
      Description
      A simple beginner clue scroll solver. Completes scrolls in 2 to 10 minutes, depending on complexity.
       
      Setup
      Have a clue scroll either in your inventory or bank Meet all item and level requirements Click start
        Features
      Quick-start support - Requires no interaction to start the script, can even be executed from within another script. Optional quick-start parameters o, open: boolean; toggles the option to open your casket at the end of the script c, check: boolean; toggles the option to check your bank for a clue scroll if there isn't one in your inventory (ideal for running in tandem with other scripts) p, plugin: boolean; set to true if run in tandem with another script to move the paint's location on screen as to not overlap the other script's paint. Teleportation - If you meet the level & item requirements for a teleport the script will cast it when appropriate. Uses home teleport only when possible. Gathers missing items - See below for full list Custom mouse movement algorithm - A combination of the two algorithms I posted which builds a "profile" for each account to create a unique play-style for each bot Anti-ban - Randomized movements, actions and sleeps to add onto the unique play-style of each bot. Start anywhere - Custom walking utility lets you start the script anywhere you'd like, even places that don't have walk nodes!
        Skill requirements
      15 Smithing: To smith an iron dagger for Charlie 15 Mining: To mine some a iron ore for Charlie 18 Crafting: To craft a leather body/chaps for Charlie 20 Cooking: To cook a trout/pike for Charlie Will catch the required fish if not found in the bank (Note: level 25 fishing required to catch a pike) 20 Fishing: To catch a raw trout/herring for Charlie Will also be potentially required to cook Charlie a trout if you don't have any in the bank
        Item requirements - must be in bank or inventory
       
      Optional items - these items will be grabbed by the script if they aren't in your bank and the rest will be purchased
      Spade Strange device Bronze axe Bronze pickaxe
         
      Mining iron for Charlie, but first getting a pickaxe from a spawn, then fishing for a herring for Charlie, then withdrawing a Chef's hat and cheering at Iffie


       
      Changelog
       
       

    19. Like
      holic reacted to LordJashin32 in Alclueholic - A beginner clue scroll solver - Re-written!   
      EDIT: that's the fastest bot ever btw.
    20. Upvote
      holic got a reaction from wettofu in Alclueholic - A beginner clue scroll solver - Re-written!   
      Alclueholic
      "It's like an alcoholic, but for clue scrolls"

       
      Description
      A simple beginner clue scroll solver. Completes scrolls in 2 to 10 minutes, depending on complexity.
       
      Setup
      Have a clue scroll either in your inventory or bank Meet all item and level requirements Click start
        Features
      Quick-start support - Requires no interaction to start the script, can even be executed from within another script. Optional quick-start parameters o, open: boolean; toggles the option to open your casket at the end of the script c, check: boolean; toggles the option to check your bank for a clue scroll if there isn't one in your inventory (ideal for running in tandem with other scripts) p, plugin: boolean; set to true if run in tandem with another script to move the paint's location on screen as to not overlap the other script's paint. Teleportation - If you meet the level & item requirements for a teleport the script will cast it when appropriate. Uses home teleport only when possible. Gathers missing items - See below for full list Custom mouse movement algorithm - A combination of the two algorithms I posted which builds a "profile" for each account to create a unique play-style for each bot Anti-ban - Randomized movements, actions and sleeps to add onto the unique play-style of each bot. Start anywhere - Custom walking utility lets you start the script anywhere you'd like, even places that don't have walk nodes!
        Skill requirements
      15 Smithing: To smith an iron dagger for Charlie 15 Mining: To mine some a iron ore for Charlie 18 Crafting: To craft a leather body/chaps for Charlie 20 Cooking: To cook a trout/pike for Charlie Will catch the required fish if not found in the bank (Note: level 25 fishing required to catch a pike) 20 Fishing: To catch a raw trout/herring for Charlie Will also be potentially required to cook Charlie a trout if you don't have any in the bank
        Item requirements - must be in bank or inventory
       
      Optional items - these items will be grabbed by the script if they aren't in your bank and the rest will be purchased
      Spade Strange device Bronze axe Bronze pickaxe
         
      Mining iron for Charlie, but first getting a pickaxe from a spawn, then fishing for a herring for Charlie, then withdrawing a Chef's hat and cheering at Iffie


       
      Changelog
       
       

    21. Upvote
      holic got a reaction from LordJashin32 in DrawMouseUtil - Draw mouse trails and custom cursors   
      Glad to hear it! Yeah I realize I changed some things at the last moment which created a bug so you'll need to just change the lines of g2.setColor(cursorColor) to g2.setColor(nextCursorColor()) in the drawMouseX methods.
      I originally didn't have separate colour options for mouse and trail functions but decided to add them for the public release and in doing so messed that bit up hah.
    22. Like
      holic got a reaction from Bruhuh in DrawMouseUtil - Draw mouse trails and custom cursors   
      I made a nifty little mouse utility for drawing custom cursors and trails that I thought I would pass onto the community. Some of the trails are meh but I think the final product is still great and it's very straightforward to use.
      Credits:
      DarkMagican for the original mouse trails & rainbow source ENFILADE for MousePathPoint Setup functions
      void setCursorColor(Color cursorColor) Manually set the cursor's colour, default white void setCursorStroke(BasicStroke cursorStroke) Manually set the cursor's stroke thickness, default 2 void setTrailColor(Color trailColor) Manually set the trail's colour, default white void setRainbow(boolean RAINBOW) Set the mouse cursor & trail colour to be rainbow void setRandomColor() Set the mouse cursor & trail colour to be random, possibly rainbow Mouse functions
      void drawRandomMouse(Graphics g) Draws the randomly selected mouse graphic. void drawPlusMouse(Graphics g) Draws a "+" for the mouse, with shadow. void drawCrossMouse(Graphics g) Draws a "x" for the mouse, with shadow. void drawCircleMouse(Graphics g) Draws a circle for the mouse, with shadow. void drawDotMouse(Graphics g) Draws a dot for the mouse, with shadow. void drawRotatingCrossMouse(Graphics g) Draws an "x" for the mouse that rotates, with shadow. void drawRotatingCircleMouse(Graphics g) Draws a circle with rotating pie slices, with shadow. Trail functions
      void drawTrail(Graphics g) Draws a typical line-based mouse trail, varying size line width void drawZoomTrail(Graphics g) Draws a "ZOOM" for a trail, varying case and size void drawTextTrail(Graphics g, String trail) Draws your specified text for a trail, could work for script status? void drawDotTrail(Graphics g) Draws a series of dots as a trail, varying sizes void drawCircleTrail(Graphics g) Draws a series of circles as a trail, varying sizes void drawPlusTrail(Graphics g) Draws a series of "+" as a trail, varying sizes void drawRotatingSlashTrail(Graphics g) Draws a series of "/" as a trail that rotate, varying sizes void drawRotatingCrossTrail(Graphics g) Draws a series of "x" as a trail that rotate, varying sizes Usage example
      First, add DrawMouseUtil to your project by copying and pasting it into a file name DrawMouseUtil.java and importing it into your project
      Second, create a variable for DrawMouseUtil so you have consistency in your setup and calls.
      private DrawMouseUtil drawMouseUtil = new DrawMouseUtil();  
      Third, set your desired settings and add it to onStart. For this example we will be setting up the mouse randomly:
      @Override public void onStart() { drawMouseUtil.setRandomColor(); //Set a random colour and leave the stroke setting at default ..... }  
      Fourth, call your desired mouse cursor and trail in onPaint. For this example we will be using random settings:
      @Override public void onPaint(Graphics g) { drawMouseUtil.drawRandomMouse(g); drawMouseUtil.drawRandomMouseTrail(g); }  
      My favourite combination currently is either
      drawMouseUtil.drawRotatingCrossMouse(g) drawMouseUtil.drawRotatingCrossTrail(g) or
      drawMouseUtil.drawRotatingCircleMouse(g); drawMouseUtil.drawDotTrail(g);  
       
      DrawMouseUtil.java:
      /** DrawMouseUtil by holic **/ import org.dreambot.api.Client; import org.dreambot.api.methods.Calculations; import java.awt.*; import java.awt.geom.AffineTransform; import java.awt.geom.Arc2D; import java.awt.geom.Line2D; import java.util.LinkedList; import static org.dreambot.api.methods.MethodProvider.log; public class DrawMouseUtil { LinkedList<MousePathPoint> mousePath = new LinkedList<MousePathPoint>(); private boolean RAINBOW = false; private int STROKE = 2; private int mX, mY; private long angle; private BasicStroke cursorStroke = new BasicStroke(STROKE); private int randomMouse = Calculations.random(5); private int randomMouseTrail = Calculations.random(7); private Color cursorColor = Color.WHITE; private Color trailColor = cursorColor; private Color[] cursorColors = {new Color(78, 216, 255), new Color(90, 222, 98), new Color(215, 182, 77), new Color(232, 134, 124), new Color(215, 120, 124), new Color(183, 138, 215), Color.WHITE}; private AffineTransform oldTransform; private int r = 0, g = 0, b = 0, duration = 650; public DrawMouseUtil() { Client.getInstance().setDrawMouse(false); } public void setRainbow(boolean RAINBOW) { if (RAINBOW) { g = 255; } else { g = 0; } this.RAINBOW = RAINBOW; } public void setRandomColor() { if (Calculations.random(2) != 1) { log("Rainbow mouse!"); setRainbow(true); } else { setRainbow(false); cursorColor = getRandomColour(); trailColor = cursorColor; } } private Color getRandomColour() { return cursorColors[Calculations.random(cursorColors.length - 1)]; } public void setCursorStroke(BasicStroke cursorStroke) { this.cursorStroke = cursorStroke; } public void setCursorColor(Color cursorColor) { this.cursorColor = cursorColor; } public void setTrailColor(Color trailColor) { this.trailColor = trailColor; } public void drawRandomMouse(Graphics g) { switch (randomMouse) { case 0: drawPlusMouse(g); break; case 1: drawCrossMouse(g); break; case 2: drawCircleMouse(g); break; case 3: drawDotMouse(g); break; case 4: drawRotatingCrossMouse(g); break; case 5: drawRotatingCircleMouse(g); break; } } public void drawRandomMouseTrail(Graphics g) { switch (randomMouseTrail) { case 0: drawTrail(g); break; case 1: drawZoomTrail(g); break; case 2: drawPlusTrail(g); break; case 3: drawCircleTrail(g); break; case 4: drawDotTrail(g); break; case 5: drawRotatingSlashTrail(g); break; case 6: drawRotatingCrossTrail(g); break; case 7: drawTextTrail(g, "your text here"); break; } } /** * * ** ** ** ** * Mouse cursor * * ** ** ** ** **/ public void drawPlusMouse(Graphics g) { Graphics2D g2 = (Graphics2D) g; int s = 4; Point cP = Client.getMousePosition(); int cX = (int) cP.getX(); int cY = (int) cP.getY(); g2.setColor(Color.BLACK); g2.setStroke(cursorStroke); /* + Cursor */ g2.drawLine(cX - s + 1, cY + 1, cX + s + 1, cY + 1); g2.drawLine(cX + 1, cY - s + 1, cX + 1, cY + s + 1); g2.setColor(cursorColor); g2.drawLine(cX - s, cY, cX + s, cY); g2.drawLine(cX, cY - s, cX, cY + s); g2.setStroke(new BasicStroke(1)); } public void drawCrossMouse(Graphics g) { Graphics2D g2 = (Graphics2D) g; int s = 3; Point cP = Client.getMousePosition(); int cX = (int) cP.getX(); int cY = (int) cP.getY(); g2.setStroke(cursorStroke); g2.setColor(Color.BLACK); /* X Cursor */ g2.drawLine(cX - s + 1, cY - s + 1, cX + s + 1, cY + s + 1); g2.drawLine(cX - s + 1, cY + s + 1, cX + s + 1, cY - s + 1); g2.setColor(cursorColor); g2.drawLine(cX - s, cY - s, cX + s, cY + s); g2.drawLine(cX - s, cY + s, cX + s, cY - s); g2.setStroke(new BasicStroke(1)); } public void drawCircleMouse(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); int mX = Client.getMousePosition().x; mY = Client.getMousePosition().y; g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); if (mX != -1) { g2.setStroke(cursorStroke); g2.setColor(Color.BLACK); g2.drawOval(mX - 1, mY - 1, 4, 4); g2.setColor(cursorColor); g2.drawOval(mX - 2, mY - 2, 4, 4); g2.setStroke(new BasicStroke(1)); } } public void drawDotMouse(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); int mX = Client.getMousePosition().x; mY = Client.getMousePosition().y; g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); if (mX != -1) { g2.setStroke(cursorStroke); g2.setColor(Color.BLACK); g2.drawOval(mX - 1, mY - 1, 4, 4); g2.setColor(cursorColor); g2.drawOval(mX - 2, mY - 2, 4, 4); g2.setStroke(new BasicStroke(1)); } } public void drawRotatingCircleMouse(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); int mX = Client.getMousePosition().x; mY = Client.getMousePosition().y; g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); if (mX != -1) { g2.setStroke(cursorStroke); g2.drawOval(mX - 2, mY - 2, 4, 4); g2.setColor(cursorColor); g2.rotate(Math.toRadians(angle += 6), mX, mY); g2.draw(new Arc2D.Double(mX - 6, mY - 6, 12, 12, 330, 60, Arc2D.OPEN)); g2.draw(new Arc2D.Double(mX - 6, mY - 6, 12, 12, 151, 60, Arc2D.OPEN)); g2.setTransform(oldTransform); g2.setStroke(new BasicStroke(1)); } } public void drawRotatingCrossMouse(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); Point cP = Client.getMousePosition(); int cX = (int) cP.getX(); int cY = (int) cP.getY(); int s = 4; g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); if (mX != -1) { g2.setStroke(cursorStroke); g2.setColor(Color.BLACK); //g.rotate(Math.toRadians(angle+=1), mX, mY); Line2D lineShadow = new Line2D.Double(cX - s + 1, cY + 1, cX + s + 1, cY + 1); Line2D lineShadow2 = new Line2D.Double(cX + 1, cY - s + 1, cX + 1, cY + s + 1); AffineTransform atS = AffineTransform.getRotateInstance( Math.toRadians(angle += 4), cX + 1, cY + 1); AffineTransform atS2 = AffineTransform.getRotateInstance( Math.toRadians(angle), cX + 1, cY + 1); g2.draw(atS.createTransformedShape(lineShadow)); g2.draw(atS2.createTransformedShape(lineShadow2)); g2.setColor(nextCursorColor()); Line2D line = new Line2D.Double(cX - s, cY, cX + s, cY); Line2D line2 = new Line2D.Double(cX, cY - s, cX, cY + s); AffineTransform at = AffineTransform.getRotateInstance( Math.toRadians(angle += 4), cX, cY); AffineTransform at2 = AffineTransform.getRotateInstance( Math.toRadians(angle), cX, cY); // Draw the rotated line g2.draw(at.createTransformedShape(line)); g2.draw(at2.createTransformedShape(line2)); g2.setStroke(new BasicStroke(1)); } } /** * * ** ** ** ** * Mouse trails * * ** ** ** ** **/ public void drawTrail(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); int mX = Client.getMousePosition().x; mY = Client.getMousePosition().y; g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); while (!mousePath.isEmpty() && mousePath.peek().isUp()) mousePath.remove(); Point clientCursor = Client.getMousePosition(); MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration); if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp)) mousePath.add(mpp); MousePathPoint lastPoint = null; for (MousePathPoint a : mousePath) { if (lastPoint != null) { Color c = nextTrailColor(); int tmpcursorStroke = STROKE; if (STROKE > 1) tmpcursorStroke = (a.getAlpha() > 175 ? STROKE : STROKE - 1); g2.setStroke(new BasicStroke(tmpcursorStroke)); g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color g2.drawLine(a.x, a.y, lastPoint.x, lastPoint.y); g2.setStroke(new BasicStroke(1)); } lastPoint = a; } } public void drawZoomTrail(Graphics g) { String zoom = "zoom zoom "; int zoomIndex = 0, zoomIndexStart = -1; Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); g2.setFont(new Font("default", Font.BOLD, 12)); g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); while (!mousePath.isEmpty() && mousePath.peek().isUp()) mousePath.remove(); Point clientCursor = Client.getMousePosition(); MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration * 2); if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp)) mousePath.add(mpp); MousePathPoint lastPoint = null; for (MousePathPoint a : mousePath) { if (zoomIndex >= zoom.length()) zoomIndex = 0; String toDraw = String.valueOf(zoom.toCharArray()[zoomIndex]); if (lastPoint != null) { Color c = nextTrailColor(); toDraw = a.getAlpha() > 175 ? toDraw.toUpperCase() : toDraw; g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color g2.drawString(toDraw, a.x, a.y + 5); } lastPoint = a; zoomIndex++; } g2.setFont(new Font("default", Font.PLAIN, 12)); } public void drawTextTrail(Graphics g, String trail) { int zoomIndex = 0, zoomIndexStart = -1; Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); g2.setFont(new Font("default", Font.BOLD, 12)); g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); while (!mousePath.isEmpty() && mousePath.peek().isUp()) mousePath.remove(); Point clientCursor = Client.getMousePosition(); MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration * 2); if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp)) mousePath.add(mpp); MousePathPoint lastPoint = null; for (MousePathPoint a : mousePath) { if (lastPoint != null) { Color c = nextTrailColor(); g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color g2.drawString(trail, a.x, a.y); } lastPoint = a; zoomIndex++; } g2.setFont(new Font("default", Font.PLAIN, 12)); } public void drawDotTrail(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); while (!mousePath.isEmpty() && mousePath.peek().isUp()) mousePath.remove(); Point clientCursor = Client.getMousePosition(); MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration * 2); if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp)) mousePath.add(mpp); MousePathPoint lastPoint = null; for (MousePathPoint a : mousePath) { if (lastPoint != null) { Color c = nextTrailColor(); int size = a.getAlpha() > 200 ? 6 : a.getAlpha() > 150 ? 5 : a.getAlpha() > 100 ? 4 : a.getAlpha() > 50 ? 3 : 2; g2.setStroke(cursorStroke); g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color g2.fillOval(a.x, a.y, size, size); g2.setStroke(new BasicStroke(1)); } lastPoint = a; } } public void drawCircleTrail(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); while (!mousePath.isEmpty() && mousePath.peek().isUp()) mousePath.remove(); Point clientCursor = Client.getMousePosition(); MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration * 2); if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp)) mousePath.add(mpp); MousePathPoint lastPoint = null; for (MousePathPoint a : mousePath) { if (lastPoint != null) { Color c = nextTrailColor(); int size = a.getAlpha() > 200 ? 6 : a.getAlpha() > 150 ? 5 : a.getAlpha() > 100 ? 4 : a.getAlpha() > 50 ? 3 : 2; g2.setStroke(cursorStroke); g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color g2.drawOval(a.x, a.y, size, size); g2.setStroke(new BasicStroke(1)); } lastPoint = a; } } public void drawPlusTrail(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); while (!mousePath.isEmpty() && mousePath.peek().isUp()) mousePath.remove(); Point clientCursor = Client.getMousePosition(); MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration * 2); if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp)) mousePath.add(mpp); MousePathPoint lastPoint = null; for (MousePathPoint a : mousePath) { if (lastPoint != null) { Color c = nextTrailColor(); int size = a.getAlpha() > 200 ? 5 : a.getAlpha() > 150 ? 4 : a.getAlpha() > 100 ? 3 : a.getAlpha() > 50 ? 2 : 1; g2.setStroke(cursorStroke); g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color g2.drawLine(a.x - size + 1, a.y + 1, a.x + size + 1, a.y + 1); g2.drawLine(a.x + 1, a.y - size + 1, a.x + 1, a.y + size + 1); g2.setStroke(new BasicStroke(1)); } lastPoint = a; } } public void drawRotatingSlashTrail(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); while (!mousePath.isEmpty() && mousePath.peek().isUp()) mousePath.remove(); Point clientCursor = Client.getMousePosition(); MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration * 2); if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp)) mousePath.add(mpp); MousePathPoint lastPoint = null; for (MousePathPoint a : mousePath) { if (lastPoint != null) { Color c = nextTrailColor(); int size = a.getAlpha() > 200 ? 5 : a.getAlpha() > 150 ? 4 : a.getAlpha() > 100 ? 3 : a.getAlpha() > 50 ? 2 : 1; g2.setStroke(cursorStroke); g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color Line2D line = new Line2D.Double(a.x - size, a.y, a.x + size, a.y); Line2D line2 = new Line2D.Double(a.x, a.y - size, a.x, a.y + size); AffineTransform at = AffineTransform.getRotateInstance( Math.toRadians(angle += 4), a.x, a.y); g2.draw(at.createTransformedShape(line)); g2.setStroke(new BasicStroke(1)); } lastPoint = a; } } public void drawRotatingCrossTrail(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); while (!mousePath.isEmpty() && mousePath.peek().isUp()) mousePath.remove(); Point clientCursor = Client.getMousePosition(); MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration * 2); if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp)) mousePath.add(mpp); MousePathPoint lastPoint = null; for (MousePathPoint a : mousePath) { if (lastPoint != null) { Color c = nextTrailColor(); int size = a.getAlpha() > 200 ? 5 : a.getAlpha() > 150 ? 4 : a.getAlpha() > 100 ? 3 : a.getAlpha() > 50 ? 2 : 1; g2.setStroke(cursorStroke); g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color Line2D line = new Line2D.Double(a.x - size, a.y, a.x + size, a.y); Line2D line2 = new Line2D.Double(a.x, a.y - size, a.x, a.y + size); AffineTransform at = AffineTransform.getRotateInstance( Math.toRadians(angle += 4), a.x, a.y); g2.draw(at.createTransformedShape(line)); g2.draw(at.createTransformedShape(line2)); g2.setStroke(new BasicStroke(1)); } lastPoint = a; } } public void nextRGB() { if (r == 255 && g < 255 & b == 0) { g++; } if (g == 255 && r > 0 && b == 0) { r--; } if (g == 255 && b < 255 && r == 0) { b++; } if (b == 255 && g > 0 && r == 0) { g--; } if (b == 255 && r < 255 && g == 0) { r++; } if (r == 255 && b > 0 && g == 0) { b--; } } public Color currentCursorColor() { if (!RAINBOW) { return cursorColor; } else { return new Color(r, g, b); } } public Color currentTrailColor() { if (!RAINBOW) { return trailColor; } else { return new Color(r, g, b); } } public Color nextCursorColor() { nextRGB(); return currentCursorColor(); } public Color nextTrailColor() { if (!RAINBOW) //Don't call this if it is set to rainbow so we're not double calling nextRGB() nextRGB(); return currentTrailColor(); } public class MousePathPoint extends Point { private long finishTime; private double lastingTime; private int alpha = 255; public MousePathPoint(int x, int y, int lastingTime) { super(x, y); this.lastingTime = lastingTime; finishTime = System.currentTimeMillis() + lastingTime; } public int getAlpha() { int newAlpha = ((int) ((finishTime - System.currentTimeMillis()) / (lastingTime / alpha))); if (newAlpha > 255) newAlpha = 255; if (newAlpha < 0) newAlpha = 0; return newAlpha; } public boolean isUp() { return System.currentTimeMillis() >= finishTime; } } }  
      Enjoy falsely tricking people into thinking your script is better than it is!
    23. Like
      holic got a reaction from Xtra in DrawMouseUtil - Draw mouse trails and custom cursors   
      I made a nifty little mouse utility for drawing custom cursors and trails that I thought I would pass onto the community. Some of the trails are meh but I think the final product is still great and it's very straightforward to use.
      Credits:
      DarkMagican for the original mouse trails & rainbow source ENFILADE for MousePathPoint Setup functions
      void setCursorColor(Color cursorColor) Manually set the cursor's colour, default white void setCursorStroke(BasicStroke cursorStroke) Manually set the cursor's stroke thickness, default 2 void setTrailColor(Color trailColor) Manually set the trail's colour, default white void setRainbow(boolean RAINBOW) Set the mouse cursor & trail colour to be rainbow void setRandomColor() Set the mouse cursor & trail colour to be random, possibly rainbow Mouse functions
      void drawRandomMouse(Graphics g) Draws the randomly selected mouse graphic. void drawPlusMouse(Graphics g) Draws a "+" for the mouse, with shadow. void drawCrossMouse(Graphics g) Draws a "x" for the mouse, with shadow. void drawCircleMouse(Graphics g) Draws a circle for the mouse, with shadow. void drawDotMouse(Graphics g) Draws a dot for the mouse, with shadow. void drawRotatingCrossMouse(Graphics g) Draws an "x" for the mouse that rotates, with shadow. void drawRotatingCircleMouse(Graphics g) Draws a circle with rotating pie slices, with shadow. Trail functions
      void drawTrail(Graphics g) Draws a typical line-based mouse trail, varying size line width void drawZoomTrail(Graphics g) Draws a "ZOOM" for a trail, varying case and size void drawTextTrail(Graphics g, String trail) Draws your specified text for a trail, could work for script status? void drawDotTrail(Graphics g) Draws a series of dots as a trail, varying sizes void drawCircleTrail(Graphics g) Draws a series of circles as a trail, varying sizes void drawPlusTrail(Graphics g) Draws a series of "+" as a trail, varying sizes void drawRotatingSlashTrail(Graphics g) Draws a series of "/" as a trail that rotate, varying sizes void drawRotatingCrossTrail(Graphics g) Draws a series of "x" as a trail that rotate, varying sizes Usage example
      First, add DrawMouseUtil to your project by copying and pasting it into a file name DrawMouseUtil.java and importing it into your project
      Second, create a variable for DrawMouseUtil so you have consistency in your setup and calls.
      private DrawMouseUtil drawMouseUtil = new DrawMouseUtil();  
      Third, set your desired settings and add it to onStart. For this example we will be setting up the mouse randomly:
      @Override public void onStart() { drawMouseUtil.setRandomColor(); //Set a random colour and leave the stroke setting at default ..... }  
      Fourth, call your desired mouse cursor and trail in onPaint. For this example we will be using random settings:
      @Override public void onPaint(Graphics g) { drawMouseUtil.drawRandomMouse(g); drawMouseUtil.drawRandomMouseTrail(g); }  
      My favourite combination currently is either
      drawMouseUtil.drawRotatingCrossMouse(g) drawMouseUtil.drawRotatingCrossTrail(g) or
      drawMouseUtil.drawRotatingCircleMouse(g); drawMouseUtil.drawDotTrail(g);  
       
      DrawMouseUtil.java:
      /** DrawMouseUtil by holic **/ import org.dreambot.api.Client; import org.dreambot.api.methods.Calculations; import java.awt.*; import java.awt.geom.AffineTransform; import java.awt.geom.Arc2D; import java.awt.geom.Line2D; import java.util.LinkedList; import static org.dreambot.api.methods.MethodProvider.log; public class DrawMouseUtil { LinkedList<MousePathPoint> mousePath = new LinkedList<MousePathPoint>(); private boolean RAINBOW = false; private int STROKE = 2; private int mX, mY; private long angle; private BasicStroke cursorStroke = new BasicStroke(STROKE); private int randomMouse = Calculations.random(5); private int randomMouseTrail = Calculations.random(7); private Color cursorColor = Color.WHITE; private Color trailColor = cursorColor; private Color[] cursorColors = {new Color(78, 216, 255), new Color(90, 222, 98), new Color(215, 182, 77), new Color(232, 134, 124), new Color(215, 120, 124), new Color(183, 138, 215), Color.WHITE}; private AffineTransform oldTransform; private int r = 0, g = 0, b = 0, duration = 650; public DrawMouseUtil() { Client.getInstance().setDrawMouse(false); } public void setRainbow(boolean RAINBOW) { if (RAINBOW) { g = 255; } else { g = 0; } this.RAINBOW = RAINBOW; } public void setRandomColor() { if (Calculations.random(2) != 1) { log("Rainbow mouse!"); setRainbow(true); } else { setRainbow(false); cursorColor = getRandomColour(); trailColor = cursorColor; } } private Color getRandomColour() { return cursorColors[Calculations.random(cursorColors.length - 1)]; } public void setCursorStroke(BasicStroke cursorStroke) { this.cursorStroke = cursorStroke; } public void setCursorColor(Color cursorColor) { this.cursorColor = cursorColor; } public void setTrailColor(Color trailColor) { this.trailColor = trailColor; } public void drawRandomMouse(Graphics g) { switch (randomMouse) { case 0: drawPlusMouse(g); break; case 1: drawCrossMouse(g); break; case 2: drawCircleMouse(g); break; case 3: drawDotMouse(g); break; case 4: drawRotatingCrossMouse(g); break; case 5: drawRotatingCircleMouse(g); break; } } public void drawRandomMouseTrail(Graphics g) { switch (randomMouseTrail) { case 0: drawTrail(g); break; case 1: drawZoomTrail(g); break; case 2: drawPlusTrail(g); break; case 3: drawCircleTrail(g); break; case 4: drawDotTrail(g); break; case 5: drawRotatingSlashTrail(g); break; case 6: drawRotatingCrossTrail(g); break; case 7: drawTextTrail(g, "your text here"); break; } } /** * * ** ** ** ** * Mouse cursor * * ** ** ** ** **/ public void drawPlusMouse(Graphics g) { Graphics2D g2 = (Graphics2D) g; int s = 4; Point cP = Client.getMousePosition(); int cX = (int) cP.getX(); int cY = (int) cP.getY(); g2.setColor(Color.BLACK); g2.setStroke(cursorStroke); /* + Cursor */ g2.drawLine(cX - s + 1, cY + 1, cX + s + 1, cY + 1); g2.drawLine(cX + 1, cY - s + 1, cX + 1, cY + s + 1); g2.setColor(cursorColor); g2.drawLine(cX - s, cY, cX + s, cY); g2.drawLine(cX, cY - s, cX, cY + s); g2.setStroke(new BasicStroke(1)); } public void drawCrossMouse(Graphics g) { Graphics2D g2 = (Graphics2D) g; int s = 3; Point cP = Client.getMousePosition(); int cX = (int) cP.getX(); int cY = (int) cP.getY(); g2.setStroke(cursorStroke); g2.setColor(Color.BLACK); /* X Cursor */ g2.drawLine(cX - s + 1, cY - s + 1, cX + s + 1, cY + s + 1); g2.drawLine(cX - s + 1, cY + s + 1, cX + s + 1, cY - s + 1); g2.setColor(cursorColor); g2.drawLine(cX - s, cY - s, cX + s, cY + s); g2.drawLine(cX - s, cY + s, cX + s, cY - s); g2.setStroke(new BasicStroke(1)); } public void drawCircleMouse(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); int mX = Client.getMousePosition().x; mY = Client.getMousePosition().y; g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); if (mX != -1) { g2.setStroke(cursorStroke); g2.setColor(Color.BLACK); g2.drawOval(mX - 1, mY - 1, 4, 4); g2.setColor(cursorColor); g2.drawOval(mX - 2, mY - 2, 4, 4); g2.setStroke(new BasicStroke(1)); } } public void drawDotMouse(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); int mX = Client.getMousePosition().x; mY = Client.getMousePosition().y; g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); if (mX != -1) { g2.setStroke(cursorStroke); g2.setColor(Color.BLACK); g2.drawOval(mX - 1, mY - 1, 4, 4); g2.setColor(cursorColor); g2.drawOval(mX - 2, mY - 2, 4, 4); g2.setStroke(new BasicStroke(1)); } } public void drawRotatingCircleMouse(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); int mX = Client.getMousePosition().x; mY = Client.getMousePosition().y; g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); if (mX != -1) { g2.setStroke(cursorStroke); g2.drawOval(mX - 2, mY - 2, 4, 4); g2.setColor(cursorColor); g2.rotate(Math.toRadians(angle += 6), mX, mY); g2.draw(new Arc2D.Double(mX - 6, mY - 6, 12, 12, 330, 60, Arc2D.OPEN)); g2.draw(new Arc2D.Double(mX - 6, mY - 6, 12, 12, 151, 60, Arc2D.OPEN)); g2.setTransform(oldTransform); g2.setStroke(new BasicStroke(1)); } } public void drawRotatingCrossMouse(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); Point cP = Client.getMousePosition(); int cX = (int) cP.getX(); int cY = (int) cP.getY(); int s = 4; g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); if (mX != -1) { g2.setStroke(cursorStroke); g2.setColor(Color.BLACK); //g.rotate(Math.toRadians(angle+=1), mX, mY); Line2D lineShadow = new Line2D.Double(cX - s + 1, cY + 1, cX + s + 1, cY + 1); Line2D lineShadow2 = new Line2D.Double(cX + 1, cY - s + 1, cX + 1, cY + s + 1); AffineTransform atS = AffineTransform.getRotateInstance( Math.toRadians(angle += 4), cX + 1, cY + 1); AffineTransform atS2 = AffineTransform.getRotateInstance( Math.toRadians(angle), cX + 1, cY + 1); g2.draw(atS.createTransformedShape(lineShadow)); g2.draw(atS2.createTransformedShape(lineShadow2)); g2.setColor(nextCursorColor()); Line2D line = new Line2D.Double(cX - s, cY, cX + s, cY); Line2D line2 = new Line2D.Double(cX, cY - s, cX, cY + s); AffineTransform at = AffineTransform.getRotateInstance( Math.toRadians(angle += 4), cX, cY); AffineTransform at2 = AffineTransform.getRotateInstance( Math.toRadians(angle), cX, cY); // Draw the rotated line g2.draw(at.createTransformedShape(line)); g2.draw(at2.createTransformedShape(line2)); g2.setStroke(new BasicStroke(1)); } } /** * * ** ** ** ** * Mouse trails * * ** ** ** ** **/ public void drawTrail(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); int mX = Client.getMousePosition().x; mY = Client.getMousePosition().y; g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); while (!mousePath.isEmpty() && mousePath.peek().isUp()) mousePath.remove(); Point clientCursor = Client.getMousePosition(); MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration); if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp)) mousePath.add(mpp); MousePathPoint lastPoint = null; for (MousePathPoint a : mousePath) { if (lastPoint != null) { Color c = nextTrailColor(); int tmpcursorStroke = STROKE; if (STROKE > 1) tmpcursorStroke = (a.getAlpha() > 175 ? STROKE : STROKE - 1); g2.setStroke(new BasicStroke(tmpcursorStroke)); g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color g2.drawLine(a.x, a.y, lastPoint.x, lastPoint.y); g2.setStroke(new BasicStroke(1)); } lastPoint = a; } } public void drawZoomTrail(Graphics g) { String zoom = "zoom zoom "; int zoomIndex = 0, zoomIndexStart = -1; Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); g2.setFont(new Font("default", Font.BOLD, 12)); g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); while (!mousePath.isEmpty() && mousePath.peek().isUp()) mousePath.remove(); Point clientCursor = Client.getMousePosition(); MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration * 2); if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp)) mousePath.add(mpp); MousePathPoint lastPoint = null; for (MousePathPoint a : mousePath) { if (zoomIndex >= zoom.length()) zoomIndex = 0; String toDraw = String.valueOf(zoom.toCharArray()[zoomIndex]); if (lastPoint != null) { Color c = nextTrailColor(); toDraw = a.getAlpha() > 175 ? toDraw.toUpperCase() : toDraw; g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color g2.drawString(toDraw, a.x, a.y + 5); } lastPoint = a; zoomIndex++; } g2.setFont(new Font("default", Font.PLAIN, 12)); } public void drawTextTrail(Graphics g, String trail) { int zoomIndex = 0, zoomIndexStart = -1; Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); g2.setFont(new Font("default", Font.BOLD, 12)); g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); while (!mousePath.isEmpty() && mousePath.peek().isUp()) mousePath.remove(); Point clientCursor = Client.getMousePosition(); MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration * 2); if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp)) mousePath.add(mpp); MousePathPoint lastPoint = null; for (MousePathPoint a : mousePath) { if (lastPoint != null) { Color c = nextTrailColor(); g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color g2.drawString(trail, a.x, a.y); } lastPoint = a; zoomIndex++; } g2.setFont(new Font("default", Font.PLAIN, 12)); } public void drawDotTrail(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); while (!mousePath.isEmpty() && mousePath.peek().isUp()) mousePath.remove(); Point clientCursor = Client.getMousePosition(); MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration * 2); if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp)) mousePath.add(mpp); MousePathPoint lastPoint = null; for (MousePathPoint a : mousePath) { if (lastPoint != null) { Color c = nextTrailColor(); int size = a.getAlpha() > 200 ? 6 : a.getAlpha() > 150 ? 5 : a.getAlpha() > 100 ? 4 : a.getAlpha() > 50 ? 3 : 2; g2.setStroke(cursorStroke); g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color g2.fillOval(a.x, a.y, size, size); g2.setStroke(new BasicStroke(1)); } lastPoint = a; } } public void drawCircleTrail(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); while (!mousePath.isEmpty() && mousePath.peek().isUp()) mousePath.remove(); Point clientCursor = Client.getMousePosition(); MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration * 2); if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp)) mousePath.add(mpp); MousePathPoint lastPoint = null; for (MousePathPoint a : mousePath) { if (lastPoint != null) { Color c = nextTrailColor(); int size = a.getAlpha() > 200 ? 6 : a.getAlpha() > 150 ? 5 : a.getAlpha() > 100 ? 4 : a.getAlpha() > 50 ? 3 : 2; g2.setStroke(cursorStroke); g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color g2.drawOval(a.x, a.y, size, size); g2.setStroke(new BasicStroke(1)); } lastPoint = a; } } public void drawPlusTrail(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); while (!mousePath.isEmpty() && mousePath.peek().isUp()) mousePath.remove(); Point clientCursor = Client.getMousePosition(); MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration * 2); if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp)) mousePath.add(mpp); MousePathPoint lastPoint = null; for (MousePathPoint a : mousePath) { if (lastPoint != null) { Color c = nextTrailColor(); int size = a.getAlpha() > 200 ? 5 : a.getAlpha() > 150 ? 4 : a.getAlpha() > 100 ? 3 : a.getAlpha() > 50 ? 2 : 1; g2.setStroke(cursorStroke); g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color g2.drawLine(a.x - size + 1, a.y + 1, a.x + size + 1, a.y + 1); g2.drawLine(a.x + 1, a.y - size + 1, a.x + 1, a.y + size + 1); g2.setStroke(new BasicStroke(1)); } lastPoint = a; } } public void drawRotatingSlashTrail(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); while (!mousePath.isEmpty() && mousePath.peek().isUp()) mousePath.remove(); Point clientCursor = Client.getMousePosition(); MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration * 2); if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp)) mousePath.add(mpp); MousePathPoint lastPoint = null; for (MousePathPoint a : mousePath) { if (lastPoint != null) { Color c = nextTrailColor(); int size = a.getAlpha() > 200 ? 5 : a.getAlpha() > 150 ? 4 : a.getAlpha() > 100 ? 3 : a.getAlpha() > 50 ? 2 : 1; g2.setStroke(cursorStroke); g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color Line2D line = new Line2D.Double(a.x - size, a.y, a.x + size, a.y); Line2D line2 = new Line2D.Double(a.x, a.y - size, a.x, a.y + size); AffineTransform at = AffineTransform.getRotateInstance( Math.toRadians(angle += 4), a.x, a.y); g2.draw(at.createTransformedShape(line)); g2.setStroke(new BasicStroke(1)); } lastPoint = a; } } public void drawRotatingCrossTrail(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); while (!mousePath.isEmpty() && mousePath.peek().isUp()) mousePath.remove(); Point clientCursor = Client.getMousePosition(); MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration * 2); if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp)) mousePath.add(mpp); MousePathPoint lastPoint = null; for (MousePathPoint a : mousePath) { if (lastPoint != null) { Color c = nextTrailColor(); int size = a.getAlpha() > 200 ? 5 : a.getAlpha() > 150 ? 4 : a.getAlpha() > 100 ? 3 : a.getAlpha() > 50 ? 2 : 1; g2.setStroke(cursorStroke); g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color Line2D line = new Line2D.Double(a.x - size, a.y, a.x + size, a.y); Line2D line2 = new Line2D.Double(a.x, a.y - size, a.x, a.y + size); AffineTransform at = AffineTransform.getRotateInstance( Math.toRadians(angle += 4), a.x, a.y); g2.draw(at.createTransformedShape(line)); g2.draw(at.createTransformedShape(line2)); g2.setStroke(new BasicStroke(1)); } lastPoint = a; } } public void nextRGB() { if (r == 255 && g < 255 & b == 0) { g++; } if (g == 255 && r > 0 && b == 0) { r--; } if (g == 255 && b < 255 && r == 0) { b++; } if (b == 255 && g > 0 && r == 0) { g--; } if (b == 255 && r < 255 && g == 0) { r++; } if (r == 255 && b > 0 && g == 0) { b--; } } public Color currentCursorColor() { if (!RAINBOW) { return cursorColor; } else { return new Color(r, g, b); } } public Color currentTrailColor() { if (!RAINBOW) { return trailColor; } else { return new Color(r, g, b); } } public Color nextCursorColor() { nextRGB(); return currentCursorColor(); } public Color nextTrailColor() { if (!RAINBOW) //Don't call this if it is set to rainbow so we're not double calling nextRGB() nextRGB(); return currentTrailColor(); } public class MousePathPoint extends Point { private long finishTime; private double lastingTime; private int alpha = 255; public MousePathPoint(int x, int y, int lastingTime) { super(x, y); this.lastingTime = lastingTime; finishTime = System.currentTimeMillis() + lastingTime; } public int getAlpha() { int newAlpha = ((int) ((finishTime - System.currentTimeMillis()) / (lastingTime / alpha))); if (newAlpha > 255) newAlpha = 255; if (newAlpha < 0) newAlpha = 0; return newAlpha; } public boolean isUp() { return System.currentTimeMillis() >= finishTime; } } }  
      Enjoy falsely tricking people into thinking your script is better than it is!
    24. Like
      holic got a reaction from xSam in DrawMouseUtil - Draw mouse trails and custom cursors   
      I made a nifty little mouse utility for drawing custom cursors and trails that I thought I would pass onto the community. Some of the trails are meh but I think the final product is still great and it's very straightforward to use.
      Credits:
      DarkMagican for the original mouse trails & rainbow source ENFILADE for MousePathPoint Setup functions
      void setCursorColor(Color cursorColor) Manually set the cursor's colour, default white void setCursorStroke(BasicStroke cursorStroke) Manually set the cursor's stroke thickness, default 2 void setTrailColor(Color trailColor) Manually set the trail's colour, default white void setRainbow(boolean RAINBOW) Set the mouse cursor & trail colour to be rainbow void setRandomColor() Set the mouse cursor & trail colour to be random, possibly rainbow Mouse functions
      void drawRandomMouse(Graphics g) Draws the randomly selected mouse graphic. void drawPlusMouse(Graphics g) Draws a "+" for the mouse, with shadow. void drawCrossMouse(Graphics g) Draws a "x" for the mouse, with shadow. void drawCircleMouse(Graphics g) Draws a circle for the mouse, with shadow. void drawDotMouse(Graphics g) Draws a dot for the mouse, with shadow. void drawRotatingCrossMouse(Graphics g) Draws an "x" for the mouse that rotates, with shadow. void drawRotatingCircleMouse(Graphics g) Draws a circle with rotating pie slices, with shadow. Trail functions
      void drawTrail(Graphics g) Draws a typical line-based mouse trail, varying size line width void drawZoomTrail(Graphics g) Draws a "ZOOM" for a trail, varying case and size void drawTextTrail(Graphics g, String trail) Draws your specified text for a trail, could work for script status? void drawDotTrail(Graphics g) Draws a series of dots as a trail, varying sizes void drawCircleTrail(Graphics g) Draws a series of circles as a trail, varying sizes void drawPlusTrail(Graphics g) Draws a series of "+" as a trail, varying sizes void drawRotatingSlashTrail(Graphics g) Draws a series of "/" as a trail that rotate, varying sizes void drawRotatingCrossTrail(Graphics g) Draws a series of "x" as a trail that rotate, varying sizes Usage example
      First, add DrawMouseUtil to your project by copying and pasting it into a file name DrawMouseUtil.java and importing it into your project
      Second, create a variable for DrawMouseUtil so you have consistency in your setup and calls.
      private DrawMouseUtil drawMouseUtil = new DrawMouseUtil();  
      Third, set your desired settings and add it to onStart. For this example we will be setting up the mouse randomly:
      @Override public void onStart() { drawMouseUtil.setRandomColor(); //Set a random colour and leave the stroke setting at default ..... }  
      Fourth, call your desired mouse cursor and trail in onPaint. For this example we will be using random settings:
      @Override public void onPaint(Graphics g) { drawMouseUtil.drawRandomMouse(g); drawMouseUtil.drawRandomMouseTrail(g); }  
      My favourite combination currently is either
      drawMouseUtil.drawRotatingCrossMouse(g) drawMouseUtil.drawRotatingCrossTrail(g) or
      drawMouseUtil.drawRotatingCircleMouse(g); drawMouseUtil.drawDotTrail(g);  
       
      DrawMouseUtil.java:
      /** DrawMouseUtil by holic **/ import org.dreambot.api.Client; import org.dreambot.api.methods.Calculations; import java.awt.*; import java.awt.geom.AffineTransform; import java.awt.geom.Arc2D; import java.awt.geom.Line2D; import java.util.LinkedList; import static org.dreambot.api.methods.MethodProvider.log; public class DrawMouseUtil { LinkedList<MousePathPoint> mousePath = new LinkedList<MousePathPoint>(); private boolean RAINBOW = false; private int STROKE = 2; private int mX, mY; private long angle; private BasicStroke cursorStroke = new BasicStroke(STROKE); private int randomMouse = Calculations.random(5); private int randomMouseTrail = Calculations.random(7); private Color cursorColor = Color.WHITE; private Color trailColor = cursorColor; private Color[] cursorColors = {new Color(78, 216, 255), new Color(90, 222, 98), new Color(215, 182, 77), new Color(232, 134, 124), new Color(215, 120, 124), new Color(183, 138, 215), Color.WHITE}; private AffineTransform oldTransform; private int r = 0, g = 0, b = 0, duration = 650; public DrawMouseUtil() { Client.getInstance().setDrawMouse(false); } public void setRainbow(boolean RAINBOW) { if (RAINBOW) { g = 255; } else { g = 0; } this.RAINBOW = RAINBOW; } public void setRandomColor() { if (Calculations.random(2) != 1) { log("Rainbow mouse!"); setRainbow(true); } else { setRainbow(false); cursorColor = getRandomColour(); trailColor = cursorColor; } } private Color getRandomColour() { return cursorColors[Calculations.random(cursorColors.length - 1)]; } public void setCursorStroke(BasicStroke cursorStroke) { this.cursorStroke = cursorStroke; } public void setCursorColor(Color cursorColor) { this.cursorColor = cursorColor; } public void setTrailColor(Color trailColor) { this.trailColor = trailColor; } public void drawRandomMouse(Graphics g) { switch (randomMouse) { case 0: drawPlusMouse(g); break; case 1: drawCrossMouse(g); break; case 2: drawCircleMouse(g); break; case 3: drawDotMouse(g); break; case 4: drawRotatingCrossMouse(g); break; case 5: drawRotatingCircleMouse(g); break; } } public void drawRandomMouseTrail(Graphics g) { switch (randomMouseTrail) { case 0: drawTrail(g); break; case 1: drawZoomTrail(g); break; case 2: drawPlusTrail(g); break; case 3: drawCircleTrail(g); break; case 4: drawDotTrail(g); break; case 5: drawRotatingSlashTrail(g); break; case 6: drawRotatingCrossTrail(g); break; case 7: drawTextTrail(g, "your text here"); break; } } /** * * ** ** ** ** * Mouse cursor * * ** ** ** ** **/ public void drawPlusMouse(Graphics g) { Graphics2D g2 = (Graphics2D) g; int s = 4; Point cP = Client.getMousePosition(); int cX = (int) cP.getX(); int cY = (int) cP.getY(); g2.setColor(Color.BLACK); g2.setStroke(cursorStroke); /* + Cursor */ g2.drawLine(cX - s + 1, cY + 1, cX + s + 1, cY + 1); g2.drawLine(cX + 1, cY - s + 1, cX + 1, cY + s + 1); g2.setColor(cursorColor); g2.drawLine(cX - s, cY, cX + s, cY); g2.drawLine(cX, cY - s, cX, cY + s); g2.setStroke(new BasicStroke(1)); } public void drawCrossMouse(Graphics g) { Graphics2D g2 = (Graphics2D) g; int s = 3; Point cP = Client.getMousePosition(); int cX = (int) cP.getX(); int cY = (int) cP.getY(); g2.setStroke(cursorStroke); g2.setColor(Color.BLACK); /* X Cursor */ g2.drawLine(cX - s + 1, cY - s + 1, cX + s + 1, cY + s + 1); g2.drawLine(cX - s + 1, cY + s + 1, cX + s + 1, cY - s + 1); g2.setColor(cursorColor); g2.drawLine(cX - s, cY - s, cX + s, cY + s); g2.drawLine(cX - s, cY + s, cX + s, cY - s); g2.setStroke(new BasicStroke(1)); } public void drawCircleMouse(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); int mX = Client.getMousePosition().x; mY = Client.getMousePosition().y; g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); if (mX != -1) { g2.setStroke(cursorStroke); g2.setColor(Color.BLACK); g2.drawOval(mX - 1, mY - 1, 4, 4); g2.setColor(cursorColor); g2.drawOval(mX - 2, mY - 2, 4, 4); g2.setStroke(new BasicStroke(1)); } } public void drawDotMouse(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); int mX = Client.getMousePosition().x; mY = Client.getMousePosition().y; g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); if (mX != -1) { g2.setStroke(cursorStroke); g2.setColor(Color.BLACK); g2.drawOval(mX - 1, mY - 1, 4, 4); g2.setColor(cursorColor); g2.drawOval(mX - 2, mY - 2, 4, 4); g2.setStroke(new BasicStroke(1)); } } public void drawRotatingCircleMouse(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); int mX = Client.getMousePosition().x; mY = Client.getMousePosition().y; g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); if (mX != -1) { g2.setStroke(cursorStroke); g2.drawOval(mX - 2, mY - 2, 4, 4); g2.setColor(cursorColor); g2.rotate(Math.toRadians(angle += 6), mX, mY); g2.draw(new Arc2D.Double(mX - 6, mY - 6, 12, 12, 330, 60, Arc2D.OPEN)); g2.draw(new Arc2D.Double(mX - 6, mY - 6, 12, 12, 151, 60, Arc2D.OPEN)); g2.setTransform(oldTransform); g2.setStroke(new BasicStroke(1)); } } public void drawRotatingCrossMouse(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); Point cP = Client.getMousePosition(); int cX = (int) cP.getX(); int cY = (int) cP.getY(); int s = 4; g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); if (mX != -1) { g2.setStroke(cursorStroke); g2.setColor(Color.BLACK); //g.rotate(Math.toRadians(angle+=1), mX, mY); Line2D lineShadow = new Line2D.Double(cX - s + 1, cY + 1, cX + s + 1, cY + 1); Line2D lineShadow2 = new Line2D.Double(cX + 1, cY - s + 1, cX + 1, cY + s + 1); AffineTransform atS = AffineTransform.getRotateInstance( Math.toRadians(angle += 4), cX + 1, cY + 1); AffineTransform atS2 = AffineTransform.getRotateInstance( Math.toRadians(angle), cX + 1, cY + 1); g2.draw(atS.createTransformedShape(lineShadow)); g2.draw(atS2.createTransformedShape(lineShadow2)); g2.setColor(nextCursorColor()); Line2D line = new Line2D.Double(cX - s, cY, cX + s, cY); Line2D line2 = new Line2D.Double(cX, cY - s, cX, cY + s); AffineTransform at = AffineTransform.getRotateInstance( Math.toRadians(angle += 4), cX, cY); AffineTransform at2 = AffineTransform.getRotateInstance( Math.toRadians(angle), cX, cY); // Draw the rotated line g2.draw(at.createTransformedShape(line)); g2.draw(at2.createTransformedShape(line2)); g2.setStroke(new BasicStroke(1)); } } /** * * ** ** ** ** * Mouse trails * * ** ** ** ** **/ public void drawTrail(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); int mX = Client.getMousePosition().x; mY = Client.getMousePosition().y; g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); while (!mousePath.isEmpty() && mousePath.peek().isUp()) mousePath.remove(); Point clientCursor = Client.getMousePosition(); MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration); if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp)) mousePath.add(mpp); MousePathPoint lastPoint = null; for (MousePathPoint a : mousePath) { if (lastPoint != null) { Color c = nextTrailColor(); int tmpcursorStroke = STROKE; if (STROKE > 1) tmpcursorStroke = (a.getAlpha() > 175 ? STROKE : STROKE - 1); g2.setStroke(new BasicStroke(tmpcursorStroke)); g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color g2.drawLine(a.x, a.y, lastPoint.x, lastPoint.y); g2.setStroke(new BasicStroke(1)); } lastPoint = a; } } public void drawZoomTrail(Graphics g) { String zoom = "zoom zoom "; int zoomIndex = 0, zoomIndexStart = -1; Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); g2.setFont(new Font("default", Font.BOLD, 12)); g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); while (!mousePath.isEmpty() && mousePath.peek().isUp()) mousePath.remove(); Point clientCursor = Client.getMousePosition(); MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration * 2); if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp)) mousePath.add(mpp); MousePathPoint lastPoint = null; for (MousePathPoint a : mousePath) { if (zoomIndex >= zoom.length()) zoomIndex = 0; String toDraw = String.valueOf(zoom.toCharArray()[zoomIndex]); if (lastPoint != null) { Color c = nextTrailColor(); toDraw = a.getAlpha() > 175 ? toDraw.toUpperCase() : toDraw; g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color g2.drawString(toDraw, a.x, a.y + 5); } lastPoint = a; zoomIndex++; } g2.setFont(new Font("default", Font.PLAIN, 12)); } public void drawTextTrail(Graphics g, String trail) { int zoomIndex = 0, zoomIndexStart = -1; Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); g2.setFont(new Font("default", Font.BOLD, 12)); g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); while (!mousePath.isEmpty() && mousePath.peek().isUp()) mousePath.remove(); Point clientCursor = Client.getMousePosition(); MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration * 2); if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp)) mousePath.add(mpp); MousePathPoint lastPoint = null; for (MousePathPoint a : mousePath) { if (lastPoint != null) { Color c = nextTrailColor(); g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color g2.drawString(trail, a.x, a.y); } lastPoint = a; zoomIndex++; } g2.setFont(new Font("default", Font.PLAIN, 12)); } public void drawDotTrail(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); while (!mousePath.isEmpty() && mousePath.peek().isUp()) mousePath.remove(); Point clientCursor = Client.getMousePosition(); MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration * 2); if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp)) mousePath.add(mpp); MousePathPoint lastPoint = null; for (MousePathPoint a : mousePath) { if (lastPoint != null) { Color c = nextTrailColor(); int size = a.getAlpha() > 200 ? 6 : a.getAlpha() > 150 ? 5 : a.getAlpha() > 100 ? 4 : a.getAlpha() > 50 ? 3 : 2; g2.setStroke(cursorStroke); g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color g2.fillOval(a.x, a.y, size, size); g2.setStroke(new BasicStroke(1)); } lastPoint = a; } } public void drawCircleTrail(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); while (!mousePath.isEmpty() && mousePath.peek().isUp()) mousePath.remove(); Point clientCursor = Client.getMousePosition(); MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration * 2); if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp)) mousePath.add(mpp); MousePathPoint lastPoint = null; for (MousePathPoint a : mousePath) { if (lastPoint != null) { Color c = nextTrailColor(); int size = a.getAlpha() > 200 ? 6 : a.getAlpha() > 150 ? 5 : a.getAlpha() > 100 ? 4 : a.getAlpha() > 50 ? 3 : 2; g2.setStroke(cursorStroke); g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color g2.drawOval(a.x, a.y, size, size); g2.setStroke(new BasicStroke(1)); } lastPoint = a; } } public void drawPlusTrail(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); while (!mousePath.isEmpty() && mousePath.peek().isUp()) mousePath.remove(); Point clientCursor = Client.getMousePosition(); MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration * 2); if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp)) mousePath.add(mpp); MousePathPoint lastPoint = null; for (MousePathPoint a : mousePath) { if (lastPoint != null) { Color c = nextTrailColor(); int size = a.getAlpha() > 200 ? 5 : a.getAlpha() > 150 ? 4 : a.getAlpha() > 100 ? 3 : a.getAlpha() > 50 ? 2 : 1; g2.setStroke(cursorStroke); g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color g2.drawLine(a.x - size + 1, a.y + 1, a.x + size + 1, a.y + 1); g2.drawLine(a.x + 1, a.y - size + 1, a.x + 1, a.y + size + 1); g2.setStroke(new BasicStroke(1)); } lastPoint = a; } } public void drawRotatingSlashTrail(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); while (!mousePath.isEmpty() && mousePath.peek().isUp()) mousePath.remove(); Point clientCursor = Client.getMousePosition(); MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration * 2); if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp)) mousePath.add(mpp); MousePathPoint lastPoint = null; for (MousePathPoint a : mousePath) { if (lastPoint != null) { Color c = nextTrailColor(); int size = a.getAlpha() > 200 ? 5 : a.getAlpha() > 150 ? 4 : a.getAlpha() > 100 ? 3 : a.getAlpha() > 50 ? 2 : 1; g2.setStroke(cursorStroke); g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color Line2D line = new Line2D.Double(a.x - size, a.y, a.x + size, a.y); Line2D line2 = new Line2D.Double(a.x, a.y - size, a.x, a.y + size); AffineTransform at = AffineTransform.getRotateInstance( Math.toRadians(angle += 4), a.x, a.y); g2.draw(at.createTransformedShape(line)); g2.setStroke(new BasicStroke(1)); } lastPoint = a; } } public void drawRotatingCrossTrail(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); while (!mousePath.isEmpty() && mousePath.peek().isUp()) mousePath.remove(); Point clientCursor = Client.getMousePosition(); MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration * 2); if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp)) mousePath.add(mpp); MousePathPoint lastPoint = null; for (MousePathPoint a : mousePath) { if (lastPoint != null) { Color c = nextTrailColor(); int size = a.getAlpha() > 200 ? 5 : a.getAlpha() > 150 ? 4 : a.getAlpha() > 100 ? 3 : a.getAlpha() > 50 ? 2 : 1; g2.setStroke(cursorStroke); g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color Line2D line = new Line2D.Double(a.x - size, a.y, a.x + size, a.y); Line2D line2 = new Line2D.Double(a.x, a.y - size, a.x, a.y + size); AffineTransform at = AffineTransform.getRotateInstance( Math.toRadians(angle += 4), a.x, a.y); g2.draw(at.createTransformedShape(line)); g2.draw(at.createTransformedShape(line2)); g2.setStroke(new BasicStroke(1)); } lastPoint = a; } } public void nextRGB() { if (r == 255 && g < 255 & b == 0) { g++; } if (g == 255 && r > 0 && b == 0) { r--; } if (g == 255 && b < 255 && r == 0) { b++; } if (b == 255 && g > 0 && r == 0) { g--; } if (b == 255 && r < 255 && g == 0) { r++; } if (r == 255 && b > 0 && g == 0) { b--; } } public Color currentCursorColor() { if (!RAINBOW) { return cursorColor; } else { return new Color(r, g, b); } } public Color currentTrailColor() { if (!RAINBOW) { return trailColor; } else { return new Color(r, g, b); } } public Color nextCursorColor() { nextRGB(); return currentCursorColor(); } public Color nextTrailColor() { if (!RAINBOW) //Don't call this if it is set to rainbow so we're not double calling nextRGB() nextRGB(); return currentTrailColor(); } public class MousePathPoint extends Point { private long finishTime; private double lastingTime; private int alpha = 255; public MousePathPoint(int x, int y, int lastingTime) { super(x, y); this.lastingTime = lastingTime; finishTime = System.currentTimeMillis() + lastingTime; } public int getAlpha() { int newAlpha = ((int) ((finishTime - System.currentTimeMillis()) / (lastingTime / alpha))); if (newAlpha > 255) newAlpha = 255; if (newAlpha < 0) newAlpha = 0; return newAlpha; } public boolean isUp() { return System.currentTimeMillis() >= finishTime; } } }  
      Enjoy falsely tricking people into thinking your script is better than it is!
    25. Upvote
      holic got a reaction from LordJashin32 in DrawMouseUtil - Draw mouse trails and custom cursors   
      I made a nifty little mouse utility for drawing custom cursors and trails that I thought I would pass onto the community. Some of the trails are meh but I think the final product is still great and it's very straightforward to use.
      Credits:
      DarkMagican for the original mouse trails & rainbow source ENFILADE for MousePathPoint Setup functions
      void setCursorColor(Color cursorColor) Manually set the cursor's colour, default white void setCursorStroke(BasicStroke cursorStroke) Manually set the cursor's stroke thickness, default 2 void setTrailColor(Color trailColor) Manually set the trail's colour, default white void setRainbow(boolean RAINBOW) Set the mouse cursor & trail colour to be rainbow void setRandomColor() Set the mouse cursor & trail colour to be random, possibly rainbow Mouse functions
      void drawRandomMouse(Graphics g) Draws the randomly selected mouse graphic. void drawPlusMouse(Graphics g) Draws a "+" for the mouse, with shadow. void drawCrossMouse(Graphics g) Draws a "x" for the mouse, with shadow. void drawCircleMouse(Graphics g) Draws a circle for the mouse, with shadow. void drawDotMouse(Graphics g) Draws a dot for the mouse, with shadow. void drawRotatingCrossMouse(Graphics g) Draws an "x" for the mouse that rotates, with shadow. void drawRotatingCircleMouse(Graphics g) Draws a circle with rotating pie slices, with shadow. Trail functions
      void drawTrail(Graphics g) Draws a typical line-based mouse trail, varying size line width void drawZoomTrail(Graphics g) Draws a "ZOOM" for a trail, varying case and size void drawTextTrail(Graphics g, String trail) Draws your specified text for a trail, could work for script status? void drawDotTrail(Graphics g) Draws a series of dots as a trail, varying sizes void drawCircleTrail(Graphics g) Draws a series of circles as a trail, varying sizes void drawPlusTrail(Graphics g) Draws a series of "+" as a trail, varying sizes void drawRotatingSlashTrail(Graphics g) Draws a series of "/" as a trail that rotate, varying sizes void drawRotatingCrossTrail(Graphics g) Draws a series of "x" as a trail that rotate, varying sizes Usage example
      First, add DrawMouseUtil to your project by copying and pasting it into a file name DrawMouseUtil.java and importing it into your project
      Second, create a variable for DrawMouseUtil so you have consistency in your setup and calls.
      private DrawMouseUtil drawMouseUtil = new DrawMouseUtil();  
      Third, set your desired settings and add it to onStart. For this example we will be setting up the mouse randomly:
      @Override public void onStart() { drawMouseUtil.setRandomColor(); //Set a random colour and leave the stroke setting at default ..... }  
      Fourth, call your desired mouse cursor and trail in onPaint. For this example we will be using random settings:
      @Override public void onPaint(Graphics g) { drawMouseUtil.drawRandomMouse(g); drawMouseUtil.drawRandomMouseTrail(g); }  
      My favourite combination currently is either
      drawMouseUtil.drawRotatingCrossMouse(g) drawMouseUtil.drawRotatingCrossTrail(g) or
      drawMouseUtil.drawRotatingCircleMouse(g); drawMouseUtil.drawDotTrail(g);  
       
      DrawMouseUtil.java:
      /** DrawMouseUtil by holic **/ import org.dreambot.api.Client; import org.dreambot.api.methods.Calculations; import java.awt.*; import java.awt.geom.AffineTransform; import java.awt.geom.Arc2D; import java.awt.geom.Line2D; import java.util.LinkedList; import static org.dreambot.api.methods.MethodProvider.log; public class DrawMouseUtil { LinkedList<MousePathPoint> mousePath = new LinkedList<MousePathPoint>(); private boolean RAINBOW = false; private int STROKE = 2; private int mX, mY; private long angle; private BasicStroke cursorStroke = new BasicStroke(STROKE); private int randomMouse = Calculations.random(5); private int randomMouseTrail = Calculations.random(7); private Color cursorColor = Color.WHITE; private Color trailColor = cursorColor; private Color[] cursorColors = {new Color(78, 216, 255), new Color(90, 222, 98), new Color(215, 182, 77), new Color(232, 134, 124), new Color(215, 120, 124), new Color(183, 138, 215), Color.WHITE}; private AffineTransform oldTransform; private int r = 0, g = 0, b = 0, duration = 650; public DrawMouseUtil() { Client.getInstance().setDrawMouse(false); } public void setRainbow(boolean RAINBOW) { if (RAINBOW) { g = 255; } else { g = 0; } this.RAINBOW = RAINBOW; } public void setRandomColor() { if (Calculations.random(2) != 1) { log("Rainbow mouse!"); setRainbow(true); } else { setRainbow(false); cursorColor = getRandomColour(); trailColor = cursorColor; } } private Color getRandomColour() { return cursorColors[Calculations.random(cursorColors.length - 1)]; } public void setCursorStroke(BasicStroke cursorStroke) { this.cursorStroke = cursorStroke; } public void setCursorColor(Color cursorColor) { this.cursorColor = cursorColor; } public void setTrailColor(Color trailColor) { this.trailColor = trailColor; } public void drawRandomMouse(Graphics g) { switch (randomMouse) { case 0: drawPlusMouse(g); break; case 1: drawCrossMouse(g); break; case 2: drawCircleMouse(g); break; case 3: drawDotMouse(g); break; case 4: drawRotatingCrossMouse(g); break; case 5: drawRotatingCircleMouse(g); break; } } public void drawRandomMouseTrail(Graphics g) { switch (randomMouseTrail) { case 0: drawTrail(g); break; case 1: drawZoomTrail(g); break; case 2: drawPlusTrail(g); break; case 3: drawCircleTrail(g); break; case 4: drawDotTrail(g); break; case 5: drawRotatingSlashTrail(g); break; case 6: drawRotatingCrossTrail(g); break; case 7: drawTextTrail(g, "your text here"); break; } } /** * * ** ** ** ** * Mouse cursor * * ** ** ** ** **/ public void drawPlusMouse(Graphics g) { Graphics2D g2 = (Graphics2D) g; int s = 4; Point cP = Client.getMousePosition(); int cX = (int) cP.getX(); int cY = (int) cP.getY(); g2.setColor(Color.BLACK); g2.setStroke(cursorStroke); /* + Cursor */ g2.drawLine(cX - s + 1, cY + 1, cX + s + 1, cY + 1); g2.drawLine(cX + 1, cY - s + 1, cX + 1, cY + s + 1); g2.setColor(cursorColor); g2.drawLine(cX - s, cY, cX + s, cY); g2.drawLine(cX, cY - s, cX, cY + s); g2.setStroke(new BasicStroke(1)); } public void drawCrossMouse(Graphics g) { Graphics2D g2 = (Graphics2D) g; int s = 3; Point cP = Client.getMousePosition(); int cX = (int) cP.getX(); int cY = (int) cP.getY(); g2.setStroke(cursorStroke); g2.setColor(Color.BLACK); /* X Cursor */ g2.drawLine(cX - s + 1, cY - s + 1, cX + s + 1, cY + s + 1); g2.drawLine(cX - s + 1, cY + s + 1, cX + s + 1, cY - s + 1); g2.setColor(cursorColor); g2.drawLine(cX - s, cY - s, cX + s, cY + s); g2.drawLine(cX - s, cY + s, cX + s, cY - s); g2.setStroke(new BasicStroke(1)); } public void drawCircleMouse(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); int mX = Client.getMousePosition().x; mY = Client.getMousePosition().y; g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); if (mX != -1) { g2.setStroke(cursorStroke); g2.setColor(Color.BLACK); g2.drawOval(mX - 1, mY - 1, 4, 4); g2.setColor(cursorColor); g2.drawOval(mX - 2, mY - 2, 4, 4); g2.setStroke(new BasicStroke(1)); } } public void drawDotMouse(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); int mX = Client.getMousePosition().x; mY = Client.getMousePosition().y; g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); if (mX != -1) { g2.setStroke(cursorStroke); g2.setColor(Color.BLACK); g2.drawOval(mX - 1, mY - 1, 4, 4); g2.setColor(cursorColor); g2.drawOval(mX - 2, mY - 2, 4, 4); g2.setStroke(new BasicStroke(1)); } } public void drawRotatingCircleMouse(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); int mX = Client.getMousePosition().x; mY = Client.getMousePosition().y; g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); if (mX != -1) { g2.setStroke(cursorStroke); g2.drawOval(mX - 2, mY - 2, 4, 4); g2.setColor(cursorColor); g2.rotate(Math.toRadians(angle += 6), mX, mY); g2.draw(new Arc2D.Double(mX - 6, mY - 6, 12, 12, 330, 60, Arc2D.OPEN)); g2.draw(new Arc2D.Double(mX - 6, mY - 6, 12, 12, 151, 60, Arc2D.OPEN)); g2.setTransform(oldTransform); g2.setStroke(new BasicStroke(1)); } } public void drawRotatingCrossMouse(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); Point cP = Client.getMousePosition(); int cX = (int) cP.getX(); int cY = (int) cP.getY(); int s = 4; g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); if (mX != -1) { g2.setStroke(cursorStroke); g2.setColor(Color.BLACK); //g.rotate(Math.toRadians(angle+=1), mX, mY); Line2D lineShadow = new Line2D.Double(cX - s + 1, cY + 1, cX + s + 1, cY + 1); Line2D lineShadow2 = new Line2D.Double(cX + 1, cY - s + 1, cX + 1, cY + s + 1); AffineTransform atS = AffineTransform.getRotateInstance( Math.toRadians(angle += 4), cX + 1, cY + 1); AffineTransform atS2 = AffineTransform.getRotateInstance( Math.toRadians(angle), cX + 1, cY + 1); g2.draw(atS.createTransformedShape(lineShadow)); g2.draw(atS2.createTransformedShape(lineShadow2)); g2.setColor(nextCursorColor()); Line2D line = new Line2D.Double(cX - s, cY, cX + s, cY); Line2D line2 = new Line2D.Double(cX, cY - s, cX, cY + s); AffineTransform at = AffineTransform.getRotateInstance( Math.toRadians(angle += 4), cX, cY); AffineTransform at2 = AffineTransform.getRotateInstance( Math.toRadians(angle), cX, cY); // Draw the rotated line g2.draw(at.createTransformedShape(line)); g2.draw(at2.createTransformedShape(line2)); g2.setStroke(new BasicStroke(1)); } } /** * * ** ** ** ** * Mouse trails * * ** ** ** ** **/ public void drawTrail(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); int mX = Client.getMousePosition().x; mY = Client.getMousePosition().y; g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); while (!mousePath.isEmpty() && mousePath.peek().isUp()) mousePath.remove(); Point clientCursor = Client.getMousePosition(); MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration); if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp)) mousePath.add(mpp); MousePathPoint lastPoint = null; for (MousePathPoint a : mousePath) { if (lastPoint != null) { Color c = nextTrailColor(); int tmpcursorStroke = STROKE; if (STROKE > 1) tmpcursorStroke = (a.getAlpha() > 175 ? STROKE : STROKE - 1); g2.setStroke(new BasicStroke(tmpcursorStroke)); g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color g2.drawLine(a.x, a.y, lastPoint.x, lastPoint.y); g2.setStroke(new BasicStroke(1)); } lastPoint = a; } } public void drawZoomTrail(Graphics g) { String zoom = "zoom zoom "; int zoomIndex = 0, zoomIndexStart = -1; Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); g2.setFont(new Font("default", Font.BOLD, 12)); g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); while (!mousePath.isEmpty() && mousePath.peek().isUp()) mousePath.remove(); Point clientCursor = Client.getMousePosition(); MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration * 2); if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp)) mousePath.add(mpp); MousePathPoint lastPoint = null; for (MousePathPoint a : mousePath) { if (zoomIndex >= zoom.length()) zoomIndex = 0; String toDraw = String.valueOf(zoom.toCharArray()[zoomIndex]); if (lastPoint != null) { Color c = nextTrailColor(); toDraw = a.getAlpha() > 175 ? toDraw.toUpperCase() : toDraw; g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color g2.drawString(toDraw, a.x, a.y + 5); } lastPoint = a; zoomIndex++; } g2.setFont(new Font("default", Font.PLAIN, 12)); } public void drawTextTrail(Graphics g, String trail) { int zoomIndex = 0, zoomIndexStart = -1; Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); g2.setFont(new Font("default", Font.BOLD, 12)); g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); while (!mousePath.isEmpty() && mousePath.peek().isUp()) mousePath.remove(); Point clientCursor = Client.getMousePosition(); MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration * 2); if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp)) mousePath.add(mpp); MousePathPoint lastPoint = null; for (MousePathPoint a : mousePath) { if (lastPoint != null) { Color c = nextTrailColor(); g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color g2.drawString(trail, a.x, a.y); } lastPoint = a; zoomIndex++; } g2.setFont(new Font("default", Font.PLAIN, 12)); } public void drawDotTrail(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); while (!mousePath.isEmpty() && mousePath.peek().isUp()) mousePath.remove(); Point clientCursor = Client.getMousePosition(); MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration * 2); if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp)) mousePath.add(mpp); MousePathPoint lastPoint = null; for (MousePathPoint a : mousePath) { if (lastPoint != null) { Color c = nextTrailColor(); int size = a.getAlpha() > 200 ? 6 : a.getAlpha() > 150 ? 5 : a.getAlpha() > 100 ? 4 : a.getAlpha() > 50 ? 3 : 2; g2.setStroke(cursorStroke); g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color g2.fillOval(a.x, a.y, size, size); g2.setStroke(new BasicStroke(1)); } lastPoint = a; } } public void drawCircleTrail(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); while (!mousePath.isEmpty() && mousePath.peek().isUp()) mousePath.remove(); Point clientCursor = Client.getMousePosition(); MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration * 2); if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp)) mousePath.add(mpp); MousePathPoint lastPoint = null; for (MousePathPoint a : mousePath) { if (lastPoint != null) { Color c = nextTrailColor(); int size = a.getAlpha() > 200 ? 6 : a.getAlpha() > 150 ? 5 : a.getAlpha() > 100 ? 4 : a.getAlpha() > 50 ? 3 : 2; g2.setStroke(cursorStroke); g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color g2.drawOval(a.x, a.y, size, size); g2.setStroke(new BasicStroke(1)); } lastPoint = a; } } public void drawPlusTrail(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); while (!mousePath.isEmpty() && mousePath.peek().isUp()) mousePath.remove(); Point clientCursor = Client.getMousePosition(); MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration * 2); if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp)) mousePath.add(mpp); MousePathPoint lastPoint = null; for (MousePathPoint a : mousePath) { if (lastPoint != null) { Color c = nextTrailColor(); int size = a.getAlpha() > 200 ? 5 : a.getAlpha() > 150 ? 4 : a.getAlpha() > 100 ? 3 : a.getAlpha() > 50 ? 2 : 1; g2.setStroke(cursorStroke); g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color g2.drawLine(a.x - size + 1, a.y + 1, a.x + size + 1, a.y + 1); g2.drawLine(a.x + 1, a.y - size + 1, a.x + 1, a.y + size + 1); g2.setStroke(new BasicStroke(1)); } lastPoint = a; } } public void drawRotatingSlashTrail(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); while (!mousePath.isEmpty() && mousePath.peek().isUp()) mousePath.remove(); Point clientCursor = Client.getMousePosition(); MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration * 2); if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp)) mousePath.add(mpp); MousePathPoint lastPoint = null; for (MousePathPoint a : mousePath) { if (lastPoint != null) { Color c = nextTrailColor(); int size = a.getAlpha() > 200 ? 5 : a.getAlpha() > 150 ? 4 : a.getAlpha() > 100 ? 3 : a.getAlpha() > 50 ? 2 : 1; g2.setStroke(cursorStroke); g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color Line2D line = new Line2D.Double(a.x - size, a.y, a.x + size, a.y); Line2D line2 = new Line2D.Double(a.x, a.y - size, a.x, a.y + size); AffineTransform at = AffineTransform.getRotateInstance( Math.toRadians(angle += 4), a.x, a.y); g2.draw(at.createTransformedShape(line)); g2.setStroke(new BasicStroke(1)); } lastPoint = a; } } public void drawRotatingCrossTrail(Graphics g) { Graphics2D g2 = (Graphics2D) g; oldTransform = g2.getTransform(); g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); while (!mousePath.isEmpty() && mousePath.peek().isUp()) mousePath.remove(); Point clientCursor = Client.getMousePosition(); MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, duration * 2); if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp)) mousePath.add(mpp); MousePathPoint lastPoint = null; for (MousePathPoint a : mousePath) { if (lastPoint != null) { Color c = nextTrailColor(); int size = a.getAlpha() > 200 ? 5 : a.getAlpha() > 150 ? 4 : a.getAlpha() > 100 ? 3 : a.getAlpha() > 50 ? 2 : 1; g2.setStroke(cursorStroke); g2.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), a.getAlpha())); //trail color Line2D line = new Line2D.Double(a.x - size, a.y, a.x + size, a.y); Line2D line2 = new Line2D.Double(a.x, a.y - size, a.x, a.y + size); AffineTransform at = AffineTransform.getRotateInstance( Math.toRadians(angle += 4), a.x, a.y); g2.draw(at.createTransformedShape(line)); g2.draw(at.createTransformedShape(line2)); g2.setStroke(new BasicStroke(1)); } lastPoint = a; } } public void nextRGB() { if (r == 255 && g < 255 & b == 0) { g++; } if (g == 255 && r > 0 && b == 0) { r--; } if (g == 255 && b < 255 && r == 0) { b++; } if (b == 255 && g > 0 && r == 0) { g--; } if (b == 255 && r < 255 && g == 0) { r++; } if (r == 255 && b > 0 && g == 0) { b--; } } public Color currentCursorColor() { if (!RAINBOW) { return cursorColor; } else { return new Color(r, g, b); } } public Color currentTrailColor() { if (!RAINBOW) { return trailColor; } else { return new Color(r, g, b); } } public Color nextCursorColor() { nextRGB(); return currentCursorColor(); } public Color nextTrailColor() { if (!RAINBOW) //Don't call this if it is set to rainbow so we're not double calling nextRGB() nextRGB(); return currentTrailColor(); } public class MousePathPoint extends Point { private long finishTime; private double lastingTime; private int alpha = 255; public MousePathPoint(int x, int y, int lastingTime) { super(x, y); this.lastingTime = lastingTime; finishTime = System.currentTimeMillis() + lastingTime; } public int getAlpha() { int newAlpha = ((int) ((finishTime - System.currentTimeMillis()) / (lastingTime / alpha))); if (newAlpha > 255) newAlpha = 255; if (newAlpha < 0) newAlpha = 0; return newAlpha; } public boolean isUp() { return System.currentTimeMillis() >= finishTime; } } }  
      Enjoy falsely tricking people into thinking your script is better than it is!
    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.