CombatTimingAPI
Event-driven player-versus-player combat timing API.
Final classRLPlugins API
public final class CombatTimingAPIThis API tracks the local attack timer, the focused target's attack timer, freeze and immunity windows, and inferred PID priority. Runtime state is updated from RuneLite events and returned as immutable snapshots, so plugin code can read it without owning event listeners, live actor references, or cross-tick timer bookkeeping.
Target selection is automatic unless a plugin sets an explicit focus. The resolver checks, in order, an explicitly selected player, an explicitly selected player name, the local player's current interaction, players attacking the local player, and recent confirmed combat events. Opponent timer, freeze, PID, and PvP safespot state is reset when that focus changes.
Members
Static methods
- voidclearTarget()
Clears the explicit and resolved combat target.
- FreezeStategetFreezeState()
Returns the local and target freeze/immunity state.
- AttackTimergetLocalAttackTimer()
Returns the local player's attack timer.
- intgetNextWeaponAttackTick()
Next local attack tick inferred from combat XP, learned animations and the equipped weapon's speed.
- PidStatusgetPidStatus()
Returns the inferred PID priority against the focused target.
- CombatSnapshotgetSnapshot()
Returns a combined combat timing snapshot for the current resolved target.
- CombatSnapshotgetSnapshot(PlayerEx)
Returns a combined combat timing snapshot after using
targetas the current explicit combat focus. - CombatSnapshotgetSnapshotForPlayer(String)
Returns a combined combat timing snapshot after resolving a player name as the explicit combat focus.
- CombatTargetgetTarget()
Returns the current resolved target snapshot.
- AttackTimergetTargetAttackTimer()
Returns the focused target's attack timer.
- booleanhasPidAdvantage()
Returns whether the local player currently has PID advantage.
- booleanisTracking()
Returns whether the timing listener has been installed.
- voidsetTarget(PlayerEx)
Sets the explicit combat target used by opponent timer, opponent freeze, PID, and PvP safespot planning.
- voidsetTargetName(String)
Sets the explicit combat target by player name.
clearTarget()static
public static void clearTarget()Clears the explicit and resolved combat target.
getFreezeState()static
public static FreezeState getFreezeState()Returns the local and target freeze/immunity state.
Returns
Immutable freeze state.
getLocalAttackTimer()static
public static AttackTimer getLocalAttackTimer()Returns the local player's attack timer.
Returns
Immutable local attack timer.
getNextWeaponAttackTick()static
public static int getNextWeaponAttackTick()Next local attack tick inferred from combat XP, learned animations and the equipped weapon's speed.
Returns -1 before an attack is observed. This cycle also supports NPC combat and is independent of PvP PID timing.
getPidStatus()static
public static PidStatus getPidStatus()Returns the inferred PID priority against the focused target.
Returns
Immutable PID status.
getSnapshot()static
public static CombatSnapshot getSnapshot()Returns a combined combat timing snapshot for the current resolved target.
Returns
Immutable combat snapshot.
getSnapshot(PlayerEx)static
public static CombatSnapshot getSnapshot(PlayerEx target)Returns a combined combat timing snapshot after using target as the current explicit combat focus.
Parameters
target- Wrapped player to use as the combat focus;
nullkeeps the current resolved target.
Returns
Immutable combat snapshot.
getSnapshotForPlayer(String)static
public static CombatSnapshot getSnapshotForPlayer(String playerName)Returns a combined combat timing snapshot after resolving a player name as the explicit combat focus.
Name matching is case-insensitive and uses the current scene player list. If the name cannot be resolved, the current target resolver remains active and the returned snapshot will explain that no target is present.
Parameters
playerName- RuneScape name to focus.
Returns
Immutable combat snapshot.
getTarget()static
public static CombatTarget getTarget()Returns the current resolved target snapshot.
Returns
Immutable target snapshot, or CombatTarget.none().
getTargetAttackTimer()static
public static AttackTimer getTargetAttackTimer()Returns the focused target's attack timer.
Returns
Immutable target attack timer.
hasPidAdvantage()static
public static boolean hasPidAdvantage()Returns whether the local player currently has PID advantage.
Returns
true only when PID has been inferred as ON_PID.
isTracking()static
public static boolean isTracking()Returns whether the timing listener has been installed.
Returns
true once this API has registered its event listener.
setTarget(PlayerEx)static
public static void setTarget(PlayerEx target)Sets the explicit combat target used by opponent timer, opponent freeze, PID, and PvP safespot planning.
Parameters
target- Wrapped player to track;
nullclears the explicit target.
setTargetName(String)static
public static void setTargetName(String playerName)Sets the explicit combat target by player name.
This is the safest way for worker code or AI-generated plugins to target a player when they should not carry a live RuneLite actor between ticks. The service resolves the name on the client thread every time it refreshes the target.
Parameters
playerName- RuneScape name to track; blank clears the explicit target.
Also allowed
Every class has these, as in plain Java.
equals, toString