Dargunslayur 0 Posted July 18, 2017 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!!!
distraction 61 Posted July 18, 2017 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.
Dinh 496 Posted July 18, 2017 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
Dorkinator 64 Posted July 18, 2017 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.
Dargunslayur 0 Author Posted July 18, 2017 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).
hexagon 18 Posted July 19, 2017 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
Dogerina 330 Posted July 20, 2017 Npcs don't have uidsthey 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
rokaHakor 171 Posted July 20, 2017 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!
hexagon 18 Posted July 20, 2017 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());
Recommended Posts
Archived
This topic is now archived and is closed to further replies.