diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersPlugin.java index fa16b99793..ac2fc07b39 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersPlugin.java @@ -39,11 +39,14 @@ import net.runelite.api.ItemContainer; import net.runelite.api.ItemID; import net.runelite.api.NPC; import net.runelite.api.NpcID; +import net.runelite.api.Player; import net.runelite.api.Prayer; import net.runelite.api.Varbits; +import net.runelite.api.coords.WorldPoint; import net.runelite.api.events.AnimationChanged; import net.runelite.api.events.ChatMessage; import net.runelite.api.events.ConfigChanged; +import net.runelite.api.events.GameTick; import net.runelite.api.events.GraphicChanged; import net.runelite.api.events.ItemContainerChanged; import net.runelite.api.events.MenuOptionClicked; @@ -109,6 +112,7 @@ public class TimersPlugin extends Plugin private static final String CHARGE_MESSAGE = "You feel charged with magic power."; private static final String EXTENDED_ANTIFIRE_DRINK_MESSAGE = "You drink some of your extended antifire potion."; private static final String EXTENDED_SUPER_ANTIFIRE_DRINK_MESSAGE = "You drink some of your extended super antifire potion."; + private static final String FROZEN_MESSAGE = "You have been frozen!"; private static final String FULL_TELEBLOCK_MESSAGE = "A teleblock spell has been cast on you. It will expire in 5 minutes, 0 seconds."; private static final String GOD_WARS_ALTAR_MESSAGE = "you recharge your prayer."; private static final String HALF_TELEBLOCK_MESSAGE = "A teleblock spell has been cast on you. It will expire in 2 minutes, 30 seconds."; @@ -124,7 +128,11 @@ public class TimersPlugin extends Plugin private static final String SUPER_ANTIFIRE_EXPIRED_MESSAGE = "Your super antifire potion has expired."; private static final String SUPER_ANTIVENOM_DRINK_MESSAGE = "You drink some of your super antivenom potion"; + private TimerTimer freezeTimer; + private int freezeTime = -1; // time frozen, in game ticks + private int lastRaidVarb; + private WorldPoint lastPoint; @Inject private ItemManager itemManager; @@ -483,6 +491,33 @@ public class TimersPlugin extends Plugin { removeGameTimer(STAFF_OF_THE_DEAD); } + + if (config.showFreezes() && event.getMessage().equals(FROZEN_MESSAGE)) + { + freezeTimer = createGameTimer(ICEBARRAGE); + freezeTime = client.getTickCount(); + } + } + + @Subscribe + public void onGameTick(GameTick event) + { + Player player = client.getLocalPlayer(); + WorldPoint currentWorldPoint = player.getWorldLocation(); + + if (freezeTimer == null) + { + lastPoint = currentWorldPoint; + return; + } + + // assume movement means unfrozen + if (!currentWorldPoint.equals(lastPoint)) + { + removeGameTimer(freezeTimer.getTimer()); + freezeTimer = null; + lastPoint = currentWorldPoint; + } } @Subscribe @@ -588,24 +623,26 @@ public class TimersPlugin extends Plugin } } - if (actor.getGraphic() == ICERUSH.getGraphicId()) + // downgrade freeze based on graphic, if at the same tick as the freeze message + if (freezeTime == client.getTickCount()) { - createGameTimer(ICERUSH); - } + if (actor.getGraphic() == ICERUSH.getGraphicId()) + { + removeGameTimer(ICEBARRAGE); + freezeTimer = createGameTimer(ICERUSH); + } - if (actor.getGraphic() == ICEBURST.getGraphicId()) - { - createGameTimer(ICEBURST); - } + if (actor.getGraphic() == ICEBURST.getGraphicId()) + { + removeGameTimer(ICEBARRAGE); + freezeTimer = createGameTimer(ICEBURST); + } - if (actor.getGraphic() == ICEBLITZ.getGraphicId()) - { - createGameTimer(ICEBLITZ); - } - - if (actor.getGraphic() == ICEBARRAGE.getGraphicId()) - { - createGameTimer(ICEBARRAGE); + if (actor.getGraphic() == ICEBLITZ.getGraphicId()) + { + removeGameTimer(ICEBARRAGE); + freezeTimer = createGameTimer(ICEBLITZ); + } } } } @@ -669,7 +706,7 @@ public class TimersPlugin extends Plugin } } - private void createGameTimer(GameTimer timer) + private TimerTimer createGameTimer(final GameTimer timer) { removeGameTimer(timer); @@ -677,6 +714,7 @@ public class TimersPlugin extends Plugin TimerTimer t = new TimerTimer(timer, this, image); t.setTooltip(timer.getDescription()); infoBoxManager.addInfoBox(t); + return t; } private void removeGameTimer(GameTimer timer)