1414import net .runelite .api .Player ;
1515import net .runelite .api .VarPlayer ;
1616import net .runelite .api .events .GameStateChanged ;
17+ import net .runelite .api .events .GameTick ;
1718import net .runelite .api .events .HitsplatApplied ;
1819import net .runelite .api .events .InteractingChanged ;
1920import net .runelite .api .events .NpcDespawned ;
2021import net .runelite .api .events .VarbitChanged ;
22+ import net .runelite .api .kit .KitType ;
2123import net .runelite .client .callback .ClientThread ;
2224import net .runelite .client .config .ConfigManager ;
2325import 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 ,
0 commit comments