diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ImagePanelComponent.java b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ImagePanelComponent.java new file mode 100644 index 0000000000..dae0a1e354 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ImagePanelComponent.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2017, Aria + * Copyright (c) 2017, Adam + * Copyright (c) 2017, Devin French + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.runelite.client.plugins.zulrah; + +import com.google.common.base.Strings; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FontMetrics; +import java.awt.Graphics2D; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.image.BufferedImage; +import javax.annotation.Nullable; +import lombok.Setter; +import net.runelite.client.ui.overlay.RenderableEntity; +import net.runelite.client.ui.overlay.components.BackgroundComponent; + +public class ImagePanelComponent implements RenderableEntity +{ + private static final int TOP_BORDER = 3; + private static final int SIDE_BORDER = 6; + private static final int BOTTOM_BORDER = 6; + private static final int SEPARATOR = 4; + + @Setter + @Nullable + private String title; + + @Setter + private Color titleColor = Color.WHITE; + + @Setter + private Color backgroundColor = new Color(70, 61, 50, 156); + + @Setter + private BufferedImage image; + + @Setter + private Point position = new Point(); + + @Override + public Dimension render(Graphics2D graphics) + { + final Dimension dimension = new Dimension(); + final FontMetrics metrics = graphics.getFontMetrics(); + int height = TOP_BORDER + (Strings.isNullOrEmpty(title) ? 0 : metrics.getHeight()) + + SEPARATOR + image.getHeight() + BOTTOM_BORDER; + int width = Math.max(Strings.isNullOrEmpty(title) ? 0 : metrics.stringWidth(title), image.getWidth()) + SIDE_BORDER * 2; + dimension.setSize(width, height); + + if (dimension.height == 0) + { + return null; + } + + // Calculate panel dimensions + int y = position.y + TOP_BORDER + metrics.getHeight(); + + // Render background + final BackgroundComponent backgroundComponent = new BackgroundComponent(); + backgroundComponent.setBackgroundColor(backgroundColor); + backgroundComponent.setRectangle(new Rectangle(position.x, position.y, dimension.width, dimension.height)); + backgroundComponent.render(graphics); + + // Render title + if (!Strings.isNullOrEmpty(title)) + { + final TextComponent titleComponent = new TextComponent(); + titleComponent.setText(title); + titleComponent.setColor(titleColor); + titleComponent.setPosition(new Point(position.x + (width - metrics.stringWidth(title)) / 2, y)); + titleComponent.render(graphics); + y += SEPARATOR; + } + + // Render image + graphics.drawImage(image, position.x + (width - image.getWidth()) / 2, y, null); + + return dimension; + } +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/TextComponent.java b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/TextComponent.java new file mode 100644 index 0000000000..043916c147 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/TextComponent.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2017, Aria + * Copyright (c) 2017, Adam + * Copyright (c) 2017, Devin French + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.runelite.client.plugins.zulrah; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FontMetrics; +import java.awt.Graphics2D; +import java.awt.Point; +import lombok.Setter; +import net.runelite.client.ui.overlay.RenderableEntity; + +public class TextComponent implements RenderableEntity +{ + @Setter + private String text; + + @Setter + private Point position = new Point(); + + @Setter + private Color color = Color.WHITE; + + @Override + public Dimension render(Graphics2D graphics) + { + // Draw shadow + graphics.setColor(Color.BLACK); + graphics.drawString(text, position.x + 1, position.y + 1); + + // Draw actual text + graphics.setColor(color); + graphics.drawString(text, position.x, position.y); + + final FontMetrics fontMetrics = graphics.getFontMetrics(); + return new Dimension(fontMetrics.stringWidth(text), fontMetrics.getHeight()); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ZulrahConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ZulrahConfig.java index c539ee6752..3955d043a2 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ZulrahConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ZulrahConfig.java @@ -1,6 +1,7 @@ /* - * Copyright (c) 2018, https://runelitepl.us - * Copyright (c) 2018, https://github.com/runeliteplusplus + * Copyright (c) 2017, Aria + * Copyright (c) 2017, Adam + * Copyright (c) 2017, Devin French * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,26 +32,15 @@ import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; @ConfigGroup("zulrah") + public interface ZulrahConfig extends Config { @ConfigItem( - position = 1, - keyName = "zulrahprayenable", - name = "Show Prayer Helper", - description = "Configures whether or not to show when to pray at Zulrah." + keyName = "enabled", + name = "Enabled", + description = "Configures whether or not zulrah overlays are displayed" ) - default boolean EnableZulrahPrayerHelper() - { - return true; - } - - @ConfigItem( - position = 2, - keyName = "jadphasehelper", - name = "Jad Phase Helper", - description = "Tells you what to pray against Zulrah jad phase" - ) - default boolean ZulrahJadHelper() + default boolean enabled() { return true; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ZulrahInstance.java b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ZulrahInstance.java new file mode 100644 index 0000000000..e701cd65f6 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ZulrahInstance.java @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2017, Aria + * Copyright (c) 2017, Adam + * Copyright (c) 2017, Devin French + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.runelite.client.plugins.zulrah; + +import net.runelite.api.NPC; +import net.runelite.api.Prayer; +import net.runelite.api.coords.LocalPoint; +import net.runelite.client.plugins.zulrah.patterns.ZulrahPattern; +import net.runelite.client.plugins.zulrah.phase.StandLocation; +import net.runelite.client.plugins.zulrah.phase.ZulrahLocation; +import net.runelite.client.plugins.zulrah.phase.ZulrahPhase; +import net.runelite.client.plugins.zulrah.phase.ZulrahType; + +public class ZulrahInstance +{ + private static final ZulrahPhase NO_PATTERN_MAGIC_PHASE = new ZulrahPhase( + ZulrahLocation.NORTH, + ZulrahType.MAGIC, + false, + StandLocation.PILLAR_WEST_OUTSIDE, + Prayer.PROTECT_FROM_MAGIC + ); + private static final ZulrahPhase NO_PATTERN_RANGE_PHASE = new ZulrahPhase( + ZulrahLocation.NORTH, + ZulrahType.RANGE, + false, + StandLocation.TOP_EAST, + Prayer.PROTECT_FROM_MISSILES + ); + private static final ZulrahPhase PATTERN_A_OR_B_RANGE_PHASE = new ZulrahPhase( + ZulrahLocation.NORTH, + ZulrahType.RANGE, + false, + StandLocation.PILLAR_WEST_OUTSIDE, + Prayer.PROTECT_FROM_MISSILES + ); + + private final LocalPoint startLocation; + private ZulrahPattern pattern; + private int stage; + private ZulrahPhase phase; + + public ZulrahInstance(NPC zulrah) + { + this.startLocation = zulrah.getLocalLocation(); + } + + public LocalPoint getStartLocation() + { + return startLocation; + } + + public ZulrahPattern getPattern() + { + return pattern; + } + + public void setPattern(ZulrahPattern pattern) + { + this.pattern = pattern; + } + + public int getStage() + { + return stage; + } + + public void nextStage() + { + ++stage; + } + + public void reset() + { + pattern = null; + stage = 0; + } + + public ZulrahPhase getPhase() + { + ZulrahPhase patternPhase = null; + if (pattern != null) + { + patternPhase = pattern.get(stage); + } + return patternPhase != null ? patternPhase : phase; + } + + public void setPhase(ZulrahPhase phase) + { + this.phase = phase; + } + + public ZulrahPhase getNextPhase() + { + if (pattern != null) + { + return pattern.get(stage + 1); + } + else if (phase != null) + { + ZulrahType type = phase.getType(); + StandLocation standLocation = phase.getStandLocation(); + if (type == ZulrahType.MELEE) + { + return standLocation == StandLocation.TOP_EAST ? NO_PATTERN_MAGIC_PHASE : NO_PATTERN_RANGE_PHASE; + } + if (type == ZulrahType.MAGIC) + { + return standLocation == StandLocation.TOP_EAST ? NO_PATTERN_RANGE_PHASE : PATTERN_A_OR_B_RANGE_PHASE; + } + } + return null; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ZulrahJadOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ZulrahJadOverlay.java deleted file mode 100644 index 161a2ee0df..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ZulrahJadOverlay.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) 2018, https://runelitepl.us - * Copyright (c) 2018, https://github.com/runeliteplusplus - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package net.runelite.client.plugins.zulrah; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics2D; -import java.awt.image.BufferedImage; -import javax.inject.Inject; -import net.runelite.api.Client; -import net.runelite.api.NPC; -import net.runelite.api.Prayer; -import net.runelite.api.SpriteID; -import net.runelite.client.game.SpriteManager; -import net.runelite.client.ui.overlay.Overlay; -import net.runelite.client.ui.overlay.OverlayLayer; -import net.runelite.client.ui.overlay.OverlayPosition; -import net.runelite.client.ui.overlay.OverlayPriority; -import net.runelite.client.ui.overlay.components.ComponentConstants; -import net.runelite.client.ui.overlay.components.ImageComponent; -import net.runelite.client.ui.overlay.components.PanelComponent; - -public class ZulrahJadOverlay extends Overlay -{ - private static final Color NOT_ACTIVATED_BACKGROUND_COLOR = new Color(150, 0, 0, 150); - private final ZulrahConfig config; - private final ZulrahPlugin plugin; - private final SpriteManager spriteManager; - private final PanelComponent imagePanelComponent = new PanelComponent(); - - @Inject - private Client client; - - @Inject - private ZulrahJadOverlay(ZulrahConfig config, ZulrahPlugin plugin, SpriteManager spriteManager) - { - this.config = config; - this.plugin = plugin; - this.spriteManager = spriteManager; - setLayer(OverlayLayer.ABOVE_SCENE); - setPosition(OverlayPosition.BOTTOM_RIGHT); - setPriority(OverlayPriority.MED); - } - - @Override - public Dimension render(Graphics2D graphics) - { - if (!config.ZulrahJadHelper()) - { - return null; - } - NPC Zulrah = plugin.Zulrah; - if (Zulrah != null) - { - if (plugin.jadphase > 0) - { - if (plugin.jadphase == 1) - { - if (plugin.jadflip) - { - final BufferedImage prayerImage = spriteManager.getSprite(SpriteID.PRAYER_PROTECT_FROM_MISSILES, 0); - imagePanelComponent.getChildren().clear(); - imagePanelComponent.getChildren().add(new ImageComponent(prayerImage)); - imagePanelComponent.setBackgroundColor(client.isPrayerActive(Prayer.PROTECT_FROM_MISSILES) - ? ComponentConstants.STANDARD_BACKGROUND_COLOR - : NOT_ACTIVATED_BACKGROUND_COLOR); - } - else - { - final BufferedImage prayerImage = spriteManager.getSprite(SpriteID.PRAYER_PROTECT_FROM_MAGIC, 0); - imagePanelComponent.getChildren().clear(); - imagePanelComponent.getChildren().add(new ImageComponent(prayerImage)); - imagePanelComponent.setBackgroundColor(client.isPrayerActive(Prayer.PROTECT_FROM_MAGIC) - ? ComponentConstants.STANDARD_BACKGROUND_COLOR - : NOT_ACTIVATED_BACKGROUND_COLOR); - } - } - else if (plugin.jadphase == 2) - { - if (plugin.jadflip) - { - final BufferedImage prayerImage = spriteManager.getSprite(SpriteID.PRAYER_PROTECT_FROM_MAGIC, 0); - imagePanelComponent.getChildren().clear(); - imagePanelComponent.getChildren().add(new ImageComponent(prayerImage)); - imagePanelComponent.setBackgroundColor(client.isPrayerActive(Prayer.PROTECT_FROM_MAGIC) - ? ComponentConstants.STANDARD_BACKGROUND_COLOR - : NOT_ACTIVATED_BACKGROUND_COLOR); - } - else - { - final BufferedImage prayerImage = spriteManager.getSprite(SpriteID.PRAYER_PROTECT_FROM_MISSILES, 0); - imagePanelComponent.getChildren().clear(); - imagePanelComponent.getChildren().add(new ImageComponent(prayerImage)); - imagePanelComponent.setBackgroundColor(client.isPrayerActive(Prayer.PROTECT_FROM_MISSILES) - ? ComponentConstants.STANDARD_BACKGROUND_COLOR - : NOT_ACTIVATED_BACKGROUND_COLOR); - } - } - return imagePanelComponent.render(graphics); - } - } - return null; - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ZulrahOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ZulrahOverlay.java deleted file mode 100644 index 47f2bd8875..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ZulrahOverlay.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2018, https://runelitepl.us - * Copyright (c) 2018, https://github.com/runeliteplusplus - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package net.runelite.client.plugins.zulrah; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics2D; -import javax.inject.Inject; -import net.runelite.api.Client; -import net.runelite.api.HeadIcon; -import net.runelite.api.NPC; -import net.runelite.api.Player; -import net.runelite.client.ui.overlay.Overlay; -import net.runelite.client.ui.overlay.OverlayLayer; -import net.runelite.client.ui.overlay.OverlayPosition; -import net.runelite.client.ui.overlay.OverlayPriority; -import net.runelite.client.ui.overlay.components.PanelComponent; -import net.runelite.client.ui.overlay.components.TitleComponent; - -public class ZulrahOverlay extends Overlay -{ - private final ZulrahConfig config; - private final ZulrahPlugin plugin; - private final PanelComponent panelComponent = new PanelComponent(); - - - @Inject - private Client client; - - @Inject - private ZulrahOverlay(ZulrahConfig config, ZulrahPlugin plugin) - { - this.config = config; - this.plugin = plugin; - setLayer(OverlayLayer.ABOVE_SCENE); - setPosition(OverlayPosition.DYNAMIC); - setPriority(OverlayPriority.MED); - panelComponent.setPreferredSize(new Dimension(150, 0)); - } - - @Override - public Dimension render(Graphics2D graphics) - { - if (!config.EnableZulrahPrayerHelper()) - { - return null; - } - NPC Zulrah = plugin.Zulrah; - if (Zulrah != null) - { - if (plugin.prayerconserve && plugin.nextprayerendticks == 0) - { - Player player = client.getLocalPlayer(); - HeadIcon icon = player.getOverheadIcon(); - if (icon != null) - { - final String text = "Disable Overhead Prayer"; - final int textWidth = graphics.getFontMetrics().stringWidth(text); - final int textHeight = graphics.getFontMetrics().getAscent() - graphics.getFontMetrics().getDescent(); - final int width = (int) client.getRealDimensions().getWidth(); - java.awt.Point jpoint = new java.awt.Point((width / 2) - textWidth, textHeight + 75); - panelComponent.getChildren().clear(); - panelComponent.getChildren().add(TitleComponent.builder().text(text).color(Color.RED).build()); - panelComponent.setPreferredLocation(jpoint); - panelComponent.render(graphics); - } - } - else if (plugin.nextprayerendticks != 0) - { - Player player = client.getLocalPlayer(); - HeadIcon icon = player.getOverheadIcon(); - if (icon == null) - { - final String text = "Protect from MAGIC: " + (plugin.nextprayerendticks - plugin.ticks); - final int textWidth = graphics.getFontMetrics().stringWidth(text); - final int textHeight = graphics.getFontMetrics().getAscent() - graphics.getFontMetrics().getDescent(); - final int width = (int) client.getRealDimensions().getWidth(); - java.awt.Point jpoint = new java.awt.Point((width / 2) - textWidth, textHeight + 75); - panelComponent.getChildren().clear(); - panelComponent.getChildren().add(TitleComponent.builder().text(text).color(Color.GREEN).build()); - panelComponent.setPreferredLocation(jpoint); - panelComponent.render(graphics); - } - } - } - return null; - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ZulrahPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ZulrahPlugin.java index 6ffd755568..6a5409bb24 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ZulrahPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ZulrahPlugin.java @@ -1,6 +1,7 @@ /* - * Copyright (c) 2018, https://runelitepl.us - * Copyright (c) 2018, https://github.com/runeliteplusplus + * Copyright (c) 2017, Aria + * Copyright (c) 2017, Adam + * Copyright (c) 2017, Devin French * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -23,798 +24,197 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - package net.runelite.client.plugins.zulrah; import com.google.inject.Provides; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.image.BufferedImage; -import java.awt.image.ColorModel; -import java.awt.image.DataBufferByte; -import java.awt.image.IndexColorModel; -import java.awt.image.WritableRaster; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; import javax.inject.Inject; -import net.runelite.api.Actor; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; import net.runelite.api.GameState; -import net.runelite.api.IndexedSprite; import net.runelite.api.NPC; -import net.runelite.api.SpriteID; -import net.runelite.api.coords.LocalPoint; -import net.runelite.api.events.AnimationChanged; -import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameTick; +import net.runelite.api.events.NpcDespawned; +import net.runelite.api.events.NpcSpawned; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; -import net.runelite.client.game.SpriteManager; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; -import net.runelite.client.plugins.PluginType; +import net.runelite.client.plugins.zulrah.overlays.ZulrahCurrentPhaseOverlay; +import net.runelite.client.plugins.zulrah.overlays.ZulrahNextPhaseOverlay; +import net.runelite.client.plugins.zulrah.overlays.ZulrahOverlay; +import net.runelite.client.plugins.zulrah.overlays.ZulrahPrayerOverlay; +import net.runelite.client.plugins.zulrah.patterns.ZulrahPattern; +import net.runelite.client.plugins.zulrah.patterns.ZulrahPatternA; +import net.runelite.client.plugins.zulrah.patterns.ZulrahPatternB; +import net.runelite.client.plugins.zulrah.patterns.ZulrahPatternC; +import net.runelite.client.plugins.zulrah.patterns.ZulrahPatternD; +import net.runelite.client.plugins.zulrah.phase.ZulrahPhase; import net.runelite.client.ui.overlay.OverlayManager; -import net.runelite.client.util.ImageUtil; @PluginDescriptor( name = "Zulrah", - description = "Zulrah Helper", - tags = {"Zulrah", "Helper"}, - type = PluginType.PVM + description = "Overlays to assist with killing Zulrah", + tags = {"zulrah", "boss", "helper"} ) +@Slf4j public class ZulrahPlugin extends Plugin { - private static final int[] PROTECTION_ICONS = { - SpriteID.PRAYER_PROTECT_FROM_MISSILES, - SpriteID.PRAYER_PROTECT_FROM_MELEE, - SpriteID.PRAYER_PROTECT_FROM_MAGIC - }; - private static final Dimension PROTECTION_ICON_DIMENSION = new Dimension(33, 33); - private static final Color PROTECTION_ICON_OUTLINE_COLOR = new Color(33, 33, 33); - public final BufferedImage[] ProtectionIcons = new BufferedImage[PROTECTION_ICONS.length]; - int zulrahstart = 0; - NPC Zulrah; - LocalPoint ZulrahPosCenter = new LocalPoint(6720, 7616); - LocalPoint ZulrahPosWest = new LocalPoint(8000, 7360); - LocalPoint ZulrahPosEast = new LocalPoint(5440, 7360); - LocalPoint ZulrahPosNorth = new LocalPoint(6720, 6208); - LocalPoint SWCornerTile = new LocalPoint(7488, 7872); - LocalPoint SWCornerTileMelee = new LocalPoint(7232, 8000); - LocalPoint WPillar = new LocalPoint(7232, 7232); - LocalPoint WPillarN = new LocalPoint(7232, 7104); - LocalPoint EPillar = new LocalPoint(6208, 7232); - LocalPoint EPillarN = new LocalPoint(6208, 7104); - LocalPoint SECornerTile = new LocalPoint(6208, 8000); - LocalPoint SECornerTileMelee = new LocalPoint(5952, 7744); - LocalPoint Middle = new LocalPoint(6720, 6848); - int ticks; - int phaseticks; - int not; - int lastphase; - int phase; - int nextprayerendticks; - boolean phase1 = true; - boolean phase2 = true; - boolean phase3 = true; - boolean phase4 = true; - boolean restart = false; - boolean prayerconserve = false; - int jadphase; - boolean jadflip = false; - Color nztcolor; - LocalPoint nextzulrahtile; - LocalPoint nexttile; - LocalPoint currenttile; - LocalPoint lastloc; - LocalPoint MeleeTile; - List phases = new ArrayList<>(); - List locations = new ArrayList<>(); - ArrayList Phase1types = new ArrayList<>(Arrays.asList(2042, 2043, 2044, 2042, 2044, 2043, 2042, 2044, 2042, 2043)); - ArrayList Phase1pos = new ArrayList<>(Arrays.asList(ZulrahPosCenter, ZulrahPosCenter, ZulrahPosCenter, ZulrahPosEast, ZulrahPosNorth, ZulrahPosCenter, ZulrahPosWest, ZulrahPosNorth, ZulrahPosEast, ZulrahPosCenter)); - ArrayList Phase1tiles = new ArrayList<>(Arrays.asList(SWCornerTile, SWCornerTile, SWCornerTile, EPillar, EPillarN, EPillar, Middle, EPillar, EPillar, SWCornerTile)); - ArrayList Phase1ticks = new ArrayList<>(Arrays.asList(28, 20, 18, 28, 39, 22, 20, 36, 48, 20)); - ArrayList Phase2types = new ArrayList<>(Arrays.asList(2042, 2043, 2044, 2042, 2043, 2044, 2042, 2044, 2042, 2043)); - ArrayList Phase2pos = new ArrayList<>(Arrays.asList(ZulrahPosCenter, ZulrahPosCenter, ZulrahPosCenter, ZulrahPosNorth, ZulrahPosCenter, ZulrahPosEast, ZulrahPosNorth, ZulrahPosNorth, ZulrahPosEast, ZulrahPosCenter)); - ArrayList Phase2tiles = new ArrayList<>(Arrays.asList(SWCornerTile, SWCornerTile, SWCornerTile, EPillar, EPillar, EPillar, WPillar, WPillarN, EPillar, SWCornerTile)); - ArrayList Phase2ticks = new ArrayList<>(Arrays.asList(28, 20, 17, 39, 22, 20, 28, 36, 48, 21)); - ArrayList Phase3types = new ArrayList<>(Arrays.asList(2042, 2042, 2043, 2044, 2042, 2044, 2042, 2042, 2044, 2042, 2044)); - ArrayList Phase3pos = new ArrayList<>(Arrays.asList(ZulrahPosCenter, ZulrahPosWest, ZulrahPosCenter, ZulrahPosEast, ZulrahPosNorth, ZulrahPosWest, ZulrahPosCenter, ZulrahPosEast, ZulrahPosCenter, ZulrahPosWest, ZulrahPosCenter)); - ArrayList Phase3tiles = new ArrayList<>(Arrays.asList(SWCornerTile, SWCornerTile, SECornerTile, EPillar, WPillar, WPillar, EPillar, EPillar, WPillar, WPillar, SWCornerTile)); - ArrayList Phase3ticks = new ArrayList<>(Arrays.asList(28, 30, 40, 20, 20, 20, 25, 20, 36, 35, 18)); - ArrayList Phase4types = new ArrayList<>(Arrays.asList(2042, 2044, 2042, 2044, 2043, 2042, 2042, 2044, 2042, 2044, 2042, 2044)); - ArrayList Phase4pos = new ArrayList<>(Arrays.asList(ZulrahPosCenter, ZulrahPosWest, ZulrahPosNorth, ZulrahPosEast, ZulrahPosCenter, ZulrahPosWest, ZulrahPosNorth, ZulrahPosEast, ZulrahPosCenter, ZulrahPosCenter, ZulrahPosWest, ZulrahPosCenter)); - ArrayList Phase4tiles = new ArrayList<>(Arrays.asList(SWCornerTile, SWCornerTile, EPillar, EPillar, WPillar, WPillar, WPillar, EPillar, WPillar, WPillar, WPillar, SWCornerTile)); - ArrayList Phase4ticks = new ArrayList<>(Arrays.asList(28, 36, 24, 30, 28, 17, 34, 33, 20, 27, 29, 18)); - @Inject - private OverlayManager overlayManager; - @Inject - private ZulrahConfig config; - @Inject - private ZulrahOverlay ZulrahOverlay; - @Inject - private ZulrahTileOverlay ZulrahTileOverlay; - @Inject - private ZulrahJadOverlay ZulrahJadOverlay; + @Getter + private NPC zulrah; + @Inject private Client client; + @Inject - private SpriteManager spriteManager; + private ZulrahConfig config; - private static IndexedSprite createIndexedSprite(final Client client, final BufferedImage bufferedImage) - { - final IndexColorModel indexedCM = (IndexColorModel) bufferedImage.getColorModel(); + @Inject + private ZulrahOverlay overlay; - final int width = bufferedImage.getWidth(); - final int height = bufferedImage.getHeight(); - final byte[] pixels = ((DataBufferByte) bufferedImage.getRaster().getDataBuffer()).getData(); - final int[] palette = new int[indexedCM.getMapSize()]; - indexedCM.getRGBs(palette); + @Inject + private OverlayManager overlayManager; - final IndexedSprite newIndexedSprite = client.createIndexedSprite(); - newIndexedSprite.setPixels(pixels); - newIndexedSprite.setPalette(palette); - newIndexedSprite.setWidth(width); - newIndexedSprite.setHeight(height); - newIndexedSprite.setOriginalWidth(width); - newIndexedSprite.setOriginalHeight(height); - newIndexedSprite.setOffsetX(0); - newIndexedSprite.setOffsetY(0); - return newIndexedSprite; - } + @Inject + private ZulrahCurrentPhaseOverlay currentPhaseOverlay; - private static BufferedImage rgbaToIndexedBufferedImage(final BufferedImage sourceBufferedImage) - { - final BufferedImage indexedImage = new BufferedImage( - sourceBufferedImage.getWidth(), - sourceBufferedImage.getHeight(), - BufferedImage.TYPE_BYTE_INDEXED); + @Inject + private ZulrahNextPhaseOverlay nextPhaseOverlay; - final ColorModel cm = indexedImage.getColorModel(); - final IndexColorModel icm = (IndexColorModel) cm; + @Inject + private ZulrahPrayerOverlay zulrahPrayerOverlay; - final int size = icm.getMapSize(); - final byte[] reds = new byte[size]; - final byte[] greens = new byte[size]; - final byte[] blues = new byte[size]; - icm.getReds(reds); - icm.getGreens(greens); - icm.getBlues(blues); + @Inject + private ZulrahOverlay zulrahOverlay; - final WritableRaster raster = indexedImage.getRaster(); - final int pixel = raster.getSample(0, 0, 0); - final IndexColorModel resultIcm = new IndexColorModel(8, size, reds, greens, blues, pixel); - final BufferedImage resultIndexedImage = new BufferedImage(resultIcm, raster, sourceBufferedImage.isAlphaPremultiplied(), null); - resultIndexedImage.getGraphics().drawImage(sourceBufferedImage, 0, 0, null); - return resultIndexedImage; - } - - private static BufferedImage ProtectionIconFromSprite(final BufferedImage freezeSprite) - { - final BufferedImage freezeCanvas = ImageUtil.resizeCanvas(freezeSprite, PROTECTION_ICON_DIMENSION.width, PROTECTION_ICON_DIMENSION.height); - return ImageUtil.outlineImage(freezeCanvas, PROTECTION_ICON_OUTLINE_COLOR); - } @Provides - ZulrahConfig provideConfig(ConfigManager configManager) + ZulrahConfig getConfig(ConfigManager configManager) { return configManager.getConfig(ZulrahConfig.class); } - @Subscribe - public void onGameStateChanged(GameStateChanged gameStateChanged) - { - if (gameStateChanged.getGameState() == GameState.LOGGED_IN) + private final ZulrahPattern[] patterns = new ZulrahPattern[] { - loadProtectionIcons(); - } - } + new ZulrahPatternA(), + new ZulrahPatternB(), + new ZulrahPatternC(), + new ZulrahPatternD() + }; + + private ZulrahInstance instance; @Override protected void startUp() throws Exception { - overlayManager.add(ZulrahOverlay); - overlayManager.add(ZulrahTileOverlay); - overlayManager.add(ZulrahJadOverlay); + overlayManager.add(currentPhaseOverlay); + overlayManager.add(nextPhaseOverlay); + overlayManager.add(zulrahPrayerOverlay); + overlayManager.add(zulrahOverlay); } @Override protected void shutDown() throws Exception { - overlayManager.remove(ZulrahOverlay); - overlayManager.remove(ZulrahTileOverlay); - overlayManager.remove(ZulrahJadOverlay); + overlayManager.remove(currentPhaseOverlay); + overlayManager.remove(nextPhaseOverlay); + overlayManager.remove(zulrahPrayerOverlay); + overlayManager.remove(zulrahOverlay); + zulrah = null; + instance = null; } @Subscribe public void onGameTick(GameTick event) { - if (phase4 && phases.size() == 11) + if (!config.enabled() || client.getGameState() != GameState.LOGGED_IN) { - jadphase = 1; - } - else if (phase3 && phases.size() == 10) - { - jadphase = 1; - } - else if (phase2 && phases.size() == 9) - { - jadphase = 2; - } - else if (phase1 && phases.size() == 9) - { - jadphase = 2; - } - else - { - jadphase = 0; - jadflip = false; + return; } - boolean foundzulrah = false; - for (NPC monster : client.getNpcs()) + if (zulrah == null) { - if (monster == null || monster.getName() == null) + if (instance != null) { - continue; + log.debug("Zulrah encounter has ended."); + instance = null; } - if (monster.getName().equalsIgnoreCase("zulrah")) - { - foundzulrah = true; - Zulrah = monster; - break; - } - } - if (!foundzulrah) - { - Zulrah = null; + return; } - if (Zulrah != null) + if (instance == null) { - if (zulrahstart == 0) + instance = new ZulrahInstance(zulrah); + log.debug("Zulrah encounter has started."); + } + + ZulrahPhase currentPhase = ZulrahPhase.valueOf(zulrah, instance.getStartLocation()); + if (instance.getPhase() == null) + { + instance.setPhase(currentPhase); + } + else if (!instance.getPhase().equals(currentPhase)) + { + ZulrahPhase previousPhase = instance.getPhase(); + instance.setPhase(currentPhase); + instance.nextStage(); + + log.debug("Zulrah phase has moved from {} -> {}, stage: {}", previousPhase, currentPhase, instance.getStage()); + } + + ZulrahPattern pattern = instance.getPattern(); + if (pattern == null) + { + int potential = 0; + ZulrahPattern potentialPattern = null; + + for (ZulrahPattern p : patterns) { - currenttile = SWCornerTile; - lastloc = Zulrah.getLocalLocation(); - lastphase = Zulrah.getId(); - zulrahstart = client.getTickCount(); - phases.add(lastphase); - locations.add(lastloc); - phaseticks = 28; - } - else - { - if (!Zulrah.getLocalLocation().equals(lastloc) || Zulrah.getId() != lastphase) + if (p.stageMatches(instance.getStage(), instance.getPhase())) { - if (restart) - { - phases.clear(); - locations.clear(); - zulrahstart = client.getTickCount(); - lastphase = 0; - lastloc = null; - phase = 0; - phase1 = true; - phase2 = true; - phase3 = true; - phase4 = true; - nextzulrahtile = null; - nztcolor = null; - nexttile = null; - currenttile = SWCornerTile; - restart = false; - ticks = 0; - prayerconserve = false; - phaseticks = 34; - not = 0; - nextprayerendticks = 0; - } - lastloc = Zulrah.getLocalLocation(); - lastphase = Zulrah.getId(); - ticks = 0; - phases.add(lastphase); - locations.add(lastloc); - if (phase == 0) - { - for (int i = 0; i < phases.size(); i++) - { - if (phase1) - { - if (!phases.get(i).equals(Phase1types.get(i)) || !locations.get(i).equals(Phase1pos.get(i))) - { - phase1 = false; - not++; - } - } - if (phase2) - { - if (!phases.get(i).equals(Phase2types.get(i)) || !locations.get(i).equals(Phase2pos.get(i))) - { - phase2 = false; - not++; - } - } - if (phase3) - { - if (!phases.get(i).equals(Phase3types.get(i)) || !locations.get(i).equals(Phase3pos.get(i))) - { - phase3 = false; - not++; - } - } - if (phase4) - { - if (!phases.get(i).equals(Phase4types.get(i)) || !locations.get(i).equals(Phase4pos.get(i))) - { - phase4 = false; - not++; - } - } - } - - if (not == 2) - { - if (lastphase == 2043) - { - nztcolor = Color.BLUE; - nextzulrahtile = ZulrahPosCenter; - currenttile = SWCornerTile; - nexttile = SWCornerTile; - phaseticks = Phase2ticks.get(phases.size() - 1); - prayerconserve = true; - } - else if (lastphase == 2044) - { - nztcolor = Color.GREEN; - nextzulrahtile = ZulrahPosNorth; - currenttile = SWCornerTile; - nexttile = EPillar; - phaseticks = Phase2ticks.get(phases.size() - 1); - prayerconserve = false; - } - } - else if (not == 3) - { - if (phase1) - { - nztcolor = zulrahtype(Phase1types.get(phases.size())); - nextzulrahtile = Phase1pos.get(phases.size()); - currenttile = Phase1tiles.get(phases.size() - 1); - nexttile = Phase1tiles.get(phases.size()); - phaseticks = Phase1ticks.get(phases.size() - 1); - prayerconserve = true; - phase = 1; - } - else if (phase2) - { - nztcolor = zulrahtype(Phase2types.get(phases.size())); - nextzulrahtile = Phase2pos.get(phases.size()); - currenttile = Phase2tiles.get(phases.size() - 1); - nexttile = Phase2tiles.get(phases.size()); - phaseticks = Phase2ticks.get(phases.size() - 1); - prayerconserve = false; - phase = 2; - } - else if (phase3) - { - nztcolor = zulrahtype(Phase3types.get(phases.size())); - nextzulrahtile = Phase3pos.get(phases.size()); - currenttile = Phase3tiles.get(phases.size() - 1); - nexttile = Phase3tiles.get(phases.size()); - phaseticks = Phase3ticks.get(phases.size() - 1); - prayerconserve = false; - phase = 3; - } - else if (phase4) - { - nztcolor = zulrahtype(Phase4types.get(phases.size())); - nextzulrahtile = Phase4pos.get(phases.size()); - currenttile = Phase4tiles.get(phases.size() - 1); - nexttile = Phase4tiles.get(phases.size()); - phaseticks = Phase4ticks.get(phases.size() - 1); - prayerconserve = true; - phase = 4; - } - else - { - System.out.println("ERROR: COULD NOT IDENTIFY ZULRAH PHASE!"); - } - not = 0; - } - } - else - { - if (phase == 1) - { - if (Phase1types.size() == phases.size()) - { - nztcolor = null; - nextzulrahtile = null; - nexttile = null; - restart = true; - } - else - { - nextzulrahtile = Phase1pos.get(phases.size()); - nexttile = Phase1tiles.get(phases.size()); - if (phases.size() == 8) - { - nztcolor = Color.YELLOW; - } - else - { - nztcolor = zulrahtype(Phase1types.get(phases.size())); - } - } - currenttile = Phase1tiles.get(phases.size() - 1); - phaseticks = Phase1ticks.get(phases.size() - 1); - } - else if (phase == 2) - { - if (Phase2types.size() == phases.size()) - { - nztcolor = null; - nextzulrahtile = null; - nexttile = null; - restart = true; - } - else - { - nextzulrahtile = Phase2pos.get(phases.size()); - nexttile = Phase2tiles.get(phases.size()); - if (phases.size() == 8) - { - nztcolor = Color.YELLOW; - } - else - { - nztcolor = zulrahtype(Phase2types.get(phases.size())); - } - } - currenttile = Phase2tiles.get(phases.size() - 1); - phaseticks = Phase2ticks.get(phases.size() - 1); - } - else if (phase == 3) - { - if (Phase3types.size() == phases.size()) - { - nztcolor = null; - nextzulrahtile = null; - nexttile = null; - restart = true; - } - else - { - nextzulrahtile = Phase3pos.get(phases.size()); - nexttile = Phase3tiles.get(phases.size()); - if (phases.size() == 9) - { - nztcolor = Color.YELLOW; - } - else - { - nztcolor = zulrahtype(Phase3types.get(phases.size())); - } - } - currenttile = Phase3tiles.get(phases.size() - 1); - phaseticks = Phase3ticks.get(phases.size() - 1); - } - else if (phase == 4) - { - if (Phase4types.size() == phases.size()) - { - nztcolor = null; - nextzulrahtile = null; - nexttile = null; - restart = true; - } - else - { - nextzulrahtile = Phase4pos.get(phases.size()); - nexttile = Phase4tiles.get(phases.size()); - if (phases.size() == 10) - { - nztcolor = Color.YELLOW; - } - else - { - nztcolor = zulrahtype(Phase4types.get(phases.size())); - } - } - currenttile = Phase4tiles.get(phases.size() - 1); - phaseticks = Phase4ticks.get(phases.size() - 1); - } - else - { - System.out.println("ERROR: COULD NOT IDENTIFY ZULRAH PHASE!"); - } - } - } - else - { - ticks++; - if (phases.size() == 1 && phaseticks == 34) - { - prayerconserve = ticks >= 18; - } - if (not == 2) - { - if (lastphase == 2043) - { - if (ticks >= 12 && ticks <= 13) - { - MeleeTile = SWCornerTileMelee; - } - else - { - MeleeTile = null; - } - } - } - else if (phase == 1) - { - if (phases.size() == 5) - { - prayerconserve = ticks >= 19; - } - else if (phases.size() == 8) - { - prayerconserve = ticks >= 19; - } - else if (phases.size() == 9) - { - prayerconserve = ticks >= 34; - } - else if (phases.size() == 10) - { - if (ticks >= 12 && ticks <= 13) - { - MeleeTile = SWCornerTileMelee; - } - else - { - MeleeTile = null; - } - } - else prayerconserve = phases.size() == 4 || phases.size() == 6 || phases.size() == 10; - } - else if (phase == 2) - { - if (phases.size() == 4) - { - prayerconserve = ticks >= 20; - } - else if (phases.size() == 8) - { - prayerconserve = ticks >= 18; - } - else if (phases.size() == 9) - { - prayerconserve = ticks >= 34; - } - else if (phases.size() == 5 || phases.size() == 7 || phases.size() == 10) - { - if (phases.size() == 10) - { - if (ticks >= 12 && ticks <= 13) - { - MeleeTile = SWCornerTileMelee; - } - else - { - MeleeTile = null; - } - } - prayerconserve = true; - } - else - { - prayerconserve = false; - } - } - else if (phase == 3) - { - if (phases.size() == 2) - { - prayerconserve = ticks >= 20; - } - else if (phases.size() == 3) - { - prayerconserve = true; - if (ticks >= 24 && ticks <= 25) - { - MeleeTile = SECornerTileMelee; - } - else if (ticks >= 32 && ticks <= 33) - { - MeleeTile = SECornerTile; - } - else - { - MeleeTile = null; - } - } - else if (phases.size() == 7 || phases.size() == 11) - { - prayerconserve = true; - } - else if (phases.size() == 9) - { - prayerconserve = ticks >= 16; - } - else - { - prayerconserve = false; - } - } - else if (phase == 4) - { - if (phases.size() == 2) - { - if (ticks >= 10 && ticks <= 16) - { - nextprayerendticks = 16; - } - else - { - nextprayerendticks = 0; - } - - prayerconserve = ticks < 16; - } - else if (phases.size() == 3) - { - prayerconserve = ticks >= 16; - } - else if (phases.size() == 4) - { - if (ticks >= 10 && ticks <= 16) - { - nextprayerendticks = 16; - } - else - { - nextprayerendticks = 0; - } - - prayerconserve = ticks <= 16; - } - else if (phases.size() == 5 || phases.size() == 7 || phases.size() == 12) - { - prayerconserve = true; - } - else if (phases.size() == 8) - { - prayerconserve = ticks >= 18; - } - else if (phases.size() == 10) - { - prayerconserve = ticks >= 14; - } - else - { - prayerconserve = false; - } - } + potential++; + potentialPattern = p; } } - } - else - { - if (zulrahstart > 0) + + if (potential == 1) { - phases.clear(); - locations.clear(); - zulrahstart = 0; - lastphase = 0; - lastloc = null; - phase = 0; - phase1 = true; - phase2 = true; - phase3 = true; - phase4 = true; - nextzulrahtile = null; - nztcolor = null; - nexttile = null; - currenttile = null; - restart = false; - ticks = 0; - prayerconserve = false; - not = 0; - nextprayerendticks = 0; - jadphase = 0; - jadflip = false; + log.debug("Zulrah pattern identified: {}", potentialPattern); + + instance.setPattern(potentialPattern); } } + else if (pattern.canReset(instance.getStage()) && (instance.getPhase() == null || instance.getPhase().equals(pattern.get(0)))) + { + log.debug("Zulrah pattern has reset."); + + instance.reset(); + } } @Subscribe - public void onAnimationChanged(AnimationChanged event) + public void onNpcSpawned(NpcSpawned event) { - Actor Zulrhyboy = event.getActor(); - if (Zulrhyboy != null && Zulrhyboy.getName() != null) + NPC npc = event.getNpc(); + if (npc != null && npc.getName().toLowerCase().contains("zulrah")) { - if (Zulrhyboy instanceof NPC) - { - if (Zulrhyboy.equals(Zulrah)) - { - if (jadphase > 0) - { - if (Zulrhyboy.getAnimation() == 5069) - { - jadflip = !jadflip; - } - } - } - } + zulrah = npc; } } - public Color zulrahtype(int type) + @Subscribe + public void onNpcDespawned(NpcDespawned event) { - switch (type) + NPC npc = event.getNpc(); + if (npc != null && npc.getName().toLowerCase().contains("zulrah")) { - case 2042: - return Color.GREEN; - case 2043: - return Color.RED; - case 2044: - return Color.BLUE; - } - return null; - } - - private void loadProtectionIcons() - { - final IndexedSprite[] protectionIcons = {}; - final IndexedSprite[] newProtectionIcons = Arrays.copyOf(protectionIcons, PROTECTION_ICONS.length); - int curPosition = 0; - - for (int i = 0; i < PROTECTION_ICONS.length; i++, curPosition++) - { - final int resource = PROTECTION_ICONS[i]; - ProtectionIcons[i] = rgbaToIndexedBufferedImage(ProtectionIconFromSprite(spriteManager.getSprite(resource, 0))); - newProtectionIcons[curPosition] = createIndexedSprite(client, ProtectionIcons[i]); + zulrah = null; } } - BufferedImage getProtectionIcon() + public ZulrahInstance getInstance() { - int type = 0; - if (phase1) - { - type = Phase1types.get(phases.size()); - } - else if (phase2) - { - type = Phase2types.get(phases.size()); - } - else if (phase3) - { - type = Phase3types.get(phases.size()); - } - else if (phase4) - { - type = Phase4types.get(phases.size()); - } - else - { - System.out.println("ERROR: COULD NOT IDENTIFY ZULRAH PHASE!"); - } - - if (type > 0) - { - switch (type) - { - case 2042: - return ProtectionIcons[0]; - case 2043: - return ProtectionIcons[1]; - case 2044: - return ProtectionIcons[2]; - } - } - return null; + return instance; } -} \ No newline at end of file +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ZulrahTileOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ZulrahTileOverlay.java deleted file mode 100644 index 65d5668be9..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ZulrahTileOverlay.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (c) 2018, https://runelitepl.us - * Copyright (c) 2018, https://github.com/runeliteplusplus - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package net.runelite.client.plugins.zulrah; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics2D; -import java.awt.Polygon; -import java.awt.image.BufferedImage; -import javax.inject.Inject; -import net.runelite.api.Client; -import net.runelite.api.NPC; -import net.runelite.api.Perspective; -import net.runelite.api.Player; -import net.runelite.api.Point; -import net.runelite.client.ui.FontManager; -import net.runelite.client.ui.overlay.Overlay; -import net.runelite.client.ui.overlay.OverlayLayer; -import net.runelite.client.ui.overlay.OverlayPosition; -import net.runelite.client.ui.overlay.OverlayPriority; -import net.runelite.client.ui.overlay.OverlayUtil; - -public class ZulrahTileOverlay extends Overlay -{ - private final ZulrahConfig config; - private final ZulrahPlugin plugin; - - @Inject - private Client client; - - @Inject - private ZulrahTileOverlay(ZulrahConfig config, ZulrahPlugin plugin) - { - this.config = config; - this.plugin = plugin; - setLayer(OverlayLayer.ABOVE_SCENE); - setPosition(OverlayPosition.DYNAMIC); - setPriority(OverlayPriority.MED); - } - - @Override - public Dimension render(Graphics2D graphics) - { - - NPC Zulrah = plugin.Zulrah; - if (Zulrah != null) - { - OverlayUtil.renderTextLocation(graphics, Zulrah.getCanvasTextLocation(graphics, Integer.toString(plugin.phaseticks - plugin.ticks), Zulrah.getLogicalHeight() + 40), Integer.toString(plugin.phaseticks - plugin.ticks), Color.WHITE); - Player player = client.getLocalPlayer(); - if (plugin.currenttile != null) - { - if (plugin.currenttile.equals(plugin.nexttile)) - { - final Polygon poly = Perspective.getCanvasTilePoly(client, plugin.currenttile); - if (poly != null) - { - Point textLocationtile = Perspective.getCanvasTextLocation(client, graphics, plugin.currenttile, "Current & Next", 50); - OverlayUtil.renderTextLocation(graphics, textLocationtile, "Current & Next", Color.WHITE); - OverlayUtil.renderPolygon(graphics, poly, Color.WHITE); - } - } - else - { - if (!player.getLocalLocation().equals(plugin.currenttile)) - { - final Polygon poly = Perspective.getCanvasTilePoly(client, plugin.currenttile); - if (poly != null) - { - Point textLocationtile = Perspective.getCanvasTextLocation(client, graphics, plugin.currenttile, "Current", 50); - OverlayUtil.renderTextLocation(graphics, textLocationtile, "Current", Color.WHITE); - OverlayUtil.renderPolygon(graphics, poly, Color.GREEN); - } - } - if (plugin.nexttile != null) - { - final Polygon poly2 = Perspective.getCanvasTilePoly(client, plugin.nexttile); - if (poly2 != null) - { - Point textLocationtile = Perspective.getCanvasTextLocation(client, graphics, plugin.nexttile, "Next", 50); - OverlayUtil.renderTextLocation(graphics, textLocationtile, "Next", Color.WHITE); - OverlayUtil.renderPolygon(graphics, poly2, Color.RED); - } - } - } - } - if (plugin.nextzulrahtile != null) - { - String style = ""; - if (plugin.nztcolor.equals(Color.RED)) - { - style = "MELEE"; - } - else if (plugin.nztcolor.equals(Color.BLUE)) - { - style = "MAGE"; - } - else if (plugin.nztcolor.equals(Color.GREEN)) - { - style = "RANGE"; - } - else if (plugin.nztcolor.equals(Color.YELLOW)) - { - style = "JAD"; - } - - final Polygon poly = Perspective.getCanvasTilePoly(client, plugin.nextzulrahtile); - Point textLocation = Perspective.getCanvasTextLocation(client, graphics, plugin.nextzulrahtile, style, 200); - if (poly != null) - { - BufferedImage clanchatImage = null; - if (style.equals("JAD")) - { - if (plugin.phase4 && plugin.phases.size() == 10) - { - clanchatImage = plugin.ProtectionIcons[2]; - } - else if (plugin.phase3 && plugin.phases.size() == 9) - { - clanchatImage = plugin.ProtectionIcons[2]; - } - else - { - clanchatImage = plugin.ProtectionIcons[0]; - } - } - else - { - clanchatImage = plugin.getProtectionIcon(); - } - - if (clanchatImage != null) - { - Point imageLocation = new Point(textLocation.getX(), textLocation.getY() + 15); - OverlayUtil.renderImageLocation(graphics, imageLocation, clanchatImage); - } - - graphics.setFont(FontManager.getRunescapeBoldFont()); - OverlayUtil.renderTextLocation(graphics, textLocation, style, Color.WHITE); - OverlayUtil.renderPolygon(graphics, poly, plugin.nztcolor); - } - } - if (plugin.MeleeTile != null) - { - final Polygon poly = Perspective.getCanvasTilePoly(client, plugin.MeleeTile); - if (poly != null) - { - Point textLocationtile = Perspective.getCanvasTextLocation(client, graphics, plugin.MeleeTile, "MOVE HERE NOW!", 50); - graphics.setFont(FontManager.getRunescapeBoldFont()); - OverlayUtil.renderTextLocation(graphics, textLocationtile, "MOVE HERE NOW!", Color.WHITE); - OverlayUtil.renderPolygon(graphics, poly, Color.BLACK); - } - } - } - return null; - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/overlays/ZulrahCurrentPhaseOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/overlays/ZulrahCurrentPhaseOverlay.java new file mode 100644 index 0000000000..2d7bbbcff1 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/overlays/ZulrahCurrentPhaseOverlay.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2017, Aria + * Copyright (c) 2017, Adam + * Copyright (c) 2017, Devin French + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.zulrah.overlays; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import javax.inject.Inject; +import net.runelite.client.plugins.zulrah.ImagePanelComponent; +import net.runelite.client.plugins.zulrah.ZulrahInstance; +import net.runelite.client.plugins.zulrah.ZulrahPlugin; +import net.runelite.client.plugins.zulrah.phase.ZulrahPhase; +import net.runelite.client.ui.overlay.Overlay; +import net.runelite.client.ui.overlay.OverlayPosition; +import net.runelite.client.ui.overlay.OverlayPriority; +import net.runelite.client.ui.overlay.components.PanelComponent; + +public class ZulrahCurrentPhaseOverlay extends Overlay +{ + private final ZulrahPlugin plugin; + private final PanelComponent imagePanelComponent = new PanelComponent(); + + @Inject + ZulrahCurrentPhaseOverlay(ZulrahPlugin plugin) + { + setPosition(OverlayPosition.BOTTOM_RIGHT); + setPriority(OverlayPriority.HIGH); + this.plugin = plugin; + } + + @Override + public Dimension render(Graphics2D graphics) + { + ZulrahInstance instance = plugin.getInstance(); + + if (instance == null) + { + return null; + } + + ZulrahPhase currentPhase = instance.getPhase(); + if (currentPhase == null) + { + return null; + } + + String pattern = instance.getPattern() != null ? instance.getPattern().toString() : "Unknown"; + String title = currentPhase.isJad() ? "JAD PHASE" : pattern; + Color backgroundColor = currentPhase.getColor(); + BufferedImage zulrahImage = ZulrahImageManager.getZulrahBufferedImage(currentPhase.getType()); + ImagePanelComponent imagePanelComponent = new ImagePanelComponent(); + imagePanelComponent.setTitle(title); + imagePanelComponent.setBackgroundColor(backgroundColor); + imagePanelComponent.setImage(zulrahImage); + return imagePanelComponent.render(graphics); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/overlays/ZulrahImageManager.java b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/overlays/ZulrahImageManager.java new file mode 100644 index 0000000000..c64736c352 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/overlays/ZulrahImageManager.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2017, Aria + * Copyright (c) 2017, Adam + * Copyright (c) 2017, Devin French + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.zulrah.overlays; + +import java.awt.image.BufferedImage; +import lombok.extern.slf4j.Slf4j; +import net.runelite.api.Prayer; +import net.runelite.client.plugins.zulrah.ZulrahPlugin; +import net.runelite.client.plugins.zulrah.phase.ZulrahType; +import net.runelite.client.util.ImageUtil; + +@Slf4j +public class ZulrahImageManager +{ + private static final BufferedImage[] zulrahBufferedImages = new BufferedImage[3]; + private static final BufferedImage[] smallZulrahBufferedImages = new BufferedImage[3]; + private static final BufferedImage[] prayerBufferedImages = new BufferedImage[2]; + + public static BufferedImage getZulrahBufferedImage(ZulrahType type) + { + switch (type) + { + case RANGE: + if (zulrahBufferedImages[0] == null) + { + zulrahBufferedImages[0] = getBufferedImage("zulrah_range.png"); + } + return zulrahBufferedImages[0]; + case MAGIC: + if (zulrahBufferedImages[1] == null) + { + zulrahBufferedImages[1] = getBufferedImage("zulrah_magic.png"); + } + return zulrahBufferedImages[1]; + case MELEE: + if (zulrahBufferedImages[2] == null) + { + zulrahBufferedImages[2] = getBufferedImage("zulrah_melee.png"); + } + return zulrahBufferedImages[2]; + } + return null; + } + + public static BufferedImage getSmallZulrahBufferedImage(ZulrahType type) + { + switch (type) + { + case RANGE: + if (smallZulrahBufferedImages[0] == null) + { + smallZulrahBufferedImages[0] = getBufferedImage("zulrah_range.png"); + } + return smallZulrahBufferedImages[0]; + case MAGIC: + if (smallZulrahBufferedImages[1] == null) + { + smallZulrahBufferedImages[1] = getBufferedImage("zulrah_magic.png"); + } + return smallZulrahBufferedImages[1]; + case MELEE: + if (smallZulrahBufferedImages[2] == null) + { + smallZulrahBufferedImages[2] = getBufferedImage("zulrah_melee.png"); + } + return smallZulrahBufferedImages[2]; + } + return null; + } + + public static BufferedImage getProtectionPrayerBufferedImage(Prayer prayer) + { + switch (prayer) + { + case PROTECT_FROM_MAGIC: + if (prayerBufferedImages[0] == null) + { + prayerBufferedImages[0] = getBufferedImage("protect_from_magic.png"); + } + return prayerBufferedImages[0]; + case PROTECT_FROM_MISSILES: + if (prayerBufferedImages[1] == null) + { + prayerBufferedImages[1] = getBufferedImage("protect_from_missiles.png"); + } + return prayerBufferedImages[1]; + } + return null; + } + + private static BufferedImage getBufferedImage(String path) + { + return ImageUtil.getResourceStreamFromClass(ZulrahPlugin.class, path); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/overlays/ZulrahNextPhaseOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/overlays/ZulrahNextPhaseOverlay.java new file mode 100644 index 0000000000..509631e9b8 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/overlays/ZulrahNextPhaseOverlay.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2017, Aria + * Copyright (c) 2017, Adam + * Copyright (c) 2017, Devin French + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.zulrah.overlays; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import javax.inject.Inject; +import net.runelite.client.plugins.zulrah.ImagePanelComponent; +import net.runelite.client.plugins.zulrah.ZulrahInstance; +import net.runelite.client.plugins.zulrah.ZulrahPlugin; +import net.runelite.client.plugins.zulrah.phase.ZulrahPhase; +import net.runelite.client.ui.overlay.Overlay; +import net.runelite.client.ui.overlay.OverlayPosition; +import net.runelite.client.ui.overlay.OverlayPriority; + +public class ZulrahNextPhaseOverlay extends Overlay +{ + private final ZulrahPlugin plugin; + + @Inject + ZulrahNextPhaseOverlay(ZulrahPlugin plugin) + { + setPosition(OverlayPosition.BOTTOM_RIGHT); + setPriority(OverlayPriority.HIGH); + this.plugin = plugin; + } + + @Override + public Dimension render(Graphics2D graphics) + { + ZulrahInstance instance = plugin.getInstance(); + + if (instance == null) + { + return null; + } + + ZulrahPhase nextPhase = instance.getNextPhase(); + if (nextPhase == null) + { + return null; + } + + Color backgroundColor = nextPhase.getColor(); + BufferedImage zulrahImage = ZulrahImageManager.getSmallZulrahBufferedImage(nextPhase.getType()); + ImagePanelComponent imagePanelComponent = new ImagePanelComponent(); + imagePanelComponent.setTitle("Next"); + imagePanelComponent.setBackgroundColor(backgroundColor); + imagePanelComponent.setImage(zulrahImage); + return imagePanelComponent.render(graphics); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/overlays/ZulrahOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/overlays/ZulrahOverlay.java new file mode 100644 index 0000000000..93ce00d4bc --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/overlays/ZulrahOverlay.java @@ -0,0 +1,246 @@ +/* + * Copyright (c) 2017, Aria + * Copyright (c) 2017, Adam + * Copyright (c) 2017, Devin French + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.zulrah.overlays; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FontMetrics; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.Polygon; +import java.awt.image.BufferedImage; +import javax.annotation.Nullable; +import javax.inject.Inject; +import lombok.extern.slf4j.Slf4j; +import net.runelite.api.Client; +import net.runelite.api.Perspective; +import net.runelite.api.Point; +import net.runelite.api.coords.LocalPoint; +import net.runelite.client.plugins.zulrah.ZulrahInstance; +import net.runelite.client.plugins.zulrah.ZulrahPlugin; +import net.runelite.client.plugins.zulrah.phase.ZulrahPhase; +import net.runelite.client.ui.overlay.Overlay; +import net.runelite.client.ui.overlay.OverlayPosition; + +@Slf4j +public class ZulrahOverlay extends Overlay +{ + private static final Color TILE_BORDER_COLOR = new Color(0, 0, 0, 100); + private static final Color NEXT_TEXT_COLOR = new Color(255, 255, 255, 100); + + private final Client client; + private final ZulrahPlugin plugin; + + @Inject + ZulrahOverlay(@Nullable Client client, ZulrahPlugin plugin) + { + setPosition(OverlayPosition.DYNAMIC); + this.client = client; + this.plugin = plugin; + } + + @Override + public Dimension render(Graphics2D graphics) + { + ZulrahInstance instance = plugin.getInstance(); + + if (instance == null) + { + return null; + } + + ZulrahPhase currentPhase = instance.getPhase(); + ZulrahPhase nextPhase = instance.getNextPhase(); + if (currentPhase == null) + { + log.debug("Current phase is NULL"); + return null; + } + + LocalPoint startTile = instance.getStartLocation(); + if (nextPhase != null && currentPhase.getStandLocation() == nextPhase.getStandLocation()) + { + drawStandTiles(graphics, startTile, currentPhase, nextPhase); + } + else + { + drawStandTile(graphics, startTile, currentPhase, false); + drawStandTile(graphics, startTile, nextPhase, true); + } + drawZulrahTileMinimap(graphics, startTile, currentPhase, false); + drawZulrahTileMinimap(graphics, startTile, nextPhase, true); + + return null; + } + + private void drawStandTiles(Graphics2D graphics, LocalPoint startTile, ZulrahPhase currentPhase, ZulrahPhase nextPhase) + { + LocalPoint localTile = currentPhase.getStandTile(startTile); + Polygon northPoly = getCanvasTileNorthPoly(client, localTile); + Polygon southPoly = getCanvasTileSouthPoly(client, localTile); + Polygon poly = Perspective.getCanvasTilePoly(client, localTile); + Point textLoc = Perspective.getCanvasTextLocation(client, graphics, localTile, "Stand / Next", 0); + if (northPoly != null && southPoly != null && poly != null && textLoc != null) + { + Color northColor = currentPhase.getColor(); + Color southColor = nextPhase.getColor(); + graphics.setColor(northColor); + graphics.fillPolygon(northPoly); + graphics.setColor(southColor); + graphics.fillPolygon(southPoly); + graphics.setColor(TILE_BORDER_COLOR); + graphics.setStroke(new BasicStroke(2)); + graphics.drawPolygon(poly); + graphics.setColor(NEXT_TEXT_COLOR); + graphics.drawString("Stand / Next", textLoc.getX(), textLoc.getY()); + } + if (nextPhase.isJad()) + { + Image jadPrayerImg = ZulrahImageManager.getProtectionPrayerBufferedImage(nextPhase.getPrayer()); + if (jadPrayerImg != null) + { + Point imageLoc = Perspective.getCanvasImageLocation(client, localTile, (BufferedImage) jadPrayerImg, 0); + if (imageLoc != null) + { + graphics.drawImage(jadPrayerImg, imageLoc.getX(), imageLoc.getY(), null); + } + } + } + } + + private void drawStandTile(Graphics2D graphics, LocalPoint startTile, ZulrahPhase phase, boolean next) + { + if (phase == null) + { + log.debug("phase null"); + return; + } + + LocalPoint localTile = phase.getStandTile(startTile); + Polygon poly = Perspective.getCanvasTilePoly(client, localTile); + Color color = phase.getColor(); + if (poly != null) + { + graphics.setColor(TILE_BORDER_COLOR); + graphics.setStroke(new BasicStroke(2)); + graphics.drawPolygon(poly); + graphics.setColor(color); + graphics.fillPolygon(poly); + Point textLoc = Perspective.getCanvasTextLocation(client, graphics, localTile, (next) ? "Next" : "Stand", 0); + if (textLoc != null) + { + graphics.setColor(NEXT_TEXT_COLOR); + graphics.drawString((next) ? "Next" : "Stand", textLoc.getX(), textLoc.getY()); + } + } + else + { + log.debug("poly null"); + } + + if (phase.isJad()) + { + Image jadPrayerImg = ZulrahImageManager.getProtectionPrayerBufferedImage(phase.getPrayer()); + if (jadPrayerImg != null) + { + Point imageLoc = Perspective.getCanvasImageLocation(client, localTile, (BufferedImage) jadPrayerImg, 0); + if (imageLoc != null) + { + graphics.drawImage(jadPrayerImg, imageLoc.getX(), imageLoc.getY(), null); + } + } + } + } + + private void drawZulrahTileMinimap(Graphics2D graphics, LocalPoint startTile, ZulrahPhase phase, boolean next) + { + if (phase == null) + { + return; + } + LocalPoint zulrahLocalTile = phase.getZulrahTile(startTile); + Point zulrahMinimapPoint = Perspective.localToMinimap(client, zulrahLocalTile); + Color color = phase.getColor(); + graphics.setColor(color); + graphics.fillOval(zulrahMinimapPoint.getX() - 2, zulrahMinimapPoint.getY() - 2, 4, 4); + graphics.setColor(TILE_BORDER_COLOR); + graphics.setStroke(new BasicStroke(1)); + graphics.drawOval(zulrahMinimapPoint.getX() - 2, zulrahMinimapPoint.getY() - 2, 4, 4); + if (next) + { + graphics.setColor(NEXT_TEXT_COLOR); + FontMetrics fm = graphics.getFontMetrics(); + graphics.drawString("Next", zulrahMinimapPoint.getX() - fm.stringWidth("Next") / 2, zulrahMinimapPoint.getY() - 2); + } + } + + private Polygon getCanvasTileNorthPoly(Client client, LocalPoint localLocation) + { + int plane = client.getPlane(); + int halfTile = Perspective.LOCAL_TILE_SIZE / 2; + + Point p1 = Perspective.localToCanvas(client, new LocalPoint(localLocation.getX() - halfTile, localLocation.getY() - halfTile), plane); + Point p2 = Perspective.localToCanvas(client, new LocalPoint(localLocation.getX() - halfTile, localLocation.getY() + halfTile), plane); + Point p3 = Perspective.localToCanvas(client, new LocalPoint(localLocation.getX() + halfTile, localLocation.getY() + halfTile), plane); + + if (p1 == null || p2 == null || p3 == null) + { + return null; + } + + Polygon poly = new Polygon(); + poly.addPoint(p1.getX(), p1.getY()); + poly.addPoint(p2.getX(), p2.getY()); + poly.addPoint(p3.getX(), p3.getY()); + + return poly; + } + + private Polygon getCanvasTileSouthPoly(Client client, LocalPoint localLocation) + { + int plane = client.getPlane(); + int halfTile = Perspective.LOCAL_TILE_SIZE / 2; + + Point p1 = Perspective.localToCanvas(client, new LocalPoint(localLocation.getX() - halfTile, localLocation.getY() - halfTile), plane); + Point p2 = Perspective.localToCanvas(client, new LocalPoint(localLocation.getX() + halfTile, localLocation.getY() + halfTile), plane); + Point p3 = Perspective.localToCanvas(client, new LocalPoint(localLocation.getX() + halfTile, localLocation.getY() - halfTile), plane); + + if (p1 == null || p2 == null || p3 == null) + { + return null; + } + + Polygon poly = new Polygon(); + poly.addPoint(p1.getX(), p1.getY()); + poly.addPoint(p2.getX(), p2.getY()); + poly.addPoint(p3.getX(), p3.getY()); + + return poly; + } + +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/overlays/ZulrahPrayerOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/overlays/ZulrahPrayerOverlay.java new file mode 100644 index 0000000000..abcd234034 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/overlays/ZulrahPrayerOverlay.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2017, Aria + * Copyright (c) 2017, Adam + * Copyright (c) 2017, Devin French + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.zulrah.overlays; + +import java.awt.Dimension; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import javax.annotation.Nullable; +import javax.inject.Inject; +import lombok.extern.slf4j.Slf4j; +import net.runelite.api.Client; +import net.runelite.api.Prayer; +import net.runelite.client.plugins.zulrah.ImagePanelComponent; +import net.runelite.client.plugins.zulrah.ZulrahInstance; +import net.runelite.client.plugins.zulrah.ZulrahPlugin; +import net.runelite.client.plugins.zulrah.phase.ZulrahPhase; +import net.runelite.client.ui.overlay.Overlay; +import net.runelite.client.ui.overlay.OverlayPosition; +import net.runelite.client.ui.overlay.OverlayPriority; + +@Slf4j +public class ZulrahPrayerOverlay extends Overlay +{ + private final Client client; + private final ZulrahPlugin plugin; + + @Inject + ZulrahPrayerOverlay(@Nullable Client client, ZulrahPlugin plugin) + { + setPosition(OverlayPosition.BOTTOM_RIGHT); + setPriority(OverlayPriority.MED); + this.client = client; + this.plugin = plugin; + } + + @Override + public Dimension render(Graphics2D graphics) + { + ZulrahInstance instance = plugin.getInstance(); + + if (instance == null) + { + return null; + } + + ZulrahPhase currentPhase = instance.getPhase(); + if (currentPhase == null) + { + return null; + } + + Prayer prayer = currentPhase.isJad() ? null : currentPhase.getPrayer(); + if (prayer == null) + { + return null; + } + + BufferedImage prayerImage = ZulrahImageManager.getProtectionPrayerBufferedImage(prayer); + ImagePanelComponent imagePanelComponent = new ImagePanelComponent(); + imagePanelComponent.setTitle((!client.isPrayerActive(prayer)) ? "Switch!" : "Prayer"); + imagePanelComponent.setImage(prayerImage); + return imagePanelComponent.render(graphics); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/patterns/ZulrahPattern.java b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/patterns/ZulrahPattern.java new file mode 100644 index 0000000000..b6c9cec4ab --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/patterns/ZulrahPattern.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2017, Aria + * Copyright (c) 2017, Adam + * Copyright (c) 2017, Devin French + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.runelite.client.plugins.zulrah.patterns; + +import java.util.ArrayList; +import java.util.List; +import net.runelite.api.Prayer; +import net.runelite.client.plugins.zulrah.phase.StandLocation; +import net.runelite.client.plugins.zulrah.phase.ZulrahLocation; +import net.runelite.client.plugins.zulrah.phase.ZulrahPhase; +import net.runelite.client.plugins.zulrah.phase.ZulrahType; + +public abstract class ZulrahPattern +{ + private final List pattern = new ArrayList<>(); + + protected final void add(ZulrahLocation loc, ZulrahType type, StandLocation standLocation, Prayer prayer) + { + add(loc, type, standLocation, false, prayer); + } + + protected final void addJad(ZulrahLocation loc, ZulrahType type, StandLocation standLocation, Prayer prayer) + { + add(loc, type, standLocation, true, prayer); + } + + private void add(ZulrahLocation loc, ZulrahType type, StandLocation standLocation, boolean jad, Prayer prayer) + { + pattern.add(new ZulrahPhase(loc, type, jad, standLocation, prayer)); + } + + public ZulrahPhase get(int index) + { + if (index >= pattern.size()) + { + return null; + } + + return pattern.get(index); + } + + public boolean stageMatches(int index, ZulrahPhase instance) + { + ZulrahPhase patternInstance = get(index); + return patternInstance != null && patternInstance.equals(instance); + } + + public boolean canReset(int index) + { + return index >= pattern.size(); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/patterns/ZulrahPatternA.java b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/patterns/ZulrahPatternA.java new file mode 100644 index 0000000000..887236f321 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/patterns/ZulrahPatternA.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2017, Aria + * Copyright (c) 2017, Adam + * Copyright (c) 2017, Devin French + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.zulrah.patterns; + +import net.runelite.api.Prayer; +import net.runelite.client.plugins.zulrah.phase.StandLocation; +import net.runelite.client.plugins.zulrah.phase.ZulrahLocation; +import net.runelite.client.plugins.zulrah.phase.ZulrahType; + +public class ZulrahPatternA extends ZulrahPattern +{ + public ZulrahPatternA() + { + add(ZulrahLocation.NORTH, ZulrahType.RANGE, StandLocation.TOP_EAST, null); + add(ZulrahLocation.NORTH, ZulrahType.MELEE, StandLocation.TOP_EAST, null); + add(ZulrahLocation.NORTH, ZulrahType.MAGIC, StandLocation.PILLAR_WEST_INSIDE, Prayer.PROTECT_FROM_MAGIC); + add(ZulrahLocation.SOUTH, ZulrahType.RANGE, StandLocation.PILLAR_WEST_INSIDE, Prayer.PROTECT_FROM_MISSILES); + add(ZulrahLocation.NORTH, ZulrahType.MELEE, StandLocation.PILLAR_WEST_INSIDE, null); + add(ZulrahLocation.WEST, ZulrahType.MAGIC, StandLocation.PILLAR_WEST_INSIDE, Prayer.PROTECT_FROM_MAGIC); + add(ZulrahLocation.SOUTH, ZulrahType.RANGE, StandLocation.PILLAR_EAST_OUTSIDE, null); + add(ZulrahLocation.SOUTH, ZulrahType.MAGIC, StandLocation.SOUTH_WEST, Prayer.PROTECT_FROM_MAGIC); + addJad(ZulrahLocation.WEST, ZulrahType.RANGE, StandLocation.TOP_WEST, Prayer.PROTECT_FROM_MISSILES); + add(ZulrahLocation.NORTH, ZulrahType.MELEE, StandLocation.TOP_WEST, null); + } + + @Override + public String toString() + { + return "Pattern A"; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/patterns/ZulrahPatternB.java b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/patterns/ZulrahPatternB.java new file mode 100644 index 0000000000..e6a7a00c6c --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/patterns/ZulrahPatternB.java @@ -0,0 +1,29 @@ +package net.runelite.client.plugins.zulrah.patterns; + +import net.runelite.api.Prayer; +import net.runelite.client.plugins.zulrah.phase.StandLocation; +import net.runelite.client.plugins.zulrah.phase.ZulrahLocation; +import net.runelite.client.plugins.zulrah.phase.ZulrahType; + +public class ZulrahPatternB extends ZulrahPattern +{ + public ZulrahPatternB() + { + add(ZulrahLocation.NORTH, ZulrahType.RANGE, StandLocation.TOP_EAST, null); + add(ZulrahLocation.NORTH, ZulrahType.MELEE, StandLocation.TOP_EAST, null); + add(ZulrahLocation.NORTH, ZulrahType.MAGIC, StandLocation.PILLAR_WEST_OUTSIDE, Prayer.PROTECT_FROM_MAGIC); + add(ZulrahLocation.WEST, ZulrahType.RANGE, StandLocation.PILLAR_WEST_OUTSIDE, null); + add(ZulrahLocation.SOUTH, ZulrahType.MAGIC, StandLocation.SOUTH_WEST, Prayer.PROTECT_FROM_MAGIC); // optional phase + add(ZulrahLocation.NORTH, ZulrahType.MELEE, StandLocation.PILLAR_WEST_INSIDE, null); + add(ZulrahLocation.EAST, ZulrahType.RANGE, StandLocation.SOUTH_EAST, Prayer.PROTECT_FROM_MISSILES); + add(ZulrahLocation.SOUTH, ZulrahType.MAGIC, StandLocation.SOUTH_WEST, Prayer.PROTECT_FROM_MAGIC); + addJad(ZulrahLocation.WEST, ZulrahType.RANGE, StandLocation.TOP_WEST, Prayer.PROTECT_FROM_MISSILES); + add(ZulrahLocation.NORTH, ZulrahType.MELEE, StandLocation.TOP_WEST, null); + } + + @Override + public String toString() + { + return "Pattern B"; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/patterns/ZulrahPatternC.java b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/patterns/ZulrahPatternC.java new file mode 100644 index 0000000000..3b9aa40edb --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/patterns/ZulrahPatternC.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2017, Aria + * Copyright (c) 2017, Adam + * Copyright (c) 2017, Devin French + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.zulrah.patterns; + +import net.runelite.api.Prayer; +import net.runelite.client.plugins.zulrah.phase.StandLocation; +import net.runelite.client.plugins.zulrah.phase.ZulrahLocation; +import net.runelite.client.plugins.zulrah.phase.ZulrahType; + +public class ZulrahPatternC extends ZulrahPattern +{ + public ZulrahPatternC() + { + add(ZulrahLocation.NORTH, ZulrahType.RANGE, StandLocation.TOP_EAST, null); + add(ZulrahLocation.EAST, ZulrahType.RANGE, StandLocation.TOP_EAST, Prayer.PROTECT_FROM_MISSILES); + add(ZulrahLocation.NORTH, ZulrahType.MELEE, StandLocation.TOP_WEST, null); + add(ZulrahLocation.WEST, ZulrahType.MAGIC, StandLocation.WEST, Prayer.PROTECT_FROM_MAGIC); + add(ZulrahLocation.SOUTH, ZulrahType.RANGE, StandLocation.SOUTH_EAST, Prayer.PROTECT_FROM_MISSILES); + add(ZulrahLocation.EAST, ZulrahType.MAGIC, StandLocation.PILLAR_EAST_OUTSIDE, Prayer.PROTECT_FROM_MAGIC); + add(ZulrahLocation.NORTH, ZulrahType.RANGE, StandLocation.PILLAR_WEST_OUTSIDE, null); + add(ZulrahLocation.WEST, ZulrahType.RANGE, StandLocation.PILLAR_WEST_OUTSIDE, Prayer.PROTECT_FROM_MISSILES); + add(ZulrahLocation.NORTH, ZulrahType.MAGIC, StandLocation.TOP_EAST, Prayer.PROTECT_FROM_MAGIC); + addJad(ZulrahLocation.EAST, ZulrahType.MAGIC, StandLocation.TOP_EAST, Prayer.PROTECT_FROM_MAGIC); + add(ZulrahLocation.NORTH, ZulrahType.MAGIC, StandLocation.TOP_EAST, null); + } + + @Override + public String toString() + { + return "Pattern C"; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/patterns/ZulrahPatternD.java b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/patterns/ZulrahPatternD.java new file mode 100644 index 0000000000..bed503e24f --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/patterns/ZulrahPatternD.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2017, Aria + * Copyright (c) 2017, Adam + * Copyright (c) 2017, Devin French + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.zulrah.patterns; + +import net.runelite.api.Prayer; +import net.runelite.client.plugins.zulrah.phase.StandLocation; +import net.runelite.client.plugins.zulrah.phase.ZulrahLocation; +import net.runelite.client.plugins.zulrah.phase.ZulrahType; + +public class ZulrahPatternD extends ZulrahPattern +{ + public ZulrahPatternD() + { + add(ZulrahLocation.NORTH, ZulrahType.RANGE, StandLocation.TOP_EAST, null); + add(ZulrahLocation.EAST, ZulrahType.MAGIC, StandLocation.TOP_EAST, Prayer.PROTECT_FROM_MAGIC); + add(ZulrahLocation.SOUTH, ZulrahType.RANGE, StandLocation.PILLAR_WEST_INSIDE, Prayer.PROTECT_FROM_MISSILES); + add(ZulrahLocation.WEST, ZulrahType.MAGIC, StandLocation.PILLAR_WEST_INSIDE, Prayer.PROTECT_FROM_MAGIC); + add(ZulrahLocation.NORTH, ZulrahType.MELEE, StandLocation.PILLAR_EAST_OUTSIDE, null); + add(ZulrahLocation.EAST, ZulrahType.RANGE, StandLocation.PILLAR_EAST_OUTSIDE, Prayer.PROTECT_FROM_MISSILES); + add(ZulrahLocation.SOUTH, ZulrahType.RANGE, StandLocation.PILLAR_WEST_OUTSIDE, null); + add(ZulrahLocation.WEST, ZulrahType.MAGIC, StandLocation.PILLAR_WEST_OUTSIDE, Prayer.PROTECT_FROM_MAGIC); + add(ZulrahLocation.NORTH, ZulrahType.RANGE, StandLocation.TOP_EAST, Prayer.PROTECT_FROM_MISSILES); + add(ZulrahLocation.NORTH, ZulrahType.MAGIC, StandLocation.TOP_EAST, Prayer.PROTECT_FROM_MAGIC); + addJad(ZulrahLocation.EAST, ZulrahType.MAGIC, StandLocation.TOP_EAST, Prayer.PROTECT_FROM_MAGIC); + add(ZulrahLocation.NORTH, ZulrahType.MAGIC, StandLocation.TOP_EAST, null); + } + + @Override + public String toString() + { + return "Pattern D"; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/phase/StandLocation.java b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/phase/StandLocation.java new file mode 100644 index 0000000000..6f2a757472 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/phase/StandLocation.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2017, Aria + * Copyright (c) 2017, Devin French + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.zulrah.phase; + +public enum StandLocation +{ + WEST, + EAST, + SOUTH, + SOUTH_WEST, + SOUTH_EAST, + TOP_EAST, + TOP_WEST, + PILLAR_WEST_INSIDE, + PILLAR_WEST_OUTSIDE, + PILLAR_EAST_INSIDE, + PILLAR_EAST_OUTSIDE +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/phase/ZulrahLocation.java b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/phase/ZulrahLocation.java new file mode 100644 index 0000000000..ce5ab0fa94 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/phase/ZulrahLocation.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2017, Aria + * Copyright (c) 2017, Devin French + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.zulrah.phase; + +import lombok.extern.slf4j.Slf4j; +import net.runelite.api.coords.LocalPoint; + +@Slf4j +public enum ZulrahLocation +{ + NORTH, SOUTH, EAST, WEST; + + public static ZulrahLocation valueOf(LocalPoint start, LocalPoint current) + { + int dx = start.getX() - current.getX(); + int dy = start.getY() - current.getY(); + if (dx == -10 * 128 && dy == 2 * 128) + { + return ZulrahLocation.EAST; + } + else if (dx == 10 * 128 && dy == 2 * 128) + { + return ZulrahLocation.WEST; + } + else if (dx == 0 && dy == 11 * 128) + { + return ZulrahLocation.SOUTH; + } + else if (dx == 0 && dy == 0) + { + return ZulrahLocation.NORTH; + } + else + { + log.debug("Unknown Zulrah location dx: {}, dy: {}", dx, dy); + return null; + } + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/phase/ZulrahPhase.java b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/phase/ZulrahPhase.java new file mode 100644 index 0000000000..86aad17841 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/phase/ZulrahPhase.java @@ -0,0 +1,188 @@ +/* + * Copyright (c) 2017, Aria + * Copyright (c) 2017, Devin French + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.zulrah.phase; + +import java.awt.Color; +import net.runelite.api.NPC; +import net.runelite.api.Prayer; +import net.runelite.api.coords.LocalPoint; + +public class ZulrahPhase +{ + private static final Color RANGE_COLOR = new Color(150, 255, 0, 100); + private static final Color MAGIC_COLOR = new Color(20, 170, 200, 100); + private static final Color MELEE_COLOR = new Color(180, 50, 20, 100); + private static final Color JAD_COLOR = new Color(255, 115, 0, 100); + + private final ZulrahLocation zulrahLocation; + private final ZulrahType type; + private final boolean jad; + private final StandLocation standLocation; + private final Prayer prayer; + + public ZulrahPhase(ZulrahLocation zulrahLocation, ZulrahType type, boolean jad, StandLocation standLocation, Prayer prayer) + { + this.zulrahLocation = zulrahLocation; + this.type = type; + this.jad = jad; + this.standLocation = standLocation; + this.prayer = prayer; + } + + public static ZulrahPhase valueOf(NPC zulrah, LocalPoint start) + { + ZulrahLocation zulrahLocation = ZulrahLocation.valueOf(start, zulrah.getLocalLocation()); + ZulrahType zulrahType = ZulrahType.valueOf(zulrah.getId()); + if (zulrahLocation == null || zulrahType == null) + { + return null; + } + StandLocation standLocation = zulrahType == ZulrahType.MAGIC ? StandLocation.PILLAR_WEST_OUTSIDE : StandLocation.TOP_EAST; + Prayer prayer = zulrahType == ZulrahType.MAGIC ? Prayer.PROTECT_FROM_MAGIC : null; + return new ZulrahPhase(zulrahLocation, zulrahType, false, standLocation, prayer); + } + + @Override + public String toString() + { + return "ZulrahPhase{" + + "zulrahLocation=" + zulrahLocation + + ", type=" + type + + ", jad=" + jad + + ", standLocation=" + standLocation + + ", prayer=" + prayer + + '}'; + } + + // world location + public LocalPoint getZulrahTile(LocalPoint startTile) + { + // NORTH doesn't need changing because it is the start + switch (zulrahLocation) + { + case SOUTH: + return new LocalPoint(startTile.getX(), startTile.getY() - (11 * 128)); + case EAST: + return new LocalPoint(startTile.getX() + (10 * 128), startTile.getY() - (2 * 128)); + case WEST: + return new LocalPoint(startTile.getX() - (10 * 128), startTile.getY() - (2 * 128)); + } + return startTile; + } + + // world location + public LocalPoint getStandTile(LocalPoint startTile) + { + switch (standLocation) + { + case WEST: + return new LocalPoint(startTile.getX() - (5 * 128), startTile.getY()); + case EAST: + return new LocalPoint(startTile.getX() + (5 * 128), startTile.getY() - (2 * 128)); + case SOUTH: + return new LocalPoint(startTile.getX(), startTile.getY() - (6 * 128)); + case SOUTH_WEST: + return new LocalPoint(startTile.getX() - (4 * 128), startTile.getY() - (4 * 128)); + case SOUTH_EAST: + return new LocalPoint(startTile.getX() + (2 * 128), startTile.getY() - (6 * 128)); + case TOP_EAST: + return new LocalPoint(startTile.getX() + (6 * 128), startTile.getY() + (2 * 128)); + case TOP_WEST: + return new LocalPoint(startTile.getX() - (4 * 128), startTile.getY() + (3 * 128)); + case PILLAR_WEST_INSIDE: + return new LocalPoint(startTile.getX() - (4 * 128), startTile.getY() - (3 * 128)); + case PILLAR_WEST_OUTSIDE: + return new LocalPoint(startTile.getX() - (5 * 128), startTile.getY() - (3 * 128)); + case PILLAR_EAST_INSIDE: + return new LocalPoint(startTile.getX() + (4 * 128), startTile.getY() - (3 * 128)); + case PILLAR_EAST_OUTSIDE: + return new LocalPoint(startTile.getX() + (4 * 128), startTile.getY() - (4 * 128)); + } + System.out.println("Fell through switch block"); + return startTile; + } + + public ZulrahLocation getZulrahLocation() + { + return zulrahLocation; + } + + public ZulrahType getType() + { + return type; + } + + public boolean isJad() + { + return jad; + } + + public StandLocation getStandLocation() + { + return standLocation; + } + + public Prayer getPrayer() + { + return prayer; + } + + @Override + public boolean equals(Object obj) + { + if (this == obj) + { + return true; + } + if (obj == null || getClass() != obj.getClass()) + { + return false; + } + ZulrahPhase other = (ZulrahPhase) obj; + return this.jad == other.jad && this.zulrahLocation == other.zulrahLocation && this.type == other.type; + } + + public Color getColor() + { + if (jad) + { + return JAD_COLOR; + } + else + { + switch (type) + { + case RANGE: + return RANGE_COLOR; + case MAGIC: + return MAGIC_COLOR; + case MELEE: + return MELEE_COLOR; + } + } + return RANGE_COLOR; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/phase/ZulrahType.java b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/phase/ZulrahType.java new file mode 100644 index 0000000000..60b6bfb9fb --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/phase/ZulrahType.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017, Aria + * Copyright (c) 2017, Devin French + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.zulrah.phase; + +import lombok.extern.slf4j.Slf4j; +import net.runelite.api.NpcID; + +@Slf4j +public enum ZulrahType +{ + RANGE, MAGIC, MELEE; + + private static final int ZULRAH_RANGE = NpcID.ZULRAH; + private static final int ZULRAH_MELEE = NpcID.ZULRAH_2043; + private static final int ZULRAH_MAGIC = NpcID.ZULRAH_2044; + + public static ZulrahType valueOf(int zulrahId) + { + switch (zulrahId) + { + case ZULRAH_RANGE: + return ZulrahType.RANGE; + case ZULRAH_MELEE: + return ZulrahType.MELEE; + case ZULRAH_MAGIC: + return ZulrahType.MAGIC; + } + log.debug("Unknown Zulrah Id: {}", zulrahId); + return null; + } +}