Class TargetLock
What it proves: the NPC returned matched the TargetSpec (steps 1, 3 and 4) or was the one already
locked, and was alive. A lock is the pair (index, id): the server reuses indices, so an index that now holds a
different id is a different NPC and the lock is dropped, never "kept".
Unreadable looks like: choose returns null when nothing qualifies, and the lock is cleared.
A locked NPC that is missing from the list (or whose index now holds another id) is no longer kept: the choice
falls through to steps 3 and 4, and the lock moves to whatever they pick, or is cleared when they pick nothing.
A locked NPC that no longer matches the spec is dropped the same way.
Thread rule: mutable, single-owner. Call choose once per game tick from the thread that builds the
NpcView list.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionchoose(List<NpcView> npcs, int currentTargetIndex, net.runelite.api.coords.WorldPoint player, TargetSpec spec) Picks the target, in this order: the current target, if it matches and is alive and not busy; the locked NPC, if present with the same index and id, still matching the spec, alive and not busy; the first matching NPC that targets us and is alive; the nearest matching NPC that is alive and not busy, ties to the lower index. A locked NPC seen dead counts a kill if it had targeted us or been our current target.intkills()Locked NPCs seen dead after they had targeted us or been our current target.intThe locked NPC's index, or -1 for none.voidreset()Forgets the lock and the kill count.
-
Constructor Details
-
TargetLock
public TargetLock()
-
-
Method Details
-
choose
public NpcView choose(List<NpcView> npcs, int currentTargetIndex, net.runelite.api.coords.WorldPoint player, TargetSpec spec) Picks the target, in this order:- the current target, if it matches and is alive and not busy;
- the locked NPC, if present with the same index and id, still matching the spec, alive and not busy;
- the first matching NPC that targets us and is alive;
- the nearest matching NPC that is alive and not busy, ties to the lower index.
- Parameters:
currentTargetIndex- the index of the NPC we are interacting with, or -1spec- which NPCs qualify; null meansTargetSpec.any()
-
lockedIndex
public int lockedIndex()The locked NPC's index, or -1 for none. -
kills
public int kills()Locked NPCs seen dead after they had targeted us or been our current target. -
reset
public void reset()Forgets the lock and the kill count.
-