Enum SpecialWeapon

    • Method Detail

      • values

        public static SpecialWeapon[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (SpecialWeapon c : SpecialWeapon.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static SpecialWeapon valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • getHitDelay

        public int getHitDelay​(int distance)
        Gets the server cycle delay between special attack energy dropping and a hitsplat being applied to the target. This will be 1 for all melee weapons.
        Parameters:
        distance - Distance from the target in tiles
        Returns:
        Number of server cycles (game ticks) delay for the special attack hitsplat to be applied
      • computeDrainPercent

        public float computeDrainPercent​(int hit,
                                         @Nullable
                                         NPC target)
      • computeHit

        public int computeHit​(int hit,
                              @Nullable
                              NPC target)
      • getName

        public String getName()
      • getItemID

        public int[] getItemID()
      • isDamage

        public boolean isDamage()
      • getClientCycleHitDelay

        public Function<Integer,​Integer> getClientCycleHitDelay()
        Accepts an int representing distance in tiles to the target, and returns an int representing client cycles of delay until the hitsplat is applied.

        For melee weapons, the returned value is always 0, as they have no delay. Calculating this delay can be done by extrapolating the difference between the cycle the projectile is created and the cycle it ends for various distances. In practice, projectiles are created at the same time special attack energy is drained for special attacks, so the difference can be taken between the cycle a player's special attack drains and the end cycle of the created projectile.

        For example, a dorgeshuun crossbow will have its projectile end 63 cycles after a spec at distance 1, 66 at distance 2, etc. Hence, we can extrapolate its formula to be int cycles = 60 + distance * 3.