From 1633c93aa1a51cb170023c9edb5f4b1fc41ac7b3 Mon Sep 17 00:00:00 2001 From: MackBryan Date: Tue, 4 Sep 2018 16:44:54 -0700 Subject: [PATCH 01/20] Added hotkey setting in raidsconfig --- .../runelite/client/plugins/raids/RaidsConfig.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsConfig.java index 18dd050f81..048546f1da 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsConfig.java @@ -27,6 +27,7 @@ package net.runelite.client.plugins.raids; import net.runelite.client.config.Config; import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; +import net.runelite.client.config.Keybind; @ConfigGroup("raids") public interface RaidsConfig extends Config @@ -151,4 +152,16 @@ public interface RaidsConfig extends Config { return ""; } + + @ConfigItem( + keyName = "hotkey", + name = "Disable/Enable scout overlay hotkey", + description = "When you press this key the scout overlay will be hidden/displayed.", + position = 11 + ) + default Keybind hotkey() + { + return Keybind.NOT_SET; + } + } From 8cf4b06079b3952d0a46f3cbb55bc799f79aca68 Mon Sep 17 00:00:00 2001 From: MackBryan Date: Tue, 4 Sep 2018 17:24:32 -0700 Subject: [PATCH 02/20] Added getter for scoutOverlayShown var in RaidsOverlay --- .../java/net/runelite/client/plugins/raids/RaidsOverlay.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsOverlay.java index 682cacab69..c5236662a4 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsOverlay.java @@ -29,6 +29,7 @@ import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; import lombok.Setter; +import lombok.Getter; import net.runelite.client.plugins.raids.solver.Room; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayPosition; @@ -43,7 +44,7 @@ public class RaidsOverlay extends Overlay private RaidsConfig config; private final PanelComponent panelComponent = new PanelComponent(); - @Setter + @Getter @Setter private boolean scoutOverlayShown = false; @Inject From 942f0887c59b289cd433f5d97ed0688985d1386a Mon Sep 17 00:00:00 2001 From: MackBryan Date: Tue, 4 Sep 2018 18:08:04 -0700 Subject: [PATCH 03/20] Cleaned up config and description --- .../client/plugins/raids/RaidsConfig.java | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsConfig.java index 048546f1da..380fefd320 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsConfig.java @@ -87,8 +87,19 @@ public interface RaidsConfig extends Config return false; } + @ConfigItem( + keyName = "hotkey", + name = "Scout overlay hotkey", + description = "When pressed the scout overlay will be toggled. Must enable show scout overlay in raid", + position = 5 + ) + default Keybind hotkey() + { + return Keybind.NOT_SET; + } + @ConfigItem( - position = 5, + position = 6, keyName = "whitelistedRooms", name = "Whitelisted rooms", description = "Display whitelisted rooms in green on the overlay. Separate with comma (full name)" @@ -99,7 +110,7 @@ public interface RaidsConfig extends Config } @ConfigItem( - position = 6, + position = 7, keyName = "blacklistedRooms", name = "Blacklisted rooms", description = "Display blacklisted rooms in red on the overlay. Separate with comma (full name)" @@ -110,7 +121,7 @@ public interface RaidsConfig extends Config } @ConfigItem( - position = 7, + position = 8, keyName = "enableRotationWhitelist", name = "Enable rotation whitelist", description = "Enable the rotation whitelist" @@ -121,7 +132,7 @@ public interface RaidsConfig extends Config } @ConfigItem( - position = 8, + position = 9, keyName = "whitelistedRotations", name = "Whitelisted rotations", description = "Warn when boss rotation doesn't match a whitelisted one. Add rotations like [tekton, muttadile, guardians]" @@ -132,7 +143,7 @@ public interface RaidsConfig extends Config } @ConfigItem( - position = 9, + position = 10, keyName = "enableLayoutWhitelist", name = "Enable layout whitelist", description = "Enable the layout whitelist" @@ -143,7 +154,7 @@ public interface RaidsConfig extends Config } @ConfigItem( - position = 10, + position = 11, keyName = "whitelistedLayouts", name = "Whitelisted layouts", description = "Warn when layout doesn't match a whitelisted one. Add layouts like CFSCPPCSCF separated with comma" @@ -152,16 +163,4 @@ public interface RaidsConfig extends Config { return ""; } - - @ConfigItem( - keyName = "hotkey", - name = "Disable/Enable scout overlay hotkey", - description = "When you press this key the scout overlay will be hidden/displayed.", - position = 11 - ) - default Keybind hotkey() - { - return Keybind.NOT_SET; - } - } From d18cabb9725e3ff3ba7cdfad0322887a14439b22 Mon Sep 17 00:00:00 2001 From: MackBryan Date: Tue, 4 Sep 2018 18:14:05 -0700 Subject: [PATCH 04/20] Implemented hotkey functionality for disabling/enabling the scout overlay. --- .../client/plugins/raids/RaidsPlugin.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java index 1a96b63d8a..6724c644dc 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java @@ -59,6 +59,7 @@ import net.runelite.client.chat.ChatMessageManager; import net.runelite.client.chat.QueuedMessage; import net.runelite.client.config.ConfigManager; import net.runelite.client.game.SpriteManager; +import net.runelite.client.input.KeyManager; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.raids.solver.Layout; @@ -66,6 +67,7 @@ import net.runelite.client.plugins.raids.solver.LayoutSolver; import net.runelite.client.plugins.raids.solver.RotationSolver; import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.infobox.InfoBoxManager; +import net.runelite.client.util.HotkeyListener; import net.runelite.client.util.Text; @PluginDescriptor( @@ -109,6 +111,9 @@ public class RaidsPlugin extends Plugin @Inject private LayoutSolver layoutSolver; + @Inject + private KeyManager keyManager; + @Inject private SpriteManager spriteManager; @@ -130,6 +135,8 @@ public class RaidsPlugin extends Plugin @Getter private boolean inRaidChambers; + private boolean raidStarted; + private RaidsTimer timer; @Provides @@ -149,6 +156,7 @@ public class RaidsPlugin extends Plugin { overlayManager.add(overlay); overlayManager.add(pointsOverlay); + keyManager.registerKeyListener(hotkeyListener); updateLists(); checkRaidPresence(true); } @@ -159,7 +167,9 @@ public class RaidsPlugin extends Plugin overlayManager.remove(overlay); overlayManager.remove(pointsOverlay); infoBoxManager.removeInfoBox(timer); + keyManager.unregisterKeyListener(hotkeyListener); inRaidChambers = false; + raidStarted = false; raid = null; timer = null; } @@ -215,6 +225,7 @@ public class RaidsPlugin extends Plugin { timer = new RaidsTimer(spriteManager.getSprite(TAB_QUESTS_BROWN_RAIDING_PARTY, 0), this, Instant.now()); infoBoxManager.addInfoBox(timer); + raidStarted = true; } if (timer != null && message.contains(LEVEL_COMPLETE_MESSAGE)) @@ -309,6 +320,7 @@ public class RaidsPlugin extends Plugin if (client.getVar(VarPlayer.IN_RAID_PARTY) == -1 && (!inRaidChambers || !config.scoutOverlayInRaid())) { overlay.setScoutOverlayShown(false); + raidStarted = false; } } @@ -599,4 +611,24 @@ public class RaidsPlugin extends Plugin return room; } + + private final HotkeyListener hotkeyListener = new HotkeyListener(() -> config.hotkey()) + { + @Override + public void hotkeyPressed() + { + if(config.scoutOverlayInRaid() && raidStarted) + { + if(overlay.isScoutOverlayShown()) + { + overlay.setScoutOverlayShown(false); + } + else + { + overlay.setScoutOverlayShown(true); + } + } + } + }; + } From 41d1ee7c51cc1d44aa733467791c029a3acd0b9a Mon Sep 17 00:00:00 2001 From: MackBryan Date: Tue, 4 Sep 2018 18:56:06 -0700 Subject: [PATCH 05/20] Test ci --- .../java/net/runelite/client/plugins/raids/RaidsConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsConfig.java index 380fefd320..39fcc1311e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsConfig.java @@ -89,7 +89,7 @@ public interface RaidsConfig extends Config @ConfigItem( keyName = "hotkey", - name = "Scout overlay hotkey", + name = "Toggle scout overlay", description = "When pressed the scout overlay will be toggled. Must enable show scout overlay in raid", position = 5 ) From eccab3b535263a6938c34de26682161fe53b64d3 Mon Sep 17 00:00:00 2001 From: MackBryan Date: Tue, 4 Sep 2018 19:03:56 -0700 Subject: [PATCH 06/20] Checkstyle fix --- .../client/plugins/raids/RaidsConfig.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsConfig.java index 39fcc1311e..41eb01e893 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsConfig.java @@ -87,16 +87,15 @@ public interface RaidsConfig extends Config return false; } - @ConfigItem( - keyName = "hotkey", - name = "Toggle scout overlay", - description = "When pressed the scout overlay will be toggled. Must enable show scout overlay in raid", - position = 5 - ) - default Keybind hotkey() - { - return Keybind.NOT_SET; - } + @ConfigItem( + keyName = "hotkey", name = "Toggle scout overlay", + description = "When pressed the scout overlay will be toggled. Must enable show scout overlay in raid", + position = 5 + ) + default Keybind hotkey() + { + return Keybind.NOT_SET; + } @ConfigItem( position = 6, From 578881a03a50940822fa0a423c4d7a6ef8bfe3dc Mon Sep 17 00:00:00 2001 From: MackBryan Date: Tue, 4 Sep 2018 19:04:47 -0700 Subject: [PATCH 07/20] Checkstyle fix --- .../java/net/runelite/client/plugins/raids/RaidsPlugin.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java index 6724c644dc..2cc16a4ca0 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java @@ -617,9 +617,9 @@ public class RaidsPlugin extends Plugin @Override public void hotkeyPressed() { - if(config.scoutOverlayInRaid() && raidStarted) + if (config.scoutOverlayInRaid() && raidStarted) { - if(overlay.isScoutOverlayShown()) + if (overlay.isScoutOverlayShown()) { overlay.setScoutOverlayShown(false); } From b2d7cbbe44cec5bdd6f6fba95123d105f951e128 Mon Sep 17 00:00:00 2001 From: MackBryan Date: Tue, 4 Sep 2018 19:13:23 -0700 Subject: [PATCH 08/20] Checkstyle fix --- .../java/net/runelite/client/plugins/raids/RaidsPlugin.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java index 2cc16a4ca0..768f193db8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java @@ -135,7 +135,7 @@ public class RaidsPlugin extends Plugin @Getter private boolean inRaidChambers; - private boolean raidStarted; + private boolean raidStarted; private RaidsTimer timer; @@ -320,7 +320,7 @@ public class RaidsPlugin extends Plugin if (client.getVar(VarPlayer.IN_RAID_PARTY) == -1 && (!inRaidChambers || !config.scoutOverlayInRaid())) { overlay.setScoutOverlayShown(false); - raidStarted = false; + raidStarted = false; } } From faed3ec1bf7d03d572ad9d2f5e5c5bdc6f0f0b48 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 11 May 2019 14:22:24 -0400 Subject: [PATCH 09/20] dps --- .../client/plugins/dpscounter/Boss.java | 78 +++++++++ .../plugins/dpscounter/DpsCounterPlugin.java | 159 ++++++++++++++++++ .../client/plugins/dpscounter/DpsMember.java | 26 +++ .../client/plugins/dpscounter/DpsOverlay.java | 73 ++++++++ .../client/plugins/dpscounter/DpsUpdate.java | 13 ++ 5 files changed, 349 insertions(+) create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/Boss.java create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsMember.java create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsOverlay.java create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsUpdate.java diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/Boss.java b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/Boss.java new file mode 100644 index 0000000000..bfd4587e25 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/Boss.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2018, Raqes + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.dpscounter; + +import com.google.common.collect.ImmutableMap; +import java.util.Map; +import lombok.Getter; +import lombok.ToString; +import net.runelite.api.NpcID; + +@Getter +@ToString +enum Boss +{ + ABYSSAL_SIRE(1.25f, NpcID.ABYSSAL_SIRE, NpcID.ABYSSAL_SIRE_5887, NpcID.ABYSSAL_SIRE_5888, NpcID.ABYSSAL_SIRE_5889, NpcID.ABYSSAL_SIRE_5890, NpcID.ABYSSAL_SIRE_5891, NpcID.ABYSSAL_SIRE_5908), + CALLISTO(1.225f, NpcID.CALLISTO, NpcID.CALLISTO_6609), + CERBERUS(1.15f, NpcID.CERBERUS, NpcID.CERBERUS_5863, NpcID.CERBERUS_5866), + CHAOS_ELEMENTAL(1.075f, NpcID.CHAOS_ELEMENTAL, NpcID.CHAOS_ELEMENTAL_6505), + CORPOREAL_BEAST(1.55f, NpcID.CORPOREAL_BEAST), + GENERAL_GRAARDOR(1.325f, NpcID.GENERAL_GRAARDOR, NpcID.GENERAL_GRAARDOR_6494), + GIANT_MOLE(1.075f, NpcID.GIANT_MOLE, NpcID.GIANT_MOLE_6499), + KALPHITE_QUEEN(1.05f, NpcID.KALPHITE_QUEEN, NpcID.KALPHITE_QUEEN_963, NpcID.KALPHITE_QUEEN_965, NpcID.KALPHITE_QUEEN_4303, NpcID.KALPHITE_QUEEN_4304, NpcID.KALPHITE_QUEEN_6500, NpcID.KALPHITE_QUEEN_6501), + KING_BLACK_DRAGON(1.075f, NpcID.KING_BLACK_DRAGON, NpcID.KING_BLACK_DRAGON_2642, NpcID.KING_BLACK_DRAGON_6502), + KRIL_TSUROTH(1.375f, NpcID.KRIL_TSUTSAROTH, NpcID.KRIL_TSUTSAROTH_6495), + VENETENATIS(1.4f, NpcID.VENENATIS, NpcID.VENENATIS_6610), + VETION(1.225f, NpcID.VETION, NpcID.VETION_REBORN); + + private final int[] ids; + private final float modifier; // Some NPCs have a modifier to the experience a player receives. + + Boss(float modifier, int... ids) + { + this.modifier = modifier; + this.ids = ids; + } + + private static final Map BOSS_MAP; + + static Boss findBoss(int id) + { + return BOSS_MAP.get(id); + } + + static + { + ImmutableMap.Builder builder = ImmutableMap.builder(); + for (Boss boss : values()) + { + for (int id : boss.ids) + { + builder.put(id, boss); + } + } + BOSS_MAP = builder.build(); + } +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java new file mode 100644 index 0000000000..af9eef5dba --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java @@ -0,0 +1,159 @@ +package net.runelite.client.plugins.dpscounter; + +import com.google.inject.Binder; +import com.google.inject.Inject; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import lombok.AccessLevel; +import lombok.Getter; +import net.runelite.api.Actor; +import net.runelite.api.Client; +import net.runelite.api.NPC; +import net.runelite.api.Player; +import net.runelite.api.Skill; +import net.runelite.api.events.ExperienceChanged; +import net.runelite.api.events.InteractingChanged; +import net.runelite.client.eventbus.Subscribe; +import net.runelite.client.plugins.Plugin; +import net.runelite.client.plugins.PluginDescriptor; +import net.runelite.client.ui.overlay.OverlayManager; +import net.runelite.client.ws.PartyMember; +import net.runelite.client.ws.PartyService; +import net.runelite.client.ws.WSClient; + +@PluginDescriptor( + name = "DPS Counter", + description = "counts dps?" +// +) +public class DpsCounterPlugin extends Plugin +{ + private int lastXp = -1; + + @Inject + private Client client; + + @Inject + private OverlayManager overlayManager; + + @Inject + private PartyService partyService; + + @Inject + private WSClient wsClient; + + @Inject + private DpsOverlay dpsOverlay; + + private Boss boss; + private NPC npc; + @Getter(AccessLevel.PACKAGE) + private final Map members = new ConcurrentHashMap<>(); + + @Override + public void configure(Binder binder) + { + //super.configure(binder); + } + + @Override + protected void startUp() + { + overlayManager.add(dpsOverlay); + //super.startUp(); + } + + @Override + protected void shutDown() + { + overlayManager.remove(dpsOverlay); + boss = null; + //super.shutDown(); + } + + @Subscribe + public void onInteractingChanged(InteractingChanged interactingChanged) { + Actor source = interactingChanged.getSource(); + Actor target = interactingChanged.getTarget(); + + if (source != client.getLocalPlayer()) { + return; + } + + if (target instanceof NPC) { + int npcId = ((NPC) target).getId(); + Boss boss = Boss.findBoss(npcId); + if (boss != null) { + this.boss = boss; + npc = (NPC) target; + // boss = Boss.ABYSSAL_SIRE; + } + } + } + + @Subscribe + public void onExperienceChanged(ExperienceChanged experienceChanged) + { + if (experienceChanged.getSkill() != Skill.HITPOINTS) + { + return; + } + + final int xp = client.getSkillExperience(Skill.HITPOINTS); + if (boss == null || lastXp < 0 || xp < lastXp) + { + lastXp = xp; + return; + } + + final int delta = xp - lastXp; + final int hit = getHit(boss.getModifier(), delta); +// final int hit = getHit(1.0f, delta); + lastXp = xp; + + // Update local member + PartyMember localMember = partyService.getLocalMember(); + Player player = client.getLocalPlayer(); + // If not in a party, user local player name + final String name = localMember == null ? player.getName() : localMember.getName(); + DpsMember dpsMember = members.computeIfAbsent(name, n -> new DpsMember(name)); + dpsMember.addDamage(hit); +// System.out.println("HIT "+ hit); + + if (!partyService.getMembers().isEmpty()) + { + // Check the player is attacking the boss + if (npc != null && player.getInteracting() == npc) + { + final DpsUpdate specialCounterUpdate = new DpsUpdate(npc.getId(), hit); + specialCounterUpdate.setMemberId(partyService.getLocalMember().getMemberId()); + wsClient.send(specialCounterUpdate); + } + } + } + + @Subscribe + public void onDpsUpdate(DpsUpdate dpsUpdate) { + if (partyService.getLocalMember().getMemberId().equals(dpsUpdate.getMemberId())) + { + return; + } + + String name = partyService.getMemberById(dpsUpdate.getMemberId()).getName(); + if (name == null) + { + return; + } + + DpsMember dpsMember = members.computeIfAbsent(name, n -> new DpsMember(name)); + dpsMember.addDamage(dpsUpdate.getHit()); + + } + + private int getHit(float modifier, int deltaExperience) + { + float modifierBase = 1f / modifier; + float damageOutput = (deltaExperience * modifierBase) / 1.3333f; + return Math.round(damageOutput); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsMember.java b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsMember.java new file mode 100644 index 0000000000..6b5693a37f --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsMember.java @@ -0,0 +1,26 @@ +package net.runelite.client.plugins.dpscounter; + +import java.time.Instant; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +@Getter +class DpsMember +{ + private final String name; + private Instant start = Instant.now(); + private int damage; + + void addDamage(int amount) + { + damage += amount; + } + + int getDps() + { + int diff = (int) (Instant.now().toEpochMilli() - start.toEpochMilli()) / 1000; + if (diff == 0) return 0; + return damage / diff; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsOverlay.java new file mode 100644 index 0000000000..42254ab92e --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsOverlay.java @@ -0,0 +1,73 @@ +package net.runelite.client.plugins.dpscounter; + +import java.awt.Dimension; +import java.awt.Graphics2D; +import java.util.Map; +import javax.inject.Inject; +import net.runelite.client.ui.overlay.Overlay; +import net.runelite.client.ui.overlay.components.LineComponent; +import net.runelite.client.ui.overlay.components.PanelComponent; +import net.runelite.client.ui.overlay.components.TitleComponent; +import net.runelite.client.ws.PartyService; + +public class DpsOverlay extends Overlay +{ + private final DpsCounterPlugin dpsCounterPlugin; + private final PartyService partyService; + + private final PanelComponent panelComponent = new PanelComponent(); + + @Inject + DpsOverlay(DpsCounterPlugin dpsCounterPlugin, PartyService partyService) + { + super(dpsCounterPlugin); + this.dpsCounterPlugin = dpsCounterPlugin; + this.partyService = partyService; + //setPosition(OverlayPosition.TOP_LEFT); + } + + @Override + public Dimension render(Graphics2D graphics) + { + Map dpsMembers = dpsCounterPlugin.getMembers(); + + panelComponent.getChildren().clear(); + panelComponent.getChildren().add( + TitleComponent.builder() + .text("DPS") + //olor(HIGHLIGHT_COLOR) + .build()); + +// panelComponent.getChildren().add( +// LineComponent.builder() +// .left("Player") +// // .leftColor(HIGHLIGHT_COLOR) +// .right("DPS") +// // .rightColor(HIGHLIGHT_COLOR) +// .build()); + + for (DpsMember dpsMember : dpsMembers.values()) { + panelComponent.getChildren().add( + LineComponent.builder() + .left(dpsMember.getName()) + .right(Integer.toString(dpsMember.getDps())) + //.right(Integer.toString(playerSkillLevel) + "/" + Integer.toString(opponentSkillLevel)) + //.rightColor(comparisonStatColor(playerSkillLevel, opponentSkillLevel)) + .build()); + } + + //partyService.getMemberByName() +// for (PartyMember member : partyService.getMembers()) { +// DpsMember dpsMember = dpsMembers.get(member.getName()); +// if (dpsMember == null) continue; +// panelComponent.getChildren().add( +// LineComponent.builder() +// .left(member.getName()) +// .right(Integer.toString(dpsMember.getDps())) +// //.right(Integer.toString(playerSkillLevel) + "/" + Integer.toString(opponentSkillLevel)) +// //.rightColor(comparisonStatColor(playerSkillLevel, opponentSkillLevel)) +// .build()); +// } + return panelComponent.render(graphics); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsUpdate.java b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsUpdate.java new file mode 100644 index 0000000000..5aa02da373 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsUpdate.java @@ -0,0 +1,13 @@ +package net.runelite.client.plugins.dpscounter; + +import lombok.EqualsAndHashCode; +import lombok.Value; +import net.runelite.http.api.ws.messages.party.PartyMemberMessage; + +@Value +@EqualsAndHashCode(callSuper = true) +public class DpsUpdate extends PartyMemberMessage +{ + private int npcId; + private int hit; +} From a7ab6153f1f1197c48a3b05a27b15b8bd070f248 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 11 May 2019 14:51:50 -0400 Subject: [PATCH 10/20] register dps --- .../runelite/client/plugins/dpscounter/DpsCounterPlugin.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java index af9eef5dba..893d31ebcd 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java @@ -60,12 +60,14 @@ public class DpsCounterPlugin extends Plugin protected void startUp() { overlayManager.add(dpsOverlay); + wsClient.registerMessage(DpsUpdate.class); //super.startUp(); } @Override protected void shutDown() { + wsClient.unregisterMessage(DpsUpdate.class); overlayManager.remove(dpsOverlay); boss = null; //super.shutDown(); From 4a81250c992ac79019bd971c2265fd9e3aa7dcb0 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 11 May 2019 15:08:40 -0400 Subject: [PATCH 11/20] More float --- .../runelite/client/plugins/dpscounter/DpsCounterPlugin.java | 4 ++-- .../net/runelite/client/plugins/dpscounter/DpsMember.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java index 893d31ebcd..0af71d34eb 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java @@ -122,7 +122,7 @@ public class DpsCounterPlugin extends Plugin dpsMember.addDamage(hit); // System.out.println("HIT "+ hit); - if (!partyService.getMembers().isEmpty()) + if (hit > 0 && !partyService.getMembers().isEmpty()) { // Check the player is attacking the boss if (npc != null && player.getInteracting() == npc) @@ -147,7 +147,7 @@ public class DpsCounterPlugin extends Plugin return; } - DpsMember dpsMember = members.computeIfAbsent(name, n -> new DpsMember(name)); + DpsMember dpsMember = members.computeIfAbsent(name, DpsMember::new); dpsMember.addDamage(dpsUpdate.getHit()); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsMember.java b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsMember.java index 6b5693a37f..1a68d06e51 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsMember.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsMember.java @@ -21,6 +21,6 @@ class DpsMember { int diff = (int) (Instant.now().toEpochMilli() - start.toEpochMilli()) / 1000; if (diff == 0) return 0; - return damage / diff; + return (int) ((float) damage / (float) diff); } } From eb0aa94ddbc760a165b9cc5f9dd18e13888d22aa Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 11 May 2019 15:39:17 -0400 Subject: [PATCH 12/20] hmm --- .../plugins/dpscounter/DpsCounterPlugin.java | 63 ++++++++++++++----- .../client/plugins/dpscounter/DpsMember.java | 19 ++++-- .../client/plugins/dpscounter/DpsOverlay.java | 49 +++++++-------- 3 files changed, 84 insertions(+), 47 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java index 0af71d34eb..71705f064e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java @@ -1,19 +1,24 @@ package net.runelite.client.plugins.dpscounter; -import com.google.inject.Binder; import com.google.inject.Inject; +import com.google.inject.Provides; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import lombok.AccessLevel; import lombok.Getter; +import lombok.extern.slf4j.Slf4j; import net.runelite.api.Actor; import net.runelite.api.Client; +import net.runelite.api.MenuAction; import net.runelite.api.NPC; import net.runelite.api.Player; import net.runelite.api.Skill; import net.runelite.api.events.ExperienceChanged; import net.runelite.api.events.InteractingChanged; +import net.runelite.api.events.NpcDespawned; +import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; +import net.runelite.client.events.OverlayMenuClicked; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.ui.overlay.OverlayManager; @@ -24,8 +29,8 @@ import net.runelite.client.ws.WSClient; @PluginDescriptor( name = "DPS Counter", description = "counts dps?" -// ) +@Slf4j public class DpsCounterPlugin extends Plugin { private int lastXp = -1; @@ -50,10 +55,10 @@ public class DpsCounterPlugin extends Plugin @Getter(AccessLevel.PACKAGE) private final Map members = new ConcurrentHashMap<>(); - @Override - public void configure(Binder binder) + @Provides + DpsConfig provideConfig(ConfigManager configManager) { - //super.configure(binder); + return configManager.getConfig(DpsConfig.class); } @Override @@ -61,7 +66,6 @@ public class DpsCounterPlugin extends Plugin { overlayManager.add(dpsOverlay); wsClient.registerMessage(DpsUpdate.class); - //super.startUp(); } @Override @@ -70,25 +74,28 @@ public class DpsCounterPlugin extends Plugin wsClient.unregisterMessage(DpsUpdate.class); overlayManager.remove(dpsOverlay); boss = null; - //super.shutDown(); } @Subscribe - public void onInteractingChanged(InteractingChanged interactingChanged) { + public void onInteractingChanged(InteractingChanged interactingChanged) + { Actor source = interactingChanged.getSource(); Actor target = interactingChanged.getTarget(); - if (source != client.getLocalPlayer()) { + if (source != client.getLocalPlayer()) + { return; } - if (target instanceof NPC) { + if (target instanceof NPC) + { int npcId = ((NPC) target).getId(); Boss boss = Boss.findBoss(npcId); - if (boss != null) { + if (boss != null) + { this.boss = boss; npc = (NPC) target; - // boss = Boss.ABYSSAL_SIRE; + // boss = Boss.ABYSSAL_SIRE; } } } @@ -110,7 +117,6 @@ public class DpsCounterPlugin extends Plugin final int delta = xp - lastXp; final int hit = getHit(boss.getModifier(), delta); -// final int hit = getHit(1.0f, delta); lastXp = xp; // Update local member @@ -120,7 +126,6 @@ public class DpsCounterPlugin extends Plugin final String name = localMember == null ? player.getName() : localMember.getName(); DpsMember dpsMember = members.computeIfAbsent(name, n -> new DpsMember(name)); dpsMember.addDamage(hit); -// System.out.println("HIT "+ hit); if (hit > 0 && !partyService.getMembers().isEmpty()) { @@ -135,7 +140,8 @@ public class DpsCounterPlugin extends Plugin } @Subscribe - public void onDpsUpdate(DpsUpdate dpsUpdate) { + public void onDpsUpdate(DpsUpdate dpsUpdate) + { if (partyService.getLocalMember().getMemberId().equals(dpsUpdate.getMemberId())) { return; @@ -147,9 +153,36 @@ public class DpsCounterPlugin extends Plugin return; } + // Hmm - not attacking the same boss I am + if (npc == null || dpsUpdate.getNpcId() != npc.getId()) + { + return; + } + DpsMember dpsMember = members.computeIfAbsent(name, DpsMember::new); dpsMember.addDamage(dpsUpdate.getHit()); + } + @Subscribe + public void onOverlayMenuClicked(OverlayMenuClicked event) + { + if (event.getEntry().getMenuAction() == MenuAction.RUNELITE_OVERLAY && + event.getEntry().getTarget().equals("Reset") && + event.getEntry().getOption().equals("DPS counter")) + { + members.clear(); + } + } + + @Subscribe + public void onNpcDespawned(NpcDespawned npcDespawned) + { + if (npc == null || npcDespawned.getNpc() != npc || !npc.isDead()) + { + return; + } + + log.debug("Boss has died!"); } private int getHit(float modifier, int deltaExperience) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsMember.java b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsMember.java index 1a68d06e51..b83425834b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsMember.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsMember.java @@ -10,6 +10,7 @@ class DpsMember { private final String name; private Instant start = Instant.now(); + private Instant end; private int damage; void addDamage(int amount) @@ -17,10 +18,20 @@ class DpsMember damage += amount; } - int getDps() + float getDps() { - int diff = (int) (Instant.now().toEpochMilli() - start.toEpochMilli()) / 1000; - if (diff == 0) return 0; - return (int) ((float) damage / (float) diff); + Instant now = end == null ? Instant.now() : end; + int diff = (int) (now.toEpochMilli() - start.toEpochMilli()) / 1000; + if (diff == 0) + { + return 0; + } + + return (float) damage / (float) diff; + } + + void pause() + { + end = Instant.now(); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsOverlay.java index 42254ab92e..52fe67dd6e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsOverlay.java @@ -2,9 +2,12 @@ package net.runelite.client.plugins.dpscounter; import java.awt.Dimension; import java.awt.Graphics2D; +import java.text.DecimalFormat; import java.util.Map; import javax.inject.Inject; +import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG; import net.runelite.client.ui.overlay.Overlay; +import net.runelite.client.ui.overlay.OverlayMenuEntry; import net.runelite.client.ui.overlay.components.LineComponent; import net.runelite.client.ui.overlay.components.PanelComponent; import net.runelite.client.ui.overlay.components.TitleComponent; @@ -12,62 +15,52 @@ import net.runelite.client.ws.PartyService; public class DpsOverlay extends Overlay { + private static final DecimalFormat DPS_FORMAT = new DecimalFormat("#0.0"); + private final DpsCounterPlugin dpsCounterPlugin; + private final DpsConfig dpsConfig; private final PartyService partyService; private final PanelComponent panelComponent = new PanelComponent(); @Inject - DpsOverlay(DpsCounterPlugin dpsCounterPlugin, PartyService partyService) + DpsOverlay(DpsCounterPlugin dpsCounterPlugin, DpsConfig dpsConfig, PartyService partyService) { super(dpsCounterPlugin); this.dpsCounterPlugin = dpsCounterPlugin; + this.dpsConfig = dpsConfig; this.partyService = partyService; - //setPosition(OverlayPosition.TOP_LEFT); + getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY_CONFIG, "Reset", "DPS counter")); } @Override public Dimension render(Graphics2D graphics) { Map dpsMembers = dpsCounterPlugin.getMembers(); + if (dpsMembers.isEmpty()) + { + return null; + } + + boolean inParty = !partyService.getMembers().isEmpty(); + boolean showDamage = dpsConfig.showDamage(); panelComponent.getChildren().clear(); + panelComponent.getChildren().add( TitleComponent.builder() - .text("DPS") - //olor(HIGHLIGHT_COLOR) + .text(inParty ? "Party DPS" : "DPS") .build()); -// panelComponent.getChildren().add( -// LineComponent.builder() -// .left("Player") -// // .leftColor(HIGHLIGHT_COLOR) -// .right("DPS") -// // .rightColor(HIGHLIGHT_COLOR) -// .build()); - - for (DpsMember dpsMember : dpsMembers.values()) { + for (DpsMember dpsMember : dpsMembers.values()) + { panelComponent.getChildren().add( LineComponent.builder() .left(dpsMember.getName()) - .right(Integer.toString(dpsMember.getDps())) - //.right(Integer.toString(playerSkillLevel) + "/" + Integer.toString(opponentSkillLevel)) - //.rightColor(comparisonStatColor(playerSkillLevel, opponentSkillLevel)) + .right(showDamage ? Integer.toString(dpsMember.getDamage()) : DPS_FORMAT.format(dpsMember.getDps())) .build()); } - //partyService.getMemberByName() -// for (PartyMember member : partyService.getMembers()) { -// DpsMember dpsMember = dpsMembers.get(member.getName()); -// if (dpsMember == null) continue; -// panelComponent.getChildren().add( -// LineComponent.builder() -// .left(member.getName()) -// .right(Integer.toString(dpsMember.getDps())) -// //.right(Integer.toString(playerSkillLevel) + "/" + Integer.toString(opponentSkillLevel)) -// //.rightColor(comparisonStatColor(playerSkillLevel, opponentSkillLevel)) -// .build()); -// } return panelComponent.render(graphics); } } From d590c64697375d7b600396930db2a3c0f456c4a7 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 11 May 2019 15:43:27 -0400 Subject: [PATCH 13/20] auto pause --- .../plugins/dpscounter/DpsCounterPlugin.java | 66 ++++++++++++++----- 1 file changed, 50 insertions(+), 16 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java index 71705f064e..a61d77bae2 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java @@ -16,6 +16,7 @@ import net.runelite.api.Skill; import net.runelite.api.events.ExperienceChanged; import net.runelite.api.events.InteractingChanged; import net.runelite.api.events.NpcDespawned; +import net.runelite.api.events.NpcSpawned; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.events.OverlayMenuClicked; @@ -25,6 +26,7 @@ import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ws.PartyMember; import net.runelite.client.ws.PartyService; import net.runelite.client.ws.WSClient; +import org.apache.commons.lang3.ArrayUtils; @PluginDescriptor( name = "DPS Counter", @@ -33,8 +35,6 @@ import net.runelite.client.ws.WSClient; @Slf4j public class DpsCounterPlugin extends Plugin { - private int lastXp = -1; - @Inject private Client client; @@ -51,7 +51,8 @@ public class DpsCounterPlugin extends Plugin private DpsOverlay dpsOverlay; private Boss boss; - private NPC npc; + private NPC bossNpc; + private int lastHpExp = -1; @Getter(AccessLevel.PACKAGE) private final Map members = new ConcurrentHashMap<>(); @@ -89,13 +90,13 @@ public class DpsCounterPlugin extends Plugin if (target instanceof NPC) { - int npcId = ((NPC) target).getId(); + NPC npc = (NPC) target; + int npcId = npc.getId(); Boss boss = Boss.findBoss(npcId); if (boss != null) { this.boss = boss; - npc = (NPC) target; - // boss = Boss.ABYSSAL_SIRE; + bossNpc = (NPC) target; } } } @@ -109,15 +110,15 @@ public class DpsCounterPlugin extends Plugin } final int xp = client.getSkillExperience(Skill.HITPOINTS); - if (boss == null || lastXp < 0 || xp < lastXp) + if (boss == null || lastHpExp < 0 || xp < lastHpExp) { - lastXp = xp; + lastHpExp = xp; return; } - final int delta = xp - lastXp; + final int delta = xp - lastHpExp; final int hit = getHit(boss.getModifier(), delta); - lastXp = xp; + lastHpExp = xp; // Update local member PartyMember localMember = partyService.getLocalMember(); @@ -130,9 +131,9 @@ public class DpsCounterPlugin extends Plugin if (hit > 0 && !partyService.getMembers().isEmpty()) { // Check the player is attacking the boss - if (npc != null && player.getInteracting() == npc) + if (bossNpc != null && player.getInteracting() == bossNpc) { - final DpsUpdate specialCounterUpdate = new DpsUpdate(npc.getId(), hit); + final DpsUpdate specialCounterUpdate = new DpsUpdate(bossNpc.getId(), hit); specialCounterUpdate.setMemberId(partyService.getLocalMember().getMemberId()); wsClient.send(specialCounterUpdate); } @@ -154,7 +155,7 @@ public class DpsCounterPlugin extends Plugin } // Hmm - not attacking the same boss I am - if (npc == null || dpsUpdate.getNpcId() != npc.getId()) + if (bossNpc == null || dpsUpdate.getNpcId() != bossNpc.getId()) { return; } @@ -175,14 +176,47 @@ public class DpsCounterPlugin extends Plugin } @Subscribe - public void onNpcDespawned(NpcDespawned npcDespawned) + public void onNpcSpawned(NpcSpawned npcSpawned) { - if (npc == null || npcDespawned.getNpc() != npc || !npc.isDead()) + if (boss == null) { return; } - log.debug("Boss has died!"); + NPC npc = npcSpawned.getNpc(); + int npcId = npc.getId(); + if (!ArrayUtils.contains(boss.getIds(), npcId)) + { + return; + } + + log.debug("Boss has spawned!"); + bossNpc = npc; + } + + @Subscribe + public void onNpcDespawned(NpcDespawned npcDespawned) + { + if (bossNpc == null || npcDespawned.getNpc() != bossNpc) + { + return; + } + + if (bossNpc.isDead()) + { + log.debug("Boss has died!"); + pause(); + } + + bossNpc = null; + } + + private void pause() + { + for (DpsMember dpsMember : members.values()) + { + dpsMember.pause(); + } } private int getHit(float modifier, int deltaExperience) From 75f835f3221e9f365374fde404c01310198e1536 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 11 May 2019 15:43:47 -0400 Subject: [PATCH 14/20] add config --- .../client/plugins/dpscounter/DpsConfig.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsConfig.java diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsConfig.java new file mode 100644 index 0000000000..5fc88bf342 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsConfig.java @@ -0,0 +1,19 @@ +package net.runelite.client.plugins.dpscounter; + +import net.runelite.client.config.ConfigGroup; +import net.runelite.client.config.ConfigItem; + +@ConfigGroup("dpscounter") +public interface DpsConfig +{ + @ConfigItem( + position = 0, + name = "Show Damage", + keyName = "showDamage", + description = "Show total damage instead of DPS" + ) + default boolean showDamage() + { + return false; + } +} From bb3463bbce7f57548d4869e7a634ecf7a9c45c20 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 11 May 2019 15:58:11 -0400 Subject: [PATCH 15/20] unpause --- .../client/plugins/dpscounter/DpsConfig.java | 3 ++- .../plugins/dpscounter/DpsCounterPlugin.java | 12 ++++++++++++ .../client/plugins/dpscounter/DpsMember.java | 17 +++++++++++++++++ .../client/plugins/dpscounter/DpsOverlay.java | 4 ++-- 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsConfig.java index 5fc88bf342..6845168f09 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsConfig.java @@ -1,10 +1,11 @@ package net.runelite.client.plugins.dpscounter; +import net.runelite.client.config.Config; import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; @ConfigGroup("dpscounter") -public interface DpsConfig +public interface DpsConfig extends Config { @ConfigItem( position = 0, diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java index a61d77bae2..64315aba19 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java @@ -128,6 +128,12 @@ public class DpsCounterPlugin extends Plugin DpsMember dpsMember = members.computeIfAbsent(name, n -> new DpsMember(name)); dpsMember.addDamage(hit); + if (dpsMember.isPaused()) + { + dpsMember.unpause(); + log.debug("Unpausing {}", dpsMember.getName()); + } + if (hit > 0 && !partyService.getMembers().isEmpty()) { // Check the player is attacking the boss @@ -162,6 +168,12 @@ public class DpsCounterPlugin extends Plugin DpsMember dpsMember = members.computeIfAbsent(name, DpsMember::new); dpsMember.addDamage(dpsUpdate.getHit()); + + if (dpsMember.isPaused()) + { + dpsMember.unpause(); + log.debug("Unpausing {}", dpsMember.getName()); + } } @Subscribe diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsMember.java b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsMember.java index b83425834b..5c1ca5a85c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsMember.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsMember.java @@ -1,5 +1,6 @@ package net.runelite.client.plugins.dpscounter; +import java.time.Duration; import java.time.Instant; import lombok.Getter; import lombok.RequiredArgsConstructor; @@ -34,4 +35,20 @@ class DpsMember { end = Instant.now(); } + + boolean isPaused() + { + return end != null; + } + + void unpause() + { + if (end == null) + { + return; + } + + start = start.plus(Duration.between(end, Instant.now()); + end = null; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsOverlay.java index 52fe67dd6e..2d1f664fe7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsOverlay.java @@ -5,7 +5,7 @@ import java.awt.Graphics2D; import java.text.DecimalFormat; import java.util.Map; import javax.inject.Inject; -import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG; +import static net.runelite.api.MenuAction.RUNELITE_OVERLAY; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayMenuEntry; import net.runelite.client.ui.overlay.components.LineComponent; @@ -30,7 +30,7 @@ public class DpsOverlay extends Overlay this.dpsCounterPlugin = dpsCounterPlugin; this.dpsConfig = dpsConfig; this.partyService = partyService; - getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY_CONFIG, "Reset", "DPS counter")); + getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY, "Reset", "DPS counter")); } @Override From f21eea455a2ddab7e031105dabca1e77ff9301b6 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 11 May 2019 16:16:49 -0400 Subject: [PATCH 16/20] ignore if xp doesnt change --- .../runelite/client/plugins/dpscounter/DpsCounterPlugin.java | 2 +- .../java/net/runelite/client/plugins/dpscounter/DpsMember.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java index 64315aba19..3623dd5589 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java @@ -110,7 +110,7 @@ public class DpsCounterPlugin extends Plugin } final int xp = client.getSkillExperience(Skill.HITPOINTS); - if (boss == null || lastHpExp < 0 || xp < lastHpExp) + if (boss == null || lastHpExp < 0 || xp <= lastHpExp) { lastHpExp = xp; return; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsMember.java b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsMember.java index 5c1ca5a85c..fd109479a0 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsMember.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsMember.java @@ -48,7 +48,7 @@ class DpsMember return; } - start = start.plus(Duration.between(end, Instant.now()); + start = start.plus(Duration.between(end, Instant.now())); end = null; } } From 1ba39cdf9a8b339253f11695b6482cdd96437dc7 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 11 May 2019 16:27:58 -0400 Subject: [PATCH 17/20] fix reset --- .../runelite/client/plugins/dpscounter/DpsCounterPlugin.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java index 3623dd5589..147824b929 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java @@ -74,6 +74,7 @@ public class DpsCounterPlugin extends Plugin { wsClient.unregisterMessage(DpsUpdate.class); overlayManager.remove(dpsOverlay); + members.clear(); boss = null; } @@ -180,8 +181,8 @@ public class DpsCounterPlugin extends Plugin public void onOverlayMenuClicked(OverlayMenuClicked event) { if (event.getEntry().getMenuAction() == MenuAction.RUNELITE_OVERLAY && - event.getEntry().getTarget().equals("Reset") && - event.getEntry().getOption().equals("DPS counter")) + event.getEntry().getOption().equals("Reset") && + event.getEntry().getTarget().equals("DPS counter")) { members.clear(); } From 88b1c47a552c63dc6c7a9cff90aa18827109a0b1 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 11 May 2019 16:28:56 -0400 Subject: [PATCH 18/20] Reset when party changes --- .../client/plugins/dpscounter/DpsCounterPlugin.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java index 147824b929..8352b4e63d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java @@ -20,6 +20,7 @@ import net.runelite.api.events.NpcSpawned; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.events.OverlayMenuClicked; +import net.runelite.client.events.PartyChanged; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.ui.overlay.OverlayManager; @@ -78,6 +79,12 @@ public class DpsCounterPlugin extends Plugin boss = null; } + @Subscribe + public void onPartyChanged(PartyChanged partyChanged) + { + members.clear(); + } + @Subscribe public void onInteractingChanged(InteractingChanged interactingChanged) { From de9b8ac6897a8827e1ee114fb31fd1ba04aa431e Mon Sep 17 00:00:00 2001 From: 15987632 Date: Mon, 13 May 2019 19:55:56 -0400 Subject: [PATCH 19/20] me start --- .../main/java/net/runelite/api/Varbits.java | 9 +++ .../client/plugins/dpscounter/Boss.java | 65 +++++++++++++++++-- .../plugins/dpscounter/DpsCounterPlugin.java | 40 +++++++++++- 3 files changed, 109 insertions(+), 5 deletions(-) diff --git a/runelite-api/src/main/java/net/runelite/api/Varbits.java b/runelite-api/src/main/java/net/runelite/api/Varbits.java index f1768c2aaf..0a3fa6038f 100644 --- a/runelite-api/src/main/java/net/runelite/api/Varbits.java +++ b/runelite-api/src/main/java/net/runelite/api/Varbits.java @@ -293,6 +293,15 @@ public enum Varbits */ THEATRE_OF_BLOOD(6440), + /** + * Theatre of Blood orb varbits each number stands for the player's health on a scale of 1-27 (I think), 0 hides the orb + */ + THEATRE_OF_BLOOD_ORB_1(6442), + THEATRE_OF_BLOOD_ORB_2(6443), + THEATRE_OF_BLOOD_ORB_3(6444), + THEATRE_OF_BLOOD_ORB_4(6445), + THEATRE_OF_BLOOD_ORB_5(6446), + /** * Nightmare Zone */ diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/Boss.java b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/Boss.java index bfd4587e25..b8ff7325cf 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/Boss.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/Boss.java @@ -25,12 +25,13 @@ package net.runelite.client.plugins.dpscounter; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import java.util.Map; +import java.util.Set; import lombok.Getter; import lombok.ToString; import net.runelite.api.NpcID; -@Getter @ToString enum Boss { @@ -45,15 +46,66 @@ enum Boss KING_BLACK_DRAGON(1.075f, NpcID.KING_BLACK_DRAGON, NpcID.KING_BLACK_DRAGON_2642, NpcID.KING_BLACK_DRAGON_6502), KRIL_TSUROTH(1.375f, NpcID.KRIL_TSUTSAROTH, NpcID.KRIL_TSUTSAROTH_6495), VENETENATIS(1.4f, NpcID.VENENATIS, NpcID.VENENATIS_6610), - VETION(1.225f, NpcID.VETION, NpcID.VETION_REBORN); + VETION(1.225f, NpcID.VETION, NpcID.VETION_REBORN), + MAIDEN(1f, NpcID.THE_MAIDEN_OF_SUGADINTI, NpcID.THE_MAIDEN_OF_SUGADINTI_8361, NpcID.THE_MAIDEN_OF_SUGADINTI_8362, NpcID.THE_MAIDEN_OF_SUGADINTI_8363, NpcID.THE_MAIDEN_OF_SUGADINTI_8364, NpcID.THE_MAIDEN_OF_SUGADINTI_8365), + BLOAT(new float[]{1.7f, 1.775f, 1.85f}, NpcID.PESTILENT_BLOAT), + NYLOCAS_BOSS(new float[]{1.175f, 1.2f, 1.225f}, NpcID.NYLOCAS_VASILIAS, NpcID.NYLOCAS_VASILIAS_8355, NpcID.NYLOCAS_VASILIAS_8356, NpcID.NYLOCAS_VASILIAS_8357), + SOTETSEG(new float[]{1.525f, 1.6f, 1.675f}, NpcID.SOTETSEG, NpcID.SOTETSEG_8388), + XARPUS(1f, NpcID.XARPUS_8340, NpcID.XARPUS_8341), + VERZIK_P1(1.05f, NpcID.VERZIK_VITUR_8370), + VERZIK_P2(new float[]{1.35f, 1.4f, 1.425f}, NpcID.VERZIK_VITUR_8372), + VERZIK_P3(new float[]{1.675f, 1.75f, 1.85f}, NpcID.VERZIK_VITUR_8374); + private static final Set TOB_BOSSES = ImmutableSet.of(MAIDEN, BLOAT, NYLOCAS_BOSS, SOTETSEG, XARPUS, VERZIK_P1, VERZIK_P2, VERZIK_P3); + + @Getter private final int[] ids; - private final float modifier; // Some NPCs have a modifier to the experience a player receives. + private final int[] minions; + private final float[] modifier; // Some NPCs have a modifier to the experience a player receives. Boss(float modifier, int... ids) { - this.modifier = modifier; + this.modifier = new float[]{modifier}; this.ids = ids; + this.minions = null; + } + + Boss(float[] modifiers, int... ids) + { + this(modifiers, null, ids); + } + + Boss(float[] modifiers, int[] minions, int ... ids) + { + this.ids = ids; + this.modifier = modifiers; + this.minions = minions; + } + + float getModifier() + { + return modifier[0]; + } + + float getModifier(int partySize) + { + if (modifier.length == 1) + { + return modifier[0]; + } + + if (partySize == 5) + { + return modifier[2]; + } + else if (partySize == 4) + { + return modifier[1]; + } + else + { + return modifier[0]; + } } private static final Map BOSS_MAP; @@ -63,6 +115,11 @@ enum Boss return BOSS_MAP.get(id); } + static boolean isTOB(Boss boss) + { + return TOB_BOSSES.contains(boss); + } + static { ImmutableMap.Builder builder = ImmutableMap.builder(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java index 8352b4e63d..79693838f4 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java @@ -1,8 +1,10 @@ package net.runelite.client.plugins.dpscounter; +import com.google.common.collect.ImmutableSet; import com.google.inject.Inject; import com.google.inject.Provides; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import lombok.AccessLevel; import lombok.Getter; @@ -13,6 +15,7 @@ import net.runelite.api.MenuAction; import net.runelite.api.NPC; import net.runelite.api.Player; import net.runelite.api.Skill; +import net.runelite.api.Varbits; import net.runelite.api.events.ExperienceChanged; import net.runelite.api.events.InteractingChanged; import net.runelite.api.events.NpcDespawned; @@ -51,6 +54,10 @@ public class DpsCounterPlugin extends Plugin @Inject private DpsOverlay dpsOverlay; + static private final Set TOB_PARTY_ORBS_VARBITS = ImmutableSet.of(Varbits.THEATRE_OF_BLOOD_ORB_1, + Varbits.THEATRE_OF_BLOOD_ORB_2, Varbits.THEATRE_OF_BLOOD_ORB_3, Varbits.THEATRE_OF_BLOOD_ORB_4, + Varbits.THEATRE_OF_BLOOD_ORB_5); + private Boss boss; private NPC bossNpc; private int lastHpExp = -1; @@ -125,7 +132,20 @@ public class DpsCounterPlugin extends Plugin } final int delta = xp - lastHpExp; - final int hit = getHit(boss.getModifier(), delta); + + float modifier; + if (Boss.isTOB(boss)) + { + int partySize = getTobPartySize(); + System.out.println(partySize); + modifier = boss.getModifier(partySize); + } + else + { + modifier = boss.getModifier(); + } + + final int hit = getHit(modifier, delta); lastHpExp = xp; // Update local member @@ -245,4 +265,22 @@ public class DpsCounterPlugin extends Plugin float damageOutput = (deltaExperience * modifierBase) / 1.3333f; return Math.round(damageOutput); } + + private int getTobPartySize() + { + int partySize = 0; + for (Varbits varbit : TOB_PARTY_ORBS_VARBITS) + { + if (client.getVar(varbit) != 0) + { + partySize++; + System.out.println(varbit.getId() + ": " + client.getVar(varbit)); + } + else + { + break; + } + } + return partySize; + } } From 4967ab87f2accd93406c4cdfe45a7f2f0d5185ea Mon Sep 17 00:00:00 2001 From: James Munson Date: Sun, 16 Jun 2019 03:30:31 -0700 Subject: [PATCH 20/20] Removed --- .../client/plugins/dpscounter/Boss.java | 135 --------- .../client/plugins/dpscounter/DpsConfig.java | 20 -- .../plugins/dpscounter/DpsCounterPlugin.java | 286 ------------------ .../client/plugins/dpscounter/DpsMember.java | 54 ---- .../client/plugins/dpscounter/DpsOverlay.java | 66 ---- .../client/plugins/dpscounter/DpsUpdate.java | 13 - 6 files changed, 574 deletions(-) delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/Boss.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsConfig.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsMember.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsOverlay.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsUpdate.java diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/Boss.java b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/Boss.java deleted file mode 100644 index b8ff7325cf..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/Boss.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 2018, Raqes - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.dpscounter; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import java.util.Map; -import java.util.Set; -import lombok.Getter; -import lombok.ToString; -import net.runelite.api.NpcID; - -@ToString -enum Boss -{ - ABYSSAL_SIRE(1.25f, NpcID.ABYSSAL_SIRE, NpcID.ABYSSAL_SIRE_5887, NpcID.ABYSSAL_SIRE_5888, NpcID.ABYSSAL_SIRE_5889, NpcID.ABYSSAL_SIRE_5890, NpcID.ABYSSAL_SIRE_5891, NpcID.ABYSSAL_SIRE_5908), - CALLISTO(1.225f, NpcID.CALLISTO, NpcID.CALLISTO_6609), - CERBERUS(1.15f, NpcID.CERBERUS, NpcID.CERBERUS_5863, NpcID.CERBERUS_5866), - CHAOS_ELEMENTAL(1.075f, NpcID.CHAOS_ELEMENTAL, NpcID.CHAOS_ELEMENTAL_6505), - CORPOREAL_BEAST(1.55f, NpcID.CORPOREAL_BEAST), - GENERAL_GRAARDOR(1.325f, NpcID.GENERAL_GRAARDOR, NpcID.GENERAL_GRAARDOR_6494), - GIANT_MOLE(1.075f, NpcID.GIANT_MOLE, NpcID.GIANT_MOLE_6499), - KALPHITE_QUEEN(1.05f, NpcID.KALPHITE_QUEEN, NpcID.KALPHITE_QUEEN_963, NpcID.KALPHITE_QUEEN_965, NpcID.KALPHITE_QUEEN_4303, NpcID.KALPHITE_QUEEN_4304, NpcID.KALPHITE_QUEEN_6500, NpcID.KALPHITE_QUEEN_6501), - KING_BLACK_DRAGON(1.075f, NpcID.KING_BLACK_DRAGON, NpcID.KING_BLACK_DRAGON_2642, NpcID.KING_BLACK_DRAGON_6502), - KRIL_TSUROTH(1.375f, NpcID.KRIL_TSUTSAROTH, NpcID.KRIL_TSUTSAROTH_6495), - VENETENATIS(1.4f, NpcID.VENENATIS, NpcID.VENENATIS_6610), - VETION(1.225f, NpcID.VETION, NpcID.VETION_REBORN), - MAIDEN(1f, NpcID.THE_MAIDEN_OF_SUGADINTI, NpcID.THE_MAIDEN_OF_SUGADINTI_8361, NpcID.THE_MAIDEN_OF_SUGADINTI_8362, NpcID.THE_MAIDEN_OF_SUGADINTI_8363, NpcID.THE_MAIDEN_OF_SUGADINTI_8364, NpcID.THE_MAIDEN_OF_SUGADINTI_8365), - BLOAT(new float[]{1.7f, 1.775f, 1.85f}, NpcID.PESTILENT_BLOAT), - NYLOCAS_BOSS(new float[]{1.175f, 1.2f, 1.225f}, NpcID.NYLOCAS_VASILIAS, NpcID.NYLOCAS_VASILIAS_8355, NpcID.NYLOCAS_VASILIAS_8356, NpcID.NYLOCAS_VASILIAS_8357), - SOTETSEG(new float[]{1.525f, 1.6f, 1.675f}, NpcID.SOTETSEG, NpcID.SOTETSEG_8388), - XARPUS(1f, NpcID.XARPUS_8340, NpcID.XARPUS_8341), - VERZIK_P1(1.05f, NpcID.VERZIK_VITUR_8370), - VERZIK_P2(new float[]{1.35f, 1.4f, 1.425f}, NpcID.VERZIK_VITUR_8372), - VERZIK_P3(new float[]{1.675f, 1.75f, 1.85f}, NpcID.VERZIK_VITUR_8374); - - private static final Set TOB_BOSSES = ImmutableSet.of(MAIDEN, BLOAT, NYLOCAS_BOSS, SOTETSEG, XARPUS, VERZIK_P1, VERZIK_P2, VERZIK_P3); - - @Getter - private final int[] ids; - private final int[] minions; - private final float[] modifier; // Some NPCs have a modifier to the experience a player receives. - - Boss(float modifier, int... ids) - { - this.modifier = new float[]{modifier}; - this.ids = ids; - this.minions = null; - } - - Boss(float[] modifiers, int... ids) - { - this(modifiers, null, ids); - } - - Boss(float[] modifiers, int[] minions, int ... ids) - { - this.ids = ids; - this.modifier = modifiers; - this.minions = minions; - } - - float getModifier() - { - return modifier[0]; - } - - float getModifier(int partySize) - { - if (modifier.length == 1) - { - return modifier[0]; - } - - if (partySize == 5) - { - return modifier[2]; - } - else if (partySize == 4) - { - return modifier[1]; - } - else - { - return modifier[0]; - } - } - - private static final Map BOSS_MAP; - - static Boss findBoss(int id) - { - return BOSS_MAP.get(id); - } - - static boolean isTOB(Boss boss) - { - return TOB_BOSSES.contains(boss); - } - - static - { - ImmutableMap.Builder builder = ImmutableMap.builder(); - for (Boss boss : values()) - { - for (int id : boss.ids) - { - builder.put(id, boss); - } - } - BOSS_MAP = builder.build(); - } -} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsConfig.java deleted file mode 100644 index 6845168f09..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsConfig.java +++ /dev/null @@ -1,20 +0,0 @@ -package net.runelite.client.plugins.dpscounter; - -import net.runelite.client.config.Config; -import net.runelite.client.config.ConfigGroup; -import net.runelite.client.config.ConfigItem; - -@ConfigGroup("dpscounter") -public interface DpsConfig extends Config -{ - @ConfigItem( - position = 0, - name = "Show Damage", - keyName = "showDamage", - description = "Show total damage instead of DPS" - ) - default boolean showDamage() - { - return false; - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java deleted file mode 100644 index 79693838f4..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsCounterPlugin.java +++ /dev/null @@ -1,286 +0,0 @@ -package net.runelite.client.plugins.dpscounter; - -import com.google.common.collect.ImmutableSet; -import com.google.inject.Inject; -import com.google.inject.Provides; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.extern.slf4j.Slf4j; -import net.runelite.api.Actor; -import net.runelite.api.Client; -import net.runelite.api.MenuAction; -import net.runelite.api.NPC; -import net.runelite.api.Player; -import net.runelite.api.Skill; -import net.runelite.api.Varbits; -import net.runelite.api.events.ExperienceChanged; -import net.runelite.api.events.InteractingChanged; -import net.runelite.api.events.NpcDespawned; -import net.runelite.api.events.NpcSpawned; -import net.runelite.client.config.ConfigManager; -import net.runelite.client.eventbus.Subscribe; -import net.runelite.client.events.OverlayMenuClicked; -import net.runelite.client.events.PartyChanged; -import net.runelite.client.plugins.Plugin; -import net.runelite.client.plugins.PluginDescriptor; -import net.runelite.client.ui.overlay.OverlayManager; -import net.runelite.client.ws.PartyMember; -import net.runelite.client.ws.PartyService; -import net.runelite.client.ws.WSClient; -import org.apache.commons.lang3.ArrayUtils; - -@PluginDescriptor( - name = "DPS Counter", - description = "counts dps?" -) -@Slf4j -public class DpsCounterPlugin extends Plugin -{ - @Inject - private Client client; - - @Inject - private OverlayManager overlayManager; - - @Inject - private PartyService partyService; - - @Inject - private WSClient wsClient; - - @Inject - private DpsOverlay dpsOverlay; - - static private final Set TOB_PARTY_ORBS_VARBITS = ImmutableSet.of(Varbits.THEATRE_OF_BLOOD_ORB_1, - Varbits.THEATRE_OF_BLOOD_ORB_2, Varbits.THEATRE_OF_BLOOD_ORB_3, Varbits.THEATRE_OF_BLOOD_ORB_4, - Varbits.THEATRE_OF_BLOOD_ORB_5); - - private Boss boss; - private NPC bossNpc; - private int lastHpExp = -1; - @Getter(AccessLevel.PACKAGE) - private final Map members = new ConcurrentHashMap<>(); - - @Provides - DpsConfig provideConfig(ConfigManager configManager) - { - return configManager.getConfig(DpsConfig.class); - } - - @Override - protected void startUp() - { - overlayManager.add(dpsOverlay); - wsClient.registerMessage(DpsUpdate.class); - } - - @Override - protected void shutDown() - { - wsClient.unregisterMessage(DpsUpdate.class); - overlayManager.remove(dpsOverlay); - members.clear(); - boss = null; - } - - @Subscribe - public void onPartyChanged(PartyChanged partyChanged) - { - members.clear(); - } - - @Subscribe - public void onInteractingChanged(InteractingChanged interactingChanged) - { - Actor source = interactingChanged.getSource(); - Actor target = interactingChanged.getTarget(); - - if (source != client.getLocalPlayer()) - { - return; - } - - if (target instanceof NPC) - { - NPC npc = (NPC) target; - int npcId = npc.getId(); - Boss boss = Boss.findBoss(npcId); - if (boss != null) - { - this.boss = boss; - bossNpc = (NPC) target; - } - } - } - - @Subscribe - public void onExperienceChanged(ExperienceChanged experienceChanged) - { - if (experienceChanged.getSkill() != Skill.HITPOINTS) - { - return; - } - - final int xp = client.getSkillExperience(Skill.HITPOINTS); - if (boss == null || lastHpExp < 0 || xp <= lastHpExp) - { - lastHpExp = xp; - return; - } - - final int delta = xp - lastHpExp; - - float modifier; - if (Boss.isTOB(boss)) - { - int partySize = getTobPartySize(); - System.out.println(partySize); - modifier = boss.getModifier(partySize); - } - else - { - modifier = boss.getModifier(); - } - - final int hit = getHit(modifier, delta); - lastHpExp = xp; - - // Update local member - PartyMember localMember = partyService.getLocalMember(); - Player player = client.getLocalPlayer(); - // If not in a party, user local player name - final String name = localMember == null ? player.getName() : localMember.getName(); - DpsMember dpsMember = members.computeIfAbsent(name, n -> new DpsMember(name)); - dpsMember.addDamage(hit); - - if (dpsMember.isPaused()) - { - dpsMember.unpause(); - log.debug("Unpausing {}", dpsMember.getName()); - } - - if (hit > 0 && !partyService.getMembers().isEmpty()) - { - // Check the player is attacking the boss - if (bossNpc != null && player.getInteracting() == bossNpc) - { - final DpsUpdate specialCounterUpdate = new DpsUpdate(bossNpc.getId(), hit); - specialCounterUpdate.setMemberId(partyService.getLocalMember().getMemberId()); - wsClient.send(specialCounterUpdate); - } - } - } - - @Subscribe - public void onDpsUpdate(DpsUpdate dpsUpdate) - { - if (partyService.getLocalMember().getMemberId().equals(dpsUpdate.getMemberId())) - { - return; - } - - String name = partyService.getMemberById(dpsUpdate.getMemberId()).getName(); - if (name == null) - { - return; - } - - // Hmm - not attacking the same boss I am - if (bossNpc == null || dpsUpdate.getNpcId() != bossNpc.getId()) - { - return; - } - - DpsMember dpsMember = members.computeIfAbsent(name, DpsMember::new); - dpsMember.addDamage(dpsUpdate.getHit()); - - if (dpsMember.isPaused()) - { - dpsMember.unpause(); - log.debug("Unpausing {}", dpsMember.getName()); - } - } - - @Subscribe - public void onOverlayMenuClicked(OverlayMenuClicked event) - { - if (event.getEntry().getMenuAction() == MenuAction.RUNELITE_OVERLAY && - event.getEntry().getOption().equals("Reset") && - event.getEntry().getTarget().equals("DPS counter")) - { - members.clear(); - } - } - - @Subscribe - public void onNpcSpawned(NpcSpawned npcSpawned) - { - if (boss == null) - { - return; - } - - NPC npc = npcSpawned.getNpc(); - int npcId = npc.getId(); - if (!ArrayUtils.contains(boss.getIds(), npcId)) - { - return; - } - - log.debug("Boss has spawned!"); - bossNpc = npc; - } - - @Subscribe - public void onNpcDespawned(NpcDespawned npcDespawned) - { - if (bossNpc == null || npcDespawned.getNpc() != bossNpc) - { - return; - } - - if (bossNpc.isDead()) - { - log.debug("Boss has died!"); - pause(); - } - - bossNpc = null; - } - - private void pause() - { - for (DpsMember dpsMember : members.values()) - { - dpsMember.pause(); - } - } - - private int getHit(float modifier, int deltaExperience) - { - float modifierBase = 1f / modifier; - float damageOutput = (deltaExperience * modifierBase) / 1.3333f; - return Math.round(damageOutput); - } - - private int getTobPartySize() - { - int partySize = 0; - for (Varbits varbit : TOB_PARTY_ORBS_VARBITS) - { - if (client.getVar(varbit) != 0) - { - partySize++; - System.out.println(varbit.getId() + ": " + client.getVar(varbit)); - } - else - { - break; - } - } - return partySize; - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsMember.java b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsMember.java deleted file mode 100644 index fd109479a0..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsMember.java +++ /dev/null @@ -1,54 +0,0 @@ -package net.runelite.client.plugins.dpscounter; - -import java.time.Duration; -import java.time.Instant; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -@RequiredArgsConstructor -@Getter -class DpsMember -{ - private final String name; - private Instant start = Instant.now(); - private Instant end; - private int damage; - - void addDamage(int amount) - { - damage += amount; - } - - float getDps() - { - Instant now = end == null ? Instant.now() : end; - int diff = (int) (now.toEpochMilli() - start.toEpochMilli()) / 1000; - if (diff == 0) - { - return 0; - } - - return (float) damage / (float) diff; - } - - void pause() - { - end = Instant.now(); - } - - boolean isPaused() - { - return end != null; - } - - void unpause() - { - if (end == null) - { - return; - } - - start = start.plus(Duration.between(end, Instant.now())); - end = null; - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsOverlay.java deleted file mode 100644 index 2d1f664fe7..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsOverlay.java +++ /dev/null @@ -1,66 +0,0 @@ -package net.runelite.client.plugins.dpscounter; - -import java.awt.Dimension; -import java.awt.Graphics2D; -import java.text.DecimalFormat; -import java.util.Map; -import javax.inject.Inject; -import static net.runelite.api.MenuAction.RUNELITE_OVERLAY; -import net.runelite.client.ui.overlay.Overlay; -import net.runelite.client.ui.overlay.OverlayMenuEntry; -import net.runelite.client.ui.overlay.components.LineComponent; -import net.runelite.client.ui.overlay.components.PanelComponent; -import net.runelite.client.ui.overlay.components.TitleComponent; -import net.runelite.client.ws.PartyService; - -public class DpsOverlay extends Overlay -{ - private static final DecimalFormat DPS_FORMAT = new DecimalFormat("#0.0"); - - private final DpsCounterPlugin dpsCounterPlugin; - private final DpsConfig dpsConfig; - private final PartyService partyService; - - private final PanelComponent panelComponent = new PanelComponent(); - - @Inject - DpsOverlay(DpsCounterPlugin dpsCounterPlugin, DpsConfig dpsConfig, PartyService partyService) - { - super(dpsCounterPlugin); - this.dpsCounterPlugin = dpsCounterPlugin; - this.dpsConfig = dpsConfig; - this.partyService = partyService; - getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY, "Reset", "DPS counter")); - } - - @Override - public Dimension render(Graphics2D graphics) - { - Map dpsMembers = dpsCounterPlugin.getMembers(); - if (dpsMembers.isEmpty()) - { - return null; - } - - boolean inParty = !partyService.getMembers().isEmpty(); - boolean showDamage = dpsConfig.showDamage(); - - panelComponent.getChildren().clear(); - - panelComponent.getChildren().add( - TitleComponent.builder() - .text(inParty ? "Party DPS" : "DPS") - .build()); - - for (DpsMember dpsMember : dpsMembers.values()) - { - panelComponent.getChildren().add( - LineComponent.builder() - .left(dpsMember.getName()) - .right(showDamage ? Integer.toString(dpsMember.getDamage()) : DPS_FORMAT.format(dpsMember.getDps())) - .build()); - } - - return panelComponent.render(graphics); - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsUpdate.java b/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsUpdate.java deleted file mode 100644 index 5aa02da373..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/dpscounter/DpsUpdate.java +++ /dev/null @@ -1,13 +0,0 @@ -package net.runelite.client.plugins.dpscounter; - -import lombok.EqualsAndHashCode; -import lombok.Value; -import net.runelite.http.api.ws.messages.party.PartyMemberMessage; - -@Value -@EqualsAndHashCode(callSuper = true) -public class DpsUpdate extends PartyMemberMessage -{ - private int npcId; - private int hit; -}