Interface CombatService
-
- All Superinterfaces:
Service
- All Known Implementing Classes:
CombatMonitoringService
public interface CombatService extends Service
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default intgetAttackCooldownTicks(Player player)Computes the number of ticks remaining before the given player may perform their next attack.default Deque<Attack>getAttacksAgainst(PathingEntity<?> entity)Convenience method for retrieving the incoming attack history of the specified entity using a default lookback window of 8 ticks.Deque<Attack>getAttacksAgainst(PathingEntity<?> entity, int lookbackTicks)Returns a deque of attacks recently performed against the specified entity.default Deque<Attack>getAttacksFrom(PathingEntity<?> entity)Convenience method for retrieving the outgoing attack history of the specified entity using a default lookback window of 8 ticks.Deque<Attack>getAttacksFrom(PathingEntity<?> entity, int lookbackTicks)Returns a deque of attacks recently performed by the specified entity.-
Methods inherited from interface org.rspeer.event.Service
onSubscribe, onUnsubscribe
-
-
-
-
Method Detail
-
getAttackCooldownTicks
default int getAttackCooldownTicks(Player player)
Computes the number of ticks remaining before the given player may perform their next attack. A value of0indicates the player is able to attack immediately.This method determines the cooldown based on the timestamp of the player's most recent recorded attack and the attack speed of the weapon they used (or the default unarmed speed if no weapon was equipped).
The lookup searches backward up to 9 ticks to find the last outgoing attack. The value 9 is chosen because the dark bow on long-range attack style is currently the slowest weapon in the game, with an attack interval of 9 ticks. This ensures the full window is captured and no valid attack is missed.
If no recent attack is found, the method assumes the player is ready to attack immediately.
- Parameters:
player- the player whose attack cooldown should be checked- Returns:
- the number of ticks until the next attack may be performed (0 if the player can already attack)
-
getAttacksFrom
Deque<Attack> getAttacksFrom(PathingEntity<?> entity, int lookbackTicks)
Returns a deque of attacks recently performed by the specified entity.The result is ordered with the most recent attack at the front (accessible via
peekFirst()) and the oldest within the lookback window at the back.- Parameters:
entity- the entity whose outgoing attacks should be retrievedlookbackTicks- the maximum number of ticks to search backward in history- Returns:
- a deque of outgoing attacks, newest first (never
null)
-
getAttacksAgainst
Deque<Attack> getAttacksAgainst(PathingEntity<?> entity, int lookbackTicks)
Returns a deque of attacks recently performed against the specified entity.The result is ordered with the most recent incoming attack at the front (accessible via
peekFirst()) and the oldest within the lookback window at the back.- Parameters:
entity- the target entity whose incoming attacks should be retrievedlookbackTicks- the maximum number of ticks to search backward in history- Returns:
- a deque of incoming attacks, newest first (never
null)
-
getAttacksFrom
default Deque<Attack> getAttacksFrom(PathingEntity<?> entity)
Convenience method for retrieving the outgoing attack history of the specified entity using a default lookback window of 8 ticks.The 8-tick window corresponds to the standard OSRS combat timer and is commonly used to determine whether an entity is considered "in combat." Attacks older than this window are excluded.
The returned deque is ordered with the most recent attack first and is never
null.- Parameters:
entity- the entity whose outgoing attacks should be retrieved- Returns:
- a deque of recent outgoing attacks within the last 8 ticks
-
getAttacksAgainst
default Deque<Attack> getAttacksAgainst(PathingEntity<?> entity)
Convenience method for retrieving the incoming attack history of the specified entity using a default lookback window of 8 ticks.The 8-tick window corresponds to the standard OSRS combat timer and is commonly used to determine whether an entity is currently engaged in combat. Incoming attacks older than this window are excluded.
The returned deque is ordered with the most recent attack first and is never
null.- Parameters:
entity- the entity whose incoming attacks should be retrieved- Returns:
- a deque of recent incoming attacks within the last 8 ticks
-
-