Special Attack Tracker

IntermediateDisplay

Tracks special attack energy and displays it. Shows how to monitor special attack percentage.

10 min read

What It Does

Tracks special attack energy and displays it. Shows how to monitor special attack percentage.

Source Code

java
1package com.example;
2
3import net.runelite.api.Client;
4import net.runelite.client.ui.overlay.Overlay;
5import net.runelite.client.ui.overlay.OverlayManager;
6import net.runelite.client.plugins.Plugin;
7import net.runelite.client.plugins.PluginDescriptor;
8import javax.inject.Inject;
9import java.awt.*;
10
11@PluginDescriptor(
12    name = "Special Attack Tracker",
13    description = "Shows special attack energy"
14)
15public class SpecialAttackPlugin extends Plugin {
16    @Inject
17    private Client client;
18
19    @Inject
20    private OverlayManager overlayManager;
21
22    private final Overlay overlay = new Overlay() {
23        @Override
24        public Dimension render(Graphics2D graphics) {
25            int specEnergy = client.getVar(net.runelite.api.Varbits.SPECIAL_ATTACK_PERCENT);
26            graphics.setColor(Color.YELLOW);
27            graphics.drawString("Special: " + specEnergy + "%", 10, 10);
28            return new Dimension(130, 20);
29        }
30    };
31
32    {
33        overlay.setLayer(OverlayLayer.ABOVE_SCENE);
34        overlay.setPosition(OverlayPosition.TOP_LEFT);
35    }
36
37    @Override
38    protected void startUp() {
39        overlayManager.add(overlay);
40    }
41
42    @Override
43    protected void shutDown() {
44        overlayManager.remove(overlay);
45    }
46}

Code Annotations

Line 25

Get special attack percentage from varbit

API Classes Used

Key Concepts

  • Get special attack percentage from varbit

Next Steps

  • Learn about Varbits API
  • Add special attack ready indicator
  • Add sound alerts