Skip to content

Commit

Permalink
Merge pull request open-osrs#2082 from Owain94/xpdrops
Browse files Browse the repository at this point in the history
experiencedrop: Fix damage done in xp drop
  • Loading branch information
Owain94 authored Nov 27, 2019
2 parents 7e801f5 + 5173b15 commit 34f8560
Showing 1 changed file with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import net.runelite.api.events.FakeXpDrop;
import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.GameTick;
import net.runelite.api.events.ScriptCallbackEvent;
import net.runelite.api.events.WidgetHiddenChanged;
import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetID;
Expand All @@ -58,6 +59,7 @@
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.client.util.ColorUtil;

@PluginDescriptor(
name = "XP Drop",
Expand Down Expand Up @@ -357,6 +359,45 @@ private void onFakeXpDrop(FakeXpDrop fakeXpDrop)
}
}

@Subscribe
private void onScriptCallbackEvent(ScriptCallbackEvent e)
{
if (this.showdamagedrops == XpDropConfig.DamageMode.NONE)
{
return;
}

final String eventName = e.getEventName();

if (eventName.equals("newXpDrop"))
{
damage = 0;
}
else if (eventName.equals("hpXpGained"))
{
final int[] intStack = client.getIntStack();
final int intStackSize = client.getIntStackSize();

final int exp = intStack[intStackSize - 1];
calculateDamageDealt(exp);
}
else if (eventName.equals("xpDropAddDamage")
&& damageMode == XpDropConfig.DamageMode.IN_XP_DROP
&& damage > 0)
{
final String[] stringStack = client.getStringStack();
final int stringStackSize = client.getStringStackSize();

String builder =
stringStack[stringStackSize - 1]
+ ColorUtil.colorTag(this.damageColor)
+ " ("
+ damage
+ ")";
stringStack[stringStackSize - 1] = builder;
}
}

private void calculateDamageDealt(int diff)
{
double damageDealt = diff / HITPOINT_RATIO;
Expand Down

0 comments on commit 34f8560

Please sign in to comment.