Add zulrah plugin

This commit is contained in:
aria
2017-05-07 11:09:10 -04:00
committed by Adam
parent feda25f1d2
commit 0469d83bb5
15 changed files with 1127 additions and 0 deletions

View File

@@ -35,6 +35,11 @@ public class NPC extends Actor
this.npc = npc;
}
public int getId()
{
return npc.getComposition().getId();
}
@Override
public String getName()
{

View File

@@ -44,6 +44,7 @@ import net.runelite.client.plugins.opponentinfo.OpponentInfo;
import net.runelite.client.plugins.pestcontrol.PestControl;
import net.runelite.client.plugins.runecraft.Runecraft;
import net.runelite.client.plugins.xtea.Xtea;
import net.runelite.client.plugins.zulrah.Zulrah;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -73,6 +74,7 @@ public class PluginManager
plugins.add(new MouseHighlight());
plugins.add(new PestControl());
plugins.add(new ClanChat());
plugins.add(new Zulrah());
if (RuneLite.getOptions().has("developer-mode"))
{

View File

@@ -0,0 +1,89 @@
/*
* 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.time.Instant;
import net.runelite.api.Point;
import net.runelite.client.plugins.zulrah.patterns.ZulrahPattern;
public class Fight
{
private final Point startLocationWorld;
private final Instant startTime = Instant.now();
private ZulrahPattern pattern;
private int stage;
private ZulrahInstance zulrah;
public Fight(Point startLocationWorld)
{
this.startLocationWorld = startLocationWorld;
}
public Point getStartLocationWorld()
{
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;
}
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright (c) 2017, Aria <aria@ar1as.space>
* 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;
public enum StandLocation
{
WEST,
EAST,
SOUTH,
TOP_EAST,
TOP_WEST,
PILLAR_WEST_INSIDE,
PILLAR_WEST_OUTSIDE,
PILLAR_EAST_INSIDE,
PILLAR_EAST_OUTSIDE;
}

View File

@@ -0,0 +1,120 @@
/*
* 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)
{
ZulrahInstance current, next;
synchronized (plugin)
{
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
current = fight.getZulrah();
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

@@ -0,0 +1,137 @@
/*
* 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.BasicStroke;
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;
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)
{
ZulrahPattern pattern;
Point startLocationWorld;
int stage;
synchronized (plugin)
{
Fight fight = plugin.getFight();
if (client.getGameState() != GameState.LOGGED_IN || fight == null)
{
return null;
}
pattern = fight.getPattern();
if (pattern == null)
{
return null;
}
startLocationWorld = fight.getStartLocationWorld();
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)
{
graphics.setColor(outlineColor);
graphics.setStroke(new BasicStroke(2));
graphics.drawPolygon(poly);
graphics.setColor(new Color(0, 0, 0, 50));
graphics.fillPolygon(poly);
}
}
}

View File

@@ -0,0 +1,190 @@
/*
* 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.util.Arrays;
import java.util.Collection;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import net.runelite.api.Client;
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;
import net.runelite.client.plugins.Plugin;
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.ui.overlay.Overlay;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Zulrah extends Plugin
{
private static final Logger logger = LoggerFactory.getLogger(Zulrah.class);
private static final String ZULRAH = "Zulrah";
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 Fight fight;
private ScheduledFuture<?> future;
@Override
public Collection<Overlay> getOverlays()
{
return Arrays.asList(overlay, tileOverlay);
}
@Override
protected void startUp() throws Exception
{
ScheduledExecutorService executor = RuneLite.getRunelite().getExecutor();
future = executor.scheduleAtFixedRate(this::update, 100, 100, TimeUnit.MILLISECONDS);
}
@Override
protected void shutDown() throws Exception
{
future.cancel(true);
}
private synchronized void update()
{
try
{
NPC zulrah = findZulrah();
if (zulrah == null)
{
if (fight != null)
{
logger.debug("Fight has ended!");
fight = null;
}
return;
}
if (fight == null)
{
Point startTile = zulrah.getLocalLocation();
startTile = Perspective.localToWorld(client, startTile);
fight = new Fight(startTile);
logger.debug("Fight has begun!");
}
ZulrahInstance currentZulrah = ZulrahInstance.of(zulrah, fight.getStartLocationWorld());
if (fight.getZulrah() == null)
{
fight.setZulrah(currentZulrah);
}
else if (!fight.getZulrah().equals(currentZulrah))
{
ZulrahInstance previousInstance = fight.getZulrah();
fight.setZulrah(currentZulrah);
fight.nextStage();
logger.debug("Zulrah has moved from {} -> {}, index now {}",
previousInstance, currentZulrah, fight.getStage());
}
ZulrahPattern pattern = fight.getPattern();
if (pattern == null)
{
int potential = 0;
ZulrahPattern potentialPattern = null;
for (ZulrahPattern p : patterns)
{
if (p.stageMatches(fight.getStage(), fight.getZulrah()))
{
potential++;
potentialPattern = p;
}
}
if (potential == 1)
{
logger.debug("Zulrah pattern identified: {}", potentialPattern);
fight.setPattern(potentialPattern);
}
}
else
{
if (pattern.canReset(fight.getStage()))
{
if (fight.getZulrah().equals(pattern.get(0)))
{
logger.debug("Fight has reset");
fight.reset();
}
}
}
}
catch (Exception ex)
{
logger.debug(null, ex);
}
}
private NPC findZulrah()
{
Query query = new NPCQuery()
.nameEquals(ZULRAH);
NPC[] result = client.runQuery(query);
return result.length == 1 ? result[0] : null;
}
public Fight getFight()
{
return fight;
}
}

View File

@@ -0,0 +1,219 @@
/*
* Copyright (c) 2017, Aria <aria@ar1as.space>
* 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.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;
/*
Original code: https://github.com/LoveLeAnon/OSLoader
*/
public class ZulrahInstance
{
private static final Logger logger = LoggerFactory.getLogger(ZulrahInstance.class);
private static final int ZULRAH_RANGE = NpcID.ZULRAH;
private static final int ZULRAH_MELEE = NpcID.ZULRAH_2;
private static final int ZULRAH_MAGIC = NpcID.ZULRAH_3;
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)
{
this.loc = loc;
this.type = type;
this.jad = jad;
this.standLoc = standLoc;
}
@Override
public String toString()
{
return "ZulrahInstance{" + "loc=" + loc + ", type=" + type + '}';
}
public Point getZulrahLoc(Point startLoc)
{
// 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;
}
public Point getStandLoc(Point startLoc)
{
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;
}
public ZulrahLocation getLoc()
{
return loc;
}
public ZulrahType getType()
{
return type;
}
public boolean isJad()
{
return jad;
}
public StandLocation getStandLoc()
{
return standLoc;
}
@Override
public int hashCode()
{
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;
}
@Override
public boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
if (obj == null)
{
return false;
}
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);
}
}

View File

@@ -0,0 +1,33 @@
/*
* Copyright (c) 2017, Aria <aria@ar1as.space>
* 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;
public enum ZulrahLocation
{
NORTH,
SOUTH,
EAST,
WEST
}

View File

@@ -0,0 +1,32 @@
/*
* Copyright (c) 2017, Aria <aria@ar1as.space>
* 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;
public enum ZulrahType
{
RANGE,
MAGIC,
MELEE
}

View File

@@ -0,0 +1,73 @@
/*
* Copyright (c) 2017, Aria <aria@ar1as.space>
* 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.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;
public abstract class ZulrahPattern
{
private final List<ZulrahInstance> pattern = new ArrayList<>();
protected final void add(ZulrahLocation loc, ZulrahType type, StandLocation standLoc)
{
add(loc, type, standLoc, false);
}
protected final void addJad(ZulrahLocation loc, ZulrahType type, StandLocation standLoc)
{
add(loc, type, standLoc, true);
}
private void add(ZulrahLocation loc, ZulrahType type, StandLocation standLoc, boolean jad)
{
pattern.add(new ZulrahInstance(loc, type, jad, standLoc));
}
public ZulrahInstance get(int index)
{
if (index >= pattern.size())
{
return null;
}
return pattern.get(index);
}
public boolean stageMatches(int index, ZulrahInstance instance)
{
ZulrahInstance patternInstance = get(index);
return patternInstance != null && patternInstance.equals(instance);
}
public boolean canReset(int index)
{
return index >= pattern.size();
}
}

View File

@@ -0,0 +1,46 @@
/*
* Copyright (c) 2017, Aria <aria@ar1as.space>
* 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.client.plugins.zulrah.StandLocation;
import net.runelite.client.plugins.zulrah.ZulrahLocation;
import net.runelite.client.plugins.zulrah.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);
}
}

View File

@@ -0,0 +1,48 @@
/*
* Copyright (c) 2017, Aria <aria@ar1as.space>
* 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.client.plugins.zulrah.StandLocation;
import net.runelite.client.plugins.zulrah.ZulrahLocation;
import net.runelite.client.plugins.zulrah.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);
}
}

View File

@@ -0,0 +1,47 @@
/*
* Copyright (c) 2017, Aria <aria@ar1as.space>
* 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.client.plugins.zulrah.StandLocation;
import net.runelite.client.plugins.zulrah.ZulrahLocation;
import net.runelite.client.plugins.zulrah.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);
}
}

View File

@@ -0,0 +1,48 @@
/*
* Copyright (c) 2017, Aria <aria@ar1as.space>
* 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.client.plugins.zulrah.StandLocation;
import net.runelite.client.plugins.zulrah.ZulrahLocation;
import net.runelite.client.plugins.zulrah.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);
}
}