Animation Tracker

BeginnerData

Tracks and displays the current animation ID. Useful for detecting specific actions like attacking or skilling.

8 min read

What It Does

Tracks and displays the current animation ID. Useful for detecting specific actions like attacking or skilling.

Source Code

java
1package com.example;
2
3import net.runelite.api.Client;
4import net.runelite.api.Player;
5import net.runelite.client.ui.overlay.Overlay;
6import net.runelite.client.ui.overlay.OverlayManager;
7import net.runelite.client.plugins.Plugin;
8import net.runelite.client.plugins.PluginDescriptor;
9import javax.inject.Inject;
10import java.awt.*;
11
12@PluginDescriptor(
13    name = "Animation Tracker",
14    description = "Shows current animation"
15)
16public class AnimationTrackerPlugin extends Plugin {
17    @Inject
18    private Client client;
19
20    @Inject
21    private OverlayManager overlayManager;
22
23    private final Overlay overlay = new Overlay() {
24        @Override
25        public Dimension render(Graphics2D graphics) {
26            Player player = client.getLocalPlayer();
27            if (player == null) {
28                return null;
29            }
30
31            int animId = player.getAnimation();
32            graphics.setColor(Color.WHITE);
33            if (animId != -1) {
34                graphics.drawString("Animation: " + animId, 10, 10);
35            } else {
36                graphics.drawString("Animation: None", 10, 10);
37            }
38
39            return new Dimension(150, 20);
40        }
41    };
42
43    @Override
44    protected void startUp() {
45        overlayManager.add(overlay);
46    }
47
48    @Override
49    protected void shutDown() {
50        overlayManager.remove(overlay);
51    }
52}

Code Annotations

Line 26

Get current animation ID

Line 28

Check if animating (-1 means no animation)

API Classes Used

Key Concepts

  • Get current animation ID
  • Check if animating (-1 means no animation)

Next Steps

  • Learn about animation IDs
  • Add animation name lookup
  • Track animation duration