slayer: fix reanimated abyssals not counting for tasks

This commit is contained in:
Adam
2022-01-21 00:04:39 -05:00
parent 9966cad9ea
commit 2eba3a886f
2 changed files with 16 additions and 13 deletions

View File

@@ -565,10 +565,10 @@ public class SlayerPlugin extends Plugin
log.debug("Slayer xp change delta: {}, killed npcs: {}", delta, taggedNpcsDiedPrevTick);
final Task task = Task.getTask(taskName);
if (task != null && task.getMinimumKillXp() > 0)
if (task != null && task.getXpMatcher() != null)
{
// Only decrement a kill if the xp drop is above the minimum threshold. This is for Tzhaar and Sire tasks.
if (delta >= task.getMinimumKillXp())
// Only decrement a kill if the xp drop delta passes the matcher. This is for Tzhaar and Sire tasks.
if (task.getXpMatcher().test(delta))
{
killed(max(taggedNpcsDiedPrevTick, 1));
}

View File

@@ -30,6 +30,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import java.util.List;
import java.util.Map;
import java.util.function.IntPredicate;
import javax.annotation.Nullable;
import lombok.Getter;
import net.runelite.api.ItemID;
@@ -42,9 +43,10 @@ enum Task
// Abyssal demon - 150 xp
// Greater abyssal demon - 4200 xp
// Abyssal sire - 450 xp
// Use 51 for minimum xp to avoid a kill triggering from killing the sire vents
ABYSSAL_DEMONS("Abyssal demons", ItemID.ABYSSAL_DEMON, 51),
ABYSSAL_SIRE("Abyssal Sire", ItemID.ABYSSAL_ORPHAN, 51),
// Reanimated abyssal - 31 xp
// Ignore 50xp drops to avoid recording a kill from sire vents
ABYSSAL_DEMONS("Abyssal demons", ItemID.ABYSSAL_DEMON, (xp) -> xp != 50),
ABYSSAL_SIRE("Abyssal Sire", ItemID.ABYSSAL_ORPHAN, (xp) -> xp != 50),
ADAMANT_DRAGONS("Adamant dragons", ItemID.ADAMANT_DRAGON_MASK),
ALCHEMICAL_HYDRA("Alchemical Hydra", ItemID.IKKLE_HYDRA),
ANKOU("Ankou", ItemID.ANKOU_MASK),
@@ -114,7 +116,7 @@ enum Task
ICE_WARRIORS("Ice warriors", ItemID.MITHRIL_FULL_HELM_T, "Icelord"),
INFERNAL_MAGES("Infernal mages", ItemID.INFERNAL_MAGE, "Malevolent mage"),
IRON_DRAGONS("Iron dragons", ItemID.IRON_DRAGON_MASK),
JAD("TzTok-Jad", ItemID.TZREKJAD, 25250),
JAD("TzTok-Jad", ItemID.TZREKJAD, (xp) -> xp == 25250),
JELLIES("Jellies", ItemID.JELLY, "Jelly"),
JUNGLE_HORROR("Jungle horrors", ItemID.ENSOULED_HORROR_HEAD),
KALPHITE("Kalphite", ItemID.KALPHITE_SOLDIER),
@@ -183,7 +185,7 @@ enum Task
WYRMS("Wyrms", ItemID.WYRM),
ZILYANA("Commander Zilyana", ItemID.PET_ZILYANA),
ZOMBIES("Zombies", ItemID.ZOMBIE_HEAD, "Undead"),
ZUK("TzKal-Zuk", ItemID.TZREKZUK, 101890),
ZUK("TzKal-Zuk", ItemID.TZREKZUK, (xp) -> xp == 101890),
ZULRAH("Zulrah", ItemID.PET_SNAKELING);
//</editor-fold>
@@ -242,7 +244,8 @@ enum Task
private final String[] targetNames;
private final int weaknessThreshold;
private final int weaknessItem;
private final int minimumKillXp;
@Nullable
private final IntPredicate xpMatcher;
static
{
@@ -264,7 +267,7 @@ enum Task
this.weaknessThreshold = -1;
this.weaknessItem = -1;
this.targetNames = targetNames;
this.minimumKillXp = 0;
this.xpMatcher = null;
}
Task(String name, int itemSpriteId, int weaknessThreshold, int weaknessItem, String... targetNames)
@@ -275,10 +278,10 @@ enum Task
this.weaknessThreshold = weaknessThreshold;
this.weaknessItem = weaknessItem;
this.targetNames = targetNames;
this.minimumKillXp = 0;
this.xpMatcher = null;
}
Task(String name, int itemSpriteId, int minimumKillXp)
Task(String name, int itemSpriteId, IntPredicate xpMatcher)
{
Preconditions.checkArgument(itemSpriteId >= 0);
this.name = name;
@@ -286,7 +289,7 @@ enum Task
this.weaknessThreshold = -1;
this.weaknessItem = -1;
this.targetNames = new String[0];
this.minimumKillXp = minimumKillXp;
this.xpMatcher = xpMatcher;
}
@Nullable