loottracker: Track herbiboar loot with an open herb sack
When looting the herbiboar with an open herb sack, instead of receiving the herbs to your inventory, the herbs are deposited to the sack directly and the player receives chat messages indicating the herbs they received. This commit adds support for reading those chat messages when looting the herbiboar. This change incidentally fixes an issue which arose when the open herb sack was introduced to the game where any inventory change after looting the herbiboar would be tracked as herbiboar loot, such as drinking a stamina potion. Closes #10655 Fixes #10718
This commit is contained in:
@@ -63,6 +63,7 @@ import net.runelite.api.GameState;
|
||||
import net.runelite.api.InventoryID;
|
||||
import net.runelite.api.ItemComposition;
|
||||
import net.runelite.api.ItemContainer;
|
||||
import net.runelite.api.MessageNode;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.Player;
|
||||
import net.runelite.api.SpriteID;
|
||||
@@ -116,8 +117,10 @@ public class LootTrackerPlugin extends Plugin
|
||||
private static final int THEATRE_OF_BLOOD_REGION = 12867;
|
||||
|
||||
// Herbiboar loot handling
|
||||
private static final String HERBIBOAR_LOOTED_MESSAGE = "You harvest herbs from the herbiboar, whereupon it escapes.";
|
||||
@VisibleForTesting
|
||||
static final String HERBIBOAR_LOOTED_MESSAGE = "You harvest herbs from the herbiboar, whereupon it escapes.";
|
||||
private static final String HERBIBOAR_EVENT = "Herbiboar";
|
||||
private static final Pattern HERBIBOAR_HERB_SACK_PATTERN = Pattern.compile(".+(Grimy .+?) herb.+");
|
||||
|
||||
// Hespori loot handling
|
||||
private static final String HESPORI_LOOTED_MESSAGE = "You have successfully cleared this patch for new crops.";
|
||||
@@ -500,10 +503,14 @@ public class LootTrackerPlugin extends Plugin
|
||||
|
||||
if (message.equals(HERBIBOAR_LOOTED_MESSAGE))
|
||||
{
|
||||
if (processHerbiboarHerbSackLoot(event.getTimestamp()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
eventType = HERBIBOAR_EVENT;
|
||||
lootRecordType = LootRecordType.EVENT;
|
||||
takeInventorySnapshot();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -677,6 +684,34 @@ public class LootTrackerPlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
private boolean processHerbiboarHerbSackLoot(int timestamp)
|
||||
{
|
||||
List<ItemStack> herbs = new ArrayList<>();
|
||||
|
||||
for (MessageNode messageNode : client.getMessages())
|
||||
{
|
||||
if (messageNode.getTimestamp() != timestamp
|
||||
|| messageNode.getType() != ChatMessageType.SPAM)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Matcher matcher = HERBIBOAR_HERB_SACK_PATTERN.matcher(messageNode.getValue());
|
||||
if (matcher.matches())
|
||||
{
|
||||
herbs.add(new ItemStack(itemManager.search(matcher.group(1)).get(0).getId(), 1, client.getLocalPlayer().getLocalLocation()));
|
||||
}
|
||||
}
|
||||
|
||||
if (herbs.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
addLoot(HERBIBOAR_EVENT, -1, LootRecordType.EVENT, herbs);
|
||||
return true;
|
||||
}
|
||||
|
||||
void toggleItem(String name, boolean ignore)
|
||||
{
|
||||
final Set<String> ignoredItemSet = new HashSet<>(ignoredItems);
|
||||
|
||||
Reference in New Issue
Block a user