Merge pull request #197 from devinfrench/zulrah

Update Zulrah plugin
This commit is contained in:
Adam
2017-11-03 10:48:31 -04:00
committed by GitHub
23 changed files with 933 additions and 593 deletions

View File

@@ -40,6 +40,8 @@ public interface Actor extends Renderable
int getHealth();
Point getWorldLocation();
Point getLocalLocation();
int getOrientation();

View File

@@ -1,115 +0,0 @@
/*
* Copyright (c) 2017, Aria <aria@ar1as.space>
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* 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.collect.Ordering;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import net.runelite.api.Client;
import net.runelite.api.GameState;
import net.runelite.client.RuneLite;
import net.runelite.client.plugins.zulrah.patterns.ZulrahPattern;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayPosition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
class StatusOverlay extends Overlay
{
private static final Logger logger = LoggerFactory.getLogger(StatusOverlay.class);
private final Zulrah plugin;
private final Client client = RuneLite.getClient();
StatusOverlay(Zulrah plugin)
{
super(OverlayPosition.TOP_RIGHT);
this.plugin = plugin;
}
@Override
public Dimension render(Graphics2D graphics)
{
Fight fight = plugin.getFight();
if (client.getGameState() != GameState.LOGGED_IN || fight == null)
{
return null;
}
//TODO: Add prayer checking and health warning
graphics.setColor(Color.WHITE);
ZulrahPattern pattern = fight.getPattern();
if (pattern == null)
{
// can draw at least the starting place here?
return null;
}
// Show current type, next type, and jad
ZulrahInstance current = fight.getZulrah();
ZulrahInstance next = pattern.get(fight.getStage() + 1);
String currentStr = "Current: " + current.getType();
String nextStr = "Next: " + (next != null ? next.getType() : "Restart");
String jadStr;
if (current.isJad())
{
jadStr = "JAD: YES";
}
else if (next != null && next.isJad())
{
jadStr = "JAD: NEXT";
}
else
{
jadStr = "JAD: NO";
}
FontMetrics metrics = graphics.getFontMetrics();
int height = metrics.getHeight();
int width = Ordering.natural().max(
metrics.stringWidth(currentStr),
metrics.stringWidth(nextStr),
metrics.stringWidth(jadStr)
);
graphics.drawString(currentStr, 0, height);
height += metrics.getHeight();
graphics.drawString(nextStr, 0, height);
height += metrics.getHeight();
graphics.drawString(jadStr, 0, height);
height += metrics.getHeight();
return new Dimension(width, height);
}
}

View File

@@ -1,126 +0,0 @@
/*
* Copyright (c) 2017, Aria <aria@ar1as.space>
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* 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 net.runelite.api.Client;
import net.runelite.api.GameState;
import net.runelite.api.Perspective;
import net.runelite.api.Point;
import net.runelite.client.RuneLite;
import net.runelite.client.plugins.zulrah.patterns.ZulrahPattern;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.OverlayUtil;
public class TileOverlay extends Overlay
{
private final Zulrah plugin;
private final Client client = RuneLite.getClient();
public TileOverlay(Zulrah plugin)
{
super(OverlayPosition.DYNAMIC);
this.plugin = plugin;
}
@Override
public Dimension render(Graphics2D graphics)
{
Fight fight = plugin.getFight();
if (client.getGameState() != GameState.LOGGED_IN || fight == null)
{
return null;
}
ZulrahPattern pattern = fight.getPattern();
if (pattern == null)
{
return null;
}
Point startLocationWorld = fight.getStartLocationWorld();
int stage = fight.getStage();
ZulrahInstance current = pattern.get(stage);
if (current == null)
{
return null;
}
renderTileOverlay(graphics, current.getStandLoc(startLocationWorld), Color.GREEN);
ZulrahInstance next = pattern.get(stage + 1);
if (next == null)
{
return null;
}
String str;
if (next.isJad())
{
str = "Next is JAD: " + next.getType();
}
else
{
str = "Next: " + next.getType();
}
Point location = next.getZulrahLoc(startLocationWorld);
location = Perspective.worldToLocal(client, location);
location = Perspective.getCanvasTextLocation(client, graphics, location, str, 0);
if (location != null)
{
graphics.setColor(Color.WHITE);
graphics.drawString(str, location.getX(), location.getY());
}
renderTileOverlay(graphics, next.getStandLoc(startLocationWorld), new Color(255, 0, 0, 150));
return null;
}
private void renderTileOverlay(Graphics2D graphics, Point tile, Color outlineColor)
{
Point localTile = Perspective.worldToLocal(client, tile);
//to make the centre of the tile on the point, rather than the tile the point resides in
localTile = new Point(localTile.getX() + Perspective.LOCAL_TILE_SIZE / 2, localTile.getY() + Perspective.LOCAL_TILE_SIZE / 2);
Polygon poly = Perspective.getCanvasTilePoly(client, localTile);
if (poly != null)
{
OverlayUtil.renderPolygon(graphics, poly, outlineColor);
}
}
}

View File

@@ -1,6 +1,7 @@
/*
* Copyright (c) 2017, Aria <aria@ar1as.space>
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,14 +26,9 @@
*/
package net.runelite.client.plugins.zulrah;
import java.time.temporal.ChronoUnit;
import java.util.Arrays;
import java.util.Collection;
import net.runelite.api.Client;
import net.runelite.api.GameState;
import net.runelite.api.NPC;
import net.runelite.api.Perspective;
import net.runelite.api.Point;
import net.runelite.api.Query;
import net.runelite.api.queries.NPCQuery;
import net.runelite.client.RuneLite;
@@ -43,11 +39,14 @@ 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.task.Schedule;
import net.runelite.client.ui.overlay.Overlay;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.time.temporal.ChronoUnit;
@PluginDescriptor(
name = "Zulrah plugin"
)
@@ -56,35 +55,34 @@ public class Zulrah extends Plugin
private static final Logger logger = LoggerFactory.getLogger(Zulrah.class);
private final RuneLite runelite = RuneLite.getRunelite();
private final ZulrahConfig config = RuneLite.getRunelite().getConfigManager().getConfig(ZulrahConfig.class);
private final Client client = RuneLite.getClient();
private final StatusOverlay overlay = new StatusOverlay(this);
private final TileOverlay tileOverlay = new TileOverlay(this);
private final ZulrahPattern[] patterns = new ZulrahPattern[]
{
new ZulrahPatternA(),
new ZulrahPatternB(),
new ZulrahPatternC(),
new ZulrahPatternD()
private final ZulrahOverlay overlay = new ZulrahOverlay(this);
private final ZulrahPattern[] patterns = new ZulrahPattern[]{
new ZulrahPatternA(),
new ZulrahPatternB(),
new ZulrahPatternC(),
new ZulrahPatternD()
};
private Fight fight;
@Override
public Collection<Overlay> getOverlays()
{
return Arrays.asList(overlay, tileOverlay);
}
private ZulrahInstance instance;
@Override
protected void startUp() throws Exception
{
}
@Override
protected void shutDown() throws Exception
{
}
@Override
public Overlay getOverlay()
{
return overlay;
}
@Schedule(
@@ -93,51 +91,43 @@ public class Zulrah extends Plugin
)
public void update()
{
if (client == null || client.getGameState() != GameState.LOGGED_IN)
if (!config.enabled() || client == null || client.getGameState() != GameState.LOGGED_IN)
{
return;
}
NPC zulrah = findZulrah();
if (zulrah == null)
{
if (fight != null)
if (instance != null)
{
logger.debug("Fight has ended!");
fight = null;
logger.debug("Zulrah encounter has ended.");
instance = null;
}
return;
}
if (fight == null)
if (instance == null)
{
Point startTile = zulrah.getLocalLocation();
startTile = Perspective.localToWorld(client, startTile);
fight = new Fight(startTile);
logger.debug("Fight has begun!");
instance = new ZulrahInstance(zulrah);
logger.debug("Zulrah encounter has started.");
}
ZulrahInstance currentZulrah = ZulrahInstance.of(zulrah, fight.getStartLocationWorld());
if (fight.getZulrah() == null)
ZulrahPhase currentPhase = ZulrahPhase.valueOf(zulrah, instance.getStartLocation());
if (instance.getPhase() == null)
{
fight.setZulrah(currentZulrah);
instance.setPhase(currentPhase);
}
else if (!fight.getZulrah().equals(currentZulrah))
else if (!instance.getPhase().equals(currentPhase))
{
ZulrahInstance previousInstance = fight.getZulrah();
fight.setZulrah(currentZulrah);
fight.nextStage();
ZulrahPhase previousPhase = instance.getPhase();
instance.setPhase(currentPhase);
instance.nextStage();
logger.debug("Zulrah has moved from {} -> {}, index now {}",
previousInstance, currentZulrah, fight.getStage());
logger.debug("Zulrah phase has moved from {} -> {}, stage: {}", previousPhase, currentPhase, instance.getStage());
}
ZulrahPattern pattern = fight.getPattern();
ZulrahPattern pattern = instance.getPattern();
if (pattern == null)
{
int potential = 0;
@@ -145,7 +135,7 @@ public class Zulrah extends Plugin
for (ZulrahPattern p : patterns)
{
if (p.stageMatches(fight.getStage(), fight.getZulrah()))
if (p.stageMatches(instance.getStage(), instance.getPhase()))
{
potential++;
potentialPattern = p;
@@ -156,20 +146,14 @@ public class Zulrah extends Plugin
{
logger.debug("Zulrah pattern identified: {}", potentialPattern);
fight.setPattern(potentialPattern);
instance.setPattern(potentialPattern);
}
}
else
else if (pattern.canReset(instance.getStage()) && (instance.getPhase() == null || instance.getPhase().equals(pattern.get(0))))
{
if (pattern.canReset(fight.getStage()))
{
if (fight.getZulrah().equals(pattern.get(0)))
{
logger.debug("Fight has reset");
logger.debug("Zulrah pattern has reset.");
fight.reset();
}
}
instance.reset();
}
}
@@ -180,8 +164,8 @@ public class Zulrah extends Plugin
return result.length == 1 ? result[0] : null;
}
public Fight getFight()
public ZulrahInstance getInstance()
{
return fight;
return instance;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Aria <aria@ar1as.space>
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -24,9 +24,23 @@
*/
package net.runelite.client.plugins.zulrah;
public enum ZulrahType
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
@ConfigGroup(
keyName = "zulrah",
name = "Zulrah",
description = "Configuration for the zulrah plugin"
)
public interface ZulrahConfig
{
RANGE,
MAGIC,
MELEE
@ConfigItem(
keyName = "enabled",
name = "Enabled",
description = "Configures whether or not zulrah overlays are displayed"
)
default boolean enabled()
{
return true;
}
}

View File

@@ -1,5 +1,6 @@
/*
* Copyright (c) 2017, Aria <aria@ar1as.space>
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -24,196 +25,114 @@
*/
package net.runelite.client.plugins.zulrah;
import java.util.Objects;
import net.runelite.api.NPC;
import net.runelite.api.NpcID;
import net.runelite.api.Perspective;
import net.runelite.api.Point;
import net.runelite.client.RuneLite;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.runelite.api.Prayer;
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;
/*
Original code: https://github.com/LoveLeAnon/OSLoader
*/
public class ZulrahInstance
{
private static final Logger logger = LoggerFactory.getLogger(ZulrahInstance.class);
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 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;
private final Point startLocation;
private ZulrahPattern pattern;
private int stage;
private ZulrahPhase phase;
private final ZulrahLocation loc;
private final ZulrahType type;
private final boolean jad;
private final StandLocation standLoc;
public ZulrahInstance(ZulrahLocation loc, ZulrahType type, boolean jad, StandLocation standLoc)
public ZulrahInstance(NPC zulrah)
{
this.loc = loc;
this.type = type;
this.jad = jad;
this.standLoc = standLoc;
this.startLocation = zulrah.getWorldLocation();
}
@Override
public String toString()
public Point getStartLocation()
{
return "ZulrahInstance{" + "loc=" + loc + ", type=" + type + '}';
return startLocation;
}
public Point getZulrahLoc(Point startLoc)
public ZulrahPattern getPattern()
{
// NORTH doesn't need changing because it is the start
switch (loc)
{
case SOUTH:
return new Point(startLoc.getX(), startLoc.getY() - 11);
case EAST:
return new Point(startLoc.getX() + 10, startLoc.getY() - 2);
case WEST:
return new Point(startLoc.getX() - 10, startLoc.getY() - 2);
}
return startLoc;
return pattern;
}
public Point getStandLoc(Point startLoc)
public void setPattern(ZulrahPattern pattern)
{
switch (standLoc)
{
case WEST:
return new Point(startLoc.getX() - 5, startLoc.getY() - 2);
case EAST:
return new Point(startLoc.getX() + 5, startLoc.getY() - 2);
case SOUTH:
return new Point(startLoc.getX(), startLoc.getY() - 6);
case TOP_EAST:
return new Point(startLoc.getX() + 6, startLoc.getY() + 2);
case TOP_WEST:
return new Point(startLoc.getX() - 4, startLoc.getY() + 3);
case PILLAR_WEST_INSIDE:
return new Point(startLoc.getX() - 3, startLoc.getY() - 5);
case PILLAR_WEST_OUTSIDE:
return new Point(startLoc.getX() - 4, startLoc.getY() - 3);
case PILLAR_EAST_INSIDE:
return new Point(startLoc.getX() + 3, startLoc.getY() - 5);
case PILLAR_EAST_OUTSIDE:
return new Point(startLoc.getX() + 4, startLoc.getY() - 3);
}
return startLoc;
this.pattern = pattern;
}
public ZulrahLocation getLoc()
public int getStage()
{
return loc;
return stage;
}
public ZulrahType getType()
public void nextStage()
{
return type;
++stage;
}
public boolean isJad()
public void reset()
{
return jad;
pattern = null;
stage = 0;
}
public StandLocation getStandLoc()
public ZulrahPhase getPhase()
{
return standLoc;
ZulrahPhase patternPhase = null;
if (pattern != null)
{
patternPhase = pattern.get(stage);
}
return patternPhase != null ? patternPhase : phase;
}
@Override
public int hashCode()
public void setPhase(ZulrahPhase phase)
{
int hash = 3;
hash = 17 * hash + Objects.hashCode(this.loc);
hash = 17 * hash + Objects.hashCode(this.type);
hash = 17 * hash + (this.jad ? 1 : 0);
return hash;
this.phase = phase;
}
@Override
public boolean equals(Object obj)
public ZulrahPhase getNextPhase()
{
if (this == obj)
if (pattern != null)
{
return true;
return pattern.get(stage + 1);
}
if (obj == null)
else if (phase != null)
{
return false;
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;
}
}
if (getClass() != obj.getClass())
{
return false;
}
final ZulrahInstance other = (ZulrahInstance) obj;
if (this.jad != other.jad)
{
return false;
}
if (this.loc != other.loc)
{
return false;
}
if (this.type != other.type)
{
return false;
}
return true;
}
public static ZulrahInstance of(NPC npc, Point start)
{
Point t = npc.getLocalLocation();
t = Perspective.localToWorld(RuneLite.getClient(), t);
int dx = start.getX() - t.getX();
int dy = start.getY() - t.getY();
ZulrahLocation loc;
ZulrahType type;
if (dx == -10 && dy == 2)
{
loc = ZulrahLocation.EAST;
}
else if (dx == 10 && dy == 2)
{
loc = ZulrahLocation.WEST;
}
else if (dx == 0 && dy == 11)
{
loc = ZulrahLocation.SOUTH;
}
else if (dx == 0 && dy == 0)
{
loc = ZulrahLocation.NORTH;
}
else
{
logger.debug("Unknown zulrah location! dx: {}, dy: {}", dx, dy);
return null;
}
int id = npc.getId();
switch (id)
{
case ZULRAH_RANGE:
type = ZulrahType.RANGE;
break;
case ZULRAH_MELEE:
type = ZulrahType.MELEE;
break;
case ZULRAH_MAGIC:
type = ZulrahType.MAGIC;
break;
default:
logger.debug("Unknown Zulrah npc! {}", id);
return null;
}
return new ZulrahInstance(loc, type, false, null);
return null;
}
}

View File

@@ -0,0 +1,461 @@
/*
* Copyright (c) 2017, Aria <aria@ar1as.space>
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
* 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.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.Rectangle;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import javax.imageio.ImageIO;
import net.runelite.api.Client;
import net.runelite.api.GameState;
import net.runelite.api.Perspective;
import net.runelite.api.Point;
import net.runelite.api.Prayer;
import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.RuneLite;
import net.runelite.client.plugins.zulrah.phase.ZulrahPhase;
import net.runelite.client.plugins.zulrah.phase.ZulrahType;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayPosition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ZulrahOverlay extends Overlay
{
private static final Logger logger = LoggerFactory.getLogger(ZulrahOverlay.class);
private static final int CURRENT_PHASE_WIDTH = 86;
private static final int NEXT_PHASE_WIDTH = 54;
private static final int SPACER = 6;
private static final int BOTTOM_BORDER = 4;
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 static final Color RANGE_BACKGROUND_COLOR = new Color(150, 255, 0, 100);
private static final Color MAGIC_BACKGROUND_COLOR = new Color(20, 170, 200, 100);
private static final Color MELEE_BACKGROUND_COLOR = new Color(180, 50, 20, 100);
private static final Color JAD_BACKGROUND_COLOR = new Color(255, 115, 0, 100);
private final Client client = RuneLite.getClient();
private final Zulrah plugin;
private final Image[] zulrahImages = new Image[3];
private final Image[] smallZulrahImages = new Image[3];
private final Image[] prayerImages = new Image[2];
ZulrahOverlay(Zulrah plugin)
{
super(OverlayPosition.DYNAMIC);
this.plugin = plugin;
}
@Override
public Dimension render(Graphics2D graphics)
{
ZulrahInstance instance = plugin.getInstance();
if (instance == null || client.getGameState() != GameState.LOGGED_IN)
{
return null;
}
Rectangle viewport = getViewportBounds();
if (viewport == null)
{
return null;
}
ZulrahPhase currentPhase = instance.getPhase();
ZulrahPhase nextPhase = instance.getNextPhase();
if (currentPhase == null)
{
return null;
}
String pattern = instance.getPattern() != null ? instance.getPattern().toString() : "Unknown";
Point 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);
drawCurrentPhaseBox(graphics, viewport, currentPhase, pattern);
drawNextPhaseBox(graphics, viewport, nextPhase);
drawPrayerOutline(graphics, currentPhase.getPrayer());
return null;
}
private void drawStandTiles(Graphics2D graphics, Point startTile, ZulrahPhase currentPhase, ZulrahPhase nextPhase)
{
Point localTile = Perspective.worldToLocal(client, currentPhase.getStandTile(startTile));
localTile = new Point(localTile.getX() + Perspective.LOCAL_TILE_SIZE / 2, localTile.getY() + Perspective.LOCAL_TILE_SIZE / 2);
Polygon northPoly = getCanvasTileNorthPoly(client, localTile);
Polygon southPoly = getCanvasTileSouthPoly(client, localTile);
Polygon poly = Perspective.getCanvasTilePoly(client, localTile);
Point textLoc = Perspective.getCanvasTextLocation(client, graphics, localTile, "Next", 0);
if (northPoly != null && southPoly != null && poly != null && textLoc != null)
{
Color northColor = getBackgroundColor(currentPhase.getType());
Color southColor = getBackgroundColor(nextPhase.getType());
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("Next", textLoc.getX(), textLoc.getY());
}
if (nextPhase.isJad())
{
Image jadPrayerImg = getProtectionPrayerImage(nextPhase.getPrayer());
if (jadPrayerImg != null)
{
Point imageLoc = Perspective.getCanvasImageLocation(client, graphics, localTile, (BufferedImage) jadPrayerImg, 0);
if (imageLoc != null)
{
graphics.drawImage(jadPrayerImg, imageLoc.getX(), imageLoc.getY(), null);
}
}
}
}
private void drawStandTile(Graphics2D graphics, Point startTile, ZulrahPhase phase, boolean next)
{
if (phase == null)
{
return;
}
Point localTile = Perspective.worldToLocal(client, phase.getStandTile(startTile));
localTile = new Point(localTile.getX() + Perspective.LOCAL_TILE_SIZE / 2, localTile.getY() + Perspective.LOCAL_TILE_SIZE / 2);
Polygon poly = Perspective.getCanvasTilePoly(client, localTile);
Color color = getBackgroundColor(phase.getType());
if (poly != null)
{
graphics.setColor(TILE_BORDER_COLOR);
graphics.setStroke(new BasicStroke(2));
graphics.drawPolygon(poly);
graphics.setColor(color);
graphics.fillPolygon(poly);
}
if (next)
{
Point textLoc = Perspective.getCanvasTextLocation(client, graphics, localTile, "Next", 0);
if (textLoc != null)
{
graphics.setColor(NEXT_TEXT_COLOR);
graphics.drawString("Next", textLoc.getX(), textLoc.getY());
}
if (phase.isJad())
{
Image jadPrayerImg = getProtectionPrayerImage(phase.getPrayer());
if (jadPrayerImg != null)
{
Point imageLoc = Perspective.getCanvasImageLocation(client, graphics, localTile, (BufferedImage) jadPrayerImg, 0);
if (imageLoc != null)
{
graphics.drawImage(jadPrayerImg, imageLoc.getX(), imageLoc.getY(), null);
}
}
}
}
}
private void drawZulrahTileMinimap(Graphics2D graphics, Point startTile, ZulrahPhase phase, boolean next)
{
if (phase == null)
{
return;
}
Point zulrahLocalTile = Perspective.worldToLocal(client, phase.getZulrahTile(startTile));
Point zulrahMinimapPoint = Perspective.worldToMiniMap(client, zulrahLocalTile.getX(), zulrahLocalTile.getY());
Color color = getBackgroundColor(phase.getType());
graphics.setColor(color);
graphics.fillOval(zulrahMinimapPoint.getX(), zulrahMinimapPoint.getY(), 5, 5);
graphics.setColor(TILE_BORDER_COLOR);
graphics.setStroke(new BasicStroke(1));
graphics.drawOval(zulrahMinimapPoint.getX(), zulrahMinimapPoint.getY(), 5, 5);
if (next)
{
graphics.setColor(NEXT_TEXT_COLOR);
FontMetrics fm = graphics.getFontMetrics();
graphics.drawString("Next", zulrahMinimapPoint.getX() - fm.stringWidth("Next") / 2, zulrahMinimapPoint.getY() - 2);
}
}
private void drawCurrentPhaseBox(Graphics2D graphics, Rectangle viewport, ZulrahPhase phase, String pattern)
{
Image zulrahImg = getZulrahImage(phase.getType());
if (zulrahImg == null)
{
return;
}
FontMetrics fm = graphics.getFontMetrics();
int height = fm.getHeight() * 2 + zulrahImg.getHeight(null) + SPACER + BOTTOM_BORDER;
int bgX = (int) (viewport.getX() + viewport.getWidth() - CURRENT_PHASE_WIDTH);
int bgY = (int) (viewport.getY() + viewport.getHeight() - height);
Color backgroundColor = phase.isJad() ? JAD_BACKGROUND_COLOR : getBackgroundColor(phase.getType());
graphics.setColor(backgroundColor);
graphics.fillRect(bgX, bgY, CURRENT_PHASE_WIDTH, height);
graphics.setColor(Color.WHITE);
graphics.drawString(pattern, bgX + (CURRENT_PHASE_WIDTH - fm.stringWidth(pattern)) / 2, bgY + fm.getHeight());
graphics.drawImage(zulrahImg, bgX + (CURRENT_PHASE_WIDTH - zulrahImg.getWidth(null)) / 2, bgY + fm.getHeight() + SPACER, null);
if (phase.isJad())
{
graphics.setColor(Color.RED.darker());
graphics.drawString("JAD PHASE", bgX + (CURRENT_PHASE_WIDTH - fm.stringWidth("JAD PHASE")) / 2, bgY + height - BOTTOM_BORDER);
}
}
private void drawNextPhaseBox(Graphics2D graphics, Rectangle viewport, ZulrahPhase phase)
{
if (phase == null)
{
return;
}
Image zulrahImg = getSmallZulrahImage(phase.getType());
if (zulrahImg == null)
{
return;
}
FontMetrics fm = graphics.getFontMetrics();
int height = fm.getHeight() + zulrahImg.getHeight(null) + SPACER + BOTTOM_BORDER;
int bgX = (int) (viewport.getX() + viewport.getWidth() - NEXT_PHASE_WIDTH - CURRENT_PHASE_WIDTH);
int bgY = (int) (viewport.getY() + viewport.getHeight() - height);
Color backgroundColor = phase.isJad() ? JAD_BACKGROUND_COLOR : getBackgroundColor(phase.getType());
graphics.setColor(backgroundColor);
graphics.fillRect(bgX, bgY, NEXT_PHASE_WIDTH, height);
graphics.drawImage(zulrahImg, bgX + (NEXT_PHASE_WIDTH - zulrahImg.getWidth(null)) / 2, bgY + fm.getHeight() + SPACER, null);
if (phase.isJad())
{
Image jadFirstPrayerImg = getProtectionPrayerImage(phase.getPrayer());
graphics.drawImage(jadFirstPrayerImg, bgX + (NEXT_PHASE_WIDTH - zulrahImg.getWidth(null)) / 2, bgY + fm.getHeight() + SPACER, null);
graphics.setColor(Color.RED.darker());
graphics.drawString("Jad Next", bgX + (NEXT_PHASE_WIDTH - fm.stringWidth("Jad Next")) / 2, bgY + fm.getHeight());
}
else
{
graphics.setColor(Color.WHITE);
graphics.drawString("Next", bgX + (NEXT_PHASE_WIDTH - fm.stringWidth("Next")) / 2, bgY + fm.getHeight());
}
}
private Rectangle getViewportBounds()
{
Widget viewport = client.getViewportWidget();
return viewport != null ? viewport.getBounds() : null;
}
private void drawPrayerOutline(Graphics2D graphics, Prayer prayer)
{
if (prayer == null || client.isPrayerActive(prayer))
{
return;
}
Widget prayerWidget;
if (prayer == Prayer.PROTECT_FROM_MISSILES)
{
prayerWidget = client.getWidget(WidgetInfo.PRAYER_PROTECT_FROM_MISSILES);
}
else
{
prayerWidget = client.getWidget(WidgetInfo.PRAYER_PROTECT_FROM_MAGIC);
}
if (prayerWidget != null)
{
Rectangle prayerBounds = prayerWidget.getBounds();
if (prayerBounds != null)
{
graphics.setColor(Color.RED.darker());
graphics.draw(prayerBounds);
}
}
}
private Polygon getCanvasTileNorthPoly(Client client, Point localLocation)
{
int plane = client.getPlane();
int halfTile = Perspective.LOCAL_TILE_SIZE / 2;
Point p1 = Perspective.worldToCanvas(client, localLocation.getX() - halfTile, localLocation.getY() - halfTile, plane);
Point p2 = Perspective.worldToCanvas(client, localLocation.getX() - halfTile, localLocation.getY() + halfTile, plane);
Point p3 = Perspective.worldToCanvas(client, 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, Point localLocation)
{
int plane = client.getPlane();
int halfTile = Perspective.LOCAL_TILE_SIZE / 2;
Point p1 = Perspective.worldToCanvas(client, localLocation.getX() - halfTile, localLocation.getY() - halfTile, plane);
Point p2 = Perspective.worldToCanvas(client, localLocation.getX() + halfTile, localLocation.getY() + halfTile, plane);
Point p3 = Perspective.worldToCanvas(client, 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 Color getBackgroundColor(ZulrahType type)
{
switch (type)
{
case RANGE:
return RANGE_BACKGROUND_COLOR;
case MAGIC:
return MAGIC_BACKGROUND_COLOR;
case MELEE:
return MELEE_BACKGROUND_COLOR;
}
return Color.DARK_GRAY;
}
private Image getZulrahImage(ZulrahType type)
{
switch (type)
{
case RANGE:
if (zulrahImages[0] == null)
{
zulrahImages[0] = getImage("zulrah_range.png");
}
return zulrahImages[0];
case MAGIC:
if (zulrahImages[1] == null)
{
zulrahImages[1] = getImage("zulrah_magic.png");
}
return zulrahImages[1];
case MELEE:
if (zulrahImages[2] == null)
{
zulrahImages[2] = getImage("zulrah_melee.png");
}
return zulrahImages[2];
}
return null;
}
private Image getSmallZulrahImage(ZulrahType type)
{
switch (type)
{
case RANGE:
if (smallZulrahImages[0] == null)
{
smallZulrahImages[0] = getImage("zulrah_range_small.png");
}
return smallZulrahImages[0];
case MAGIC:
if (smallZulrahImages[1] == null)
{
smallZulrahImages[1] = getImage("zulrah_magic_small.png");
}
return smallZulrahImages[1];
case MELEE:
if (smallZulrahImages[2] == null)
{
smallZulrahImages[2] = getImage("zulrah_melee_small.png");
}
return smallZulrahImages[2];
}
return null;
}
private Image getProtectionPrayerImage(Prayer prayer)
{
switch (prayer)
{
case PROTECT_FROM_MAGIC:
if (prayerImages[0] == null)
{
prayerImages[0] = getImage("/prayers/protect_from_magic.png");
}
return prayerImages[0];
case PROTECT_FROM_MISSILES:
if (prayerImages[1] == null)
{
prayerImages[1] = getImage("/prayers/protect_from_missiles.png");
}
return prayerImages[1];
}
return null;
}
private Image getImage(String path)
{
Image image = null;
try
{
InputStream in = ZulrahOverlay.class.getResourceAsStream(path);
image = ImageIO.read(in);
}
catch (IOException e)
{
logger.debug("Error loading image {}", e);
}
return image;
}
}

View File

@@ -1,5 +1,6 @@
/*
* Copyright (c) 2017, Aria <aria@ar1as.space>
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -26,31 +27,32 @@ package net.runelite.client.plugins.zulrah.patterns;
import java.util.ArrayList;
import java.util.List;
import net.runelite.client.plugins.zulrah.StandLocation;
import net.runelite.client.plugins.zulrah.ZulrahInstance;
import net.runelite.client.plugins.zulrah.ZulrahLocation;
import net.runelite.client.plugins.zulrah.ZulrahType;
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<ZulrahInstance> pattern = new ArrayList<>();
private final List<ZulrahPhase> pattern = new ArrayList<>();
protected final void add(ZulrahLocation loc, ZulrahType type, StandLocation standLoc)
protected final void add(ZulrahLocation loc, ZulrahType type, StandLocation standLocation, Prayer prayer)
{
add(loc, type, standLoc, false);
add(loc, type, standLocation, false, prayer);
}
protected final void addJad(ZulrahLocation loc, ZulrahType type, StandLocation standLoc)
protected final void addJad(ZulrahLocation loc, ZulrahType type, StandLocation standLocation, Prayer prayer)
{
add(loc, type, standLoc, true);
add(loc, type, standLocation, true, prayer);
}
private void add(ZulrahLocation loc, ZulrahType type, StandLocation standLoc, boolean jad)
private void add(ZulrahLocation loc, ZulrahType type, StandLocation standLocation, boolean jad, Prayer prayer)
{
pattern.add(new ZulrahInstance(loc, type, jad, standLoc));
pattern.add(new ZulrahPhase(loc, type, jad, standLocation, prayer));
}
public ZulrahInstance get(int index)
public ZulrahPhase get(int index)
{
if (index >= pattern.size())
{
@@ -60,9 +62,9 @@ public abstract class ZulrahPattern
return pattern.get(index);
}
public boolean stageMatches(int index, ZulrahInstance instance)
public boolean stageMatches(int index, ZulrahPhase instance)
{
ZulrahInstance patternInstance = get(index);
ZulrahPhase patternInstance = get(index);
return patternInstance != null && patternInstance.equals(instance);
}

View File

@@ -1,5 +1,6 @@
/*
* Copyright (c) 2017, Aria <aria@ar1as.space>
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -24,23 +25,30 @@
*/
package net.runelite.client.plugins.zulrah.patterns;
import net.runelite.client.plugins.zulrah.StandLocation;
import net.runelite.client.plugins.zulrah.ZulrahLocation;
import net.runelite.client.plugins.zulrah.ZulrahType;
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);
add(ZulrahLocation.NORTH, ZulrahType.MELEE, StandLocation.TOP_EAST);
add(ZulrahLocation.NORTH, ZulrahType.MAGIC, StandLocation.WEST);
add(ZulrahLocation.SOUTH, ZulrahType.RANGE, StandLocation.PILLAR_WEST_OUTSIDE);
add(ZulrahLocation.NORTH, ZulrahType.MELEE, StandLocation.PILLAR_WEST_OUTSIDE);
add(ZulrahLocation.WEST, ZulrahType.MAGIC, StandLocation.PILLAR_WEST_OUTSIDE);
add(ZulrahLocation.SOUTH, ZulrahType.RANGE, StandLocation.EAST);
add(ZulrahLocation.SOUTH, ZulrahType.MAGIC, StandLocation.EAST);
addJad(ZulrahLocation.WEST, ZulrahType.RANGE, StandLocation.TOP_WEST);
add(ZulrahLocation.NORTH, ZulrahType.MELEE, StandLocation.TOP_WEST);
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";
}
}

View File

@@ -1,5 +1,6 @@
/*
* Copyright (c) 2017, Aria <aria@ar1as.space>
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -24,25 +25,30 @@
*/
package net.runelite.client.plugins.zulrah.patterns;
import net.runelite.client.plugins.zulrah.StandLocation;
import net.runelite.client.plugins.zulrah.ZulrahLocation;
import net.runelite.client.plugins.zulrah.ZulrahType;
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);
add(ZulrahLocation.NORTH, ZulrahType.MELEE, StandLocation.TOP_EAST);
add(ZulrahLocation.NORTH, ZulrahType.MAGIC, StandLocation.WEST);
add(ZulrahLocation.WEST, ZulrahType.RANGE, StandLocation.PILLAR_WEST_OUTSIDE);
// there is an optional phase here?
add(ZulrahLocation.SOUTH, ZulrahType.MAGIC, StandLocation.PILLAR_WEST_INSIDE);
add(ZulrahLocation.NORTH, ZulrahType.MELEE, StandLocation.TOP_EAST);
add(ZulrahLocation.EAST, ZulrahType.RANGE, StandLocation.EAST);
add(ZulrahLocation.SOUTH, ZulrahType.MAGIC, StandLocation.PILLAR_WEST_INSIDE);
addJad(ZulrahLocation.WEST, ZulrahType.RANGE, StandLocation.TOP_WEST);
add(ZulrahLocation.NORTH, ZulrahType.MELEE, StandLocation.TOP_WEST);
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";
}
}

View File

@@ -1,5 +1,6 @@
/*
* Copyright (c) 2017, Aria <aria@ar1as.space>
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -24,24 +25,31 @@
*/
package net.runelite.client.plugins.zulrah.patterns;
import net.runelite.client.plugins.zulrah.StandLocation;
import net.runelite.client.plugins.zulrah.ZulrahLocation;
import net.runelite.client.plugins.zulrah.ZulrahType;
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);
add(ZulrahLocation.EAST, ZulrahType.RANGE, StandLocation.TOP_EAST);
add(ZulrahLocation.NORTH, ZulrahType.MELEE, StandLocation.TOP_WEST);
add(ZulrahLocation.WEST, ZulrahType.MAGIC, StandLocation.TOP_WEST);
add(ZulrahLocation.SOUTH, ZulrahType.RANGE, StandLocation.EAST);
add(ZulrahLocation.EAST, ZulrahType.MAGIC, StandLocation.PILLAR_EAST_OUTSIDE);
add(ZulrahLocation.NORTH, ZulrahType.RANGE, StandLocation.WEST);
add(ZulrahLocation.WEST, ZulrahType.RANGE, StandLocation.PILLAR_WEST_OUTSIDE);
add(ZulrahLocation.NORTH, ZulrahType.MAGIC, StandLocation.PILLAR_EAST_OUTSIDE);
addJad(ZulrahLocation.EAST, ZulrahType.MAGIC, StandLocation.PILLAR_EAST_OUTSIDE);
add(ZulrahLocation.NORTH, ZulrahType.MAGIC, StandLocation.EAST);
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";
}
}

View File

@@ -1,5 +1,6 @@
/*
* Copyright (c) 2017, Aria <aria@ar1as.space>
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -24,25 +25,32 @@
*/
package net.runelite.client.plugins.zulrah.patterns;
import net.runelite.client.plugins.zulrah.StandLocation;
import net.runelite.client.plugins.zulrah.ZulrahLocation;
import net.runelite.client.plugins.zulrah.ZulrahType;
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);
add(ZulrahLocation.EAST, ZulrahType.MAGIC, StandLocation.TOP_EAST);
add(ZulrahLocation.SOUTH, ZulrahType.RANGE, StandLocation.PILLAR_WEST_INSIDE);
add(ZulrahLocation.WEST, ZulrahType.MAGIC, StandLocation.WEST);
add(ZulrahLocation.NORTH, ZulrahType.MELEE, StandLocation.PILLAR_EAST_OUTSIDE);
add(ZulrahLocation.EAST, ZulrahType.RANGE, StandLocation.PILLAR_EAST_OUTSIDE);
add(ZulrahLocation.SOUTH, ZulrahType.RANGE, StandLocation.PILLAR_EAST_OUTSIDE);
add(ZulrahLocation.WEST, ZulrahType.MAGIC, StandLocation.PILLAR_WEST_OUTSIDE);
add(ZulrahLocation.NORTH, ZulrahType.RANGE, StandLocation.TOP_EAST);
add(ZulrahLocation.NORTH, ZulrahType.MAGIC, StandLocation.TOP_EAST);
addJad(ZulrahLocation.EAST, ZulrahType.MAGIC, StandLocation.TOP_EAST);
add(ZulrahLocation.NORTH, ZulrahType.MAGIC, StandLocation.TOP_EAST);
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";
}
}

View File

@@ -1,5 +1,6 @@
/*
* Copyright (c) 2017, Aria <aria@ar1as.space>
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -22,17 +23,19 @@
* (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;
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;
PILLAR_EAST_OUTSIDE
}

View File

@@ -1,5 +1,6 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* Copyright (c) 2017, Aria <aria@ar1as.space>
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -22,68 +23,42 @@
* (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;
package net.runelite.client.plugins.zulrah.phase;
import java.time.Instant;
import net.runelite.api.Point;
import net.runelite.client.plugins.zulrah.patterns.ZulrahPattern;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Fight
public enum ZulrahLocation
{
private final Point startLocationWorld;
private final Instant startTime = Instant.now();
private ZulrahPattern pattern;
private int stage;
private ZulrahInstance zulrah;
NORTH, SOUTH, EAST, WEST;
public Fight(Point startLocationWorld)
{
this.startLocationWorld = startLocationWorld;
}
private static final Logger logger = LoggerFactory.getLogger(ZulrahLocation.class);
public Point getStartLocationWorld()
public static ZulrahLocation valueOf(Point start, Point current)
{
return startLocationWorld;
}
public Instant getStartTime()
{
return startTime;
}
public ZulrahPattern getPattern()
{
return pattern;
}
public void setPattern(ZulrahPattern pattern)
{
this.pattern = pattern;
}
public ZulrahInstance getZulrah()
{
return zulrah;
}
public void setZulrah(ZulrahInstance zulrah)
{
this.zulrah = zulrah;
}
public int getStage()
{
return stage;
}
public void nextStage()
{
++stage;
}
public void reset()
{
pattern = null;
stage = 0;
int dx = start.getX() - current.getX();
int dy = start.getY() - current.getY();
if (dx == -10 && dy == 2)
{
return ZulrahLocation.EAST;
}
else if (dx == 10 && dy == 2)
{
return ZulrahLocation.WEST;
}
else if (dx == 0 && dy == 11)
{
return ZulrahLocation.SOUTH;
}
else if (dx == 0 && dy == 0)
{
return ZulrahLocation.NORTH;
}
else
{
logger.debug("Unknown Zulrah location dx: {}, dy: {}", dx, dy);
return null;
}
}
}

View File

@@ -0,0 +1,160 @@
/*
* Copyright (c) 2017, Aria <aria@ar1as.space>
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
* 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 net.runelite.api.NPC;
import net.runelite.api.Point;
import net.runelite.api.Prayer;
public class ZulrahPhase
{
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, Point start)
{
ZulrahLocation zulrahLocation = ZulrahLocation.valueOf(start, zulrah.getWorldLocation());
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 Point getZulrahTile(Point startTile)
{
// NORTH doesn't need changing because it is the start
switch (zulrahLocation)
{
case SOUTH:
return new Point(startTile.getX(), startTile.getY() - 11);
case EAST:
return new Point(startTile.getX() + 10, startTile.getY() - 2);
case WEST:
return new Point(startTile.getX() - 10, startTile.getY() - 2);
}
return startTile;
}
// world location
public Point getStandTile(Point startTile)
{
switch (standLocation)
{
case WEST:
return new Point(startTile.getX() - 5, startTile.getY());
case EAST:
return new Point(startTile.getX() + 5, startTile.getY() - 2);
case SOUTH:
return new Point(startTile.getX(), startTile.getY() - 6);
case SOUTH_WEST:
return new Point(startTile.getX() - 4, startTile.getY() - 4);
case SOUTH_EAST:
return new Point(startTile.getX() + 2, startTile.getY() - 6);
case TOP_EAST:
return new Point(startTile.getX() + 6, startTile.getY() + 2);
case TOP_WEST:
return new Point(startTile.getX() - 4, startTile.getY() + 3);
case PILLAR_WEST_INSIDE:
return new Point(startTile.getX() - 4, startTile.getY() - 3);
case PILLAR_WEST_OUTSIDE:
return new Point(startTile.getX() - 5, startTile.getY() - 3);
case PILLAR_EAST_INSIDE:
return new Point(startTile.getX() + 4, startTile.getY() - 3);
case PILLAR_EAST_OUTSIDE:
return new Point(startTile.getX() + 4, startTile.getY() - 4);
}
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;
}
}

View File

@@ -1,5 +1,6 @@
/*
* Copyright (c) 2017, Aria <aria@ar1as.space>
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -22,12 +23,34 @@
* (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;
package net.runelite.client.plugins.zulrah.phase;
public enum ZulrahLocation
import net.runelite.api.NpcID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public enum ZulrahType
{
NORTH,
SOUTH,
EAST,
WEST
RANGE, MAGIC, MELEE;
private static final Logger logger = LoggerFactory.getLogger(ZulrahType.class);
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;
}
logger.debug("Unknown Zulrah Id: {}", zulrahId);
return null;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@@ -116,6 +116,14 @@ public abstract class RSActorMixin implements RSActor
return -1;
}
@Override
@Inject
public Point getWorldLocation()
{
Point localLocation = getLocalLocation();
return Perspective.localToWorld(client, localLocation);
}
@Inject
@Override
public Point getLocalLocation()