Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.62 KB | None | 0 0
  1. /*
  2. * THIS SOFTWARE WRITTEN BY A KEYBOARD-WIELDING MONKEY BOI
  3. * No rights reserved. Use, redistribute, and modify at your own discretion,
  4. * and in accordance with Yagex and RuneLite guidelines.
  5. * However, aforementioned monkey would prefer if you don't sell this plugin for profit.
  6. * Good luck on your raids!
  7. */
  8.  
  9. package net.runelite.client.plugins.ztob;
  10.  
  11. import java.awt.BasicStroke;
  12. import java.awt.Color;
  13. import java.awt.Font;
  14. import java.awt.Polygon;
  15. import java.awt.Dimension;
  16. import java.awt.Graphics2D;
  17. import java.util.List;
  18. import java.util.Map;
  19. import java.util.Iterator;
  20. import javax.inject.Inject;
  21. import net.runelite.api.Point;
  22. import net.runelite.api.coords.LocalPoint;
  23. import net.runelite.api.coords.WorldArea;
  24. import net.runelite.api.coords.WorldPoint;
  25. import net.runelite.api.NPC;
  26. import net.runelite.api.NpcID;
  27. import net.runelite.api.NPCComposition;
  28. import net.runelite.api.Projectile;
  29. import net.runelite.api.Client;
  30. import net.runelite.api.GroundObject;
  31. import net.runelite.api.Perspective;
  32. import net.runelite.client.ui.overlay.Overlay;
  33. import net.runelite.client.ui.overlay.OverlayLayer;
  34. import net.runelite.client.ui.overlay.OverlayPosition;
  35. import net.runelite.client.ui.overlay.OverlayPriority;
  36. import net.runelite.client.ui.overlay.OverlayUtil;
  37.  
  38. public class TheatreOverlay extends Overlay {
  39. private final Client client;
  40. private final TheatrePlugin plugin;
  41. private final TheatreConfig config;
  42.  
  43. @Inject
  44. private TheatreOverlay(Client client, TheatrePlugin plugin, TheatreConfig config) {
  45. this.client = client;
  46. this.plugin = plugin;
  47. this.config = config;
  48. setPosition(OverlayPosition.DYNAMIC);
  49. setPriority(OverlayPriority.HIGH);
  50. setLayer(OverlayLayer.ABOVE_SCENE);
  51. }
  52.  
  53. @Override
  54. public Dimension render(Graphics2D graphics)
  55. {
  56. if (plugin.isRunMaiden())
  57. {
  58. if (config.MaidenBlood())
  59. {
  60. for (WorldPoint point : plugin.getMaiden_BloodSpatters())
  61. {
  62. drawTile(graphics, point, new Color(0,150,200), 2, 150, 10);
  63. }
  64. }
  65.  
  66. if (config.MaidenSpawns())
  67. {
  68. for (WorldPoint point : plugin.getMaiden_SpawnLocations())
  69. {
  70. drawTile(graphics, point, new Color(0,150,200), 2, 180, 20);
  71. }
  72. for (WorldPoint point : plugin.getMaiden_SpawnLocations2())
  73. {
  74. drawTile(graphics, point, new Color(0,150,200), 1,120, 10);
  75. }
  76. }
  77. }
  78.  
  79. if (plugin.isRunBloat() && config.BloatIndicator())
  80. {
  81. NPC bloat = plugin.getBloat_NPC();
  82. int state = plugin.getBloat_State();
  83. if (bloat == null)
  84. {
  85. return null;
  86. }
  87. switch (state)
  88. {
  89. case 2:
  90. renderNpcOverlay(graphics, bloat, Color.GREEN, 3, 150, 0);
  91. break;
  92. case 3:
  93. renderNpcOverlay(graphics, bloat, Color.YELLOW, 3, 150, 0);
  94. break;
  95. default:
  96. renderNpcOverlay(graphics, bloat, new Color(223, 109, 255), 3, 150, 0);
  97. break;
  98. }
  99. }
  100.  
  101. if (plugin.isRunNylocas())
  102. {
  103. if (config.NyloPillars())
  104. {
  105. Map<NPC, Integer> pillars = plugin.getNylocas_Pillars();
  106. for (NPC npc : pillars.keySet()) {
  107. final int health = pillars.get(npc);
  108. final String healthStr = String.valueOf(health) + "%";
  109. WorldPoint p = npc.getWorldLocation();
  110. LocalPoint lp = LocalPoint.fromWorld(client, p.getX() + 1, p.getY() + 1);
  111. final double rMod = 130.0 * health / 100.0;
  112. final double gMod = 255.0 * health / 100.0;
  113. final double bMod = 125.0 * health / 100.0;
  114. final Color c = new Color((int) (255 - rMod), (int) (0 + gMod), (int) (0 + bMod));
  115. Point canvasPoint = Perspective.localToCanvas(client, lp, client.getPlane(),
  116. 65);
  117. renderTextLocation(graphics, healthStr, 13, Font.BOLD, c, canvasPoint);
  118. }
  119. }
  120.  
  121. if (config.NyloBlasts())
  122. {
  123. final Map<NPC, Integer> npcMap = plugin.getNylocas_Map();
  124. for (NPC RangeCrab : client.getNpcs()) {
  125. if (RangeCrab.getId() == 8343 || RangeCrab.getId() == 8346) {
  126. if (plugin.getHighlightRangeCrabcolor() == "range") {
  127. Color color = new Color(0, 255, 0, 180);
  128. int outlineWidth = 2;
  129. int outlineAlpha = 150;
  130. renderNpcOverlay(graphics, RangeCrab, color, outlineWidth, outlineAlpha, 5);
  131. }
  132. }
  133. }
  134. for (NPC MageCrab : client.getNpcs()) {
  135. if (MageCrab.getId() == 8344 || MageCrab.getId() == 8347) {
  136. if (plugin.getHighlightMageCrabcolor() == "mage") {
  137. Color color = new Color(0, 0, 255, 180);
  138. int outlineWidth = 2;
  139. int outlineAlpha = 150;
  140. renderNpcOverlay(graphics, MageCrab, color, outlineWidth, outlineAlpha, 5);
  141. }
  142. }
  143. }
  144. for (NPC MeleeCrab : client.getNpcs()) {
  145. if (MeleeCrab.getId() == 8342 || MeleeCrab.getId() == 8345 || MeleeCrab.getId() == 8351 ){
  146. if (plugin.getHighlightMeleeCrabcolor() == "melee") {
  147. Color color = new Color(255, 0, 0, 180);
  148. int outlineWidth = 2;
  149. int outlineAlpha = 150;
  150. renderNpcOverlay(graphics, MeleeCrab, color, outlineWidth, outlineAlpha, 5);
  151. }
  152. }
  153. }
  154.  
  155.  
  156. for (NPC npc : npcMap.keySet())
  157. {
  158. int ticksLeft = npcMap.get(npc);
  159. if (ticksLeft > -1) {
  160. if (ticksLeft <= 6) {
  161. Color color = new Color(255, 255,0 ,180);
  162. int outlineWidth = 2;
  163. int outlineAlpha = 150;
  164. renderNpcOverlay(graphics, npc, color, outlineWidth, outlineAlpha, 0);
  165. }
  166. }
  167. }
  168. }
  169. }
  170.  
  171. if (plugin.isRunSotetseg())
  172. {
  173. if (config.SotetsegMaze1())
  174. {
  175. int i = 1;
  176. for (GroundObject o : plugin.getRedTiles().keySet())
  177. {
  178. Polygon poly = o.getCanvasTilePoly();
  179. if (poly != null)
  180. {
  181. graphics.setColor(Color.WHITE);
  182. graphics.setStroke(new BasicStroke(2));
  183. graphics.draw(poly);
  184. }
  185. Point textLocation = o.getCanvasTextLocation(graphics, String.valueOf(i), 0);
  186. if (textLocation != null)
  187. {
  188. OverlayUtil.renderTextLocation(graphics, textLocation, String.valueOf(i), Color.WHITE);
  189. }
  190.  
  191. i++;
  192. }
  193. }
  194.  
  195. if (config.SotetsegMaze2())
  196. {
  197. for (WorldPoint p : plugin.getRedTilesOverworld())
  198. {
  199. drawTile(graphics, p, Color.WHITE, 2, 255, 10);
  200. }
  201. }
  202. }
  203.  
  204.  
  205. if (plugin.isRunXarpus())
  206. {
  207. NPC boss = plugin.getXarpus_NPC();
  208.  
  209. if (boss.getId() == NpcID.XARPUS_8340 && !plugin.isXarpus_Stare() && config.XarpusTick())
  210. {
  211. int tick = plugin.getXarpus_TicksUntilShoot();
  212. if (tick < 1)
  213. {
  214. tick = tick % 4 + 4;
  215. }
  216. final String ticksLeftStr = String.valueOf(tick);
  217. Point canvasPoint = boss.getCanvasTextLocation(graphics, ticksLeftStr, 130);
  218. renderTextLocation(graphics, ticksLeftStr, 12, Font.BOLD, Color.WHITE, canvasPoint);
  219. }
  220. if (boss.getId() == NpcID.XARPUS_8339 && config.XarpusExhumed())
  221. {
  222. for (GroundObject o : plugin.getXarpus_Exhumeds().keySet())
  223. {
  224. Polygon poly = o.getCanvasTilePoly();
  225. if (poly != null)
  226. {
  227. graphics.setColor(new Color(0, 255, 0, 130));
  228. graphics.setStroke(new BasicStroke(1));
  229. graphics.draw(poly);
  230. }
  231. }
  232. }
  233. }
  234.  
  235.  
  236. if (plugin.isRunVerzik())
  237. {
  238. if (config.VerzikCupcakes())
  239. {
  240. for (WorldPoint p : plugin.getVerzik_RangeProjectiles().values())
  241. {
  242. drawTile(graphics, p, Color.RED, 2, 180, 50);
  243. }
  244. }
  245.  
  246. if (config.VerzikYellow())
  247. {
  248. for (WorldPoint p : plugin.getVerzik_YellowTiles())
  249. {
  250. drawTile(graphics, p, Color.YELLOW,3,255,0);
  251.  
  252. Projectile yellowBall = plugin.getVerzik_YellowBall();
  253. final int yellowticksLeft = plugin.getP3_YellowTicksUntilAttack();
  254.  
  255. if (yellowticksLeft != -1)
  256. {
  257. final String Yellowticksleftstr = String.valueOf(yellowticksLeft);
  258. Point canvasPoint = Perspective.getCanvasTextLocation(client, graphics, LocalPoint.fromWorld(client, p), Yellowticksleftstr, 0);
  259. renderTextLocation(graphics, Yellowticksleftstr, 12, Font.BOLD, Color.WHITE, canvasPoint);
  260. }
  261. }
  262. }
  263. final NPC boss2 = plugin.getVerzik_NPC();
  264. if (boss2.getId() == NpcID.VERZIK_VITUR_8370)
  265. {
  266. if (config.VerzikTick()){
  267. final int ticksLefts = plugin.getP1_TicksUntilAttack();
  268. if (ticksLefts > 0 && ticksLefts < 10)
  269. {
  270. final String ticksLeftsStr = String.valueOf(ticksLefts);
  271. Point canvasPoints = boss2.getCanvasTextLocation(graphics, ticksLeftsStr, 60);
  272. renderTextLocation(graphics, ticksLeftsStr, 15, Font.BOLD, Color.WHITE, canvasPoints);
  273. }
  274. }
  275. }
  276. final NPC boss = plugin.getVerzik_NPC();
  277.  
  278. if (boss.getId() == NpcID.VERZIK_VITUR_8374)
  279. {
  280.  
  281. if (config.VerzikTick())
  282. {
  283. final int yellowticksLeft = plugin.getP3_YellowTicksUntilAttack();
  284. if (yellowticksLeft > 0 && yellowticksLeft < 13);
  285. {
  286. final String Yellowticksleftstr = String.valueOf(yellowticksLeft);
  287. }
  288. final int ticksLeft = plugin.getP3_TicksUntilAttack();
  289. if (ticksLeft > 0 && ticksLeft < 8)
  290. {
  291. final String ticksLeftStr = String.valueOf(ticksLeft);
  292. Point canvasPoint = boss.getCanvasTextLocation(graphics, ticksLeftStr, 60);
  293. renderTextLocation(graphics, ticksLeftStr, 15, Font.BOLD, Color.WHITE, canvasPoint);
  294.  
  295. }
  296.  
  297. }
  298.  
  299. if (config.VerzikMelee() && boss.getAnimation() != 8127)
  300. {
  301. List<WorldPoint> meleeRange = getHitSquares(boss.getWorldLocation(), 7, 1, false);
  302.  
  303. for (WorldPoint p : meleeRange)
  304. {
  305. drawTile(graphics, p, Color.WHITE, 1,155, 10);
  306. }
  307. }
  308. }
  309.  
  310. }
  311.  
  312. return null;
  313. }
  314.  
  315. private void drawTile(Graphics2D graphics, WorldPoint point, Color color, int strokeWidth, int outlineAlpha, int fillAlpha) {
  316. WorldPoint playerLocation = client.getLocalPlayer().getWorldLocation();
  317. if (point.distanceTo(playerLocation) >= 32) {
  318. return;
  319. }
  320. LocalPoint lp = LocalPoint.fromWorld(client, point);
  321. if (lp == null) {
  322. return;
  323. }
  324.  
  325. Polygon poly = Perspective.getCanvasTilePoly(client, lp);
  326. if (poly == null) {
  327. return;
  328. }
  329. //OverlayUtil.renderPolygon(graphics, poly, color);
  330. graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), outlineAlpha));
  331. graphics.setStroke(new BasicStroke(strokeWidth));
  332. graphics.draw(poly);
  333. graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), fillAlpha));
  334. graphics.fill(poly);
  335. }
  336.  
  337. private void renderNpcOverlay(Graphics2D graphics, NPC actor, Color color, int outlineWidth, int outlineAlpha, int fillAlpha)
  338. {
  339. int size = 1;
  340. NPCComposition composition = actor.getTransformedComposition();
  341. if (composition != null)
  342. {
  343. size = composition.getSize();
  344. }
  345. LocalPoint lp = actor.getLocalLocation();
  346. Polygon tilePoly = Perspective.getCanvasTileAreaPoly(client, lp, size);
  347.  
  348. if (tilePoly != null)
  349. {
  350. graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), outlineAlpha));
  351. graphics.setStroke(new BasicStroke(outlineWidth));
  352. graphics.draw(tilePoly);
  353. graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), fillAlpha));
  354. graphics.fill(tilePoly);
  355. }
  356. }
  357.  
  358. private void renderTextLocation(Graphics2D graphics, String txtString, int fontSize, int fontStyle, Color fontColor, Point canvasPoint)
  359. {
  360. graphics.setFont(new Font("Arial", fontStyle, fontSize));
  361. if (canvasPoint != null)
  362. {
  363. final Point canvasCenterPoint = new Point(
  364. canvasPoint.getX(),
  365. canvasPoint.getY());
  366. final Point canvasCenterPoint_shadow = new Point(
  367. canvasPoint.getX() + 1,
  368. canvasPoint.getY() + 1) ;
  369. OverlayUtil.renderTextLocation(graphics, canvasCenterPoint_shadow, txtString, Color.BLACK);
  370. OverlayUtil.renderTextLocation(graphics, canvasCenterPoint, txtString, fontColor);
  371. }
  372. }
  373.  
  374. private List<WorldPoint> getHitSquares(WorldPoint npcLoc, int npcSize, int thickness, boolean includeUnder)
  375. {
  376. List<WorldPoint> little = new WorldArea(npcLoc, npcSize, npcSize).toWorldPointList();
  377. List<WorldPoint> big = new WorldArea(npcLoc.getX()-thickness, npcLoc.getY()-thickness, npcSize + (thickness * 2), npcSize + (thickness * 2), npcLoc.getPlane()).toWorldPointList();
  378. if (!includeUnder)
  379. {
  380. for (Iterator<WorldPoint> it = big.iterator(); it.hasNext();)
  381. {
  382. WorldPoint p = it.next();
  383. if (little.contains(p))
  384. {
  385. it.remove();
  386. }
  387. }
  388. }
  389. return big;
  390. }
  391. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement