Skip to content
Open
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ A RuneLite plugin to help solve random events by displaying solutions for each r

- Displays the correct coffin solution for all the graves via color-coded highlights
- Swaps "Use" to be the first option on a coffin
- View either skill icons or item icons related to the grave

### [Mime](https://oldschool.runescape.wiki/w/Mime_(Random_Event))
<details>
Expand Down
66 changes: 44 additions & 22 deletions src/main/java/randomeventhelper/RandomEventHelperConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,70 @@ default boolean isDrillDemonEnabled()
return true;
}

@ConfigSection(
name = "Freaky Forester",
description = "Freaky Forester random event options",
position = 3,
closedByDefault = true
)
String SECTION_FREAKY_FORESTER = "sectionFreakyForester";

@ConfigItem(
keyName = "isFreakyForesterEnabled",
name = "Freaky Forester",
description = "Helps highlight the correct pheasant to kill for the Freaky Forester random event.",
position = 3
section = SECTION_FREAKY_FORESTER,
position = 0
)
default boolean isFreakyForesterEnabled()
{
return true;
}

@ConfigItem(
keyName = "pheasantHighlightMode",
name = "Pheasant Highlight Mode",
description = "Configures how to highlight the pheasant(s) for the Freaky Forester random event.",
section = SECTION_FREAKY_FORESTER,
position = 1
)
default PheasantMode pheasantHighlightMode()
{
return PheasantMode.SPECIFIC;
}

@ConfigSection(
name = "Gravedigger",
description = "Gravedigger random event options",
position = 4,
closedByDefault = true
)
String SECTION_GRAVEDIGGER = "sectionGravedigger";

@ConfigItem(
keyName = "isGravediggerEnabled",
name = "Gravedigger",
description = "Helps highlight where each coffin belongs to each grave for the Gravedigger random event.",
position = 4
section = SECTION_GRAVEDIGGER,
position = 0
)
default boolean isGravediggerEnabled()
{
return true;
}

@ConfigItem(
keyName = "gravediggerUseSkillIcons",
name = "Use skill icons instead of item icons",
description = "Use the associated skill icons instead of item icons for gravestones and coffins in the Gravedigger random event.",
section = SECTION_GRAVEDIGGER,
position = 1
)
default boolean gravediggerUseSkillIcons()
{
return true;
}

@ConfigItem(
keyName = "isMazeEnabled",
name = "Maze",
Expand Down Expand Up @@ -129,24 +171,4 @@ default boolean isQuizMasterEnabled()
{
return true;
}

@ConfigSection(
name = "Options",
description = "Further configure various options",
position = 11,
closedByDefault = true
)
String SECTION_OPTIONS = "sectionOptions";

@ConfigItem(
keyName = "pheasantHighlightMode",
name = "Pheasant Highlight Mode",
description = "Configures how to highlight the pheasant(s) for the Freaky Forester random event.",
section = SECTION_OPTIONS,
position = 0
)
default PheasantMode pheasantHighlightMode()
{
return PheasantMode.SPECIFIC;
}
}
8 changes: 6 additions & 2 deletions src/main/java/randomeventhelper/RandomEventHelperPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import randomeventhelper.randomevents.drilldemon.DrillDemonHelper;
import randomeventhelper.randomevents.freakyforester.FreakyForesterHelper;
import randomeventhelper.randomevents.gravedigger.GravediggerHelper;
import randomeventhelper.randomevents.gravedigger.GravediggerOverlay;
import randomeventhelper.randomevents.maze.MazeHelper;
import randomeventhelper.randomevents.mime.MimeHelper;
import randomeventhelper.randomevents.pinball.PinballHelper;
Expand Down Expand Up @@ -87,6 +88,9 @@ public class RandomEventHelperPlugin extends Plugin
@Inject
private GravediggerHelper gravediggerHelper;

@Inject
private GravediggerOverlay gravediggerOverlay;

@Inject
private MimeHelper mimeHelper;

Expand Down Expand Up @@ -129,7 +133,7 @@ protected void startUp() throws Exception
}
if (config.isGravediggerEnabled())
{
gravediggerHelper.startUp();
gravediggerHelper.startUp(gravediggerOverlay);
}
if (config.isMimeEnabled())
{
Expand Down Expand Up @@ -236,7 +240,7 @@ else if (configChanged.getKey().equals("isGravediggerEnabled"))
{
if (config.isGravediggerEnabled())
{
gravediggerHelper.startUp();
gravediggerHelper.startUp(gravediggerOverlay);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,26 @@
import lombok.AllArgsConstructor;
import lombok.Getter;
import net.runelite.api.gameval.ItemID;
import net.runelite.api.gameval.SpriteID;
import net.runelite.client.game.ItemManager;
import net.runelite.client.game.SpriteManager;

@Getter
@AllArgsConstructor
public enum Coffin
{
CRAFTING(0, ItemID.MACRO_DIGGER_COFFIN_OBJECT_1, ItemID.POT_EMPTY, new Color(88, 58, 12)),
MINING(1, ItemID.MACRO_DIGGER_COFFIN_OBJECT_2, ItemID.BRONZE_PICKAXE, Color.LIGHT_GRAY),
COOKING(2, ItemID.MACRO_DIGGER_COFFIN_OBJECT_3, ItemID.CHEFS_HAT, Color.ORANGE),
FARMING(3, ItemID.MACRO_DIGGER_COFFIN_OBJECT_4, ItemID.DIBBER, Color.BLUE),
WOODCUTTING(4, ItemID.MACRO_DIGGER_COFFIN_OBJECT_5, ItemID.BRONZE_AXE, Color.GREEN),
EMPTY(5, -1, -1, Color.BLACK); // No item ID for empty coffin
CRAFTING(0, ItemID.MACRO_DIGGER_COFFIN_OBJECT_1, ItemID.POT_EMPTY, SpriteID.Staticons.CRAFTING, new Color(88, 58, 12)),
MINING(1, ItemID.MACRO_DIGGER_COFFIN_OBJECT_2, ItemID.BRONZE_PICKAXE, SpriteID.Staticons.MINING, Color.LIGHT_GRAY),
COOKING(2, ItemID.MACRO_DIGGER_COFFIN_OBJECT_3, ItemID.CHEFS_HAT, SpriteID.Staticons.COOKING, Color.ORANGE),
FARMING(3, ItemID.MACRO_DIGGER_COFFIN_OBJECT_4, ItemID.DIBBER, SpriteID.Staticons2.FARMING, Color.BLUE),
WOODCUTTING(4, ItemID.MACRO_DIGGER_COFFIN_OBJECT_5, ItemID.BRONZE_AXE, SpriteID.Staticons.WOODCUTTING, Color.GREEN),
EMPTY(5, -1, -1, -1, Color.BLACK); // No item ID for empty coffin

private final int varbitValue; // Value for both MACRO_DIGGER_GRAVE and MACRO_DIGGER_COFFIN
private final int itemID; // Item ID of the coffin item
private final int associatedItemID; // An item ID associated with the coffin
private final Color color;
private final int itemID; // Item ID of the coffin item itself
private final int associatedItemID; // An item ID associated with the coffin's contents
private final int associatedSkillSpriteID; // Skill sprite ID associated with the coffin's contents
private final Color color; // A color associated with the coffin and the skill it represents based on its contents

private static final Map<Integer, Coffin> VARBIT_COFFIN_MAP;
private static final Map<Integer, Coffin> ITEMID_COFFIN_MAP;
Expand Down Expand Up @@ -54,4 +57,13 @@ public BufferedImage getItemImage(ItemManager itemManager)
}
return itemManager.getImage(this.associatedItemID);
}

public BufferedImage getSkillIconImage(SpriteManager spriteManager)
{
if (this.associatedSkillSpriteID == -1)
{
return null;
}
return spriteManager.getSprite(this.associatedSkillSpriteID, 0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import net.runelite.api.GameObject;
import net.runelite.api.Item;
import net.runelite.api.NPC;
import net.runelite.api.Tile;
import net.runelite.api.events.GameObjectSpawned;
import net.runelite.api.events.GameTick;
import net.runelite.api.events.ItemContainerChanged;
Expand All @@ -32,6 +33,7 @@
import net.runelite.client.eventbus.EventBus;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.game.ItemManager;
import net.runelite.client.game.SpriteManager;
import net.runelite.client.ui.overlay.OverlayManager;
import randomeventhelper.RandomEventHelperPlugin;

Expand All @@ -49,9 +51,11 @@ public class GravediggerHelper
private ItemManager itemManager;

@Inject
private OverlayManager overlayManager;
private SpriteManager spriteManager;

@Inject
private OverlayManager overlayManager;

private GravediggerOverlay gravediggerOverlay;

@Inject
Expand All @@ -66,21 +70,25 @@ public class GravediggerHelper
@Getter
private Map<Coffin, BufferedImage> coffinItemImageMap;

@Getter
private Map<Coffin, BufferedImage> coffinSkillImageMap;

private Multiset<Integer> previousInventory;
private Multiset<Integer> currentInventoryItems;

@Getter
private Set<Integer> coffinsInInventory;


public void startUp()
public void startUp(GravediggerOverlay gravediggerOverlay)
{
this.gravediggerOverlay = gravediggerOverlay;
this.eventBus.register(this);
this.overlayManager.add(gravediggerOverlay);
this.overlayManager.add(this.gravediggerOverlay);
this.overlayManager.add(gravediggerItemOverlay);
this.initiallyEnteredGraveDiggerArea = false;
this.initiallyEnteredGraveDiggerArea = true;
this.graveMap = Maps.newHashMapWithExpectedSize(5);
this.coffinItemImageMap = Maps.newHashMapWithExpectedSize(5);
this.coffinSkillImageMap = Maps.newHashMapWithExpectedSize(5);
this.previousInventory = HashMultiset.create();
this.currentInventoryItems = HashMultiset.create();
this.coffinsInInventory = Sets.newHashSetWithExpectedSize(5);
Expand All @@ -89,11 +97,16 @@ public void startUp()
public void shutDown()
{
this.eventBus.unregister(this);
this.overlayManager.remove(gravediggerOverlay);
if (this.gravediggerOverlay != null)
{
this.overlayManager.remove(gravediggerOverlay);
this.gravediggerOverlay = null;
}
this.overlayManager.remove(gravediggerItemOverlay);
this.initiallyEnteredGraveDiggerArea = false;
this.initiallyEnteredGraveDiggerArea = true;
this.graveMap = null;
this.coffinItemImageMap = null;
this.coffinSkillImageMap = null;
this.previousInventory = null;
this.currentInventoryItems = null;
this.coffinsInInventory = null;
Expand All @@ -107,6 +120,39 @@ public void onGameTick(GameTick gameTick)
// And by using a separate variable to make sure not to run this constantly every game tick
if (this.initiallyEnteredGraveDiggerArea)
{
if (this.currentInventoryItems.isEmpty())
{
ItemContainerChanged itemContainerChangedEvent = new ItemContainerChanged(InventoryID.INV, this.client.getItemContainer(InventoryID.INV));
this.onItemContainerChanged(itemContainerChangedEvent);
}

if (this.graveMap.isEmpty())
{
Tile[][][] sceneTiles = this.client.getTopLevelWorldView().getScene().getTiles(); // [Plane][x][y]
Tile[][] tilesInZ = sceneTiles[this.client.getTopLevelWorldView().getPlane()]; // Tiles at [z]

for (Tile[] tilesInZX : tilesInZ) // Tiles at [z][x]
{
for (Tile tile : tilesInZX) // Tiles at [z][x][y]
{
if (tile != null && tile.getGameObjects() != null)
{
for (GameObject gameObject : tile.getGameObjects())
{
// There seemed to be some case where the game object was null
if (gameObject == null)
{
continue;
}
GameObjectSpawned gameObjectSpawnedEvent = new GameObjectSpawned();
gameObjectSpawnedEvent.setGameObject(gameObject);
this.onGameObjectSpawned(gameObjectSpawnedEvent);
}
}
}
}
}

for (GraveNumber graveNumber : GraveNumber.values())
{
VarbitChanged graveTypeVarbitChangedEvent = new VarbitChanged();
Expand All @@ -117,8 +163,25 @@ public void onGameTick(GameTick gameTick)
placedCoffinVarbitChangedEvent.setValue(this.client.getVarbitValue(graveNumber.getPlacedCoffinVarbitID()));
this.onVarbitChanged(graveTypeVarbitChangedEvent);
this.onVarbitChanged(placedCoffinVarbitChangedEvent);
this.initiallyEnteredGraveDiggerArea = false;
}

if (this.coffinItemImageMap.isEmpty())
{
for (Coffin coffin : Coffin.values())
{
this.coffinItemImageMap.put(coffin, coffin.getItemImage(this.itemManager));
}
}

if (this.coffinSkillImageMap.isEmpty())
{
for (Coffin coffin : Coffin.values())
{
this.coffinSkillImageMap.put(coffin, coffin.getSkillIconImage(this.spriteManager));
}
}

this.initiallyEnteredGraveDiggerArea = false;
}
}

Expand Down Expand Up @@ -243,11 +306,6 @@ public void onNpcSpawned(NpcSpawned npcSpawned)
{
log.debug("Grave Digger Leo NPC spawned in grave digger random event area.");
this.initiallyEnteredGraveDiggerArea = true;
// Take this opportunity to initialize the BufferedImage for the coffin items
for (Coffin coffin : Coffin.values())
{
coffinItemImageMap.put(coffin, coffin.getItemImage(this.itemManager));
}
}
}
}
Expand Down
Loading