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
  • Try asking for help in the chatbox
  • Getting drop tile of multi-tiled NPC?


    Dargunslayur
     Share

    Recommended Posts

    Hi, I'm new to botting and DreamBot and I'm making a basic cow-killing script.  Not new to Java.

     

    So if you have an NPC whose model takes up several tiles (such as a cow), how do you get the tile where the drops show up?  I don't want to just get the closest GroundItems because I may be using ranged and there may be drops from other people's kills closer to me.

     

    Thanks!!!

    Link to comment
    Share on other sites

    I'm not sure if there is a way to determine which tile the items will drop on, but you could probably cache the position of the npc while its still alive and then find the loot that is closest to that position once it dies.

    Link to comment
    Share on other sites

    i think its always a specific one

    aka mostern

     

    north-east

    south-east

    south-west

    norht-west

     

    im not 100% sure but i think when you get the tile of a multi-tiled npc its always going to be 1 tile only and that should also be the loot tile afaik

    Link to comment
    Share on other sites

    I'm pretty sure if you apply this code to NPCs it'd give you the drop tile.

     

    	public Tile normalizeTile(GameObject o){
    		int UID = o.getIndex();
    		return new Tile((UID & 0x7f) + c.getClient().getBaseX(), ((UID >> 7) & 0x7f) + c.getClient().getBaseY(), o.getPlane());
    	}
    
    Credit goes to Hexagon for this btw. Edited by Dorkinator
    Link to comment
    Share on other sites

    I'm pretty sure if you apply this code to NPCs it'd give you the drop tile.

     

    	public Tile normalizeTile(GameObject o){
    		int UID = o.getIndex();
    		return new Tile((UID & 0x7f) + c.getClient().getBaseX(), ((UID >> 7) & 0x7f) + c.getClient().getBaseY(), o.getPlane());
    	}
    
    Credit goes to Hexagon for this btw.

     

     

    So I played around with this code, in order to get it to work I changed parameter "o" to an NPC and changed "o.getPlane()" to 0 (I assumed it was a z-axis).

     

    I did getWalking().walk(outputTile) but instead of walking to the drop pile it always goes and opens a nearby door (same door everytime).

    Link to comment
    Share on other sites

    I'm pretty sure if you apply this code to NPCs it'd give you the drop tile.

     

    	public Tile normalizeTile(GameObject o){
    		int UID = o.getIndex();
    		return new Tile((UID & 0x7f) + c.getClient().getBaseX(), ((UID >> 7) & 0x7f) + c.getClient().getBaseY(), o.getPlane());
    	}
    
    Credit goes to Hexagon for this btw.

     

     

    Npcs don't have uids

    Link to comment
    Share on other sites

    Npcs don't have uids

    they can, because npcs are also of type "GameObject" (the api probably filters them out from objects). It is a little different from object uids, but the uid defined in the client is as follows.

    (npc_array_index << 14) + 0x20000000
    
    This wouldn't help op with his solution either though Edited by Dogerina
    Link to comment
    Share on other sites

    they can, because npcs are also of type "GameObject" (the api probably filters them out from objects). It is a little different from object uids, but the uid defined in the client is as follows.

    (npc_array_index << 14) + 0x20000000
    
    This wouldn't help op with his solution either though

     

    Yeah you tell him Dog!

    Link to comment
    Share on other sites

    they can, because npcs are also of type "GameObject" (the api probably filters them out from objects). It is a little different from object uids, but the uid defined in the client is as follows.

    (npc_array_index << 14) + 0x20000000
    
    This wouldn't help op with his solution either though

     

    Well, the class that represents the npc dosen't have an uid but if you're taking in consideration when stuff gets appended to the region/scene (w/e you call it) then yes, everything has an uid, including players, projectiles and spot animations.

     

    Answering the question:

     

    Most of the bot clients handle players/npc real positions wrongly (well, player pos aren't affected because the player size is 1), they usually just leech how things work from another client instead of looking at the real client to figure how stuff actually works. Consequently most of the clients do something like this to get the npc position:

     

    new Tile(Client.getRegionBaseX() + npc.getAbsoluteX() / 128, Client.getRegionBaseY() + npc.getAbsoluteY() / 128, Client.getPlane());
    

     

    And it will work fine for most of the npcs (the ones that only occupy one tile) but when you get to npcs that occupy more than one tile you'll soon realize that that code isn't returning the south-western most tile but it will return a tile that tends to the center of the model (in 2x2 npcs it will return the most north-eastern tile) and that's because the getAbsoluteX, getAbsoluteY values are actually the player/npc model center point coordinates. Since a tile is actually a 128x128 'units' square, in order to center the model into the tile, the client just adds 64 * the size of the npc to the x & y, so to counter that and find the real npc position we simply need to subtract 64 * size from the x & y coordinates and that will be where the loot will land because that's where the npc is standing on the server:

     

    int realX = (accessor.getAbsoluteX() - accessor.getSize() * 64) / 128;
    int realY = (accessor.getAbsoluteY() - accessor.getSize() * 64) / 128;
    
    return new Tile(Client.getRegionBaseX() + realX, Client.getRegionBaseY() + realY, Client.getPlane());
    
    Edited by hexagon
    Link to comment
    Share on other sites

     Share

    ×
    ×
    • 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.