Mr Pro Pop Posted September 14, 2016 Share Posted September 14, 2016 (edited) Hello guys, I need help adding a Polygon Shape in to my target object, I dont know whats wrong with my code.. Best regards, Mr Pro Pop. Thanks In Advance! here is the code: import java.awt.Color; import java.awt.Graphics2D; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(author = "Mr Pro Pop", info = "", logo = "", name = "woodcutting", version = 1) public class wc extends Script { public void chop() throws InterruptedException { if (!myPlayer().isAnimating() && !getInventory().isFull()) { RS2Object tree = getObjects().closest("Tree"); tree.interact("Chop down"); } } public int onLoop() throws InterruptedException { chop(); sleep(random(100+1800,2100)); return 0; } public void onPaint(Graphics2D g) { Color color1 = new Color(255, 255, 255, 255); g.setColor(color1); RS2Object tree = getObjects().closest("Tree"); int x = tree.getPosition().getX(); int y = tree.getPosition().getY(); int h = tree.getHeight(); g.drawRect(x, y, 75, h); } } Edited September 14, 2016 by Mr Pro Pop Quote Link to comment Share on other sites More sharing options...
Token Posted September 14, 2016 Share Posted September 14, 2016 Polygon is a 2D shape. Your tree is in 3D space. 1 Quote Link to comment Share on other sites More sharing options...
Saiyan Posted September 14, 2016 Share Posted September 14, 2016 Hello guys, I need help adding a Polygon Shape in to my target object, I dont know whats wrong with my code.. Best regards, Mr Pro Pop. Thanks In Advance! here is the code: import java.awt.Color; import java.awt.Graphics2D; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(author = "Mr Pro Pop", info = "", logo = "", name = "woodcutting", version = 1) public class wc extends Script { public void chop() throws InterruptedException { if (!myPlayer().isAnimating() && !getInventory().isFull()) { RS2Object tree = getObjects().closest("Tree"); tree.interact("Chop down"); } } public int onLoop() throws InterruptedException { chop(); sleep(random(100+1800,2100)); return 0; } public void onPaint(Graphics2D g) { Color color1 = new Color(255, 255, 255, 255); g.setColor(color1); RS2Object tree = getObjects().closest("Tree"); int x = tree.getPosition().getX(); int y = tree.getPosition().getY(); int h = tree.getHeight(); g.drawRect(x, y, 75, h); } } you should use conditional sleeps instead of random sleeps also couldn't you just use a uhh bounding box is that for npc's only idk Quote Link to comment Share on other sites More sharing options...
Mr Pro Pop Posted September 14, 2016 Author Share Posted September 14, 2016 you should use conditional sleeps instead of random sleeps also couldn't you just use a uhh bounding box is that for npc's only idk Okay bro ill use conditional sleeps. anyways i dont know how to add the bounding box, can you provide me with the code please.. ? Polygon is a 2D shape. Your tree is in 3D space. so what do i need to do, any method to get it working ? Quote Link to comment Share on other sites More sharing options...
Token Posted September 14, 2016 Share Posted September 14, 2016 Okay bro ill use conditional sleeps. anyways i dont know how to add the bounding box, can you provide me with the code please.. ? so what do i need to do, any method to get it working ? Graphics2D paints on your canvas, not in runescape space, so you can't paint based on runescape coordinates. You need to project the 3D runescape space coordinates onto the camera plane to get the actual position on the canvas of a game object. Take a look at the GraphicUtilities class, everything you need should be there. 1 Quote Link to comment Share on other sites More sharing options...
Mr Pro Pop Posted September 15, 2016 Author Share Posted September 15, 2016 (edited) Graphics2D paints on your canvas, not in runescape space, so you can't paint based on runescape coordinates. You need to project the 3D runescape space coordinates onto the camera plane to get the actual position on the canvas of a game object. Take a look at the GraphicUtilities class, everything you need should be there. I tryed but couldnt get it to work with me, can you please provide me with the code, Will really appreciate. Thanks Edited September 15, 2016 by Mr Pro Pop Quote Link to comment Share on other sites More sharing options...