Hello everyone,
I'm currently encountering a problem in my project where I can only access the tile on which a player is rendered, rather than their actual location. I believe retrieving the true tile is feasible, as demonstrated by similar functions in RuneLite plugins.
My requirement is to determine the true tile of the nearest player, not just the rendered one. When using closestPlayer.getTile(), it appears to return only the rendered tile. For a clearer understanding, I've made a demonstration comparing this with the RuneLite plugin that accurately shows the true tile. Unfortunately, my script does not seem to replicate this functionality for the local player.
Here is my code:
import org.dreambot.api.methods.map.Tile;
import org.dreambot.api.methods.interactive.Players;
import org.dreambot.api.script.Category;
import org.dreambot.api.script.ScriptManifest;
import org.dreambot.api.script.listener.PaintListener;
import org.dreambot.api.wrappers.interactive.Player;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Polygon;
@ScriptManifest(author = "ClosetCheater", name = "Highlight Closest Player", version = 1.0, description = "Test", category = Category.MISC)
public class HighlightClosestPlayerScript extends org.dreambot.api.script.AbstractScript implements PaintListener {
private Player closestPlayer;
@Override
Highlights the closest player's tile
public void onStart() {
log("Script started!");
}
@Override
public int onLoop() {
closestPlayer = Players.closest(player -> !player.equals(Players.getLocal())); // Get closest player thats not us
return 300; // Render twice every tick
}
@Override
public void onPaint(Graphics g) {
if (closestPlayer != null && closestPlayer.getTile() != null) {
Tile tile = closestPlayer.getTile();
Polygon poly = tile.getPolygon();
g.setColor(new Color(255, 0, 0, 100));
g.fillPolygon(poly);
g.setColor(Color.RED);
g.drawPolygon(poly);
}
}
@Override
public void onExit() {
log("Script stopped!");
}
public static void main(String[] args) {
// method isn't necessary for the script but is here for completeness
}
}
I've recorded a comparison showing how this issue manifests in DreamBot versus how accurately RuneLite handles this with the correct API call. Unfortunately, it seems like DreamBot might not be getting the true tile during these specific scenarios unless there is another call I've missed that I should be using?
Thanks