Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ Ticks until next attack may be enabled over your player's head.

## Updates

## 1.3.5 - 1.3.7
## 1.3.5 - 1.3.8

* Support for The Fractured Archive weapons
* Obligator (3 tick, 5 tick thrust)
* Ascension crossbows (2 tick on rapid)
* Zorya's tome (3 tick). A landed special attack makes the next 3 attacks 2 tick, or the next 5 if two specials in a row land
* Buffed attacks expiry after 30 seconds or if the player teleports.
* Fix the timer not showing with weapons from new weapon categories (e.g. Zorya's tome)
* Fixes for Doom and Volatile earth with demonbane weapons setting cooldown to 1 incorrectly
* Support more than one overlay layer for the attack bar (see [#202](https://github.com/ngraves95/attacktimer/issues/202))
Expand Down
2 changes: 1 addition & 1 deletion runelite-plugin.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
displayName=AttackTimer
author=ngraves95,Lexer747
build=standard
version=1.3.7
version=1.3.8
description=A plugin to countdown until your next attack
tags=pvm,timer,attack,combat,weapon
plugins=com.attacktimer.AttackTimerMetronomePlugin
11 changes: 7 additions & 4 deletions src/main/java/com/attacktimer/AttackSpeed.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class AttackSpeed
}

private ArrayDeque<Integer> specialPercentageEvents = new ArrayDeque<Integer>();
private int specChangedTick = -1;
private final Damage damage = new Damage();
@Getter
private int dmgDealt = -1;
Expand Down Expand Up @@ -94,15 +95,15 @@ public int compute(final Client client, final AnimationData curAnimation, final
// We are currently dealing with a staves in which case we can make decisions based on the
// spellbook flag. We can only improve this by using a deprecated API to check the projectile
// matches the stave rather than a manual spell, but this is good enough for now.
return VariableSpeed.compute(client, curAnimation, AttackProcedure.POWERED_STAVE, spellbook, dmgDealt, specDelta, 4);
return VariableSpeed.compute(client, curAnimation, AttackProcedure.POWERED_STAVE, spellbook, dmgDealt, specDelta, specChangedTick, 4);
}

if (matchesSpellbook(client, curAnimation, spellbook)
&& ManualCasting.is(client, curAnimation, soundEffectTick, soundEffectId))
{
isUsingMagic = true;
// You can cast with anything equipped in which case we shouldn't look to invent for speed.
return VariableSpeed.compute(client, curAnimation, AttackProcedure.MANUAL_AUTO_CAST, spellbook, dmgDealt, specDelta, getMagicBaseSpeed(weaponId));
return VariableSpeed.compute(client, curAnimation, AttackProcedure.MANUAL_AUTO_CAST, spellbook, dmgDealt, specDelta, specChangedTick, getMagicBaseSpeed(weaponId));
}

isUsingMagic = false;
Expand All @@ -112,12 +113,12 @@ public int compute(final Client client, final AnimationData curAnimation, final
// For now we assume the only sailing specific weapon is
// https://oldschool.runescape.wiki/w/Cannon_(facility) if they add other facilities which can
// "attack" that assumption obviously needs re-visiting. The cannons currently are all 7-tick.
return VariableSpeed.compute(client, curAnimation, AttackProcedure.MELEE_OR_RANGE, spellbook, dmgDealt, specDelta, 7);
return VariableSpeed.compute(client, curAnimation, AttackProcedure.MELEE_OR_RANGE, spellbook, dmgDealt, specDelta, specChangedTick, 7);
}

final int aspeed = Utils.getWeaponSpeed(client, itemManager, weaponId);
// Deadline for next available attack.
return VariableSpeed.compute(client, curAnimation, AttackProcedure.MELEE_OR_RANGE, spellbook, dmgDealt, specDelta, aspeed);
return VariableSpeed.compute(client, curAnimation, AttackProcedure.MELEE_OR_RANGE, spellbook, dmgDealt, specDelta, specChangedTick, aspeed);
}

public void onTick()
Expand All @@ -132,6 +133,7 @@ public void onTick()
public void varbitSpecialAttackChanged(final int value)
{
specialPercentageEvents.addLast(value);
specChangedTick = tickCount.get();
}

public boolean onXpDrop(final FakeXpDrop event)
Expand Down Expand Up @@ -197,6 +199,7 @@ public void reset()
soundEffectTick = -1;
isUsingMagic = false;
specialPercentageEvents.clear();
specChangedTick = -1;
damage.reset();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ default boolean debugLogs()
@ConfigItem(
position = 10000,
keyName = "attacktimerVersion",
name = "Plugin version: v1.3.7",
name = "Plugin version: v1.3.8",
description = ""
)
default void version()
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/attacktimer/VariableSpeed/Amoxliatl.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public class Amoxliatl implements IVariableSpeed
private static final int AMOXLIATL_REGION_ID = 5446;

public int apply(final Client client, final AnimationData curAnimation, final AttackProcedure atkType,
final Spellbook spellbook, final int damageDealt, final int lastSpecDelta, final int baseSpeed,
final int curSpeed)
final Spellbook spellbook, final int damageDealt, final int lastSpecDelta, final int specChangedTick,
final int baseSpeed, final int curSpeed)
{
final WorldPoint location = Utils.getLocalLocation(client);
final int targetId = Utils.getTargetId(client);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/attacktimer/VariableSpeed/BloodMoonSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
public class BloodMoonSet implements IVariableSpeed
{
public int apply(final Client client, final AnimationData curAnimation, final AttackProcedure atkType,
final Spellbook spellbook, final int damageDealt, final int lastSpecDelta, final int baseSpeed,
final int curSpeed)
final Spellbook spellbook, final int damageDealt, final int lastSpecDelta, final int specChangedTick,
final int baseSpeed, final int curSpeed)
{
if (client.getLocalPlayer().hasSpotAnim(SpotanimID.SPECIAL_DUAL_MACUAHUITL_SPOTANIM))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ else if (npcId == NpcID.DOM_BOSS)

// Take care here to ensure no infinite loop or affect on the speed as the onRender does call this via variable speed
public int apply(final Client client, final AnimationData curAnimation, final AttackProcedure atkType,
final Spellbook spellbook, final int damageDealt, final int lastSpecDelta, final int baseSpeed,
final int curSpeed)
final Spellbook spellbook, final int damageDealt, final int lastSpecDelta, final int specChangedTick,
final int baseSpeed, final int curSpeed)
{
final int targetId = Utils.getTargetId(client);
final boolean inDoom = Utils.isInRegionId(client, DOOM_REGION_IDS);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/attacktimer/VariableSpeed/EyeOfAyak.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
public class EyeOfAyak implements IVariableSpeed
{
public int apply(final Client client, final AnimationData curAnimation, final AttackProcedure atkType,
final Spellbook spellbook, final int damageDealt, final int lastSpecDelta, final int baseSpeed,
final int curSpeed)
final Spellbook spellbook, final int damageDealt, final int lastSpecDelta, final int specChangedTick,
final int baseSpeed, final int curSpeed)
{
// https://oldschool.runescape.wiki/w/Eye_of_ayak#Charged
// https://oldschool.runescape.wiki/w/Eye_of_ayak#Special_attack
Expand Down
49 changes: 39 additions & 10 deletions src/main/java/com/attacktimer/VariableSpeed/FracturedArchive.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.attacktimer.Attacking.Attacking;
import com.attacktimer.ClientUtils.Utils;
import com.attacktimer.Spellbook;
import com.attacktimer.VariableSpeed.State.Teleported;
import com.attacktimer.VariableSpeed.State.TickCount;
import net.runelite.api.Actor;
import net.runelite.api.Client;
Expand All @@ -45,32 +46,43 @@
public class FracturedArchive implements IVariableSpeed
{
private static final int ZORYA_FAST_ATTACKS = 3;
// The buff only last for 30 seconds after landing (30 * 0.6 = 50)
private static final int ZORYA_TIMEOUT_TICKS = 50;

private final TickCount tickCount;
// Tome attacks expire when the player teleports so use the tracker
private final Teleported tp;

// In order to track if the buff has timed out store when the spec lands (or is refreshed).
private int zoryaSpecTick = -1;

// Buffed (2t) Zorya's tome attacks left after the current attack.
private int zoryaFastAttacksRemaining = 0;
// The speed can be computed more than once for the same attack (again when the xp drop arrives), so the
// buff is always recomputed from the state it had before the first computation on that tick.
private int zoryaAttackTick = -1;
private int zoryaFastAttacksBeforeAttack = 0;

FracturedArchive(final TickCount tc)
FracturedArchive(final TickCount tc, final Teleported tp)
{
this.tickCount = tc;
this.tp = tp;
}

public int apply(final Client client, final AnimationData curAnimation, final AttackProcedure atkType,
final Spellbook spellbook, final int damageDealt, final int lastSpecDelta, final int baseSpeed,
final int curSpeed)
final Spellbook spellbook, final int damageDealt, final int lastSpecDelta, final int specChangedTick,
final int baseSpeed, final int curSpeed)
{
if (curAnimation == null)
{
return curSpeed;
}
// There is a specific edge case with the tome if you attack on the tick that the death charge (other
// spells may also trigger this) animation ends, you end on a null animation and the attack for the
// tome only has spot anim. Therefore to ensure that the later switch statements can fall into the
// `default` cases, we set some arbitrary animation here. With java21 we could do this a bit nicer
// with `case null ->` alas.
final var safeCurAnimation = curAnimation == null ? AnimationData.MAGIC_WARPED_SCEPTRE : curAnimation;
final int weaponId = Utils.getWeaponId(client);
if (isObligator(weaponId))
{
switch (curAnimation)
switch (safeCurAnimation)
{
case MELEE_OBLIGATOR:
case MELEE_OBLIGATOR_FEMALE:
Expand All @@ -95,7 +107,7 @@ public int apply(final Client client, final AnimationData curAnimation, final At
else if (isZoryasTome(weaponId))
{
final boolean hit = successfulHit(client, damageDealt);
switch (curAnimation)
switch (safeCurAnimation)
{
case MAGIC_ZORYA_TOME_SPEC:
case MAGIC_ZORYA_TOME_SPEC_FEMALE:
Expand All @@ -107,7 +119,9 @@ else if (isZoryasTome(weaponId))
// A player may be attacking but also summoning a thrall, (or some other way to hide the
// animation) in which case we should infer speed/spec from delta
final Player localPlayer = client.getLocalPlayer();
final boolean specAndHit = hit && (lastSpecDelta == -500 || Attacking.getZoryaSpecAttack(localPlayer));
// Ensure the delta was within a tick, otherwise consecutive attacks all look like specs.
final boolean fromDelta = lastSpecDelta == -500 && tickCount.isWithinNTicks(specChangedTick, 1);
final boolean specAndHit = hit && (fromDelta || Attacking.getZoryaSpecAttack(localPlayer));
return zoryaAttackSpeed(specAndHit);
// Since we know the weapon ID we should always use `zoryaAttackSpeed` to track fast attacks
// accurately
Expand Down Expand Up @@ -138,16 +152,25 @@ private int zoryaAttackSpeed(final boolean isSpecAndHit)
zoryaAttackTick = tick;
zoryaFastAttacksBeforeAttack = zoryaFastAttacksRemaining;
}
if (specExpired(tick))
{
zoryaFastAttacksRemaining = 0;
zoryaFastAttacksBeforeAttack = 0;
zoryaSpecTick = -1;
}
int remaining = zoryaFastAttacksBeforeAttack;
int speed = 3;
if (remaining > 0)
{
remaining--;
speed = 2;
// the 30 second window is refreshed each time it's used
zoryaSpecTick = tick;
}
if (isSpecAndHit)
{
remaining += ZORYA_FAST_ATTACKS;
zoryaSpecTick = tick; // note when the spec happened to time it out properly
}
zoryaFastAttacksRemaining = remaining;
return speed;
Expand All @@ -168,4 +191,10 @@ private boolean successfulHit(final Client client, final int damageDealt)
}
return false;
}

private boolean specExpired(final int tick)
{
final int end = zoryaSpecTick + ZORYA_TIMEOUT_TICKS;
return tick > end || tp.TeleportedInWindow(zoryaSpecTick, end);
}
}
26 changes: 14 additions & 12 deletions src/main/java/com/attacktimer/VariableSpeed/IVariableSpeed.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,19 @@ public interface IVariableSpeed extends IStateTracker
* attacking and hence a new cooldown. to ensure a new IVariableSpeed implementation is used ensure
* to add a new instance of that class in {@see VariableSpeed.toApply}.
*
* @param client the RuneScape client.
* @param curAnimation the animation currently being used to attack.
* @param atkType the overarching "attack type" for this attack, this is based on all the
* inference made about manual casts, etc. For more details about the attack
* {@see com.attacktimer.ClientUtils.Utils}.
* @param damageDealt the amount of damage being dealt by this attack (still WIP)
* @param lastSpecDelta the amount of spec consumed or generated by this attack (in 100s of percent,
* so consuming 25% spec would be -250.)
* @param baseSpeed the speed at which the attack speed started before any other variable speeds
* have changed it.
* @param curSpeed the current speed at which the attack is now after variable speeds have been
* applied, e.g. rapid with range style.
* @param client the RuneScape client.
* @param curAnimation the animation currently being used to attack.
* @param atkType the overarching "attack type" for this attack, this is based on all the
* inference made about manual casts, etc. For more details about the attack
* {@see com.attacktimer.ClientUtils.Utils}.
* @param damageDealt the amount of damage being dealt by this attack (still WIP)
* @param lastSpecDelta the amount of spec consumed or generated by this attack (in 100s of
* percent, so consuming 25% spec would be -250.)
* @param specChangedTick the tick on which the `lastSpecDelta` changed
* @param baseSpeed the speed at which the attack speed started before any other variable
* speeds have changed it.
* @param curSpeed the current speed at which the attack is now after variable speeds have
* been applied, e.g. rapid with range style.
* @return the new attack speed if the pre-conditions for this variable attack speed where met.
*/
public int apply(
Expand All @@ -60,6 +61,7 @@ public int apply(
final Spellbook spellbook,
final int damageDealt,
final int lastSpecDelta,
final int specChangedTick,
final int baseSpeed,
final int curSpeed
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public class PurgingStaffSpec implements IVariableSpeed

// https://oldschool.runescape.wiki/w/Purging_staff#Special_attack
public int apply(final Client client, final AnimationData curAnimation, final AttackProcedure atkType,
final Spellbook spellbook, final int damageDealt, final int lastSpecDelta, final int baseSpeed,
final int curSpeed)
final Spellbook spellbook, final int damageDealt, final int lastSpecDelta, final int specChangedTick,
final int baseSpeed, final int curSpeed)
{
// For now the plugin only works for yama
if (!this.yama.inYamaRegion)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
public class RapidAttackStyle implements IVariableSpeed
{
public int apply(final Client client, final AnimationData curAnimation, final AttackProcedure atkType,
final Spellbook spellbook, final int damageDealt, final int lastSpecDelta, final int baseSpeed,
final int curSpeed)
final Spellbook spellbook, final int damageDealt, final int lastSpecDelta, final int specChangedTick,
final int baseSpeed, final int curSpeed)
{
// index 1 == rapid
final boolean isRapid = client.getVarpValue(VarPlayerID.COM_MODE) == 1;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/attacktimer/VariableSpeed/RedKerisSpec.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
public class RedKerisSpec implements IVariableSpeed
{
public int apply(final Client client, final AnimationData curAnimation, final AttackProcedure atkType,
final Spellbook spellbook, final int damageDealt, final int lastSpecDelta, final int baseSpeed,
final int curSpeed)
final Spellbook spellbook, final int damageDealt, final int lastSpecDelta, final int specChangedTick,
final int baseSpeed, final int curSpeed)
{
// https://oldschool.runescape.wiki/w/Keris_partisan_of_corruption#Special_attack
if (lastSpecDelta != -750 || curAnimation != AnimationData.MELEE_RED_KERIS_SPEC)
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/attacktimer/VariableSpeed/RoyalTitans.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ public class RoyalTitans implements IVariableSpeed

@Override
public int apply(final Client client, final AnimationData curAnimation, final AttackProcedure atkType,
final Spellbook spellbook, final int damageDealt, final int lastSpecDelta, final int baseSpeed,
final int curSpeed)
final Spellbook spellbook, final int damageDealt, final int lastSpecDelta, final int specChangedTick,
final int baseSpeed, final int curSpeed)
{
if (earlyExit(client, atkType, damageDealt, spellbook))
{
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/attacktimer/VariableSpeed/Scurrius.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ private static boolean attackingGiantRatWithBoneWeapon(final int equipped, final
}

public int apply(final Client client, final AnimationData curAnimation, final AttackProcedure atkType,
final Spellbook spellbook, final int damageDealt, final int lastSpecDelta, final int baseSpeed,
final int curSpeed)
final Spellbook spellbook, final int damageDealt, final int lastSpecDelta, final int specChangedTick,
final int baseSpeed, final int curSpeed)
{
final WorldPoint location = Utils.getLocalLocation(client);
final int weaponId = Utils.getWeaponId(client);
Expand Down
Loading
Loading