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
  • Painting GameObjects & Npcs\Entities in dreambot


    Luxe

    Recommended Posts

    I discussed the EDU discord with @Smokeyjay, who helped me figure out how to paint entities and objects similar to runelite and I thought I should document it for any future googlers.

     

    pK28i1n.png

    nghZ2lR.png

    173Ycqb.png

    EXd8Rim.png

    The final result turned out like this

    X2RTU3a.png

    and here is the code (with some code from my private hunting script). The code should be placed in the onPaint method

          if(this.getCurrentLeafName() != null && this.getCurrentLeafName().toLowerCase().contains("lizard")) {
                List<NPC> lizards = NPCs.all(x -> x.getName().equalsIgnoreCase(getSettings().huntingActivity.getPreyName()));
                for (NPC lizard : lizards) {
                    if(lizard.isOnScreen()) {
    
                        ViewportTools v = new ViewportTools();
                        Graphics2D g2D = (Graphics2D) graphics;
                        if (lizard != null) {
                            Model cloudModel = lizard.getModel();
                            cloudModel.drawWireFrame(graphics);
                            graphics.drawString("Animation: " + lizard.getAnimation(), lizard.getX(), lizard.getY());
                            v.getModelArea(lizard);
                            v.drawModel(g2D, lizard.getGridX(), lizard.getGridY(), lizard.getZ(), cloudModel);
    
    
                                        graphics.drawRect(
                            (int) lizard.getBoundingBox().getX(),
                            (int) lizard.getBoundingBox().getY(),
                            (int) lizard.getBoundingBox().getHeight(),
                            (int) lizard.getBoundingBox().getWidth()
                    );
                        }
    
    
                    }
                }
            }

     

    Note that drawing too many entities will slow the framerate significantly!

    Hope this helps someone else in the future!

     

     

    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    On another note, does anyone know how to get a paint similar to this?

    npctag.png

     

    Link to comment
    Share on other sites

    1 hour ago, Luxe said:

    On another note, does anyone know how to get a paint similar to this?

    You can use Model#getHullBounds

    @Override
    public void onPaint(Graphics2D graphics2D){
        
        NPC banker = NPCs.closest(i -> i != null && i.getName().equals("Banker"));
        Shape shape = banker.getModel().getHullBounds(1.f);
        
        // Enable anti-aliasing for smoother lines
        graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    
        // Set the color to Cyan
        graphics2D.setColor(Color.CYAN);
    
        // Set the thickness of the boarder
        graphics2D.setStroke(new BasicStroke(2.f));
        
        //Draw the shape
        graphics2D.draw(shape);
    }

    image.png.9862ff0d5262eb4f87a7feeeb056b551.png

    Link to comment
    Share on other sites

    • 5 weeks later...
    21 hours ago, Meteorite said:

    Would be very interesting to see something similar to RuneLite's ModelOutlineRenderer#drawOutline method that is used in some plugins like
    https://github.com/neilrush/Player-Outline

    I've done this. It kills the FPS and wouldn't recommend it. Perhaps you could optimize it but I think it's pointless. It's a QOL feature that only players can enjoy, really. When it comes to debugging bots it serves next to no purpose.
    image.png.9a9ef063b7bd906d38aed6a0645a04ba.png

    graphics2D.setColor(new Color(0, 0, 0, 125));
    NPC guard = NPCs.closest("Guard");
    if(guard != null && guard.getModel() != null){
        java.awt.geom.Area modelArea = guard.getModel().calculateModelArea();
        graphics2D.draw(modelArea);
    }
    Link to comment
    Share on other sites

    1 hour ago, morten1ela said:

    I've done this. It kills the FPS and wouldn't recommend it. Perhaps you could optimize it but I think it's pointless. It's a QOL feature that only players can enjoy, really. When it comes to debugging bots it serves next to no purpose.
    image.png.9a9ef063b7bd906d38aed6a0645a04ba.png

    graphics2D.setColor(new Color(0, 0, 0, 125));
    NPC guard = NPCs.closest("Guard");
    if(guard != null && guard.getModel() != null){
        java.awt.geom.Area modelArea = guard.getModel().calculateModelArea();
        graphics2D.draw(modelArea);
    }

    What's heavy about it, the model is complex and costly to paint or the calculateModelArea call?
    Can cache the calculateModelArea call and if it's too complex then could make it a little more simple?

    Link to comment
    Share on other sites

    1 hour ago, Meteorite said:

    What's heavy about it, the model is complex and costly to paint or the calculateModelArea call?
    Can cache the calculateModelArea call and if it's too complex then could make it a little more simple?

    Just the model calculation, it seems.

    No area calculation or drawing:
    withoutareacalcandwithoutdrawing.png.feff7c5af1cd92eac06483a0a25ffac4.png

    Just calculating:
    nodrawing.png.cfa949de4d744c18bd5ea3024de3f9be.png

    Calculating and drawing:
    calcanddraw.png.a540075998b17a8eaf5aef76b8389333.png

    Link to comment
    Share on other sites

    Improved Model#calculateModelArea/ViewportTools#getModelArea's performance in the latest client hotfix, the version should show 3.27.8.1 for those.

    For backward compatibility reasons I couldn't include an on canvas check, but that would save a lot of time also (making sure the NPC is on screen before getting the model area).

    Link to comment
    Share on other sites

    image.png.46b1d91321e23d12127ff12e263bff96.png
    Good enough, I guess... I guarantee there is a better method to do the feathering effect but this is all I'm willing to play around with for now. The model area calculation doesn't noticeably impact performance anymore, but my for loop absolutely does.

    if(Players.getLocal().getModel() != null){
        java.awt.geom.Area modelArea = Players.getLocal().getModel().calculateModelArea();
    
        // Glowing effect:
        for (int i = 1; i <= 3; i++) {
            BasicStroke stroke = new BasicStroke(i * 2, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
    
            // Create an expanded area for the glow effect
            java.awt.geom.Area expandedArea = new java.awt.geom.Area(stroke.createStrokedShape(modelArea));
            expandedArea.subtract(modelArea);
    
            graphics2D.setColor(new Color(0, 0, 0, 75 - (i * 20))); // Decrease alpha for each layer
            graphics2D.fill(expandedArea); // Fill the glow area outside the outline
        }
    
        // Draw the main outline
        graphics2D.setStroke(new BasicStroke(1));
        graphics2D.setColor(new Color(0, 0, 0, 100));
        graphics2D.draw(modelArea);
    }
    Link to comment
    Share on other sites

    On 7/5/2024 at 8:46 AM, morten1ela said:

    image.png.46b1d91321e23d12127ff12e263bff96.png
    Good enough, I guess... I guarantee there is a better method to do the feathering effect but this is all I'm willing to play around with for now. The model area calculation doesn't noticeably impact performance anymore, but my for loop absolutely does.

    if(Players.getLocal().getModel() != null){
        java.awt.geom.Area modelArea = Players.getLocal().getModel().calculateModelArea();
    
        // Glowing effect:
        for (int i = 1; i <= 3; i++) {
            BasicStroke stroke = new BasicStroke(i * 2, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
    
            // Create an expanded area for the glow effect
            java.awt.geom.Area expandedArea = new java.awt.geom.Area(stroke.createStrokedShape(modelArea));
            expandedArea.subtract(modelArea);
    
            graphics2D.setColor(new Color(0, 0, 0, 75 - (i * 20))); // Decrease alpha for each layer
            graphics2D.fill(expandedArea); // Fill the glow area outside the outline
        }
    
        // Draw the main outline
        graphics2D.setStroke(new BasicStroke(1));
        graphics2D.setColor(new Color(0, 0, 0, 100));
        graphics2D.draw(modelArea);
    }

    Did you end up getting a benchmark for fps?

    Link to comment
    Share on other sites

    11 hours ago, Luxe said:

    Did you end up getting a benchmark for fps?

    From <1 ms per frame to about 5-15 depending on how zoomed in on the character you are. That's with the for loop at 3 iterations. I tried caching the area and feathered thing but it only improved the fps while standing still. As soon as I start moving it'd stutter a bunch.

    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
    ×
    ×
    • 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.