Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Owain van Brakel
2020-02-09 12:00:23 +01:00
4 changed files with 3621 additions and 9 deletions

1
.gitignore vendored
View File

@@ -23,3 +23,4 @@ runelite-client/dependencies.txt
.staging/
.vscode
.factorypath
hs_err_pid*.log

View File

@@ -0,0 +1,57 @@
/*
* Copyright (c) 2020 ThatGamerBlue
* 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.api.geometry;
import net.runelite.api.coords.WorldPoint;
public class Cuboid
{
private WorldPoint southWest;
private WorldPoint northEast;
public Cuboid(int x1, int y1, int z1, int x2, int y2, int z2)
{
this(new WorldPoint(x1, y1, z1), new WorldPoint(x2, y2, z2));
}
public Cuboid(WorldPoint southWest, WorldPoint northEast)
{
this.southWest = southWest;
this.northEast = northEast;
}
public boolean contains(WorldPoint worldPoint)
{
if (worldPoint.getPlane() < southWest.getPlane() || worldPoint.getPlane() > northEast.getPlane())
{
return false;
}
if (worldPoint.getY() < southWest.getY() || worldPoint.getY() > northEast.getY())
{
return false;
}
return worldPoint.getX() >= southWest.getX() && worldPoint.getX() <= northEast.getX();
}
}

View File

@@ -6,12 +6,8 @@
* Written by PKLite(ST0NEWALL, others) <stonewall@thots.cc.usa>, 2019
*
*/
package net.runelite.client.util;
import java.util.Comparator;
import java.util.Objects;
import java.util.TreeMap;
import net.runelite.api.Client;
import net.runelite.api.InventoryID;
import net.runelite.api.Item;
@@ -20,29 +16,59 @@ import net.runelite.api.Player;
import net.runelite.api.Varbits;
import net.runelite.api.WorldType;
import net.runelite.api.coords.WorldPoint;
import net.runelite.api.geometry.Cuboid;
import net.runelite.client.game.ItemManager;
import org.apache.commons.lang3.ArrayUtils;
import java.awt.Polygon;
import java.util.Comparator;
import java.util.Objects;
import java.util.TreeMap;
/**
*
*/
public class PvPUtil
{
private static final Polygon NOT_WILDERNESS_BLACK_KNIGHTS = new Polygon( // this is black knights castle
new int[]{2994, 2995, 2996, 2996, 2994, 2994, 2997, 2998, 2998, 2999, 3000, 3001, 3002, 3003, 3004, 3005, 3005,
3005, 3019, 3020, 3022, 3023, 3024, 3025, 3026, 3026, 3027, 3027, 3028, 3028, 3029, 3029, 3030, 3030, 3031,
3031, 3032, 3033, 3034, 3035, 3036, 3037, 3037},
new int[]{3525, 3526, 3527, 3529, 3529, 3534, 3534, 3535, 3536, 3537, 3538, 3539, 3540, 3541, 3542, 3543, 3544,
3545, 3545, 3546, 3546, 3545, 3544, 3543, 3543, 3542, 3541, 3540, 3539, 3537, 3536, 3535, 3534, 3533, 3532,
3531, 3530, 3529, 3528, 3527, 3526, 3526, 3525},
43
);
private static final Cuboid MAIN_WILDERNESS_CUBOID = new Cuboid(2944, 3525, 0, 3391, 4351, 3);
private static final Cuboid GOD_WARS_WILDERNESS_CUBOID = new Cuboid(3008, 10112, 0, 3071, 10175, 3);
private static final Cuboid WILDERNESS_UNDERGROUND_CUBOID = new Cuboid(2944, 9920, 0, 3391, 10879, 3);
/**
* Gets the wilderness level based on a world point
* Java reimplementation of clientscript 384 [proc,wilderness_level]
*
* @param point the point in the world to get the wilderness level for
* @return the int representing the wilderness level
*/
public static int getWildernessLevelFrom(WorldPoint point)
{
int y = point.getY();
if (MAIN_WILDERNESS_CUBOID.contains(point))
{
if (NOT_WILDERNESS_BLACK_KNIGHTS.contains(point.getX(), point.getY()))
{
return 0;
}
int underLevel = ((y - 9920) / 8) + 1;
int upperLevel = ((y - 3520) / 8) + 1;
return y > 6400 ? underLevel : upperLevel;
return ((point.getY() - 3520) / 8) + 1; // calc(((coordz(coord) - (55 * 64)) / 8) + 1)
}
else if (GOD_WARS_WILDERNESS_CUBOID.contains(point))
{
return ((point.getY() - 9920) / 8) - 1; // calc(((coordz(coord) - (155 * 64)) / 8) - 1)
}
else if (WILDERNESS_UNDERGROUND_CUBOID.contains(point))
{
return ((point.getY() - 9920) / 8) + 1; // calc(((coordz(coord) - (155 * 64)) / 8) + 1)
}
return 0;
}
/**