Big Cox Update (#330)

* Adding Timers to Cox

* Prayer now turns red when not active.

* Enum includes prayer type now.

* Adding Timers Overlay

* Complete Refactor/Update to Cox

* Complete Refactor/Update to Cox
This commit is contained in:
Ganom
2019-05-20 16:38:16 -04:00
committed by Kyleeld
parent 68fa0ef253
commit 016b0ce0e6
8 changed files with 362 additions and 167 deletions

View File

@@ -1,5 +1,6 @@
/*
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* Copyright (c) 2019, Ganom <https://github.com/Ganom>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -27,8 +28,8 @@ package net.runelite.api;
public class GraphicID
{
public static final int SPLASH = 85;
public static final int TELEPORT = 111;
public static final int GREY_BUBBLE_TELEPORT = 86;
public static final int TELEPORT = 111;
public static final int ENTANGLE = 179;
public static final int SNARE = 180;
public static final int BIND = 181;
@@ -38,6 +39,9 @@ public class GraphicID
public static final int ICE_BARRAGE = 369;
public static final int VENGEANCE_OTHER = 725;
public static final int VENGEANCE = 726;
public static final int NPC_CONTACT = 728;
public static final int POT_SHARE = 733;
public static final int BAKE_PIE = 746;
public static final int BOOK_HOME_TELEPORT_1 = 800;
public static final int BOOK_HOME_TELEPORT_2 = 802;
public static final int BOOK_HOME_TELEPORT_3 = 803;
@@ -45,8 +49,7 @@ public class GraphicID
public static final int STAFF_OF_THE_DEAD = 1228;
public static final int IMBUED_HEART = 1316;
public static final int FLYING_FISH = 1387;
public static final int NPC_CONTACT = 728;
public static final int POT_SHARE = 733;
public static final int BAKE_PIE = 746;
public static final int OLM_BURN = 1351;
public static final int OLM_TELEPORT = 1359;
public static final int XERIC_TELEPORT = 1612;
}

View File

@@ -23,7 +23,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.client.plugins.zcox;
package net.runelite.client.plugins.coxhelper;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
@@ -68,11 +68,33 @@ public interface CoxConfig extends Config
@ConfigItem(
position = 3,
keyName = "OlmSpec",
name = "Olm Next Spec",
description = ""
keyName = "prayAgainstOlm",
name = "Olm Show Prayer",
description = "Shows what prayer to use during olm."
)
default boolean OlmSpec()
default boolean prayAgainstOlm()
{
return true;
}
@ConfigItem(
position = 3,
keyName = "timers",
name = "Olm Show Burn/Acid Timers",
description = "Shows tick timers for burns/acids."
)
default boolean timers()
{
return true;
}
@ConfigItem(
position = 3,
keyName = "tpOverlay",
name = "Olm Show Teleport Overlays",
description = "Shows Overlays for targeted teleports."
)
default boolean tpOverlay()
{
return true;
}
@@ -81,33 +103,11 @@ public interface CoxConfig extends Config
position = 4,
keyName = "OlmTick",
name = "Olm Tick Counter",
description = ""
description = "Show Tick Counter on Olm"
)
default boolean OlmTick()
{
return true;
}
@ConfigItem(
position = 5,
keyName = "OlmCrystals",
name = "Olm AoE Indicator",
description = ""
)
default boolean OlmCrystals()
{
return true;
}
@ConfigItem(
position = 6,
keyName = "LargeCrystals",
name = "Mark Large AoE Crystals rather then small ones",
description = ""
)
default boolean LargeCrystals()
{
return true;
}
}

View File

@@ -23,7 +23,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.client.plugins.zcox;
package net.runelite.client.plugins.coxhelper;
import java.awt.BasicStroke;
import java.awt.Color;
@@ -75,7 +75,6 @@ public class CoxOverlay extends Overlay
if (config.Muttadile())
{
NPC boss = plugin.getMomma_NPC();
NPC baby = plugin.getMutta_NPC();
if (boss != null)
{
@@ -84,9 +83,7 @@ public class CoxOverlay extends Overlay
{
size = composition.getSize();
}
List<WorldPoint> meleeRangeMom = getHitSquares(boss.getWorldLocation(), size, 1, false);
for (WorldPoint p : meleeRangeMom)
{
drawTile(graphics, p, Color.RED, 2, 155, 10);
@@ -99,9 +96,7 @@ public class CoxOverlay extends Overlay
{
size = compositionbaby.getSize();
}
List<WorldPoint> meleeRange = getHitSquares(baby.getWorldLocation(), size, 1, false);
for (WorldPoint p : meleeRange)
{
drawTile(graphics, p, Color.RED, 1, 155, 10);
@@ -127,9 +122,7 @@ public class CoxOverlay extends Overlay
{
size = composition.getSize();
}
List<WorldPoint> meleeRange = getHitSquares(G1.getWorldLocation(), size, 1, true);
for (WorldPoint p : meleeRange)
{
drawTile(graphics, p, Color.GREEN, 1, 155, 10);
@@ -142,9 +135,7 @@ public class CoxOverlay extends Overlay
{
size = composition.getSize();
}
List<WorldPoint> meleeRange = getHitSquares(G2.getWorldLocation(), size, 1, true);
for (WorldPoint p : meleeRange)
{
drawTile(graphics, p, Color.GREEN, 1, 155, 10);
@@ -159,9 +150,7 @@ public class CoxOverlay extends Overlay
{
if (config.Tekton())
{
NPC boss = plugin.getTekton_NPC();
if (boss != null)
{
int size = 1;
@@ -169,9 +158,7 @@ public class CoxOverlay extends Overlay
{
size = composition.getSize();
}
List<WorldPoint> meleeRange = getHitSquares(boss.getWorldLocation(), size, 1, false);
for (WorldPoint p : meleeRange)
{
drawTile(graphics, p, Color.WHITE, 1, 155, 10);
@@ -183,28 +170,7 @@ public class CoxOverlay extends Overlay
if (plugin.isRunOlm())
{
NPC boss = plugin.getOlm_NPC();
if (config.OlmCrystals())
{
for (WorldPoint p : plugin.getOlm_Crystals())
{
drawTile(graphics, p, Color.RED, 1, 255, 0);
}
for (WorldPoint p : plugin.getOlm_Heal())
{
drawTile(graphics, p, Color.BLUE, 3, 255, 0);
}
for (WorldPoint p : plugin.getOlm_PSN())
{
drawTile(graphics, p, Color.GREEN, 3, 255, 0);
}
}
if (config.OlmSpec())
{
}
if (config.OlmTick())
{
if (boss != null)

View File

@@ -24,7 +24,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.client.plugins.zcox;
package net.runelite.client.plugins.coxhelper;
import com.google.inject.Provides;
import java.util.ArrayList;
@@ -35,7 +35,9 @@ import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Actor;
import net.runelite.api.Client;
import net.runelite.api.GraphicID;
import net.runelite.api.GraphicsObject;
import net.runelite.api.MessageNode;
import net.runelite.api.NPC;
@@ -46,6 +48,7 @@ import net.runelite.api.Varbits;
import net.runelite.api.coords.WorldPoint;
import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.GameTick;
import net.runelite.api.events.GraphicChanged;
import net.runelite.api.events.NpcDespawned;
import net.runelite.api.events.NpcSpawned;
import net.runelite.api.events.ProjectileMoved;
@@ -58,7 +61,7 @@ import net.runelite.client.plugins.PluginType;
import net.runelite.client.ui.overlay.OverlayManager;
@PluginDescriptor(
name = "CoX Helper ",
name = "CoX Helper",
description = "All-in-one plugin for Chambers of Xeric",
tags = {"CoX", "chamber", "xeric", "helper"},
enabledByDefault = false,
@@ -73,40 +76,73 @@ public class CoxPlugin extends Plugin
private static final int GRAPHICSOBJECT_ID_CRYSTAL = 1447;
private static final int GRAPHICSOBJECT_ID_HEAL = 1363;
private static final int ANIMATION_ID_G1 = 430;
int sleepcount = 0;
private boolean needOlm = false;
@Getter(AccessLevel.PACKAGE)
private int guardTick = -1;
@Getter(AccessLevel.PACKAGE)
private boolean runGuard = false;
@Getter(AccessLevel.PACKAGE)
private NPC Guard1_NPC;
@Getter(AccessLevel.PACKAGE)
private NPC Guard2_NPC;
private static final String OLM_HAND_CRIPPLE = "The Great Olm\'s left claw clenches to protect itself temporarily.";
private int sleepcount = 0;
private boolean needOlm = false;
@Inject
private Client client;
@Getter(AccessLevel.PACKAGE)
private boolean HandCripple;
@Getter(AccessLevel.PACKAGE)
private int timer = 45;
@Getter(AccessLevel.PACKAGE)
private NPC hand;
@Inject
private ChatMessageManager chatMessageManager;
@Inject
private CoxOverlay overlay;
@Inject
private TimersOverlay timersOverlay;
@Inject
private CoxConfig config;
@Inject
private OverlayManager overlayManager;
@Inject
private OlmCrippleTimerOverlay olmCrippleTimerOverlay;
@Setter
@Getter
protected PrayAgainst prayAgainstOlm;
@Getter
protected long lastPrayTime;
@Inject
private OlmPrayAgainstOverlay prayAgainstOverlay;
@Setter
@Getter(AccessLevel.PACKAGE)
protected PrayAgainst prayAgainstOlm;
@Getter(AccessLevel.PACKAGE)
private boolean runMutta;
@Getter(AccessLevel.PACKAGE)
private boolean runTekton;
@Getter(AccessLevel.PACKAGE)
private boolean runVanguards;
@Getter(AccessLevel.PACKAGE)
private boolean runGuard = false;
@Getter(AccessLevel.PACKAGE)
private boolean HandCripple;
@Getter(AccessLevel.PACKAGE)
private boolean runOlm;
@Getter(AccessLevel.PACKAGE)
private NPC Guard1_NPC;
@Getter(AccessLevel.PACKAGE)
private NPC Guard2_NPC;
@Getter(AccessLevel.PACKAGE)
private NPC Tekton_NPC;
@Getter(AccessLevel.PACKAGE)
private NPC hand;
@Getter(AccessLevel.PACKAGE)
private NPC Olm_NPC;
@Getter(AccessLevel.PACKAGE)
private NPC OlmMelee_NPC;
@Getter(AccessLevel.PACKAGE)
private NPC Mutta_NPC;
@@ -114,22 +150,9 @@ public class CoxPlugin extends Plugin
@Getter(AccessLevel.PACKAGE)
private NPC Momma_NPC;
@Getter(AccessLevel.PACKAGE)
private int OlmPhase = 0;
@Getter(AccessLevel.PACKAGE)
private boolean runTekton;
@Getter(AccessLevel.PACKAGE)
private NPC Tekton_NPC;
@Getter(AccessLevel.PACKAGE)
private boolean runVanguards;
@Getter(AccessLevel.PACKAGE)
private NPC meleeVanguard_NPC;
@Getter(AccessLevel.PACKAGE)
private NPC mageVanguard_NPC;
@@ -137,13 +160,40 @@ public class CoxPlugin extends Plugin
private NPC rangeVanguard_NPC;
@Getter(AccessLevel.PACKAGE)
private boolean runOlm;
private List<WorldPoint> Olm_Crystals = new ArrayList<>();
@Getter(AccessLevel.PACKAGE)
private NPC Olm_NPC;
private List<WorldPoint> Olm_Heal = new ArrayList<>();
@Getter(AccessLevel.PACKAGE)
private NPC OlmMelee_NPC;
private List<WorldPoint> Olm_PSN = new ArrayList<>();
@Getter(AccessLevel.PACKAGE)
private List<Actor> burnTarget = new ArrayList<>();
@Getter(AccessLevel.PACKAGE)
private List<Actor> teleportTarget = new ArrayList<>();
@Getter(AccessLevel.PACKAGE)
private Actor acidTarget;
@Getter(AccessLevel.PACKAGE)
private int timer = 45;
@Getter(AccessLevel.PACKAGE)
private int burnTicks = 41;
@Getter(AccessLevel.PACKAGE)
private int acidTicks = 25;
@Getter(AccessLevel.PACKAGE)
private int teleportTicks = 10;
@Getter(AccessLevel.PACKAGE)
private int guardTick = -1;
@Getter(AccessLevel.PACKAGE)
private int OlmPhase = 0;
@Getter(AccessLevel.PACKAGE)
private int Olm_TicksUntilAction = -1;
@@ -155,22 +205,7 @@ public class CoxPlugin extends Plugin
private int Olm_NextSpec = -1; // 1= crystals 2=lightnig 3=portals 4= heal hand if p4
@Getter(AccessLevel.PACKAGE)
private List<WorldPoint> Olm_Crystals = new ArrayList<>();
@Getter(AccessLevel.PACKAGE)
private List<WorldPoint> Olm_Heal = new ArrayList<>();
@Getter(AccessLevel.PACKAGE)
private List<WorldPoint> Olm_PSN = new ArrayList<>();
@Inject
private ChatMessageManager chatMessageManager;
@Inject
private CoxOverlay overlay;
@Inject
private CoxConfig config;
protected long lastPrayTime;
@Provides
CoxConfig getConfig(ConfigManager configManager)
@@ -184,6 +219,7 @@ public class CoxPlugin extends Plugin
overlayManager.add(overlay);
overlayManager.add(olmCrippleTimerOverlay);
overlayManager.add(prayAgainstOverlay);
overlayManager.add(timersOverlay);
}
@Override
@@ -192,8 +228,14 @@ public class CoxPlugin extends Plugin
overlayManager.remove(overlay);
overlayManager.remove(olmCrippleTimerOverlay);
overlayManager.remove(prayAgainstOverlay);
overlayManager.remove(timersOverlay);
HandCripple = false;
acidTarget = null;
teleportTarget.clear();
burnTarget.clear();
timer = 45;
burnTicks = 40;
acidTicks = 25;
hand = null;
}
@@ -205,7 +247,6 @@ public class CoxPlugin extends Plugin
if (messageNode.getValue().toLowerCase().contains("The Great Olm rises with the power of".toLowerCase()) || messageNode.getValue().toLowerCase().contains("!olm".toLowerCase()))
{
System.out.println("finding Olm NPC");
if (!runOlm)
{
Olm_ActionCycle = -1;
@@ -224,7 +265,6 @@ public class CoxPlugin extends Plugin
if (messageNode.getValue().toLowerCase().contains("The Great Olm is giving its all. this is its final stand".toLowerCase()))
{
System.out.println("finding Olm NPC");
if (!runOlm)
{
Olm_ActionCycle = -1;
@@ -236,7 +276,6 @@ public class CoxPlugin extends Plugin
Olm_TicksUntilAction = 3;
}
OlmPhase = 1;
System.out.println("OLM PHASE:" + OlmPhase);
runOlm = true;
needOlm = true;
Olm_NextSpec = -1;
@@ -248,19 +287,16 @@ public class CoxPlugin extends Plugin
}
if (messageNode.getValue().toLowerCase().contains("aggression"))
{
log.debug("Melee Detected");
prayAgainstOlm = PrayAgainst.MELEE;
lastPrayTime = System.currentTimeMillis();
}
if (messageNode.getValue().toLowerCase().contains("of magical power"))
{
log.debug("Mage Detected");
prayAgainstOlm = PrayAgainst.MAGIC;
lastPrayTime = System.currentTimeMillis();
}
if (messageNode.getValue().toLowerCase().contains("accuracy and dexterity"))
{
log.debug("Missile Detected");
prayAgainstOlm = PrayAgainst.RANGED;
lastPrayTime = System.currentTimeMillis();
}
@@ -272,16 +308,33 @@ public class CoxPlugin extends Plugin
Projectile projectile = event.getProjectile();
if (projectile.getId() == ProjectileID.OLM_MAGE_ATTACK)
{
log.debug("Mage Detected");
prayAgainstOlm = PrayAgainst.MAGIC;
lastPrayTime = System.currentTimeMillis();
}
if (projectile.getId() == ProjectileID.OLM_RANGE_ATTACK)
{
log.debug("Range Detected");
prayAgainstOlm = PrayAgainst.RANGED;
lastPrayTime = System.currentTimeMillis();
}
if (projectile.getId() == ProjectileID.OLM_ACID_TRAIL)
{
acidTarget = projectile.getInteracting();
}
}
@Subscribe
public void onGraphicChanged(GraphicChanged graphicChanged)
{
Actor actor = graphicChanged.getActor();
if (actor.getGraphic() == GraphicID.OLM_BURN)
{
burnTarget.add(actor);
}
if (actor.getGraphic() == GraphicID.OLM_TELEPORT)
{
teleportTarget.add(actor);
}
}
@Subscribe
@@ -365,8 +418,8 @@ public class CoxPlugin extends Plugin
case NpcID.GUARDIAN_7571:
case NpcID.GUARDIAN_7572:
Guard1_NPC = null;
runGuard = false;
Guard2_NPC = null;
runGuard = false;
break;
case NpcID.GREAT_OLM_RIGHT_CLAW_7553:
case NpcID.GREAT_OLM_LEFT_CLAW:
@@ -379,6 +432,33 @@ public class CoxPlugin extends Plugin
@Subscribe
public void onGameTick(GameTick event)
{
if (acidTarget != null)
{
acidTicks--;
if (acidTicks <= 0)
{
acidTarget = null;
acidTicks = 25;
}
}
if (teleportTarget.size() > 0)
{
teleportTicks--;
if (teleportTicks <= 0)
{
teleportTarget.clear();
teleportTicks = 10;
}
}
if (burnTarget.size() > 0)
{
burnTicks--;
if (burnTicks <= 0)
{
burnTarget.clear();
burnTicks = 41;
}
}
if (client.getVar(Varbits.IN_RAID) == 0)
{
@@ -391,10 +471,6 @@ public class CoxPlugin extends Plugin
sleepcount = 0;
Olm_Heal.clear();
}
else
{
}
if (HandCripple)
{
@@ -413,14 +489,8 @@ public class CoxPlugin extends Plugin
{
needOlm = false;
Olm_NPC = monster;
System.out.println("Found olm Npc");
break;
}
else
{
continue;
}
}
}
@@ -512,20 +582,12 @@ public class CoxPlugin extends Plugin
for (int y = -1; y <= 1; y++)
{
newloc = WorldPoint.fromLocal(client, o.getLocation());
if (config.LargeCrystals())
{
newloc = newloc.dx(x);
newloc = newloc.dy(y);
}
newloc = newloc.dx(x);
newloc = newloc.dy(y);
Olm_Crystals.add(newloc);
}
}
}
if (sleepcount <= 0)
{
if (o.getId() == 1338)
@@ -534,7 +596,6 @@ public class CoxPlugin extends Plugin
Olm_NextSpec = 2;
Olm_ActionCycle = 4; //spec=1 null=3
sleepcount = 5;
System.out.println("setting off 1338 id - crystals");
}
if (o.getId() == 1356)
{
@@ -542,9 +603,7 @@ public class CoxPlugin extends Plugin
Olm_NextSpec = 1;
Olm_ActionCycle = 4; //spec=1 null=3
sleepcount = 50;
System.out.println("setting off 1338 id - lighning");
}
}
@@ -553,9 +612,6 @@ public class CoxPlugin extends Plugin
Olm_Heal.add(WorldPoint.fromLocal(client, o.getLocation()));
}
}
}
}
}

View File

@@ -23,7 +23,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.client.plugins.zcox;
package net.runelite.client.plugins.coxhelper;
import java.awt.Color;

View File

@@ -22,7 +22,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.client.plugins.zcox;
package net.runelite.client.plugins.coxhelper;
import java.awt.Color;
import java.awt.Dimension;
@@ -37,22 +37,25 @@ import net.runelite.api.SpriteID;
import net.runelite.client.game.SpriteManager;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.components.ComponentConstants;
import net.runelite.client.ui.overlay.components.ComponentOrientation;
import net.runelite.client.ui.overlay.components.InfoBoxComponent;
import net.runelite.client.ui.overlay.components.PanelComponent;
class OlmPrayAgainstOverlay extends Overlay
{
private static final Color NOT_ACTIVATED_BACKGROUND_COLOR = new Color(150, 0, 0, 150);
private final CoxPlugin plugin;
private final CoxConfig config;
private final Client client;
private final SpriteManager spriteManager;
private final PanelComponent panelComponent = new PanelComponent();
@Inject
OlmPrayAgainstOverlay(CoxPlugin plugin, Client client, SpriteManager spriteManager)
OlmPrayAgainstOverlay(CoxPlugin plugin, CoxConfig config, Client client, SpriteManager spriteManager)
{
this.plugin = plugin;
this.config = config;
this.client = client;
this.spriteManager = spriteManager;
setPosition(OverlayPosition.BOTTOM_RIGHT);
@@ -61,7 +64,8 @@ class OlmPrayAgainstOverlay extends Overlay
public Dimension render(Graphics2D graphics2D)
{
if (plugin.getPrayAgainstOlm() == null)
final PrayAgainst prayAgainst = plugin.getPrayAgainstOlm();
if (plugin.getPrayAgainstOlm() == null && !config.prayAgainstOlm())
{
return null;
}
@@ -74,6 +78,9 @@ class OlmPrayAgainstOverlay extends Overlay
Image prayImg = scaleImg(getPrayerImage(plugin.prayAgainstOlm));
prayComponent.setImage(prayImg);
prayComponent.setColor(Color.WHITE);
prayComponent.setBackgroundColor(client.isPrayerActive(prayAgainst.getPrayer())
? ComponentConstants.STANDARD_BACKGROUND_COLOR
: NOT_ACTIVATED_BACKGROUND_COLOR);
prayComponent.setPreferredSize(new Dimension(40, 40));
panelComponent.getChildren().add(prayComponent);
@@ -85,6 +92,10 @@ class OlmPrayAgainstOverlay extends Overlay
{
plugin.setPrayAgainstOlm(null);
}
if (client.getLocalPlayer().getWorldLocation().getRegionID() == 4919)
{
plugin.setPrayAgainstOlm(null);
}
return null;
}

View File

@@ -22,11 +22,25 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.client.plugins.zcox;
package net.runelite.client.plugins.coxhelper;
enum PrayAgainst
import net.runelite.api.Prayer;
public enum PrayAgainst
{
MELEE,
MAGIC,
RANGED
MELEE(Prayer.PROTECT_FROM_MELEE),
MAGIC(Prayer.PROTECT_FROM_MAGIC),
RANGED(Prayer.PROTECT_FROM_MISSILES);
private final Prayer prayer;
PrayAgainst(Prayer prayer)
{
this.prayer = prayer;
}
public Prayer getPrayer()
{
return prayer;
}
}

View File

@@ -0,0 +1,145 @@
package net.runelite.client.plugins.coxhelper;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.Polygon;
import javax.inject.Inject;
import net.runelite.api.Actor;
import net.runelite.api.Client;
import net.runelite.api.Perspective;
import net.runelite.api.Point;
import net.runelite.api.coords.LocalPoint;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayLayer;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.OverlayPriority;
import net.runelite.client.ui.overlay.OverlayUtil;
public class TimersOverlay extends Overlay
{
private CoxPlugin plugin;
private CoxConfig config;
private Client client;
private Color tickcolor = new Color(255, 255, 255, 255);
@Inject
TimersOverlay(CoxPlugin plugin, CoxConfig config, Client client)
{
this.plugin = plugin;
this.config = config;
this.client = client;
setPosition(OverlayPosition.DYNAMIC);
setPriority(OverlayPriority.HIGHEST);
setLayer(OverlayLayer.ALWAYS_ON_TOP);
}
@Override
public Dimension render(Graphics2D graphics)
{
if (config.timers())
{
if (plugin.getBurnTarget().size() > 0)
{
for (Actor actor : plugin.getBurnTarget())
{
renderNpcOverlay(graphics, actor, new Color(255, 100, 0, 255), 2, 100, 10);
final int ticksLeft = plugin.getBurnTicks();
String ticksLeftStr = String.valueOf(ticksLeft);
if (ticksLeft >= 0)
{
if (ticksLeft == 34 ||
ticksLeft == 33 ||
ticksLeft == 26 ||
ticksLeft == 25 ||
ticksLeft == 18 ||
ticksLeft == 17 ||
ticksLeft == 10 ||
ticksLeft == 9 ||
ticksLeft == 2 ||
ticksLeft == 1)
{
tickcolor = new Color(255, 0, 0, 255);
ticksLeftStr = "GAP";
}
else
{
tickcolor = new Color(255, 255, 255, 255);
}
Point canvasPoint = actor.getCanvasTextLocation(graphics, ticksLeftStr, 0);
renderTextLocation(graphics, ticksLeftStr, 14, Font.BOLD, tickcolor, canvasPoint);
}
}
}
if (plugin.getAcidTarget() != null)
{
Actor actor = plugin.getAcidTarget();
renderNpcOverlay(graphics, actor, new Color(69, 241, 44, 255), 2, 100, 10);
final int ticksLeft = plugin.getAcidTicks();
if (ticksLeft > 0)
{
if (ticksLeft > 1)
{
tickcolor = new Color(69, 241, 44, 255);
}
else
{
tickcolor = new Color(255, 255, 255, 255);
}
final String ticksLeftStr = String.valueOf(ticksLeft);
Point canvasPoint = actor.getCanvasTextLocation(graphics, ticksLeftStr, 0);
renderTextLocation(graphics, ticksLeftStr, 14, Font.BOLD, tickcolor, canvasPoint);
}
}
}
if (config.tpOverlay())
{
if (plugin.getTeleportTarget().size() > 0)
{
for (Actor actor : plugin.getTeleportTarget())
{
renderNpcOverlay(graphics, actor, new Color(193, 255, 245, 255), 2, 100, 10);
}
}
}
return null;
}
private void renderNpcOverlay(Graphics2D graphics, Actor actor, Color color, int outlineWidth, int outlineAlpha, int fillAlpha)
{
int size = 1;
LocalPoint lp = actor.getLocalLocation();
Polygon tilePoly = Perspective.getCanvasTileAreaPoly(client, lp, size);
if (tilePoly != null)
{
graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), outlineAlpha));
graphics.setStroke(new BasicStroke(outlineWidth));
graphics.draw(tilePoly);
graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), fillAlpha));
graphics.fill(tilePoly);
}
}
private void renderTextLocation(Graphics2D graphics, String txtString, int fontSize, int fontStyle, Color fontColor, Point canvasPoint)
{
graphics.setFont(new Font("Arial", fontStyle, fontSize));
if (canvasPoint != null)
{
final Point canvasCenterPoint = new Point(
canvasPoint.getX(),
canvasPoint.getY());
final Point canvasCenterPoint_shadow = new Point(
canvasPoint.getX() + 1,
canvasPoint.getY() + 1);
OverlayUtil.renderTextLocation(graphics, canvasCenterPoint_shadow, txtString, Color.BLACK);
OverlayUtil.renderTextLocation(graphics, canvasCenterPoint, txtString, fontColor);
}
}
}