dps counter: fix only boss damage to work in parties
When in a party, "Only boss damage" would work only if everyone in the party had it setup the same. Members who had it enabled would not send their hit to those who had it disabled. Members who had it enabled would receive and count hits from those who had it disabled.
This commit is contained in:
@@ -186,36 +186,36 @@ public class DpsCounterPlugin extends Plugin
|
|||||||
|
|
||||||
Hitsplat hitsplat = hitsplatApplied.getHitsplat();
|
Hitsplat hitsplat = hitsplatApplied.getHitsplat();
|
||||||
|
|
||||||
|
final int npcId = ((NPC) actor).getId();
|
||||||
|
final boolean isBoss = BOSSES.contains(npcId);
|
||||||
|
|
||||||
if (hitsplat.isMine())
|
if (hitsplat.isMine())
|
||||||
{
|
{
|
||||||
final int npcId = ((NPC) actor).getId();
|
int hit = hitsplat.getAmount();
|
||||||
boolean isBoss = BOSSES.contains(npcId);
|
PartyMember localMember = partyService.getLocalMember();
|
||||||
|
|
||||||
|
// broadcast damage
|
||||||
|
if (localMember != null)
|
||||||
|
{
|
||||||
|
final DpsUpdate dpsUpdate = new DpsUpdate(hit, isBoss);
|
||||||
|
dpsUpdate.setMemberId(localMember.getMemberId());
|
||||||
|
wsClient.send(dpsUpdate);
|
||||||
|
}
|
||||||
|
|
||||||
if (dpsConfig.bossDamage() && !isBoss)
|
if (dpsConfig.bossDamage() && !isBoss)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int hit = hitsplat.getAmount();
|
|
||||||
// Update local member
|
|
||||||
PartyMember localMember = partyService.getLocalMember();
|
|
||||||
// If not in a party, user local player name
|
// If not in a party, user local player name
|
||||||
final String name = localMember == null ? player.getName() : localMember.getName();
|
final String name = localMember == null ? player.getName() : localMember.getName();
|
||||||
DpsMember dpsMember = members.computeIfAbsent(name, DpsMember::new);
|
DpsMember dpsMember = members.computeIfAbsent(name, DpsMember::new);
|
||||||
dpsMember.addDamage(hit);
|
dpsMember.addDamage(hit);
|
||||||
|
|
||||||
// broadcast damage
|
|
||||||
if (localMember != null)
|
|
||||||
{
|
|
||||||
final DpsUpdate specialCounterUpdate = new DpsUpdate(hit);
|
|
||||||
specialCounterUpdate.setMemberId(localMember.getMemberId());
|
|
||||||
wsClient.send(specialCounterUpdate);
|
|
||||||
}
|
|
||||||
// apply to total
|
// apply to total
|
||||||
}
|
}
|
||||||
else if (hitsplat.isOthers())
|
else if (hitsplat.isOthers())
|
||||||
{
|
{
|
||||||
final int npcId = ((NPC) actor).getId();
|
|
||||||
boolean isBoss = BOSSES.contains(npcId);
|
|
||||||
if ((dpsConfig.bossDamage() || actor != player.getInteracting()) && !isBoss)
|
if ((dpsConfig.bossDamage() || actor != player.getInteracting()) && !isBoss)
|
||||||
{
|
{
|
||||||
// only track damage to npcs we are attacking, or is a nearby common boss
|
// only track damage to npcs we are attacking, or is a nearby common boss
|
||||||
@@ -246,6 +246,12 @@ public class DpsCounterPlugin extends Plugin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Received non-boss damage, but we only want boss damage
|
||||||
|
if (!dpsUpdate.isBoss() && dpsConfig.bossDamage())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
unpause();
|
unpause();
|
||||||
|
|
||||||
DpsMember dpsMember = members.computeIfAbsent(name, DpsMember::new);
|
DpsMember dpsMember = members.computeIfAbsent(name, DpsMember::new);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2020 Adam <Adam@sigterm.info>
|
* Copyright (c) 2020 Adam <Adam@sigterm.info>
|
||||||
|
* Copyright (c) 2021, Jonathan Rousseau <https://github.com/JoRouss>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -33,4 +34,5 @@ import net.runelite.http.api.ws.messages.party.PartyMemberMessage;
|
|||||||
public class DpsUpdate extends PartyMemberMessage
|
public class DpsUpdate extends PartyMemberMessage
|
||||||
{
|
{
|
||||||
private int hit;
|
private int hit;
|
||||||
|
private boolean isBoss;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user