Skip to content

Commit dc706fb

Browse files
committed
Draw Over Prayer
1 parent 792be20 commit dc706fb

4 files changed

Lines changed: 68 additions & 17 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ A standalone extension of the default ``Special Attack Counter`` plugin. This pl
121121

122122
![alt text](https://www.kthisiscvpv.com/azgkm1587524036HW5Vh.gif "Plugin Visual")
123123

124+
![alt text](https://www.kthisiscvpv.com/jIOBV1587559442NdOUj.gif "Plugin Visual")
125+
124126
### Dependencies
125127

126128
> Socket Client Plugin

specialcounterextended/SpecialCounterExtendedPlugin.java

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
import net.runelite.api.Player;
1515
import net.runelite.api.VarPlayer;
1616
import net.runelite.api.events.GameStateChanged;
17+
import net.runelite.api.events.GameTick;
1718
import net.runelite.api.events.HitsplatApplied;
1819
import net.runelite.api.events.InteractingChanged;
1920
import net.runelite.api.events.NpcDespawned;
2021
import net.runelite.api.events.VarbitChanged;
22+
import net.runelite.api.kit.KitType;
2123
import net.runelite.client.callback.ClientThread;
2224
import net.runelite.client.config.ConfigManager;
2325
import net.runelite.client.eventbus.EventBus;
@@ -84,6 +86,10 @@ protected void startUp() {
8486
lastSpecTarget = null;
8587
lastSpecTick = -1;
8688
interactedNpcIds.clear();
89+
90+
specialUsed = false;
91+
specialExperience = -1;
92+
8793
this.overlayManager.add(this.overlay);
8894
}
8995

@@ -116,6 +122,9 @@ public void onGameStateChanged(GameStateChanged event) {
116122
private final Set<Integer> interactedNpcIds = new HashSet<>();
117123
private final SpecialCounter[] specialCounter = new SpecialCounter[SpecialWeapon.values().length];
118124

125+
private boolean specialUsed = false;
126+
private long specialExperience = -1;
127+
119128
@Subscribe // Player changed attack targets after queuing special.
120129
public void onInteractingChanged(InteractingChanged interactingChanged) {
121130
Actor source = interactingChanged.getSource();
@@ -139,8 +148,43 @@ public void onVarbitChanged(VarbitChanged event) {
139148
this.specialPercentage = specialPercentage;
140149
this.specialWeapon = usedSpecialWeapon();
141150

142-
lastSpecTarget = client.getLocalPlayer().getInteracting();
143-
lastSpecTick = client.getTickCount();
151+
this.lastSpecTarget = client.getLocalPlayer().getInteracting();
152+
this.lastSpecTick = client.getTickCount();
153+
154+
this.specialUsed = true;
155+
this.specialExperience = this.client.getOverallExperience();
156+
}
157+
158+
@Subscribe // For Dawnbringer, EXP tracked.
159+
public void onGameTick(GameTick event) {
160+
if (client.getGameState() != GameState.LOGGED_IN)
161+
return;
162+
163+
if (this.specialExperience != -1 && this.specialUsed && this.lastSpecTarget != null && this.lastSpecTarget instanceof NPC) {
164+
this.specialUsed = false;
165+
166+
long deltaExp = this.client.getOverallExperience() - this.specialExperience;
167+
this.specialExperience = -1;
168+
169+
if (this.specialWeapon != null && this.specialWeapon == SpecialWeapon.DAWNBRINGER) {
170+
int damage = (int) (((double) deltaExp) / 3.5d);
171+
172+
String pName = this.client.getLocalPlayer().getName();
173+
updateCounter(pName, this.specialWeapon, null, damage);
174+
175+
JSONObject data = new JSONObject();
176+
data.put("player", pName);
177+
data.put("target", ((NPC) this.lastSpecTarget).getId());
178+
data.put("weapon", specialWeapon.ordinal());
179+
data.put("hit", damage);
180+
181+
JSONObject payload = new JSONObject();
182+
payload.put("special-extended", data);
183+
eventBus.post(new SocketBroadcastPacket(payload));
184+
185+
this.lastSpecTarget = null;
186+
}
187+
}
144188
}
145189

146190
@Subscribe
@@ -161,6 +205,8 @@ public void onHitsplatApplied(HitsplatApplied hitsplatApplied) {
161205

162206
boolean wasSpec = lastSpecTarget != null;
163207
lastSpecTarget = null;
208+
specialUsed = false;
209+
specialExperience = -1L;
164210

165211
if (!(target instanceof NPC))
166212
return;
@@ -254,7 +300,8 @@ private void updateCounter(String player, SpecialWeapon specialWeapon, String na
254300
SpecialCounter counter = specialCounter[specialWeapon.ordinal()];
255301

256302
BufferedImage image = itemManager.getImage(specialWeapon.getItemID());
257-
this.overlay.addOverlay(player, new SpecialIcon(image, specialWeapon.isDamage() ? Integer.toString(hit) : null, System.currentTimeMillis()));
303+
// this.overlay.addOverlay(player, new SpecialIcon(image, specialWeapon.isDamage() ? Integer.toString(hit) : null, System.currentTimeMillis()));
304+
this.overlay.addOverlay(player, new SpecialIcon(image, Integer.toString(hit), System.currentTimeMillis()));
258305

259306
if (counter == null) {
260307
counter = new SpecialCounter(image, this,

specialcounterextended/SpecialCounterOverlay.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ private SpecialCounterOverlay(Client client, SpecialCounterExtendedPlugin plugin
3535

3636
setPosition(OverlayPosition.DYNAMIC);
3737
setPriority(OverlayPriority.HIGH);
38-
setLayer(OverlayLayer.ABOVE_SCENE);
38+
setLayer(OverlayLayer.ALWAYS_ON_TOP);
3939
}
4040

4141
public void addOverlay(String player, SpecialIcon icon) {
@@ -61,7 +61,7 @@ public Dimension render(Graphics2D graphics) {
6161
if (center != null) {
6262
ArrayList<SpecialIcon> icons = this.drawings.get(playerName);
6363
ArrayList<SpecialIcon> removeIcons = new ArrayList<>();
64-
int currentHeight = 200; // Base height.
64+
int currentHeight = 200; // Base height for a player.
6565

6666
for (int i = (icons.size() - 1); i >= 0; i--) {
6767
SpecialIcon icon = icons.get(i);
@@ -76,10 +76,11 @@ public Dimension render(Graphics2D graphics) {
7676
}
7777

7878
float opacity = ((float) timeRemaining) / ((float) fadeDelay);
79-
graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacity));
79+
float thresh = Math.min(opacity + 0.2f, 1.0f);
80+
graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, thresh));
8081

8182
final int maxHeight = Math.max(config.getMaxHeight(), 1);
82-
int updatedHeight = maxHeight - (int) (((float) maxHeight) * opacity);
83+
int updatedHeight = maxHeight - (int) (((float) maxHeight) * thresh);
8384

8485
Point drawPoint = Perspective.getCanvasImageLocation(this.client, center, icon.getImage(), currentHeight + updatedHeight);
8586
graphics.drawImage(icon.getImage(), drawPoint.getX(), drawPoint.getY(), null);

specialcounterextended/SpecialWeapon.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,16 @@
3030

3131
@AllArgsConstructor
3232
@Getter
33-
enum SpecialWeapon
34-
{
35-
DRAGON_WARHAMMER("Dragon Warhammer", ItemID.DRAGON_WARHAMMER, false),
36-
ARCLIGHT("Arclight", ItemID.ARCLIGHT, false),
37-
DARKLIGHT("Darklight", ItemID.DARKLIGHT, false),
38-
BANDOS_GODSWORD("Bandos Godsword", ItemID.BANDOS_GODSWORD, true),
39-
BANDOS_GODSWORD_OR("Bandos Godsword", ItemID.BANDOS_GODSWORD_OR, true);
33+
enum SpecialWeapon {
4034

41-
private final String name;
42-
private final int itemID;
43-
private final boolean damage;
35+
DRAGON_WARHAMMER("Dragon Warhammer", ItemID.DRAGON_WARHAMMER, false),
36+
ARCLIGHT("Arclight", ItemID.ARCLIGHT, false),
37+
DARKLIGHT("Darklight", ItemID.DARKLIGHT, false),
38+
BANDOS_GODSWORD("Bandos Godsword", ItemID.BANDOS_GODSWORD, true),
39+
BANDOS_GODSWORD_OR("Bandos Godsword", ItemID.BANDOS_GODSWORD_OR, true),
40+
DAWNBRINGER("Dawnbringer", ItemID.DAWNBRINGER, true);
41+
42+
private final String name;
43+
private final int itemID;
44+
private final boolean damage;
4445
}

0 commit comments

Comments
 (0)