Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package net.runelite.client.plugins.microbot.thieving;

import net.runelite.client.plugins.microbot.Microbot;
import net.runelite.client.plugins.microbot.api.npc.models.Rs2NpcModel;
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.OverlayUtil;

import javax.inject.Inject;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Shape;

/**
* Draws a simple outline/label on the current thieving target NPC.
*/
public class ThievingNpcOverlay extends Overlay {
private static final Color TARGET_COLOR = new Color(0, 200, 60, 140);

private final ThievingPlugin plugin;

@Inject
ThievingNpcOverlay(ThievingPlugin plugin) {
this.plugin = plugin;
setPosition(OverlayPosition.DYNAMIC);
setLayer(OverlayLayer.ABOVE_SCENE);
setNaughty();
}

@Override
public Dimension render(Graphics2D graphics) {
final Rs2NpcModel npc = plugin.getThievingScript().getThievingNpc();
if (npc == null) return null;

// Compute on client thread to avoid cross-thread actor access issues.
final Shape hull = Microbot.getClientThread().runOnClientThreadOptional(npc::getConvexHull).orElse(null);
if (hull == null) return null;

OverlayUtil.renderPolygon(graphics, hull, TARGET_COLOR);

final String label = plugin.getThievingScript().getThievingNpcName();
Microbot.getClientThread().runOnClientThreadOptional(() -> npc.getCanvasTextLocation(graphics, label, npc.getLogicalHeight() + 40))
.ifPresent(point -> OverlayUtil.renderTextLocation(graphics, point, label, Color.WHITE));

return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.runelite.client.plugins.microbot.Microbot;
import net.runelite.client.plugins.microbot.thieving.enums.ThievingNpc;
import net.runelite.client.plugins.microbot.thieving.npc.ThievingNpcStrategy;
import net.runelite.client.plugins.microbot.util.magic.Rs2Magic;
import net.runelite.client.plugins.microbot.util.player.Rs2Player;
import net.runelite.client.ui.overlay.OverlayPanel;
Expand All @@ -14,6 +15,7 @@
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.time.Duration;
import java.util.List;

public class ThievingOverlay extends OverlayPanel {
private final ThievingPlugin plugin;
Expand Down Expand Up @@ -45,7 +47,7 @@ private String getShadowVeilString() {
@Override
public Dimension render(Graphics2D graphics) {
try {
panelComponent.setPreferredSize(new Dimension(220, 160));
panelComponent.setPreferredSize(new Dimension(240, 200));

panelComponent.getChildren().add(
TitleComponent.builder()
Expand All @@ -68,6 +70,13 @@ public Dimension render(Graphics2D graphics) {
.build()
);

panelComponent.getChildren().add(
LineComponent.builder()
.left("Target:")
.right(plugin.getConfig().THIEVING_NPC().toString())
.build()
);

panelComponent.getChildren().add(
LineComponent.builder()
.left("NPC:")
Expand Down Expand Up @@ -113,6 +122,12 @@ public Dimension render(Graphics2D graphics) {
.right(getFormattedDuration(plugin.getRunTime()))
.build()
);

final ThievingNpcStrategy strategy = plugin.getThievingScript().getActiveStrategy();
if (strategy != null) {
final List<LineComponent> lines = strategy.overlayLines(plugin.getThievingScript());
panelComponent.getChildren().addAll(lines);
}
} catch (Exception ex) {
Microbot.logStackTrace(this.getClass().getSimpleName(), ex);
}
Expand All @@ -126,4 +141,4 @@ private String getFormattedDuration(Duration duration)
long seconds = duration.getSeconds() % 60;
return String.format("%02d:%02d:%02d", hours, minutes, seconds);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
)
@Slf4j
public class ThievingPlugin extends Plugin {
public static final String version = "2.0.7";
public static final String version = "2.1.0";

@Inject
@Getter
Expand All @@ -49,6 +49,8 @@ ThievingConfig provideConfig(ConfigManager configManager) {
@Inject
private ThievingOverlay thievingOverlay;
@Inject
private ThievingNpcOverlay thievingNpcOverlay;
@Inject
@Getter
private ThievingScript thievingScript;

Expand All @@ -61,16 +63,18 @@ ThievingConfig provideConfig(ConfigManager configManager) {
protected void startUp() throws AWTException {
if (overlayManager != null) {
overlayManager.add(thievingOverlay);
overlayManager.add(thievingNpcOverlay);
}
startXp = 0;
maxCoinPouch = determineMaxCoinPouch();
maxCoinPouch = determineMaxCoinPouch();
thievingScript.run();
}

protected void shutDown() {
thievingScript.shutdown();
overlayManager.remove(thievingOverlay);
maxCoinPouch = 0;
overlayManager.remove(thievingNpcOverlay);
maxCoinPouch = 0;
startXp = 0;
}

Expand Down Expand Up @@ -111,11 +115,12 @@ public State getState() {

@Subscribe
public void onChatMessage(ChatMessage event) {
if (!event.getMessage().toLowerCase().contains("you can only cast shadow veil every 30 seconds.")) {
return;
final String message = event.getMessage().toLowerCase();
if (message.contains("you can only cast shadow veil every 30 seconds.")) {
log.warn("Attempted to cast shadow veil while it was active");
getThievingScript().forceShadowVeilActive = System.currentTimeMillis()+30_000;
}
log.warn("Attempted to cast shadow veil while it was active");
getThievingScript().forceShadowVeilActive = System.currentTimeMillis()+30_000;
getThievingScript().onChatMessage(event);
}

@Subscribe
Expand Down
Loading