Thread: Object dump script for RSBot

Page 1 of 2 12 LastLast
Results 1 to 10 of 16
  1. #1 Object dump script for RSBot 
    Valar Morghulis

    Laxika's Avatar
    Join Date
    Sep 2006
    Age
    29
    Posts
    2,813
    Thanks given
    1,804
    Thanks received
    274
    Rep Power
    2128
    Here the script what I wrote to dump out objects. Now it save every tile what have object on it to a new file so it can generate 30k+ file, or you change it to use a PHP script, what save the values to MySQL. Why I do to save every X/Y to a new file? If i don't it do too much duplicated save. Who have better ideas to do this feel free to post.

    The script:

    Code:
    import java.io.*;
    import java.net.*;
    import java.util.Map;
    
    import com.speljohan.rsbot.script.Methods;
    import com.speljohan.rsbot.script.wrappers.RSObject;
    import com.speljohan.rsbot.script.wrappers.RSPlayer;
    import com.speljohan.rsbot.script.wrappers.RSTile;
    import com.speljohan.rsbot.bot.Bot;
    import com.speljohan.rsbot.script.Script;
    
    public class TileExplorer extends Script {
    
        final int blocks[][] = Bot.getClient().getGroundDataArray()[Bot.getClient().getPlane()].getBlocks();
        final RSPlayer player = getMyPlayer();
    		
        @Override
        public String getAuthor() {
    	return "Laxika";
        }
    
        @Override
        public String getName() {
            return "Tile Explorer";
        }
    
        @Override
        public String getScriptCategory() {
            return "Other";
        }
    
        @Override
        public String getScriptDescription() {
            String html = "";
            html += "<html>";
            html += "<center>";
            html += "<h2>" + getName() + "</h2>";
            html += "<br />";
            html += "<b>Author:</b> " + getAuthor();
            html += "<br />";
            html += "<b>Version:</b> " + getVersion();
            html += "</center>";
            html += "</html>";
            return html;
        }
    
        @Override
        public double getVersion() {
            return 1.0;
        }
    
        @Override
        public int loop() {
            try {
                final RSPlayer player = getMyPlayer();
                final RSTile location = player.getLocation();
                final int locX = location.getX();
                final int locY = location.getY();
    
                for (int x = locX - 25; x < locX + 25; x++) {
                    for (int y = locY - 25; y < locY + 25; y++) {
                        final RSObject object = getObjectAt(x, y);
                        if (object != null && object.getID() != 0) {
    //				URL url = new URL("http://127.0.0.1/addToDB.php?x="+x+"&y="+y+"&object="+object.getID());
    //				URLConnection con = url.openConnection();
    //				con.connect();				
                            File file = new File("ObjectDump/" + object.getID() + "/" + x + "_" + y + "_" + object.getID() + ".xml");
    
                            if (!file.exists()) {
                                File file2 = new File("ObjectDump/" + object.getID());
                                file2.mkdirs();
                                BufferedWriter bw = new BufferedWriter(new FileWriter(file));
                                bw.write("<?xml version=\"1.0\"?>");
                                bw.newLine();
                                bw.write("<maptile>");
                                bw.newLine();
                                bw.write("	<xcoord>" + x + "</xcoord>");
                                bw.newLine();
                                bw.write("	<ycoord>" + y + "</ycoord>");
                                bw.newLine();
                                bw.write("	<mapobject>" + object.getID() + "</mapobject>");
                                bw.newLine();
                                bw.write("</maptile>");
                                bw.flush();
                                bw.close();
                            }
                        }
                    }
                }
            } catch (IOException e) {
                System.out.println("ERROR!");
                e.printStackTrace();
            }
            return 1000;
        }
    
        @Override
        public boolean onStart(final Map<String, String> args) {
            return true;
        }
    }
    PHP script:

    Code:
    <?php
    $x = $_REQUEST['x'];
    $y = $_REQUEST['y'];
    $object = $_REQUEST['object'];
    
    //echo "object: $object x: $x y: $y";
    
    $mysqlIp = "127.0.0.1";
    $mysqlUser = "tehnoobshow";
    $mysqlPass = "noobninja";
    $mysqlDb = "rsobjectdump";
    
    mysql_connect("$mysqlIp", "$mysqlUser", "$mysqlPass");
    mysql_select_db("$mysqlDb");
    mysql_query("SET NAMES 'utf8'");
    
    $isEmpty = mysql_num_rows(mysql_query("SELECT * FROM objectdata WHERE coordX = '" . $x. "' AND coordY ='".$y."'"." AND objectId='".$object."'"));
    
    if ($isEmpty == 0) {
        mysql_query("INSERT INTO objectdata SET coordX ='" . $x . "', coordY ='". $y . "', objectId = '" . $object . "'");
    }
    ?>
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  2. #2  
    Ben121
    Guest
    Very nice, I guess you could put it into a 2d array if you really wanted to, then dump that when you want to
    Reply With Quote  
     

  3. #3  
    Valar Morghulis

    Laxika's Avatar
    Join Date
    Sep 2006
    Age
    29
    Posts
    2,813
    Thanks given
    1,804
    Thanks received
    274
    Rep Power
    2128
    Ty Yeppa, i think that too, to add it into a HashMap or an Array, then when the script finished (onFinish void) I save it.
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  4. #4  
    Annexation
    Guest
    ... In the 508 LD client this is a 2d array with all objects of your mapregions heightlevel:
    Code:
    Class109.aClass38Array1843[Class61.anInt1149].anIntArrayArray681;
    No need to walk around on rs? you can just force it all or tele to the regions you want then dump it
    Code:
    	int[][] is = Class109.aClass38Array1843[Class61.anInt1149].anIntArrayArray681;
    	BufferedWriter bw = null;
    	try {
    		bw = new BufferedWriter(new FileWriter("./<INSERT MAP REGION VARIABLE HERE>.txt", true));
    		for(int i1 = 0; i1 < is.length; i1++) {
    			for(int j = 0; j < is[i1].length; j++) {
    				bw.append((is[i1][j])+ " ");
    			}
    			bw.newLine();
    		}
    		bw.flush();
    	} catch(Exception e) {
    	}
    Reply With Quote  
     

  5. #5  
    Valar Morghulis

    Laxika's Avatar
    Join Date
    Sep 2006
    Age
    29
    Posts
    2,813
    Thanks given
    1,804
    Thanks received
    274
    Rep Power
    2128
    Yess, but thus dump the global x/y or the local? Cuz I found the not walkable tiles array, but that only have the local not walkable x/y and don't know how to convert it to global x/y...

    Local looks like eg 33/52 global 2333/2131...

    Or I just need to hadle it with mapregion serverside, not with global x/y?

    And ty for the idea.
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  6. #6  
    Donator

    iZAjz's Avatar
    Join Date
    Mar 2007
    Age
    26
    Posts
    3,675
    Thanks given
    105
    Thanks received
    47
    Rep Power
    1882
    Nice one laxika.

    Havent seen you in the 503+ section yet.
    Reply With Quote  
     

  7. #7  
    Annexation
    Guest
    Quote Originally Posted by laxika View Post
    Yess, but thus dump the global x/y or the local? Cuz I found the not walkable tiles array, but that only have the local not walkable x/y and don't know how to convert it to global x/y...

    Local looks like eg 33/52 global 2333/2131...

    Or I just need to hadle it with mapregion serverside, not with global x/y?

    And ty for the idea.
    you can do it fine with the local coords, if you do it with global and you try to move to a unreachable area it would check the FULL runescape map if there is ANY possible route to there, which will be pretty much like a infinite loop (it will stop but will take a while and lag server), if you use the local coords the area to check is much smaller and wont cause those problems if the destination is not reachable

    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  8. #8  
    I_-_I
    Guest
    Quote Originally Posted by Annexation View Post
    you can do it fine with the local coords, if you do it with global and you try to move to a unreachable area it would check the FULL runescape map if there is ANY possible route to there, which will be pretty much like a infinite loop (it will stop but will take a while and lag server), if you use the local coords the area to check is much smaller and wont cause those problems if the destination is not reachable

    [Only registered and activated users can see links. ]
    explain to me where exactly you would click to enter a unreachable area
    Reply With Quote  
     

  9. #9  
    Annexation
    Guest
    Quote Originally Posted by I_-_I View Post
    explain to me where exactly you would click to enter a unreachable area
    uh inside a closed house or something or an small isle on a river or whatever
    Reply With Quote  
     

  10. #10  
    Respected Member


    Luke132's Avatar
    Join Date
    Dec 2007
    Age
    32
    Posts
    12,549
    Thanks given
    177
    Thanks received
    5,784
    Discord
    View profile
    Rep Power
    5000
    RSBot dosen't count some walls/fences, JSYK.

    Reply With Quote  
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •