74 lines
1.7 KiB
Java
74 lines
1.7 KiB
Java
package com.example.essentialsplus.helpers.combat;
|
|||
|
|
|
||
|
|
import com.example.essentialsplus.helpers.combat.variablespeed.state.TickCount;
|
||
|
|
import java.util.ArrayDeque;
|
||
|
|
import net.runelite.api.Skill;
|
||
|
|
import net.runelite.api.events.FakeXpDrop;
|
||
|
|
import net.runelite.api.events.StatChanged;
|
||
|
|
|
||
|
|
public class Damage
|
||
|
|
{
|
||
|
|
private static final double MODIFIER = 1;
|
||
|
|
private static final double GLOBAL_MODIFIER = 1;
|
||
|
|
|
||
|
|
private final ArrayDeque<Integer> hpExpEarned = new ArrayDeque<>();
|
||
|
|
private final ArrayDeque<Integer> hpExpEarnedTickCount = new ArrayDeque<>();
|
||
|
|
|
||
|
|
public boolean onXpDrop(StatChanged event, TickCount tc)
|
||
|
|
{
|
||
|
|
if (event.getSkill() != Skill.HITPOINTS)
|
||
|
|
{
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
hpExpEarnedTickCount.addLast(tc.get());
|
||
|
|
hpExpEarned.addLast(event.getXp());
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
|
||
|
|
public boolean onXpDrop(FakeXpDrop event, TickCount tc)
|
||
|
|
{
|
||
|
|
if (event.getSkill() != Skill.HITPOINTS)
|
||
|
|
{
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
hpExpEarnedTickCount.addLast(tc.get());
|
||
|
|
hpExpEarnedTickCount.addLast(tc.get());
|
||
|
|
hpExpEarned.addLast(0);
|
||
|
|
hpExpEarned.addLast(event.getXp());
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
|
||
|
|
public int compute(TickCount tc)
|
||
|
|
{
|
||
|
|
if (hpExpEarnedTickCount.isEmpty())
|
||
|
|
{
|
||
|
|
return -1;
|
||
|
|
}
|
||
|
|
final int lastTc = hpExpEarnedTickCount.getLast();
|
||
|
|
if (!tc.isWithinNTicks(lastTc, 1))
|
||
|
|
{
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
final double xp = (double) CombatUtils.getLastDelta(hpExpEarned);
|
||
|
|
return (int) Math.round(xp * (3.0d / 4.0d) * MODIFIER * GLOBAL_MODIFIER);
|
||
|
|
}
|
||
|
|
|
||
|
|
public void onTick()
|
||
|
|
{
|
||
|
|
while (hpExpEarnedTickCount.size() > 5)
|
||
|
|
{
|
||
|
|
hpExpEarnedTickCount.removeFirst();
|
||
|
|
}
|
||
|
|
while (hpExpEarned.size() > 5)
|
||
|
|
{
|
||
|
|
hpExpEarned.removeFirst();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public void reset()
|
||
|
|
{
|
||
|
|
hpExpEarned.clear();
|
||
|
|
hpExpEarnedTickCount.clear();
|
||
|
|
}
|
||
|
|
}
|