Class WeaponSpeeds

java.lang.Object
privbot.mechanics.WeaponSpeeds

public final class WeaponSpeeds extends Object
How many ticks a weapon takes between attacks.

This is what turns "enough ticks have passed" into a real attack cycle. A dark bow and a whip are not the same weapon, and pacing both at a fixed three ticks throws away hits with one and wastes clicks with the other.

Precedence, first match wins:

  1. the plugin's overrides (a private server can give any weapon any speed it likes, so a configured speed is the authority);
  2. the keyword table, lifted from ElorinPvP services/WeaponSpeeds with the Elorin captures it was corrected from (Dharok's greataxe 6, Ursine chainmace 4, Eclipse atlatl 3). It is matched by keyword, most specific first, because a substring match on "bow" finds a crossbow;
  3. the OSRS table, AutoPvP's osrs_weapon_ticks.json copied into this package's resources: an exact (case- and space-blind) item name, then the name with (or), (empty) and similar suffixes normalised away. Its values are clamped to 2-8 ticks. It is read once, lazily, on the first lookup that reaches it; if it cannot be read every lookup falls through to the default;
  4. the style's default: MELEE_DEFAULT (also used when the style is null), RANGED_DEFAULT, MAGIC_DEFAULT.

Pure apart from the one resource read; no client reads, any thread.

  • Field Details

    • MELEE_DEFAULT

      public static final int MELEE_DEFAULT
      Used when nothing recognises the weapon (and for a null style).
      See Also:
    • RANGED_DEFAULT

      public static final int RANGED_DEFAULT
      See Also:
    • MAGIC_DEFAULT

      public static final int MAGIC_DEFAULT
      See Also:
  • Method Details

    • ticks

      public static int ticks(String weapon, CombatStyle style, Map<String,Integer> overrides)
      The attack cycle of this weapon in ticks: overrides (keys lower-cased, matched by containment, as parse(java.lang.String, java.util.List<java.lang.String>) produces them), then the keyword table, then the OSRS table, then the style's default.
    • parse

      public static Map<String,Integer> parse(String text, List<String> ignored)
      Parses "Dark bow=9, Abyssal whip=4" into lower-cased keys. A malformed pair is dropped and named in ignored rather than throwing: a typo in a text box must not stop a fight.
    • known

      public static List<String> known()
      The keywords the built-in table knows, for a studio hint.