Fix weapon special usage

This commit is contained in:
Yuri Moens 2022-01-22 12:09:39 +01:00
parent 344ee6cb24
commit 5c1991fb1a
Signed by: ymo
GPG Key ID: F6D51D6FE15BE924

View File

@ -126,6 +126,7 @@ public class Consume extends Plugin implements KeyListener {
private boolean shouldDrinkMagic; private boolean shouldDrinkMagic;
private long lastMagic; private long lastMagic;
private boolean shouldUseSpecial; private boolean shouldUseSpecial;
private long lastSpecial;
private boolean pkTeleport; private boolean pkTeleport;
@SuppressWarnings("unused") @SuppressWarnings("unused")
@ -179,7 +180,8 @@ public class Consume extends Plugin implements KeyListener {
if (config.useSpecial() if (config.useSpecial()
&& event.getIndex() == VarPlayer.SPECIAL_ATTACK_PERCENT.getId() && event.getIndex() == VarPlayer.SPECIAL_ATTACK_PERCENT.getId()
&& game.client().getVarpValue(VarPlayer.SPECIAL_ATTACK_PERCENT.getId()) > config.specialCost()) { && game.client().getVarpValue(VarPlayer.SPECIAL_ATTACK_PERCENT.getId()) / 10 >= config.specialCost()
&& lastSpecial + 2000 < System.currentTimeMillis()) {
shouldUseSpecial = true; shouldUseSpecial = true;
} }
} }
@ -281,8 +283,9 @@ public class Consume extends Plugin implements KeyListener {
if (shouldUseSpecial && game.client().getVarpValue(VarPlayer.SPECIAL_ATTACK_ENABLED.getId()) == 0) { if (shouldUseSpecial && game.client().getVarpValue(VarPlayer.SPECIAL_ATTACK_ENABLED.getId()) == 0) {
shouldUseSpecial = false; shouldUseSpecial = false;
lastSpecial = System.currentTimeMillis();
if (game.client().getVar(Varbits.PVP_SPEC_ORB) == 0) { if (game.varb(Varbits.PVP_SPEC_ORB.getId()) == 0) {
iWidget special = game.widget(WidgetInfo.MINIMAP_SPEC_CLICKBOX); iWidget special = game.widget(WidgetInfo.MINIMAP_SPEC_CLICKBOX);
if (special == null) return; if (special == null) return;
@ -400,7 +403,7 @@ public class Consume extends Plugin implements KeyListener {
private void onInteractingChanged(InteractingChanged event) { private void onInteractingChanged(InteractingChanged event) {
if (!config.tpOnPlayerAttack() || !pkTeleport || game.client().getVar(Varbits.IN_WILDERNESS) == 0) return; if (!config.tpOnPlayerAttack() || !pkTeleport || game.client().getVar(Varbits.IN_WILDERNESS) == 0) return;
if (event.getSource() == null || event.getTarget() == null) return; if (event.getSource() == null || event.getTarget() == null || event.getTarget().getName() == null) return;
if (event.getSource() instanceof Player && event.getTarget().equals(game.client().getLocalPlayer())) { if (event.getSource() instanceof Player && event.getTarget().equals(game.client().getLocalPlayer())) {
log.info("Player attacking us: " + event.getSource().getName()); log.info("Player attacking us: " + event.getSource().getName());