Highlight dark mage NPC in the center of the abyss when inventory contains a degraded pouch
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
package net.runelite.client.plugins.runecraft;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Polygon;
|
||||
import java.awt.geom.Area;
|
||||
import static net.runelite.client.plugins.runecraft.AbyssRifts.AIR_RIFT;
|
||||
import static net.runelite.client.plugins.runecraft.AbyssRifts.BLOOD_RIFT;
|
||||
@@ -49,6 +50,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.DecorativeObject;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.Perspective;
|
||||
import net.runelite.api.Point;
|
||||
import net.runelite.api.coords.LocalPoint;
|
||||
@@ -56,6 +58,7 @@ import net.runelite.client.game.ItemManager;
|
||||
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;
|
||||
|
||||
class AbyssOverlay extends Overlay
|
||||
{
|
||||
@@ -85,24 +88,49 @@ class AbyssOverlay extends Overlay
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
if (!config.showRifts())
|
||||
if (config.showRifts())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
LocalPoint localLocation = client.getLocalPlayer().getLocalLocation();
|
||||
for (DecorativeObject object : plugin.getAbyssObjects())
|
||||
{
|
||||
LocalPoint location = object.getLocalLocation();
|
||||
if (localLocation.distanceTo(location) <= MAX_DISTANCE)
|
||||
LocalPoint localLocation = client.getLocalPlayer().getLocalLocation();
|
||||
for (DecorativeObject object : plugin.getAbyssObjects())
|
||||
{
|
||||
renderRifts(graphics, object);
|
||||
LocalPoint location = object.getLocalLocation();
|
||||
if (localLocation.distanceTo(location) <= MAX_DISTANCE)
|
||||
{
|
||||
renderRifts(graphics, object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (config.hightlightDarkMage())
|
||||
{
|
||||
highlightDarkMage(graphics);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void highlightDarkMage(Graphics2D graphics)
|
||||
{
|
||||
if (!plugin.isDegradedPouchInInventory())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
NPC darkMage = plugin.getDarkMage();
|
||||
if (darkMage == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Polygon tilePoly = darkMage.getCanvasTilePoly();
|
||||
if (tilePoly == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
OverlayUtil.renderPolygon(graphics, tilePoly, Color.green);
|
||||
}
|
||||
|
||||
private void renderRifts(Graphics2D graphics, DecorativeObject object)
|
||||
{
|
||||
AbyssRifts rift = AbyssRifts.getRift(object.getId());
|
||||
|
||||
@@ -205,4 +205,14 @@ public interface RunecraftConfig extends Config
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "hightlightDarkMage",
|
||||
name = "Highlight Dark Mage NPC",
|
||||
description = "Configures whether to highlight the Dark Mage when pouches are degraded"
|
||||
)
|
||||
default boolean hightlightDarkMage()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,18 +35,20 @@ import java.util.regex.Pattern;
|
||||
import javax.inject.Inject;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.api.DecorativeObject;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.*;
|
||||
import net.runelite.api.events.ChatMessage;
|
||||
import net.runelite.api.events.ConfigChanged;
|
||||
import net.runelite.api.events.DecorativeObjectDespawned;
|
||||
import net.runelite.api.events.DecorativeObjectSpawned;
|
||||
import net.runelite.api.events.GameStateChanged;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.api.queries.InventoryItemQuery;
|
||||
import net.runelite.api.queries.NPCQuery;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.util.QueryRunner;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Runecraft"
|
||||
@@ -58,6 +60,12 @@ public class RunecraftPlugin extends Plugin
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private final Set<DecorativeObject> abyssObjects = new HashSet<>();
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private boolean degradedPouchInInventory;
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private NPC darkMage;
|
||||
|
||||
@Inject
|
||||
private RunecraftOverlay overlay;
|
||||
|
||||
@@ -67,6 +75,12 @@ public class RunecraftPlugin extends Plugin
|
||||
@Inject
|
||||
private AbyssOverlay abyssOverlay;
|
||||
|
||||
@Inject
|
||||
private QueryRunner queryRunner;
|
||||
|
||||
@Inject
|
||||
private RunecraftConfig config;
|
||||
|
||||
@Provides
|
||||
RunecraftConfig getConfig(ConfigManager configManager)
|
||||
{
|
||||
@@ -89,6 +103,8 @@ public class RunecraftPlugin extends Plugin
|
||||
protected void shutDown() throws Exception
|
||||
{
|
||||
abyssObjects.clear();
|
||||
darkMage = null;
|
||||
degradedPouchInInventory = false;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -100,7 +116,7 @@ public class RunecraftPlugin extends Plugin
|
||||
@Subscribe
|
||||
public void onChatMessage(ChatMessage event)
|
||||
{
|
||||
if (event.getType() != ChatMessageType.SERVER)
|
||||
if (event.getType() != ChatMessageType.SERVER || !config.showBindNeck())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -158,4 +174,31 @@ public class RunecraftPlugin extends Plugin
|
||||
abyssObjects.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onGameTick(GameTick event)
|
||||
{
|
||||
darkMage = null;
|
||||
|
||||
if (!config.hightlightDarkMage())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Query inventoryQuery = new InventoryItemQuery(InventoryID.INVENTORY).idEquals(
|
||||
ItemID.MEDIUM_POUCH_5511,
|
||||
ItemID.LARGE_POUCH_5513,
|
||||
ItemID.GIANT_POUCH_5515
|
||||
);
|
||||
|
||||
Item[] items = queryRunner.runQuery(inventoryQuery);
|
||||
degradedPouchInInventory = items.length > 0;
|
||||
|
||||
if (degradedPouchInInventory)
|
||||
{
|
||||
Query darkMageQuery = new NPCQuery().idEquals(NpcID.DARK_MAGE);
|
||||
NPC[] result = queryRunner.runQuery(darkMageQuery);
|
||||
darkMage = result.length >= 1 ? result[0] : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user