Animation duration



  • /**
     * @author Jacob Rhiel - Intelli created Feb, 2019
     */
    public interface MobAnimation {
    
        /**
         * Retrieves the length of the current animation in ticks
         * @param animationId The animation id
         * @return The amount of ticks the duration of the animation is
         */
        default int getDurationTicks(int animationId) {
            return getDurationTicks(ClientSupplier.get().getAnimationSequence(animationId).getFrameLengths());
        }
    
        /**
         * Gets the MS time of an animation
         * @param lengths The frame lengths of the animation definition
         * @return The time in MS of the animation
         */
        default int getDurationMS(int[] lengths) {
            if (lengths == null) {
                return 0;
            }
            int ms = 0;
            for (int i : lengths) {
                ms += i;
            }
            return ms * 30;
        }
    
        /**
         * Gets the amount of ticks an animations duration is
         * @param lengths The frame lengths of the animation definition
         * @return The amount of ticks the animations duration is
         */
        default int getDurationTicks(int[] lengths) {
            int duration = getDurationMS(lengths) / 600;
            return duration < 1 ? 1 : duration;
        }
    
    }
    
    


  • Can't you just use Npc#getAnimationFrame() instead?



  • No because frame lengths is not the same as animation frame. There is no safe way to access them per Spencer but you can do it like this.



  • Time.sleepWhile(() -> Plaers.getLocal().getAnimation() != -1, Random.mid(int, int));


  • Director

    @Phasecoder said in Animation duration:

    Time.sleepWhile(() -> Plaers.getLocal().getAnimation() != -1, Random.mid(int, int));

    Think you're in the wrong topic?



  • @Yasper said in Animation duration:

    @Phasecoder said in Animation duration:

    Time.sleepWhile(() -> Plaers.getLocal().getAnimation() != -1, Random.mid(int, int));

    Think you're in the wrong topic?

    my bad i was too much of the green stuff.



  • Nice find! How did you figure out one unit of animation length is 30ms?

    EDIT: Also, RSAnimationSequence has a getDuration() method.



  • @Meister said in Animation duration:

    Nice find! How did you figure out one unit of animation length is 30ms?

    EDIT: Also, RSAnimationSequence has a getDuration() method.

    If they do its because i mentioned it already, also 30ms is found from the client.


 

76
Online

11.3k
Users

1.1k
Topics

14.7k
Posts