Solzhenitsyn Posted October 21, 2016 Share Posted October 21, 2016 Hi, I am drawing wireframes of relevant entities while I am debugging, but on my toaster it is causing a lot of lag. Is there any way to reduce the refresh rate of onPaint, or a cheaper way of drawing wireframes? Drawing tiny rectangles... Quote Link to comment Share on other sites More sharing options...
Team Cape Posted October 21, 2016 Share Posted October 21, 2016 (edited) Hi, I am drawing wireframes of relevant entities while I am debugging, but on my toaster it is causing a lot of lag. Is there any way to reduce the refresh rate of onPaint, or a cheaper way of drawing wireframes? Drawing tiny rectangles... Ran into a similar problem with my agility script... With small obstacles that didn't have a lot of area on the screen, it didn't lag at all, but once I got to big gaps that had a lot of area, i basically completely froze. i'd offer a possible recommendation (idk the kind of precision you need) of just highlighting the tiles upon which the object is located, something like this: g.fill(GraphicUtilities.getModelArea(getBot(), ent.getGridX(), ent.getGridY(), ent.getZ(), ent.getModel())); given an entity 'ent' and a graphics2d g this is probably the simplest solution that i could give on the fly Edited October 21, 2016 by Imateamcape Quote Link to comment Share on other sites More sharing options...
House Posted October 21, 2016 Share Posted October 21, 2016 Ran into a similar problem with my agility script... With small obstacles that didn't have a lot of area on the screen, it didn't lag at all, but once I got to big gaps that had a lot of area, i basically completely froze. i'd offer a possible recommendation (idk the kind of precision you need) of just highlighting the tiles upon which the object is located, something like this: g.fill(GraphicUtilities.getModelArea(getBot(), ent.getGridX(), ent.getGridY(), ent.getZ(), ent.getModel())); given an entity 'ent' and a graphics2d g this is probably the simplest solution that i could give on the fly This seems a bit more straight forward but same outcome g.drawPolygon(rs2object.getPosition().getPolygon(getBot())); 1 Quote Link to comment Share on other sites More sharing options...
Team Cape Posted October 21, 2016 Share Posted October 21, 2016 This seems a bit more straight forward but same outcome g.drawPolygon(rs2object.getPosition().getPolygon(getBot())); Note that many entities have an area of more than 1 - this would only draw one specific tile under the entity bro, whereas the other snippet would draw the complete area Quote Link to comment Share on other sites More sharing options...
Swizzbeat Posted October 21, 2016 Share Posted October 21, 2016 The refresh rate is what's causing the "lag". Typically injection based bots (OSBot?) will hook into the relevant graphics methods to paint over the game buffer before it's drawn to the canvas. You're going to want to post your code so we can see if there's any optimizations you could do. Quote Link to comment Share on other sites More sharing options...
House Posted October 22, 2016 Share Posted October 22, 2016 Note that many entities have an area of more than 1 - this would only draw one specific tile under the entity bro, whereas the other snippet would draw the complete area Alright different result then, uses less resources? Quote Link to comment Share on other sites More sharing options...
Team Cape Posted October 22, 2016 Share Posted October 22, 2016 Alright different result then, uses less resources? not really much of a difference for the system to paint 1 tile vs 4 lol Quote Link to comment Share on other sites More sharing options...
House Posted October 22, 2016 Share Posted October 22, 2016 not really much of a difference for the system to paint 1 tile vs 4 lol He said he has a toaster! Quote Link to comment Share on other sites More sharing options...
Solzhenitsyn Posted October 22, 2016 Author Share Posted October 22, 2016 (edited) Swizz, don't take this personally (or do, I don't really care) -- I don't think you've ever said anything useful to me before. Half of the time, I don't even think you've read the post or any of the thread. For that matter, I'm actually trying to think of the last time I've seen you say something useful, period. My question: Is there any way to reduce the refresh rate of onPaint (...)? Your response: The refresh rate is what's causing the "lag". Typically injection based bots (OSBot?) will hook into the relevant graphics methods to paint over the game buffer before it's drawn to the canvas. You're going to want to post your code so we can see if there's any optimizations you could do. The worst part is, your response isn't even correct -- the refresh rate only matters because it contributes to the quadratic explosion (e.g., a high number of vertices versus a high refresh rate). Thanks, @Imateamcape @@House. Here is my solution, which is more resource intensive than House or TC, but reduces it to a manageable level: Filter out 2/3 of the vertices which exist in the mesh: Old: New (increased opacity to compensate for fewer vertices): If anyone knows how to reduce the refresh rate of the paint, I would still like to know so that I can do both. Edited October 22, 2016 by Solzhenitsyn Quote Link to comment Share on other sites More sharing options...
Lemons Posted October 22, 2016 Share Posted October 22, 2016 Can look at my paint class here for buffering/caching the paint. https://github.com/Lem0ns/OSBotAPI/blob/master/painters/Painter.java Other than that, drawing anything that isn't 100% opaque is going to be expensive, if you're doing a wireframe best to just have it solid color. Also, possibly allow toggling of these expensive calls for a "low cpu" mode. 2 Quote Link to comment Share on other sites More sharing options...
Swizzbeat Posted October 22, 2016 Share Posted October 22, 2016 Swizz, don't take this personally (or do, I don't really care) -- I don't think you've ever said anything useful to me before. Half of the time, I don't even think you've read the post or any of the thread. For that matter, I'm actually trying to think of the last time I've seen you say something useful, period. My question: Your response: The worst part is, your response isn't even correct -- the refresh rate only matters because it contributes to the quadratic explosion (e.g., a high number of vertices versus a high refresh rate). Thanks, @Imateamcape @@House. Here is my solution, which is more resource intensive than House or TC, but reduces it to a manageable level: Filter out 2/3 of the vertices which exist in the mesh: Old: New (increased opacity to compensate for fewer vertices): If anyone knows how to reduce the refresh rate of the paint, I would still like to know so that I can do both. I obviously misread your post, doesn't take a genius to see that. Do I even know you? I don't think we've ever even talked before lol. Not sure why you're trying to act like such an elitist when you're clearly just the typical "I wrote a binary search algorithm and therefore am a wizard" kid. Get off your high horse before you start making a fool of yourself. As for your actual question no I don't think it's possible unless you manipulate the game directly. The bots refresh rate is directly correlated to the game because, as I said, the bot does nothing but draw using the same graphics context. Quote Link to comment Share on other sites More sharing options...
Solzhenitsyn Posted October 22, 2016 Author Share Posted October 22, 2016 I obviously misread your post, doesn't take a genius to see that. Do I even know you? I don't think we've ever even talked before lol. Not sure why you're trying to act like such an elitist when you're clearly just the typical "I wrote a binary search algorithm and therefore am a wizard" kid. Get off your high horse before you start making a fool of yourself. As for your actual question no I don't think it's possible unless you manipulate the game directly. The bots refresh rate is directly correlated to the game because, as I said, the bot does nothing but draw using the same graphics context. I am totally willing to admit that I know almost nothing about computer science. What you are not willing to admit is that you don't read threads, often not even the first post in a thread, before posting advice. That's useless, and a waste of space. So you are correct, I'm no wizard -- but your thoughtless and lazy posts on the threads of myself and others contribute less than virtually any other member who regularly posts on the scripting forums. You obviously know a lot, but withholding that information by teasing only a hint of the solution, or worse yet, delivering nothing at all is far worse than knowing little but making a real attempt to help. 1 Quote Link to comment Share on other sites More sharing options...
Swizzbeat Posted October 22, 2016 Share Posted October 22, 2016 I am totally willing to admit that I know almost nothing about computer science. What you are not willing to admit is that you don't read threads, often not even the first post in a thread, before posting advice. That's useless, and a waste of space. So you are correct, I'm no wizard -- but your thoughtless and lazy posts on the threads of myself and others contribute less than virtually any other member who regularly posts on the scripting forums. You obviously know a lot, but withholding that information by teasing only a hint of the solution, or worse yet, delivering nothing at all is far worse than knowing little but making a real attempt to help. Can you provide some sort of proof to back up your "thoughtless and lazy posts" claim? I've contributed much more to this site than 90% of the active scripters here. I'm also not here to spoon feed people unless they ask for it. You learn nothing but receiving complete solutions for all of your problems. Quote Link to comment Share on other sites More sharing options...
Botre Posted October 22, 2016 Share Posted October 22, 2016 New (increased opacity to compensate for fewer vertices): Remove transparency altogether. The rendering isn't hardware-accelerated and the java gfx lib is trash. When using non-opaque colors, the system has to calculate the result of colors overlapping, expensive in the above context, 2 Quote Link to comment Share on other sites More sharing options...
Mr Pro Pop Posted October 22, 2016 Share Posted October 22, 2016 do you now have it working ? Quote Link to comment Share on other sites More sharing options...