Class Targets
ctx.targets. newLock() gives you a TargetLock that chooses an NPC from
the NpcView list of a threat snapshot and sticks to it; resolve(privbot.mechanics.NpcView) turns the chosen view back into a
live NPC you can attack.
What a result proves. A non-null PrivNPC from resolve(privbot.mechanics.NpcView) was found in a fresh NPC list at
the view's index, and it has the view's id, so it is still the same kind of NPC the lock chose (the server reuses
indices, so an index alone is not an identity). It does not say the NPC is alive or in reach; the view you got it
from is a snapshot.
Unreadable. A null from resolve(privbot.mechanics.NpcView) means "do not act on this view": the index is empty, holds a
different NPC id, the NPC list could not be read at all, a read threw, or the client-thread read timed out. It
does not mean the NPC died. Re-read the threat snapshot (unreadable there is reported explicitly) before treating
a target as gone.
Thread. resolve(privbot.mechanics.NpcView) reads through ctx.npcs, which marshals its own read. A
TargetLock is not thread safe: choose from the one worker thread that builds the view list.
-
Method Summary
-
Method Details
-
newLock
- Returns:
- a new lock with no target and no kills; keep it in the plugin's state
-
resolve
-