corp plugin: use varbit changed event to track damage
In masses it has been observed that the players damage counter can increment after the last hitsplat has been applied, which causes the final damage summary message to be incorrect
This commit is contained in:
@@ -43,6 +43,7 @@ import net.runelite.api.events.HitsplatApplied;
|
||||
import net.runelite.api.events.InteractingChanged;
|
||||
import net.runelite.api.events.NpcDespawned;
|
||||
import net.runelite.api.events.NpcSpawned;
|
||||
import net.runelite.api.events.VarbitChanged;
|
||||
import net.runelite.client.chat.ChatColorType;
|
||||
import net.runelite.client.chat.ChatMessageBuilder;
|
||||
import net.runelite.client.chat.ChatMessageManager;
|
||||
@@ -191,12 +192,6 @@ public class CorpPlugin extends Plugin
|
||||
return;
|
||||
}
|
||||
|
||||
int myDamage = client.getVar(Varbits.CORP_DAMAGE);
|
||||
// sometimes hitsplats are applied after the damage counter has been reset
|
||||
if (myDamage > 0)
|
||||
{
|
||||
yourDamage = myDamage;
|
||||
}
|
||||
totalDamage += hitsplatApplied.getHitsplat().getAmount();
|
||||
}
|
||||
|
||||
@@ -213,4 +208,18 @@ public class CorpPlugin extends Plugin
|
||||
|
||||
players.add(source);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onVarbitChanged(VarbitChanged varbitChanged)
|
||||
{
|
||||
if (corp != null)
|
||||
{
|
||||
int myDamage = client.getVar(Varbits.CORP_DAMAGE);
|
||||
// avoid resetting our counter when the client's is reset
|
||||
if (myDamage > 0)
|
||||
{
|
||||
yourDamage = myDamage;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user