Jump to content

battleguard

Members
  • Posts

    54
  • Joined

  • Last visited

  • Feedback

    100%

Posts posted by battleguard

  1. You should look into using a memory profiler and taking snapshots of your memory at the start of your run and after a while when it reaches the higher memory levels. Then look at the objects its holding onto and tracking down where those references are created. I have only done this mainly in c# though for work but I am sure its just as easy to do in java.

     

    Edit from what I can tell it looks like osbot adds this argument when running a script "-XX:+DisableAttachMechanism". Which looks to disable heap dumps if anyone knows if this is correct and you cannot looks at your scripts heap please let me know.

  2. Works great thanks for open sourcing this.

    The main problem I ran into was the stop was not working because the message

    } else if (outputLine.contains("OSBot is now ready!")) {

    https://github.com/Explv/osbot_manager/blob/master/osbot_manager/src/bot_parameters/configuration/Configuration.java#L422

    never fired on mine so I changed it to

    } else if (outputLine.contains("Successfully loaded OSBot!")) {
    

    Also I am hoping I can find a way to call my onstop on the script so I can gracefully shutdown the script.

    And it would be nice for the parameters you put on a script to show up when selecting them because if you have 2 different CLI commands you cannot see the difference in the script selector.

    If you are down for changes I can push some of these up to you I also made it a maven project so its easier to get running after cloning.

  3. Instead of calling this line

    !myPlayer().isMoving() & !myPlayer().isAnimating()

    On every single area type you should just check the statement at the beginning of your loop and return if either is found to be true.

    Once you get more java experience you should look into using parallel arrays or creating a class for each area jump action. That way you dont have a long list of if statements. A good way to think of it is what if you had 1000 areas for that course how would you handle it so that you did not have to call 1000 if checks in your main loop.

    • Like 1
  4. Here is some code that i wrote years ago that might be of some help to you. It looks like I went with checking the message listener for when the coal bag was full you could also though count the number of times you put coal in the bag I would imagine.

     

    https://github.com/battleguard/rsbot5scripts/blob/master/rsbot5/src/com/battleguard/olderscripts/p****bot-Miner/CoalBag.java

     

    package Miner;
    
    import org.p****bot.core.event.events.MessageEvent;
    import org.p****bot.core.script.job.Task;
    import org.p****bot.core.script.job.state.Node;
    import org.p****bot.game.api.methods.tab.Inventory;
    import org.p****bot.game.api.wrappers.node.Item;
    
    public class CoalBag extends Node {
    	public static final int COAL_BAG_ID = 18339;
    	private static final int COAL_ID = 453;
    	
    	private static final String EMTPY_MSG = "Your coal bag is empty.";	
    	private static final String FULL_MSG = "Your coal bag is already full.";
    	
    	private static boolean inUse = false;
    	public static boolean bagFull = false;
    
    	public static final boolean setup() {
    		return inUse = Inventory.getCount(COAL_BAG_ID) > 0;
    	}
    	
    	public static final boolean isValid() {
    		return inUse;
    	}
    
    	public static final void withdrawCoal() {
    		RockTimer.state = "Withdrawing Coal";
    		final Item CoalBag = Inventory.getItem(COAL_BAG_ID);
    		if (CoalBag != null) {
    			if(CoalBag.getWidgetChild().interact("Withdraw-many")) {
    				bagFull = false;
    			} else {
    				checkBag();
    			}
    			Task.sleep(1000);
    		}
    	}
    
    	public static final void checkBag() {
    		RockTimer.state = "Checking Bag";
    		final Item CoalBag = Inventory.getItem(COAL_BAG_ID);
    		if (CoalBag != null) {
    			CoalBag.getWidgetChild().click(true);
    		}
    	}
    
    	public static final void putCoalInBag() {
    		RockTimer.state = "Adding coal to bag";
    		final Item CoalBag = Inventory.getItem(COAL_BAG_ID);
    		final Item Coal = Inventory.getItem(COAL_ID);
    		if (CoalBag != null && Coal != null) {
    			Coal.getWidgetChild().click(true);
    			Task.sleep(1000);
    			CoalBag.getWidgetChild().click(true);
    			Task.sleep(1000);
    		}
    	}
    
    	public static final void checkMessage(final MessageEvent msg) {
    		if (msg.getId() == 0) {
    			if (msg.getMessage().equals(FULL_MSG)) {
    				bagFull = true;
    			}
    			if (msg.getMessage().equals(EMTPY_MSG)) {
    				bagFull = false;
    			}
    		}
    	}
    
    	@Override
    	public boolean activate() {
    		return !Banker.isDepoOpen() && Inventory.isFull() && !bagFull;
    	}
    
    	@Override
    	public void execute() {
    		putCoalInBag();
    	}
    
    }

     

  5. 12 hours ago, Karyza said:

    offer ea?

    I am willing to offer 360k per account.

    Since a tutorial account costs only 120k I figured 240k to do 7qp with one of the many free 7qp scripts should be enough.

  6. 6 minutes ago, IDontEB said:

    90ea for oak logs is normal to you?

    considering thats just one item I dont see that as a trend.

    Look at 3 months out on

    Yew Logs
    Willow Logs
    Gold ore
    Iron ore
    Raw Lobster
    Big Bones
    Cowhide
    Copper ore
    etc...

    They all are going through there normal peaks and valleys

    I feel like all items would be surging like oak logs if there was a big hit to the f2p bots.
     

  7.     public static OsBuddyItemConfig[] getItems() throws IOException {
            JsonParser parser = new JsonParser();
            JsonElement parse = parser.parse(readUrl("https://rsbuddy.com/exchange/summary.json"));
            JsonObject asJsonObject = parse.getAsJsonObject();
            Gson gson = new Gson();
            Set<Map.Entry<String, JsonElement>> entries = asJsonObject.entrySet();
            Iterator<Map.Entry<String, JsonElement>> iterator = entries.iterator();
            OsBuddyItemConfig[] items = new OsBuddyItemConfig[entries.size()];
            for(int i = 0; i < entries.size(); i++)
            {
                JsonElement value = iterator.next().getValue();
                OsBuddyItemConfig osBuddyItemConfig = gson.fromJson(value, OsBuddyItemConfig.class);
                items[i] = osBuddyItemConfig;
            }
            return items;
        }
    
        private static String readUrl(final String urlPath) throws IOException {
            URL url = new URL(urlPath);
            URLConnection con = url.openConnection();
            con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36");
            con.setUseCaches(true);
            BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream()));
            String json = br.readLine();
            br.close();
            return json;
        }
    
        public class OsBuddyItemConfig
        {
            public int id;
            public String name;
            public int buy_average;
            public int sp;
            public int overall_average;
            public boolean members;
            public int sell_average;
        }

    Here is what I have been using lately, but this requires you to extract GSON's source into your script, but its so nice and clean and I use many json classes so rolling my own parser just was not worth it.

    • Like 1
  8. I have a problem where I am making a folder hierarchy that has a folder for each run and a folder for each account being ran. This works great for saving off everything, but I cannot seem to find a way to change where the script logging output goes at runtime. Currently I log the script output using intellij's save console to output file feature, but I need to change the folder path at runtime so this wont work.

    - Things I have tried or thought about
    - redirecting output of jar using > out.txt in command line arguments but once again this is not runtime
    - redirecting system output using System.setOut(printstream), but once again the super locked down jar does not support this feature sadly
    - I can change all my calls in the entire script from the bots logger to a custom logger that I have implemented that saves the output to a fiile

     

    So far this is all I have thought of and I really do not like the idea of using the final option.

  9. 12 hours ago, battleguard said:

    I am trying to modify the policy information so I can use rxjava in my local script. I looked into the permissions you suggested because it looks like you are correct and its not something in osbot at all. I tried changing my policy to allow everything and I tried manually specifying the policy file when loading up the jar with vm variables but nothing seems to work sadly.

     

    4 hours ago, nosepicker said:

    As I mentioned before - OSBot blocks all external dependencies and correct me if I'm wrong. As someone mentioned you can extract the source of the external jar and place it in your script - should work but might be messy. I gave up playing around with this when I noticed that even simple JSON parser jars are blocked :D

    I didnt think of extracting the source thanks I will have to try that and let you know how it works.

  10. On 12/28/2017 at 5:10 PM, jca said:

    You can do it all with core Java if you build an API and run a POST request to an endpoint with account details. Then to parse data use Gson as a dependency and reference it like a normal object. 

    But as Alek said, if you don't need to use it across servers just generate a local file. 

    From what I've found with SystemProperties is it's the external environment that you're working in blocking the jar - which isn't OSBOT specific. Look at setting permissions on system. What are you trying to do? There's probably a simpler solution that doesn't require modifying permissions.

    I am trying to modify the policy information so I can use rxjava in my local script. I looked into the permissions you suggested because it looks like you are correct and its not something in osbot at all. I tried changing my policy to allow everything and I tried manually specifying the policy file when loading up the jar with vm variables but nothing seems to work sadly.

  11. 5 hours ago, nosepicker said:

    As far as I tried, OSBot blocks external dependencies (jars), like jdbc or whatever else. Correct me if I'm wrong.

    To bypass this you can either do calls via POST from your script to something which will parse your data, or can communicate via sockets to an external program.

    you can extract the jar inside your artifact to get around this problem. The main problem is it has a locked down security permissions so it might not be able to do everything you need it to do. Also if your making an SDN script I highly doubt the developers are going to approve of a script that has giant library's extracted into there main script jar.

     

    Capture.PNG

     

    @Alek Is there anyway to fix this problem when running the jar where I cannot view the System Properties.

    This line here "System.getProperties();" will always throw this error -> Blocked permission: ("java.util.PropertyPermission" "*" "read,write").

    I am using jxjava in a script but I am unable to do anything with time intervals because it requires making a scheduler from a SchedulerPoolFactory but on the static constructor of the class it blows up because it cannot access these properties (https://github.com/ReactiveX/RxJava/blob/2.x/src/main/java/io/reactivex/internal/schedulers/SchedulerPoolFactory.java#L95)

        static {
            boolean purgeEnable = true;
            int purgePeriod = 1;
    
            Properties properties = System.getProperties();
    
            if (properties.containsKey(PURGE_ENABLED_KEY)) {
                purgeEnable = Boolean.getBoolean(PURGE_ENABLED_KEY);
            }
    
            if (purgeEnable && properties.containsKey(PURGE_PERIOD_SECONDS_KEY)) {
                purgePeriod = Integer.getInteger(PURGE_PERIOD_SECONDS_KEY, purgePeriod);
            }
    
            PURGE_ENABLED = purgeEnable;
            PURGE_PERIOD_SECONDS = purgePeriod;
    
            start();
        }

     

  12. Debugging scripts in osbot is pretty simple once you learn abut debugging localprocesses. Here are the basic steps you will need

    1. Add a breakpoint into your local script you have create

    2. Set your build output to go to your OSBOT scripts folder

    uWNlKWR.gif

    fCc1j3i.gif

    3. Create a debug configuration that starts an application with the entry point of org.osbot.boot

    hDNkilV.gif

    4. Run your configuration (do not debug it) to bring up osbot so your local processes in intellij can see it.

    5fyQfdo.gif

    5. log into your account and then you are ready to attach to the local script process through intellij. Once you have attached run your script and you should now be debugging your script so any breakpoints that the code hits will now stop and allow you to see the variables.

    bXTYCEU.gif

    6. you can also add watches to quickly look up things without using print lines and make debugging much easier now.

    rZoII0h.gif

    7. if you need to do more complex statements you can use evaluate expression to have multiple lines.

    Looks like images got deleted from site so to view the gifs that explain each step use this google cache link

    https://webcache.googleusercontent.com/search?q=cache:zre9YWkp3WsJ:https://osbot.org/forum/topic/133159-using-the-debugger-with-osbot-local-scripts/+&amp;cd=1&amp;hl=en&amp;ct=clnk&amp;gl=us

    or this imgur link: https://imgur.com/a/smwr5lu

    C1ftlgJ.gif

    • Like 10
  13. you can debug osbot by running debugging intellij as an application and setting your main class to org.osbot.Boot. You then need to just use run instead of debug configuration when running it. Once you start your script inside the jar you can then go to run->attach process and you will now see your script running in a process you can attach to. From there your breakpoints should work

     

     

    debugger.PNG

    • Like 2
×
×
  • Create New...