diff --git a/src/main/java/com/attacktimer/Attacking/Attack.java b/src/main/java/com/attacktimer/Attacking/Attack.java index aa0fb97..4c7062b 100644 --- a/src/main/java/com/attacktimer/Attacking/Attack.java +++ b/src/main/java/com/attacktimer/Attacking/Attack.java @@ -33,14 +33,11 @@ public final class Attack @Getter private final int animationId; @Getter - private final boolean salamander; - @Getter private final Actor target; - public Attack(final int animationId, final boolean salamander, final Actor target) + public Attack(final int animationId, final Actor target) { this.animationId = animationId; - this.salamander = salamander; this.target = target; } } diff --git a/src/main/java/com/attacktimer/Attacking/Attacking.java b/src/main/java/com/attacktimer/Attacking/Attacking.java index df7488b..b26024a 100644 --- a/src/main/java/com/attacktimer/Attacking/Attacking.java +++ b/src/main/java/com/attacktimer/Attacking/Attacking.java @@ -62,21 +62,28 @@ public class Attacking .add(AnimationData.MELEE_OBLIGATOR).add(AnimationData.MELEE_OBLIGATOR_FEMALE) .add(AnimationData.MELEE_OBLIGATOR_MULTIHIT).add(AnimationData.MELEE_OBLIGATOR_MULTIHIT_FEMALE).build(); - // Combat Dummy + Nightmare Pillars - private static final Set SPECIAL_NPCS = new ImmutableSet.Builder() + // Combat Dummy + public static final Set COMBAT_DUMMY = new ImmutableSet.Builder() .add(NpcID.POH_COMBAT_DUMMY_UPGRADED_UNDEADSLAYER_NPC, NpcID.POH_COMBAT_DUMMY_UPGRADED_ETHER_NPC, NpcID.POH_COMBAT_DUMMY_UPGRADED_KQ_NPC, NpcID.POH_COMBAT_DUMMY_UPGRADED_KURASK_NPC, NpcID.POH_COMBAT_DUMMY_UPGRADED_VAMPIRE_NPC, NpcID.POH_COMBAT_DUMMY_UPGRADED_VORKATH_NPC, NpcID.POH_COMBAT_DUMMY_NPC, NpcID.POH_COMBAT_DUMMY_UNDEADSLAYER_NPC, - NpcID.POH_COMBAT_DUMMY_UPGRADED_NPC, NpcID.NIGHTMARE_TOTEM_1_READY, NpcID.NIGHTMARE_TOTEM_2_READY, + NpcID.POH_COMBAT_DUMMY_UPGRADED_NPC) + .build(); + + // Combat Dummy + Nightmare Pillars + private static final Set SPECIAL_NPCS = new ImmutableSet.Builder() + .add(NpcID.NIGHTMARE_TOTEM_1_READY, NpcID.NIGHTMARE_TOTEM_2_READY, NpcID.NIGHTMARE_TOTEM_3_READY, NpcID.NIGHTMARE_TOTEM_4_READY) + .addAll(COMBAT_DUMMY) .build(); public static boolean isPlayerAttacking(final Client client, final NPCManager npcManager, final Map sailingCannons) { final Player localPlayer = client.getLocalPlayer(); final int animationId = localPlayer.getAnimation(); - if (AnimationData.isBlockListAnimation(animationId)) + // Most weapons overwrite blockList animations, apart from the zorya tome, how odd. + if (AnimationData.isBlockListAnimation(animationId) && !getZoryaAttack(localPlayer)) { return false; } @@ -93,7 +100,7 @@ public static boolean isPlayerAttacking(final Client client, final NPCManager np // Not walking is either ANY player animation or the edge cases which don't trigger an animation, // e.g Salamander. - final boolean notWalking = animationId != -1 || getSalamanderAttack(client); + final boolean notWalking = animationId != -1 || getSpotAnimAttack(localPlayer); // Testing if we are attacking by checking the target is more future proof to new weapons which don't // need custom code and the weapon stats are enough. @@ -135,14 +142,33 @@ public static Attack PlayerAttack(final Client client) final Player localPlayer = client.getLocalPlayer(); final int animationId = localPlayer.getAnimation(); final Actor target = localPlayer.getInteracting(); - return new Attack(animationId, getSalamanderAttack(client), target); + return new Attack(animationId, target); + } + + private static boolean getSpotAnimAttack(final Player lp) + { + return getSalamanderAttack(lp) || getZoryaAttack(lp); + } + + private static boolean getSalamanderAttack(final Player lp) + { + return lp.hasSpotAnim(SpotanimID.FIREBREATH); } - private static boolean getSalamanderAttack(final Client client) + private static boolean getZoryaAttack(final Player lp) { - return client.getLocalPlayer().hasSpotAnim(SpotanimID.FIREBREATH); + return lp.hasSpotAnim(SpotanimID.VFX_ZORYA_TOME_STANDARD_SPOTANIM) + || lp.hasSpotAnim(SpotanimID.VFX_ZORYA_TOME_STANDARD_SPOTANIM_FEMALE) + || getZoryaSpecAttack(lp); } + public static boolean getZoryaSpecAttack(final Player lp) + { + return lp.hasSpotAnim(SpotanimID.VFX_ZORYA_TOME_SPEC_SPOTANIM) + || lp.hasSpotAnim(SpotanimID.VFX_ZORYA_TOME_SPEC_SPOTANIM_FEMALE); + } + + private static boolean sailingAttack(final Client client, final Map sailingCannons, final AnimationData anim) { // Normal combat (e.g. shooting a bow) from a boat does follow all the normal rules and therefore diff --git a/src/main/java/com/attacktimer/VariableSpeed/FracturedArchive.java b/src/main/java/com/attacktimer/VariableSpeed/FracturedArchive.java index eb3f2bd..0e80f25 100644 --- a/src/main/java/com/attacktimer/VariableSpeed/FracturedArchive.java +++ b/src/main/java/com/attacktimer/VariableSpeed/FracturedArchive.java @@ -2,6 +2,7 @@ /* * Copyright (c) 2026, Richardant + * Copyright (c) 2026, Lexer747 * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -27,10 +28,14 @@ import com.attacktimer.AnimationData; import com.attacktimer.AttackProcedure; +import com.attacktimer.Attacking.Attacking; import com.attacktimer.ClientUtils.Utils; import com.attacktimer.Spellbook; import com.attacktimer.VariableSpeed.State.TickCount; +import net.runelite.api.Actor; import net.runelite.api.Client; +import net.runelite.api.NPC; +import net.runelite.api.Player; import net.runelite.api.gameval.ItemID; // Weapons from The Fractured Archive. @@ -63,23 +68,53 @@ public int apply(final Client client, final AnimationData curAnimation, final At return curSpeed; } final int weaponId = Utils.getWeaponId(client); - switch (curAnimation) + if (isObligator(weaponId)) { + switch (curAnimation) + { case MELEE_OBLIGATOR: case MELEE_OBLIGATOR_FEMALE: - return isObligator(weaponId) ? 3 : curSpeed; + return 3; case MELEE_OBLIGATOR_MULTIHIT: case MELEE_OBLIGATOR_MULTIHIT_FEMALE: - return isObligator(weaponId) ? 5 : curSpeed; + return 5; + default: + // 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 from the attack option. + final var option = Utils.getAttackStyle(client); + switch (option) + { + case ACCURATE: + return 3; + case AGGRESSIVE: + default: + return 5; + } + } + } + else if (isZoryasTome(weaponId)) + { + final boolean hit = successfulHit(client, damageDealt); + switch (curAnimation) + { case MAGIC_ZORYA_TOME_SPEC: case MAGIC_ZORYA_TOME_SPEC_FEMALE: - return isZoryasTome(weaponId) ? zoryaAttackSpeed(true, damageDealt) : curSpeed; + return zoryaAttackSpeed(hit); case MAGIC_ZORYA_TOME: case MAGIC_ZORYA_TOME_FEMALE: - return isZoryasTome(weaponId) ? zoryaAttackSpeed(false, damageDealt) : curSpeed; + return zoryaAttackSpeed(false); default: - return curSpeed; + // 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)); + return zoryaAttackSpeed(specAndHit); + // Since we know the weapon ID we should always use `zoryaAttackSpeed` to track fast attacks + // accurately + } } + + return curSpeed; } private static boolean isObligator(final int weaponId) @@ -92,7 +127,7 @@ private static boolean isZoryasTome(final int weaponId) return weaponId == ItemID.ZORYAS_TOME || weaponId == ItemID.ZORYAS_TOME_UNCHARGED; } - private int zoryaAttackSpeed(final boolean isSpec, final int damageDealt) + private int zoryaAttackSpeed(final boolean isSpecAndHit) { // https://oldschool.runescape.wiki/w/Zorya%27s_tome // A landed spec buffs the next 3 attacks (2t instead of 3t). A spec used while buffed is itself a @@ -110,11 +145,27 @@ private int zoryaAttackSpeed(final boolean isSpec, final int damageDealt) remaining--; speed = 2; } - if (isSpec && damageDealt > 0) + if (isSpecAndHit) { remaining += ZORYA_FAST_ATTACKS; } zoryaFastAttacksRemaining = remaining; return speed; } + + private boolean successfulHit(final Client client, final int damageDealt) + { + if (damageDealt > 0) + { + return true; + } + final Actor target = client.getLocalPlayer().getInteracting(); + if (target != null && (target instanceof NPC)) + { + final NPC npc = (NPC) target; + // These don't compute damage normally (zero exp) + return Attacking.COMBAT_DUMMY.contains(npc.getId()); + } + return false; + } }