mirror of
https://github.com/2006-Scape/2006Scape.git
synced 2026-07-02 16:49:03 +00:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7f1dc47c98 | |||
| 45b85d728f | |||
| d2fe8b0769 | |||
| 20ccc2399a | |||
| af522dbe1b | |||
| db696431e6 | |||
| 43775016ba | |||
| 4fe3f446a4 | |||
| 0120892521 | |||
| e404eadb3b | |||
| fd731242dd | |||
| 86e7b93b3b | |||
| cad090d8fe |
@@ -7,6 +7,47 @@ import java.math.BigInteger;
|
||||
*/
|
||||
|
||||
public class ClientSettings {
|
||||
/**
|
||||
* @QoL
|
||||
* Require control key to zoom the client
|
||||
*/
|
||||
public static boolean CONTROL_KEY_ZOOMING = false;
|
||||
|
||||
/**
|
||||
* @QoL
|
||||
* Show zoom level messages in chat when changing zoom levels
|
||||
*/
|
||||
public static boolean SHOW_ZOOM_LEVEL_MESSAGES = false;
|
||||
/**
|
||||
* @QoL
|
||||
* Hide roofs
|
||||
*/
|
||||
public static boolean HIDE_ROOFS = false;
|
||||
/**
|
||||
* @QoL
|
||||
* Hide buggy varrock sword shop snow
|
||||
*/
|
||||
public static boolean HIDE_BUGGY_VARROCK_SWORD_SHOP_SNOW = true;
|
||||
/**
|
||||
* @QoL
|
||||
* Forces Server-Wide Snow floor
|
||||
*/
|
||||
public static boolean SNOW_FLOOR_FORCE_ENABLED = false;
|
||||
/**
|
||||
* @QoL
|
||||
* Toggles Server-Wide Snow floor (for the designated month)
|
||||
*/
|
||||
public static boolean SNOW_FLOOR_ENABLED = true;
|
||||
/**
|
||||
* @QoL
|
||||
* Forces Server-Wide Snow overlay
|
||||
*/
|
||||
public static boolean SNOW_OVERLAY_FORCE_ENABLED = false;
|
||||
/**
|
||||
* @QoL
|
||||
* Toggles Server-Wide Snow overlay (for the designated month)
|
||||
*/
|
||||
public static boolean SNOW_OVERLAY_ENABLED = false;
|
||||
/**
|
||||
* @QoL
|
||||
* Enables Server-Wide Snow In The Designated Month
|
||||
@@ -75,6 +116,19 @@ public class ClientSettings {
|
||||
* FileServer Must Be Running Before Starting The Client If This Is True
|
||||
*/
|
||||
public static boolean CHECK_CRC = true;
|
||||
|
||||
/**
|
||||
* @QoL
|
||||
* Enables the ability to take screenshots
|
||||
*/
|
||||
public static boolean SCREENSHOTS_ENABLED = false;
|
||||
|
||||
/**
|
||||
* @QoL
|
||||
* Enables the ability to take automatic screenshots on stats tab click and bank open
|
||||
* This is a poor man's player exports.
|
||||
*/
|
||||
public static boolean AUTOMATIC_SCREENSHOTS_ENABLED = false;
|
||||
|
||||
/**
|
||||
* The Npc Bits for the Server
|
||||
|
||||
@@ -35,7 +35,7 @@ public final class Flo {
|
||||
} else if (i == 1) {
|
||||
anInt390 = stream.read3Bytes();
|
||||
Calendar date = new GregorianCalendar();
|
||||
if ((date.get(Calendar.MONTH) + 1) == 12) {
|
||||
if (ClientSettings.SNOW_FLOOR_FORCE_ENABLED || (ClientSettings.SNOW_FLOOR_ENABLED && (date.get(Calendar.MONTH) + 1) == Integer.parseInt(ClientSettings.SNOW_MONTH.substring(1)))) {
|
||||
anInt390 = 0xffffff;
|
||||
}
|
||||
method262(anInt390);
|
||||
|
||||
@@ -3,12 +3,14 @@
|
||||
* THIS IS TO ALLOW LOCAL PARABOT TO CONTINUE TO WORK
|
||||
*/
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.*;
|
||||
import java.applet.AppletContext;
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.EOFException;
|
||||
@@ -23,6 +25,7 @@ import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.zip.CRC32;
|
||||
@@ -2975,7 +2978,11 @@ public class Game extends RSApplet {
|
||||
if (anInt1011 > 0) {
|
||||
anInt1011--;
|
||||
}
|
||||
for (int j = 0; j < 5; j++) {
|
||||
//TODO: Technically, this loop should be < 5 for authenticity, but until we reduce server inefficiencies
|
||||
//(for example killing a bunch of cows results in client lag,
|
||||
//likely from all the items on the ground for example), < 100 is fine.
|
||||
//OSRS uses < 100 and there are no drawbacks from having this < 100.
|
||||
for (int j = 0; j < 100; j++) {
|
||||
if (!parsePacket()) {
|
||||
break;
|
||||
}
|
||||
@@ -3758,7 +3765,7 @@ public class Game extends RSApplet {
|
||||
worldController.method312(k - 4, j - 4);
|
||||
}
|
||||
}
|
||||
if (l == 1062) {
|
||||
if (l == 1062) { //Fifth click
|
||||
anInt924 += baseX;
|
||||
if (anInt924 >= 113) {
|
||||
stream.createFrame(183);
|
||||
@@ -5034,6 +5041,10 @@ public class Game extends RSApplet {
|
||||
if (inputString.equals("::gfxtgl") || inputString.equals("::tglgfx") || inputString.equals("::togglerender") || inputString.equals("::togglegfx")) {
|
||||
graphicsEnabled = !graphicsEnabled;
|
||||
}
|
||||
if (inputString.equals("::crtlkeyzoom") || inputString.equals("::controlkeyzoom")) {
|
||||
ClientSettings.CONTROL_KEY_ZOOMING = !ClientSettings.CONTROL_KEY_ZOOMING;
|
||||
pushMessage("Your control key zooming is now: " + (ClientSettings.CONTROL_KEY_ZOOMING ? "enabled" : "disabled"), 0, "");
|
||||
}
|
||||
if (myPrivilege >= 2) {
|
||||
if (inputString.equals("::noclip"))
|
||||
for (int k1 = 0; k1 < 4; k1++)
|
||||
@@ -5579,7 +5590,51 @@ public class Game extends RSApplet {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void screenshot(boolean sendMessage, String... subfolders) {
|
||||
try {
|
||||
Window window = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow();
|
||||
if (window == null) {
|
||||
return;
|
||||
}
|
||||
Point point = window.getLocationOnScreen();
|
||||
int x = (int) point.getX();
|
||||
int y = (int) point.getY();
|
||||
int w = window.getWidth();
|
||||
int h = window.getHeight();
|
||||
Robot robot = new Robot(window.getGraphicsConfiguration().getDevice());
|
||||
Rectangle captureSize = new Rectangle(x, y, w, h);
|
||||
BufferedImage bufferedimage = robot.createScreenCapture(captureSize);
|
||||
|
||||
// Format the current date and time
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy_MM_dd-HH_mm_ss");
|
||||
String dateTime = dateFormat.format(new Date());
|
||||
|
||||
// Update the file path and naming
|
||||
String fileExtension = myUsername != null && !myUsername.isEmpty() ? myUsername : ClientSettings.SERVER_NAME;
|
||||
|
||||
String subfolderPath = String.join(File.separator, subfolders);
|
||||
if (!subfolderPath.isEmpty()) {
|
||||
subfolderPath += File.separator;
|
||||
}
|
||||
|
||||
String screenshotDir = System.getProperty("user.home") + File.separatorChar + ClientSettings.SERVER_NAME + File.separatorChar + "screenshots" + File.separatorChar + subfolderPath;
|
||||
File dir = new File(screenshotDir);
|
||||
if (!dir.exists()) {
|
||||
dir.mkdirs(); // Create the directory if it doesn't exist
|
||||
}
|
||||
|
||||
File file = new File(screenshotDir, fileExtension + "_" + dateTime + ".png");
|
||||
|
||||
if (!file.exists()) {
|
||||
ImageIO.write(bufferedimage, "png", file);
|
||||
if (sendMessage) {
|
||||
pushMessage("A picture has been saved in your screenshots folder.", 0, "");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void pushMessage(String s, int i, String s1) {
|
||||
if (i == 0 && dialogID != -1) {
|
||||
aString844 = s;
|
||||
@@ -5629,6 +5684,16 @@ public class Game extends RSApplet {
|
||||
needDrawTabArea = true;
|
||||
tabID = 1;
|
||||
tabAreaAltered = true;
|
||||
if(ClientSettings.SCREENSHOTS_ENABLED && ClientSettings.AUTOMATIC_SCREENSHOTS_ENABLED) {
|
||||
java.util.Timer timer = new java.util.Timer();
|
||||
java.util.TimerTask delayedScreenshot = new java.util.TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
screenshot(false, "stats");
|
||||
}
|
||||
};
|
||||
timer.schedule(delayedScreenshot, 300);
|
||||
}
|
||||
}
|
||||
if (super.saveClickX >= 597 && super.saveClickX <= 627 && super.saveClickY >= 168 && super.saveClickY < 205 && tabInterfaceIDs[2] != -1) {
|
||||
needDrawTabArea = true;
|
||||
@@ -6155,7 +6220,7 @@ public class Game extends RSApplet {
|
||||
return;
|
||||
}
|
||||
if (k == 11) {
|
||||
loginMessage2 = "Login server rejected session.";
|
||||
loginMessage1 = "Login server rejected session.";
|
||||
loginMessage2 = "Please try again.";
|
||||
return;
|
||||
}
|
||||
@@ -9042,7 +9107,14 @@ public class Game extends RSApplet {
|
||||
return;
|
||||
}
|
||||
if (k == 3) {
|
||||
boolean debugPlanes = false;
|
||||
if (debugPlanes) {
|
||||
System.out.println("plane is " + plane);
|
||||
}
|
||||
plane = stream.readBits(2);
|
||||
if (debugPlanes) {
|
||||
System.out.println("plane is now " + plane);
|
||||
}
|
||||
int j1 = stream.readBits(1);
|
||||
int i2 = stream.readBits(1);
|
||||
if (i2 == 1) {
|
||||
@@ -9051,6 +9123,15 @@ public class Game extends RSApplet {
|
||||
int k2 = stream.readBits(7);
|
||||
int l2 = stream.readBits(7);
|
||||
myPlayer.setPos(l2, k2, j1 == 1);
|
||||
//Handle plane changes, higher planes need the roof drawing checks disabled, and we need to manually update ObjectManager's anInt131 (plane) then manually call method22 to let the ObjectManaegr know we're on a different plane. This makes plane changes draw properly. Coords for testing this: lumb: 3207 3227 and varrock: 3209, 3392 and gnome agil: 2474, 3427
|
||||
ObjectManager.hideRoofs = ClientSettings.HIDE_ROOFS;
|
||||
ObjectManager.hideBuggyVarrockSwordShopSnow = ClientSettings.HIDE_BUGGY_VARROCK_SWORD_SHOP_SNOW;
|
||||
if (plane > 0) {
|
||||
ObjectManager.hideRoofs = false;
|
||||
ObjectManager.hideBuggyVarrockSwordShopSnow = false;
|
||||
}
|
||||
ObjectManager.anInt131 = plane;
|
||||
method22();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11247,6 +11328,16 @@ public class Game extends RSApplet {
|
||||
tabAreaAltered = true;
|
||||
aBoolean1149 = false;
|
||||
pktType = -1;
|
||||
if (ClientSettings.SCREENSHOTS_ENABLED && ClientSettings.AUTOMATIC_SCREENSHOTS_ENABLED && i5 == 5292) {
|
||||
java.util.Timer timer = new java.util.Timer();
|
||||
java.util.TimerTask delayedScreenshot = new java.util.TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
screenshot(false, "bank");
|
||||
}
|
||||
};
|
||||
timer.schedule(delayedScreenshot, 600);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (pktType == 79) {
|
||||
@@ -11571,7 +11662,7 @@ public class Game extends RSApplet {
|
||||
// 15774 = Good/Bad Password
|
||||
// 15767 = Drama Type
|
||||
if (l7 == 15244) {
|
||||
if (Flo.getTodaysDate().contains(ClientSettings.SNOW_MONTH)) {
|
||||
if (ClientSettings.SNOW_OVERLAY_FORCE_ENABLED || (ClientSettings.SNOW_OVERLAY_ENABLED && Flo.getTodaysDate().contains(ClientSettings.SNOW_MONTH))) {
|
||||
openInterfaceID = 15819;
|
||||
} else {
|
||||
openInterfaceID = 15801;
|
||||
@@ -11814,8 +11905,8 @@ public class Game extends RSApplet {
|
||||
draw3dScreen();
|
||||
if (showInfo) {
|
||||
int debugX = 0;
|
||||
int debugY = 249;
|
||||
int debugItems = 4;
|
||||
int debugY = 234;
|
||||
int debugItems = 5;
|
||||
int debugWidth = 140;
|
||||
int debugHeight = 25 + (debugItems * 15);
|
||||
int fill = 0x5d5447;
|
||||
@@ -11842,6 +11933,8 @@ public class Game extends RSApplet {
|
||||
chatTextDrawingArea.textRightShadow(true, debugX + debugWidth - 4, Color.YELLOW.hashCode(), (myPlayer.smallX[0] + baseX) + ", " + (myPlayer.smallY[0] + baseY), debugY);
|
||||
chatTextDrawingArea.textLeftShadow(true, debugX + 4, Color.WHITE.hashCode(), "Interface:", debugY += 15);
|
||||
chatTextDrawingArea.textRightShadow(true, debugX + debugWidth - 4, Color.YELLOW.hashCode(), "" + openInterfaceID, debugY);
|
||||
chatTextDrawingArea.textLeftShadow(true, debugX + 4, Color.WHITE.hashCode(), "Zoom level:", debugY += 15);
|
||||
chatTextDrawingArea.textRightShadow(true, debugX + debugWidth - 4, Color.YELLOW.hashCode(), "" + zoom, debugY);
|
||||
}
|
||||
|
||||
if (customSettingShowExperiencePerHour) {
|
||||
@@ -12619,12 +12712,20 @@ public class Game extends RSApplet {
|
||||
tabAreaAltered = true;
|
||||
break;
|
||||
case KeyEvent.VK_PAGE_UP:
|
||||
if (zoom > -1)
|
||||
if (zoom > -1) {
|
||||
zoom--;
|
||||
if (ClientSettings.SHOW_ZOOM_LEVEL_MESSAGES) {
|
||||
pushMessage("Your zoom level is now: " + zoom, 0, "");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case KeyEvent.VK_PAGE_DOWN:
|
||||
if (zoom < (WorldController.drawDistance / 3))
|
||||
if (zoom < (WorldController.drawDistance / 3)) {
|
||||
zoom++;
|
||||
if (ClientSettings.SHOW_ZOOM_LEVEL_MESSAGES) {
|
||||
pushMessage("Your zoom level is now: " + zoom, 0, "");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case KeyEvent.VK_V:
|
||||
if (keyevent.isControlDown()) {
|
||||
@@ -12636,6 +12737,9 @@ public class Game extends RSApplet {
|
||||
}
|
||||
|
||||
}
|
||||
if (ClientSettings.SCREENSHOTS_ENABLED && keyevent.getKeyCode() == KeyEvent.VK_PRINTSCREEN && keyevent.isControlDown()) {
|
||||
screenshot(true);
|
||||
}
|
||||
}
|
||||
|
||||
public long calculateTotalExp() {
|
||||
@@ -12783,7 +12887,7 @@ public class Game extends RSApplet {
|
||||
inputTaken = true;
|
||||
}
|
||||
if (interfaceID == 15244) {
|
||||
if (Flo.getTodaysDate().contains(ClientSettings.SNOW_MONTH)) {
|
||||
if (ClientSettings.SNOW_OVERLAY_FORCE_ENABLED || (ClientSettings.SNOW_OVERLAY_ENABLED && Flo.getTodaysDate().contains(ClientSettings.SNOW_MONTH))) {
|
||||
openInterfaceID = 15819;
|
||||
} else {
|
||||
openInterfaceID = 15801;
|
||||
@@ -12806,14 +12910,25 @@ public class Game extends RSApplet {
|
||||
|
||||
public final void mouseWheelMoved(MouseWheelEvent e) {
|
||||
int notches = e.getWheelRotation();
|
||||
if (ClientSettings.CONTROL_KEY_ZOOMING && !e.isControlDown()) {
|
||||
return;
|
||||
}
|
||||
// If mouse over main game screen, without anything else opened
|
||||
if (openInterfaceID == -1 && mouseX < 515 && mouseY < 340) {
|
||||
if (notches < 0) {
|
||||
if (zoom > -1)
|
||||
if (zoom > -1) {
|
||||
zoom--;
|
||||
if (ClientSettings.SHOW_ZOOM_LEVEL_MESSAGES) {
|
||||
pushMessage("Your zoom level is now: " + zoom, 0, "");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (zoom < (WorldController.drawDistance / 3))
|
||||
if (zoom < (WorldController.drawDistance / 3)) {
|
||||
zoom++;
|
||||
if (ClientSettings.SHOW_ZOOM_LEVEL_MESSAGES) {
|
||||
pushMessage("Your zoom level is now: " + zoom, 0, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,13 +32,36 @@ public final class Main {
|
||||
ClientSettings.BILINEAR_MINIMAP_FILTERING = true;
|
||||
ClientSettings.FIX_TRANSPARENCY_OVERFLOW = true;
|
||||
ClientSettings.FULL_512PX_VIEWPORT = true;
|
||||
Game.customSettingVisiblePlayerNames = true;
|
||||
Game.customSettingMinItemValue = 1000;
|
||||
ClientSettings.CONTROL_KEY_ZOOMING = true;
|
||||
break;
|
||||
case "-no-nav":
|
||||
case"-disable-nav":
|
||||
case "-disable-nav":
|
||||
ClientSettings.SHOW_NAVBAR = false;
|
||||
break;
|
||||
case"-no-snow":
|
||||
case"-hide-snow":
|
||||
case"-disable-snow":
|
||||
ClientSettings.SNOW_FLOOR_ENABLED = false;
|
||||
ClientSettings.SNOW_FLOOR_FORCE_ENABLED = false;
|
||||
ClientSettings.SNOW_OVERLAY_FORCE_ENABLED = false;
|
||||
ClientSettings.SNOW_OVERLAY_ENABLED = false;
|
||||
break;
|
||||
case"-no-roofs":
|
||||
case"-hide-roofs":
|
||||
case"-disable-roofs":
|
||||
ClientSettings.HIDE_ROOFS = true;
|
||||
break;
|
||||
case"-show-zoom":
|
||||
ClientSettings.SHOW_ZOOM_LEVEL_MESSAGES = true;
|
||||
break;
|
||||
case"-screenshots":
|
||||
case"-enable-screenshots":
|
||||
ClientSettings.SCREENSHOTS_ENABLED = true;
|
||||
break;
|
||||
case"-auto-screenshots":
|
||||
case"-enable-auto-screenshots":
|
||||
ClientSettings.AUTOMATIC_SCREENSHOTS_ENABLED = true;
|
||||
break;
|
||||
}
|
||||
if (args[i].startsWith("-") && (i + 1) < args.length && !args[i + 1].startsWith("-")) {
|
||||
switch(args[i]) {
|
||||
|
||||
@@ -146,7 +146,7 @@ final class ObjectManager {
|
||||
k15 -= anIntArray127[k18];
|
||||
k16 -= anIntArray128[k18];
|
||||
}
|
||||
if (k17 >= 1 && k17 < anInt147 - 1 && (!lowMem || (aByteArrayArrayArray149[0][l6][k17] & 2) != 0 || (aByteArrayArrayArray149[l][l6][k17] & 0x10) == 0 && method182(k17, l, l6) == anInt131)) {
|
||||
if (k17 >= 1 && k17 < anInt147 - 1 && ((!hideBuggyVarrockSwordShopSnow && !hideRoofs && !lowMem) || (aByteArrayArrayArray149[0][l6][k17] & 2) != 0 || (aByteArrayArrayArray149[l][l6][k17] & 0x10) == 0 && method182(k17, l, l6) == anInt131)) {
|
||||
if (l < anInt145) {
|
||||
anInt145 = l;
|
||||
}
|
||||
@@ -456,7 +456,7 @@ final class ObjectManager {
|
||||
}
|
||||
|
||||
private void method175(int i, WorldController worldController, CollisionMap class11, int j, int k, int l, int i1, int j1) {
|
||||
if (lowMem && (aByteArrayArrayArray149[0][l][i] & 2) == 0) {
|
||||
if ((hideRoofs || lowMem) && (aByteArrayArrayArray149[0][l][i] & 2) == 0) {
|
||||
if ((aByteArrayArrayArray149[k][l][i] & 0x10) != 0) {
|
||||
return;
|
||||
}
|
||||
@@ -1355,6 +1355,10 @@ final class ObjectManager {
|
||||
private final byte[][][] aByteArrayArrayArray148;
|
||||
private final byte[][][] aByteArrayArrayArray149;
|
||||
static boolean lowMem = true;
|
||||
|
||||
static boolean hideRoofs = ClientSettings.HIDE_ROOFS;
|
||||
|
||||
static boolean hideBuggyVarrockSwordShopSnow = ClientSettings.HIDE_BUGGY_VARROCK_SWORD_SHOP_SNOW; //There is some buggy snow near Varrock sword shop, let's hide it. I know, this is not ideal, but it does work.
|
||||
private static final int anIntArray152[] = {1, 2, 4, 8};
|
||||
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ final class RSFrame extends Frame {
|
||||
public RSFrame(RSApplet applet) {
|
||||
rsApplet = applet;
|
||||
|
||||
setTitle(ClientSettings.SERVER_NAME + " World: " + ClientSettings.SERVER_WORLD);
|
||||
setTitle(ClientSettings.SERVER_NAME + " World: " + ClientSettings.SERVER_WORLD + ((ClientSettings.SERVER_IP.equals("localhost") || ClientSettings.SERVER_IP.equals("127.0.0.1")) ? " [Local]" : ""));
|
||||
this.setResizable(false);
|
||||
this.setBackground(Color.BLACK);
|
||||
|
||||
|
||||
@@ -23,5 +23,7 @@
|
||||
"timeout": 60,
|
||||
"item_requirements": true,
|
||||
"max_players": 200,
|
||||
"website_integration": false
|
||||
"website_integration": false,
|
||||
"cycle_logging": true,
|
||||
"cycle_logging_tick": 10
|
||||
}
|
||||
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -3789,36 +3789,6 @@
|
||||
"walk": 1,
|
||||
"height": 0
|
||||
},
|
||||
{
|
||||
"maxHit": 32,
|
||||
"strength": 200,
|
||||
"attack": 300,
|
||||
"x": 1738,
|
||||
"y": 5226,
|
||||
"id": 3340,
|
||||
"walk": 1,
|
||||
"height": 0
|
||||
},
|
||||
{
|
||||
"maxHit": 32,
|
||||
"strength": 200,
|
||||
"attack": 300,
|
||||
"x": 1777,
|
||||
"y": 5237,
|
||||
"id": 3340,
|
||||
"walk": 1,
|
||||
"height": 0
|
||||
},
|
||||
{
|
||||
"maxHit": 32,
|
||||
"strength": 200,
|
||||
"attack": 300,
|
||||
"x": 1740,
|
||||
"y": 5178,
|
||||
"id": 3340,
|
||||
"walk": 1,
|
||||
"height": 0
|
||||
},
|
||||
{
|
||||
"maxHit": 32,
|
||||
"strength": 200,
|
||||
@@ -3829,16 +3799,6 @@
|
||||
"walk": 1,
|
||||
"height": 0
|
||||
},
|
||||
{
|
||||
"maxHit": 32,
|
||||
"strength": 200,
|
||||
"attack": 300,
|
||||
"x": 1780,
|
||||
"y": 5190,
|
||||
"id": 3340,
|
||||
"walk": 1,
|
||||
"height": 0
|
||||
},
|
||||
{
|
||||
"maxHit": 38,
|
||||
"strength": 200,
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package plugin.buttons.gameframe;
|
||||
|
||||
import com.rs2.event.SubscribesTo;
|
||||
import com.rs2.event.impl.ButtonActionEvent;
|
||||
import com.rs2.game.content.music.Music;
|
||||
import com.rs2.game.players.Player;
|
||||
import plugin.buttons.ButtonClick;
|
||||
|
||||
@SubscribesTo(ButtonActionEvent.class)
|
||||
public final class SoundVolumeButtons extends ButtonClick {
|
||||
|
||||
@Override
|
||||
protected void execute(Player player, ButtonActionEvent event) {
|
||||
switch (event.getButton()) {
|
||||
|
||||
case 3173:
|
||||
if (player.soundOn) {
|
||||
player.soundOn = false;
|
||||
} else {
|
||||
player.getPacketSender().sendMessage("Your sound is already turned off.");
|
||||
}
|
||||
break;
|
||||
case 3174:
|
||||
case 3175:
|
||||
case 3176:
|
||||
case 3177:
|
||||
player.soundOn = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(ButtonActionEvent event) {
|
||||
return event.getButton() == 3173 || event.getButton() == 3174 || event.getButton() == 3175 || event.getButton() == 3176 || event.getButton() == 3177;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -72,6 +72,11 @@ public class ConfigLoader {
|
||||
}
|
||||
if (obj.has("website_integration"))
|
||||
Constants.WEBSITE_INTEGRATION = obj.getBoolean("website_integration");
|
||||
|
||||
if (obj.has("cycle_logging"))
|
||||
Constants.CYCLE_LOGGING = obj.getBoolean("cycle_logging");
|
||||
if (obj.has("cycle_logging_tick"))
|
||||
Constants.CYCLE_LOGGING_TICK = obj.getInt("cycle_logging_tick");
|
||||
}
|
||||
|
||||
private static void initialize() {
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
package com.rs2;
|
||||
|
||||
import com.rs2.game.content.StaticNpcList;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
|
||||
public class Constants {
|
||||
|
||||
@@ -34,11 +39,11 @@ public class Constants {
|
||||
* WEBSITE_INTEGRATION Enables/Disables Website Features(Total Accounts Registered & Players Online)
|
||||
*/
|
||||
public static String SERVER_NAME = "2006Scape", WEBSITE_LINK = "https://2006Scape.org";
|
||||
public static int WORLD = 1, HTTP_PORT = 8080, JAGGRAB_PORT = 43595, MAX_PLAYERS = 200, SAVE_TIMER = 120, TIMEOUT = 60, RESPAWN_X = 3222, RESPAWN_Y = 3218;
|
||||
public static int WORLD = 1, HTTP_PORT = 8080, JAGGRAB_PORT = 43595, MAX_PLAYERS = 200, SAVE_TIMER = 120, TIMEOUT = 60, RESPAWN_X = 3222, RESPAWN_Y = 3218, CYCLE_LOGGING_TICK = 10;
|
||||
public static boolean GUI_ENABLED = false, FILE_SERVER = true, SERVER_DEBUG = false, MEMBERS_ONLY = false, TUTORIAL_ISLAND = false,
|
||||
PARTY_ROOM_DISABLED = false, CLUES_ENABLED = true, ITEM_REQUIREMENTS = true,
|
||||
ADMIN_CAN_TRADE = false, ADMIN_DROP_ITEMS = false, ADMIN_CAN_SELL_ITEMS = false, VARIABLE_XP_RATE = false,
|
||||
WEBSITE_INTEGRATION = false;
|
||||
WEBSITE_INTEGRATION = false, CYCLE_LOGGING = true;
|
||||
public static int[] VARIABLE_XP_RATES = new int[] {1, 2, 5, 10};
|
||||
public static double TEST_VERSION = 2.3, XP_RATE = 1.0;
|
||||
|
||||
@@ -105,4 +110,89 @@ public class Constants {
|
||||
CRAFTING = 12, SMITHING = 13, MINING = 14, HERBLORE = 15,
|
||||
AGILITY = 16, THIEVING = 17, SLAYER = 18, FARMING = 19,
|
||||
RUNECRAFTING = 20;
|
||||
|
||||
public static final LinkedHashSet<Integer> BOSS_NPC_IDS = new LinkedHashSet<>(Arrays.asList(
|
||||
StaticNpcList.CHAOS_ELEMENTAL,
|
||||
StaticNpcList.DAGANNOTH_REX,
|
||||
StaticNpcList.DAGANNOTH_PRIME,
|
||||
StaticNpcList.DAGANNOTH_SUPREME,
|
||||
StaticNpcList.GIANT_MOLE,
|
||||
StaticNpcList.KING_BLACK_DRAGON,
|
||||
StaticNpcList.KALPHITE_QUEEN,
|
||||
StaticNpcList.TZTOKJAD
|
||||
));
|
||||
|
||||
public static final LinkedHashSet<Integer> SLAYER_NPC_IDS = new LinkedHashSet<>(Arrays.asList(
|
||||
StaticNpcList.CRAWLING_HAND,
|
||||
StaticNpcList.CRAWLING_HAND_1649,
|
||||
StaticNpcList.CRAWLING_HAND_1650,
|
||||
StaticNpcList.CRAWLING_HAND_1651,
|
||||
StaticNpcList.CRAWLING_HAND_1652,
|
||||
StaticNpcList.CRAWLING_HAND_1653,
|
||||
StaticNpcList.CRAWLING_HAND_1654,
|
||||
StaticNpcList.CRAWLING_HAND_1655,
|
||||
StaticNpcList.CRAWLING_HAND_1656,
|
||||
StaticNpcList.CRAWLING_HAND_1657,
|
||||
StaticNpcList.CAVE_BUG,
|
||||
StaticNpcList.CAVE_CRAWLER,
|
||||
StaticNpcList.CAVE_CRAWLER_1601,
|
||||
StaticNpcList.CAVE_CRAWLER_1602,
|
||||
StaticNpcList.CAVE_CRAWLER_1603,
|
||||
StaticNpcList.BANSHEE,
|
||||
StaticNpcList.CAVE_SLIME,
|
||||
StaticNpcList.ROCKSLUG,
|
||||
StaticNpcList.ROCKSLUG_1623,
|
||||
StaticNpcList.DESERT_LIZARD,
|
||||
StaticNpcList.DESERT_LIZARD_2805,
|
||||
StaticNpcList.DESERT_LIZARD_2806,
|
||||
StaticNpcList.COCKATRICE,
|
||||
StaticNpcList.COCKATRICE_1621,
|
||||
StaticNpcList.PYREFIEND,
|
||||
StaticNpcList.PYREFIEND_1634,
|
||||
StaticNpcList.PYREFIEND_1635,
|
||||
StaticNpcList.PYREFIEND_1636,
|
||||
StaticNpcList.MOGRE,
|
||||
StaticNpcList.HARPIE_BUG_SWARM,
|
||||
StaticNpcList.WALL_BEAST,
|
||||
StaticNpcList.KILLERWATT,
|
||||
StaticNpcList.KILLERWATT_3202,
|
||||
StaticNpcList.BASILISK,
|
||||
StaticNpcList.BASILISK_1617,
|
||||
StaticNpcList.FEVER_SPIDER,
|
||||
StaticNpcList.INFERNAL_MAGE,
|
||||
StaticNpcList.INFERNAL_MAGE_1644,
|
||||
StaticNpcList.INFERNAL_MAGE_1645,
|
||||
StaticNpcList.INFERNAL_MAGE_1646,
|
||||
StaticNpcList.INFERNAL_MAGE_1647,
|
||||
StaticNpcList.JELLY,
|
||||
StaticNpcList.JELLY_1638,
|
||||
StaticNpcList.JELLY_1639,
|
||||
StaticNpcList.JELLY_1640,
|
||||
StaticNpcList.JELLY_1641,
|
||||
StaticNpcList.JELLY_1642,
|
||||
StaticNpcList.TUROTH,
|
||||
StaticNpcList.TUROTH_1627,
|
||||
StaticNpcList.TUROTH_1628,
|
||||
StaticNpcList.TUROTH_1629,
|
||||
StaticNpcList.TUROTH_1630,
|
||||
StaticNpcList.TUROTH_1631,
|
||||
StaticNpcList.TUROTH_1632,
|
||||
StaticNpcList.ABERRANT_SPECTER,
|
||||
StaticNpcList.ABERRANT_SPECTER_1605,
|
||||
StaticNpcList.ABERRANT_SPECTER_1606,
|
||||
StaticNpcList.ABERRANT_SPECTER_1607,
|
||||
StaticNpcList.DUST_DEVIL,
|
||||
StaticNpcList.KURASK,
|
||||
StaticNpcList.KURASK_1609,
|
||||
StaticNpcList.SKELETAL_WYVERN,
|
||||
StaticNpcList.SKELETAL_WYVERN_3069,
|
||||
StaticNpcList.SKELETAL_WYVERN_3070,
|
||||
StaticNpcList.SKELETAL_WYVERN_3071,
|
||||
StaticNpcList.GARGOYLE,
|
||||
StaticNpcList.GARGOYLE_1611,
|
||||
StaticNpcList.NECHRYAEL,
|
||||
StaticNpcList.ABYSSAL_DEMON,
|
||||
StaticNpcList.DARK_BEAST,
|
||||
StaticNpcList.SMOKEDEVIL
|
||||
));
|
||||
}
|
||||
@@ -13,8 +13,12 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import com.google.common.base.Stopwatch;
|
||||
import com.rs2.game.npcs.Npc;
|
||||
import com.rs2.game.npcs.NpcList;
|
||||
import com.rs2.gui.ControlPanel;
|
||||
|
||||
import com.rs2.util.CustomPrintStream;
|
||||
import org.apollo.cache.IndexedFileSystem;
|
||||
import org.apollo.cache.decoder.ItemDefinitionDecoder;
|
||||
import org.apollo.cache.decoder.ObjectDefinitionDecoder;
|
||||
@@ -116,6 +120,7 @@ public class GameEngine {
|
||||
private final static ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
|
||||
private final static Lock lock = new ReentrantLock();
|
||||
public static ControlPanel panel;
|
||||
private static long serverStartTime;
|
||||
|
||||
static {
|
||||
shutdownServer = false;
|
||||
@@ -123,6 +128,11 @@ public class GameEngine {
|
||||
|
||||
public static void main(java.lang.String[] args)
|
||||
throws NullPointerException, IOException {
|
||||
CustomPrintStream errorStream = new CustomPrintStream(System.err, "ERROR", true);
|
||||
System.setErr(errorStream);
|
||||
CustomPrintStream infoStream = new CustomPrintStream(System.out, "INFO", true);
|
||||
System.setOut(infoStream);
|
||||
serverStartTime = System.currentTimeMillis();
|
||||
if (NetworkConstants.RSA_EXPONENT != Constants.RSA_EXPONENT) {
|
||||
NetworkConstants.RSA_EXPONENT = Constants.RSA_EXPONENT;
|
||||
NetworkConstants.RSA_MODULUS = Constants.RSA_MODULUS;
|
||||
@@ -153,15 +163,15 @@ public class GameEngine {
|
||||
}
|
||||
|
||||
if (!new File("data").exists()) {
|
||||
System.out.println("************************************");
|
||||
System.out.println("************************************");
|
||||
System.out.println("************************************");
|
||||
System.out.println("WARNING: I could not find the /data folder. You are LIKELY running this in the wrong directory!");
|
||||
System.out.println("In IntelliJ, fix it by clicking \"Server\" > Edit Configurations at the top of your screen");
|
||||
System.out.println("Then changing the \"Working Directory\" to be in \"2006Scape/2006Scape Server\", instead of just \"2006Scape\"");
|
||||
System.out.println("************************************");
|
||||
System.out.println("************************************");
|
||||
System.out.println("************************************");
|
||||
System.err.println("************************************");
|
||||
System.err.println("************************************");
|
||||
System.err.println("************************************");
|
||||
System.err.println("WARNING: I could not find the /data folder. You are LIKELY running this in the wrong directory!");
|
||||
System.err.println("In IntelliJ, fix it by clicking \"Server\" > Edit Configurations at the top of your screen");
|
||||
System.err.println("Then changing the \"Working Directory\" to be in \"2006Scape/2006Scape Server\", instead of just \"2006Scape\"");
|
||||
System.err.println("************************************");
|
||||
System.err.println("************************************");
|
||||
System.err.println("************************************");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
@@ -237,8 +247,10 @@ public class GameEngine {
|
||||
* scheduleAtFixedRate() does not invoke concurrent Runnables.
|
||||
*/
|
||||
scheduler.scheduleAtFixedRate(new Runnable() {
|
||||
int gameTicksIncrementor;
|
||||
final int printInfoTick = Constants.CYCLE_LOGGING_TICK;
|
||||
public void run() {
|
||||
//TODO debug Stopwatch stopwatch = Stopwatch.createStarted();
|
||||
Stopwatch stopwatch = Stopwatch.createStarted();
|
||||
/**
|
||||
* Main Server Tick
|
||||
*/
|
||||
@@ -246,17 +258,51 @@ public class GameEngine {
|
||||
if (GameEngine.shutdownServer) {
|
||||
scheduler.shutdown();
|
||||
}
|
||||
long startItemHandler = System.currentTimeMillis();
|
||||
itemHandler.process();
|
||||
long durationItemHandler = System.currentTimeMillis() - startItemHandler;
|
||||
checkAndLogDuration("ItemHandler", durationItemHandler);
|
||||
long startPlayerHandler = System.currentTimeMillis();
|
||||
playerHandler.process();
|
||||
long durationPlayerHandler = System.currentTimeMillis() - startPlayerHandler;
|
||||
checkAndLogDuration("PlayerHandler", durationPlayerHandler);
|
||||
long startNpcHandler = System.currentTimeMillis();
|
||||
npcHandler.process();
|
||||
long durationNpcHandler = System.currentTimeMillis() - startNpcHandler;
|
||||
checkAndLogDuration("NpcHandler", durationNpcHandler);
|
||||
long startShopHandler = System.currentTimeMillis();
|
||||
shopHandler.process();
|
||||
long durationShopHandler = System.currentTimeMillis() - startShopHandler;
|
||||
checkAndLogDuration("ShopHandler", durationShopHandler);
|
||||
long startObjectManager = System.currentTimeMillis();
|
||||
objectManager.process();
|
||||
long durationObjectManager = System.currentTimeMillis() - startObjectManager;
|
||||
checkAndLogDuration("ObjectManager", durationObjectManager);
|
||||
long startCastleWars = System.currentTimeMillis();
|
||||
CastleWars.process();
|
||||
long durationCastleWars = System.currentTimeMillis() - startCastleWars;
|
||||
checkAndLogDuration("CastleWars", durationCastleWars);
|
||||
long startFightPits = System.currentTimeMillis();
|
||||
FightPits.process();
|
||||
long durationFightPits = System.currentTimeMillis() - startFightPits;
|
||||
checkAndLogDuration("FightPits", durationFightPits);
|
||||
long startPestControl = System.currentTimeMillis();
|
||||
pestControl.process();
|
||||
long durationPestControl = System.currentTimeMillis() - startPestControl;
|
||||
checkAndLogDuration("PestControl", durationPestControl);
|
||||
long startObjectHandler = System.currentTimeMillis();
|
||||
objectHandler.process();
|
||||
long durationObjectHandler = System.currentTimeMillis() - startObjectHandler;
|
||||
checkAndLogDuration("CastleWars", durationObjectHandler);
|
||||
long startMageTrainingArena = System.currentTimeMillis();
|
||||
MageTrainingArena.process();
|
||||
long durationMageTrainingArena = System.currentTimeMillis() - startMageTrainingArena;
|
||||
checkAndLogDuration("MageTrainingArena", durationMageTrainingArena);
|
||||
long startCycleEventHandler = System.currentTimeMillis();
|
||||
CycleEventHandler.getSingleton().process();
|
||||
long durationCycleEventHandler = System.currentTimeMillis() - startCycleEventHandler;
|
||||
checkAndLogDuration("CycleEventHandler", durationCycleEventHandler);
|
||||
long startIntegrationEvents = System.currentTimeMillis();
|
||||
if (Constants.WEBSITE_INTEGRATION) {
|
||||
PlayersOnlineWebsite.addUpdatePlayersOnlineTask();
|
||||
RegisteredAccsWebsite.addUpdateRegisteredUsersTask();
|
||||
@@ -264,6 +310,9 @@ public class GameEngine {
|
||||
if (DiscordActivity.playerCount) {
|
||||
DiscordActivity.updateActivity();
|
||||
}
|
||||
long durationIntegrationEvents = System.currentTimeMillis() - startIntegrationEvents;
|
||||
checkAndLogDuration("IntegrationEvents", durationIntegrationEvents);
|
||||
long startSaveEvents = System.currentTimeMillis();
|
||||
if (System.currentTimeMillis() - lastMassSave > 300000) {
|
||||
for (Player p : PlayerHandler.players) {
|
||||
if (p == null) {
|
||||
@@ -274,9 +323,42 @@ public class GameEngine {
|
||||
lastMassSave = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
long durationSaveEvents = System.currentTimeMillis() - startSaveEvents;
|
||||
checkAndLogDuration("SaveEvents", durationSaveEvents);
|
||||
long totalCycleDuration = stopwatch.elapsed(TimeUnit.MILLISECONDS);
|
||||
//Technically, we could add commands to test both client lag (creating many tile objects) and server lag (creating a BCrypt hash on game thread)
|
||||
if (totalCycleDuration > 500) {
|
||||
System.err.println("ERROR: Cycle duration exceeded 500 ms!");
|
||||
} else if (totalCycleDuration > 250) {
|
||||
System.err.println("WARNING: Cycle duration exceeded 250 ms!");
|
||||
} else if (totalCycleDuration > 100) {
|
||||
System.out.println("NOTICE: Cycle duration exceeded 100 ms.");
|
||||
}
|
||||
gameTicksIncrementor++;
|
||||
if (Constants.CYCLE_LOGGING && gameTicksIncrementor > 1 && gameTicksIncrementor % printInfoTick == 0) {
|
||||
long totalMem = Runtime.getRuntime().totalMemory();
|
||||
long freeMem = Runtime.getRuntime().freeMemory();
|
||||
long maxMem = Runtime.getRuntime().maxMemory();
|
||||
int playerCount = 0;
|
||||
for (Player p : PlayerHandler.players) {
|
||||
if (p != null) {
|
||||
playerCount++;
|
||||
}
|
||||
}
|
||||
int npcCount = 0;
|
||||
for (Npc npc : NpcHandler.npcs) {
|
||||
if (npc != null) {
|
||||
npcCount++;
|
||||
}
|
||||
}
|
||||
System.out.println("Cycle #" + gameTicksIncrementor + " took " + totalCycleDuration + " ms. Players: " + playerCount + ", NPCs: " + npcCount +
|
||||
", [Durations: i: " + durationItemHandler + " ms, p: " + durationPlayerHandler + " ms, n: " + durationNpcHandler + " ms, s: " + durationShopHandler +
|
||||
" ms, oh: " + durationObjectHandler + " ms, om: " + durationObjectManager + " ms], Memory: " + (totalMem - freeMem) / 1024 / 1024 + "MB/" +
|
||||
totalMem / 1024 / 1024 + "MB. Max: " + maxMem / 1024 / 1024 + "MB, Threads: " + Thread.activeCount() + ".");
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
System.out.println("A fatal exception has been thrown!");
|
||||
System.err.println("A fatal exception has been thrown in the GameEngine cycle! Saving all players.");
|
||||
for (Player p : PlayerHandler.players) {
|
||||
if (p == null) {
|
||||
continue;
|
||||
@@ -292,7 +374,6 @@ public class GameEngine {
|
||||
}
|
||||
scheduler.shutdown(); // Kills the tickloop thread if Exception is thrown.
|
||||
}
|
||||
//TODO debug System.out.println("Cycle took " + stopwatch.elapsed(TimeUnit.MILLISECONDS) + " ms.");
|
||||
}
|
||||
}, 0, Constants.CYCLE_TIME, TimeUnit.MILLISECONDS);
|
||||
|
||||
@@ -313,7 +394,21 @@ public class GameEngine {
|
||||
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
private static void checkAndLogDuration(String processName, long duration) {
|
||||
if (duration > 500) {
|
||||
System.err.println("ERROR: " + processName + " duration exceeded 500 ms! Duration: " + duration + " ms.");
|
||||
} else if (duration > 250) {
|
||||
System.err.println("WARNING: " + processName + " duration exceeded 250 ms! Duration: " + duration + " ms.");
|
||||
} else if (duration > 100) {
|
||||
System.out.println("NOTICE: " + processName + " duration exceeded 100 ms. Duration: " + duration + " ms.");
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean playerExecuted = false;
|
||||
private static BufferedReader minuteFile;
|
||||
|
||||
public static long getServerStartTime() {
|
||||
return serverStartTime;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.rs2.game.content.combat;
|
||||
|
||||
public enum AttackType {
|
||||
MELEE(0),
|
||||
RANGE(1),
|
||||
MAGIC(2),
|
||||
FIRE_BREATH(3);
|
||||
|
||||
private final int value;
|
||||
|
||||
AttackType(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,8 @@ import com.rs2.util.Misc;
|
||||
import com.rs2.world.Boundary;
|
||||
import com.rs2.world.clip.PathFinder;
|
||||
|
||||
import static com.rs2.game.content.StaticNpcList.*;
|
||||
|
||||
/**
|
||||
* @author whoever contributed
|
||||
* @author Andrew (Mr Extremez)
|
||||
@@ -89,7 +91,7 @@ public class CombatAssistant {
|
||||
NpcHandler.npcs[i].gfx0(758);
|
||||
}
|
||||
if (Misc.random(NpcHandler.npcs[i].defence) > Misc.random(10 + calculateRangeAttack()) && !ignoreDef
|
||||
|| (NpcHandler.npcs[i].npcType == 2881 || NpcHandler.npcs[i].npcType == 2883 && !ignoreDef)) {
|
||||
|| (NpcHandler.npcs[i].npcType == DAGANNOTH_SUPREME || NpcHandler.npcs[i].npcType == DAGANNOTH_REX && !ignoreDef)) {
|
||||
damage = 0;
|
||||
}
|
||||
if (Misc.random(4) == 1 && player.lastArrowUsed == 9242 && damage > 0) {
|
||||
@@ -182,7 +184,7 @@ public class CombatAssistant {
|
||||
if (Misc.random(NpcHandler.npcs[i].defence) > 10 + Misc.random(mageAtk()) + bonusAttack) {
|
||||
damage = 0;
|
||||
magicFailed = true;
|
||||
} else if (NpcHandler.npcs[i].npcType == 2881 || NpcHandler.npcs[i].npcType == 2882) {
|
||||
} else if (NpcHandler.npcs[i].npcType == DAGANNOTH_SUPREME || NpcHandler.npcs[i].npcType == DAGANNOTH_PRIME) {
|
||||
damage = 0;
|
||||
magicFailed = true;
|
||||
}
|
||||
@@ -278,7 +280,7 @@ public class CombatAssistant {
|
||||
if (!fullVeracsEffect) {
|
||||
if (Misc.random(NpcHandler.npcs[i].defence) > 10 + Misc.random(calcAtt())) {
|
||||
damage = 0;
|
||||
} else if (NpcHandler.npcs[i].npcType == 2882 || NpcHandler.npcs[i].npcType == 2883) {
|
||||
} else if (NpcHandler.npcs[i].npcType == DAGANNOTH_PRIME || NpcHandler.npcs[i].npcType == DAGANNOTH_REX) {
|
||||
damage = 0;
|
||||
}
|
||||
}
|
||||
@@ -296,7 +298,7 @@ public class CombatAssistant {
|
||||
guthansEffect = true;
|
||||
}
|
||||
}
|
||||
if (player.fightMode == 3 && NpcHandler.npcs[i].npcType != 2459 && NpcHandler.npcs[i].npcType != 2460 && NpcHandler.npcs[i].npcType != 2461 && NpcHandler.npcs[i].npcType != 2462) {
|
||||
if (player.fightMode == 3 && NpcHandler.npcs[i].npcType != PHEASANT && NpcHandler.npcs[i].npcType != PHEASANT_2460 && NpcHandler.npcs[i].npcType != PHEASANT_2461 && NpcHandler.npcs[i].npcType != PHEASANT_2462) {
|
||||
player.getPlayerAssistant().addSkillXP(damage * CombatConstants.MELEE_EXP_RATE / 3, 0);
|
||||
player.getPlayerAssistant().addSkillXP(damage * CombatConstants.MELEE_EXP_RATE / 3, 1);
|
||||
player.getPlayerAssistant().addSkillXP(damage * CombatConstants.MELEE_EXP_RATE / 3, 2);
|
||||
@@ -306,7 +308,7 @@ public class CombatAssistant {
|
||||
player.getPlayerAssistant().refreshSkill(Constants.STRENGTH);
|
||||
player.getPlayerAssistant().refreshSkill(Constants.HITPOINTS);
|
||||
} else {
|
||||
if (NpcHandler.npcs[i].npcType != 2459 && NpcHandler.npcs[i].npcType != 2460 && NpcHandler.npcs[i].npcType != 2461 && NpcHandler.npcs[i].npcType != 2462) {
|
||||
if (NpcHandler.npcs[i].npcType != PHEASANT && NpcHandler.npcs[i].npcType != PHEASANT_2460 && NpcHandler.npcs[i].npcType != PHEASANT_2461 && NpcHandler.npcs[i].npcType != PHEASANT_2462) {
|
||||
player.getPlayerAssistant().addSkillXP(damage * CombatConstants.MELEE_EXP_RATE, player.fightMode);
|
||||
player.getPlayerAssistant().addSkillXP(damage * CombatConstants.MELEE_EXP_RATE / 3, 3);
|
||||
player.getPlayerAssistant().refreshSkill(player.fightMode);
|
||||
@@ -385,7 +387,7 @@ public class CombatAssistant {
|
||||
if (i > 0 && NpcHandler.npcs[i] != null) {
|
||||
if (NpcHandler.npcs[i].isDead) {
|
||||
player.npcIndex = 0;
|
||||
player.followId2 = 0;
|
||||
player.followNpcId = 0;
|
||||
player.faceNpc(0);
|
||||
return;
|
||||
}
|
||||
@@ -410,6 +412,9 @@ public class CombatAssistant {
|
||||
|| !player.goodDistance(player.getX(), player.getY(), NpcHandler.npcs[i].getX(), NpcHandler.npcs[i].getY(), 7) && (player.usingBow || player.usingMagic)) {
|
||||
return;
|
||||
} else {
|
||||
if (player.usingMagic || player.usingBow || player.usingRangeWeapon) {
|
||||
player.followNpcId = 0;
|
||||
}
|
||||
player.stopMovement();
|
||||
}
|
||||
}
|
||||
@@ -420,7 +425,7 @@ public class CombatAssistant {
|
||||
if (i > 0 && PlayerHandler.players[i] != null) {
|
||||
if (PlayerHandler.players[i].isDead) {
|
||||
player.playerIndex = 0;
|
||||
player.followId = 0;
|
||||
player.followPlayerId = 0;
|
||||
player.faceNpc(0);
|
||||
return;
|
||||
}
|
||||
@@ -443,6 +448,9 @@ public class CombatAssistant {
|
||||
|| !player.goodDistance(player.getX(), player.getY(), PlayerHandler.players[i].getX(), PlayerHandler.players[i].getY(), 10) && (player.usingBow || player.usingMagic)) {
|
||||
return;
|
||||
} else {
|
||||
if (player.usingMagic || player.usingBow || player.usingRangeWeapon) {
|
||||
player.followPlayerId = 0;
|
||||
}
|
||||
player.stopMovement();
|
||||
}
|
||||
}
|
||||
@@ -473,7 +481,7 @@ public class CombatAssistant {
|
||||
if (!SlayerRequirements.itemNeededSlayer(player, i) || !player.getSlayer().canAttackNpc(i)) {
|
||||
return;
|
||||
}
|
||||
if (NpcHandler.npcs[i].npcType == 757 && player.vampSlayer > 2) {
|
||||
if (NpcHandler.npcs[i].npcType == COUNT_DRAYNOR && player.vampSlayer > 2) {
|
||||
if (!player.getItemAssistant().playerHasItem(1549, 1) || !player.getItemAssistant().playerHasItem(2347, 1)) {
|
||||
player.getPacketSender().sendMessage("You need a stake and hammer to attack count draynor.");
|
||||
resetPlayerAttack();
|
||||
@@ -485,12 +493,12 @@ public class CombatAssistant {
|
||||
resetPlayerAttack();
|
||||
return;
|
||||
}
|
||||
if (NpcHandler.npcs[i].npcType == 1676) {
|
||||
if (NpcHandler.npcs[i].npcType == EXPERIMENT) {
|
||||
player.getPacketSender().sendMessage("You don't have the heart to kill the poor creature again.");
|
||||
resetPlayerAttack();
|
||||
return;
|
||||
}
|
||||
if (NpcHandler.npcs[i].npcType == 411) {
|
||||
if (NpcHandler.npcs[i].npcType == SWARM) {
|
||||
player.getPacketSender().sendMessage("You can't attack a swarm!");
|
||||
resetPlayerAttack();
|
||||
return;
|
||||
@@ -511,8 +519,8 @@ public class CombatAssistant {
|
||||
return;
|
||||
}
|
||||
|
||||
player.followId2 = i;
|
||||
player.followId = 0;
|
||||
player.followNpcId = i;
|
||||
player.followPlayerId = 0;
|
||||
if (player.attackTimer <= 0) {
|
||||
player.usingBow = false;
|
||||
player.usingRangeWeapon = false;
|
||||
@@ -566,6 +574,9 @@ public class CombatAssistant {
|
||||
|| !player.goodDistance(player.getX(), player.getY(), NpcHandler.npcs[i].getX(), NpcHandler.npcs[i].getY(), 8) && (player.usingBow || player.usingMagic)) {
|
||||
return;
|
||||
} else {
|
||||
if (player.usingMagic || player.usingBow || player.usingRangeWeapon) {
|
||||
player.followNpcId = 0;
|
||||
}
|
||||
player.stopMovement();
|
||||
}
|
||||
|
||||
@@ -794,7 +805,7 @@ public class CombatAssistant {
|
||||
resetPlayerAttack();
|
||||
return;
|
||||
}
|
||||
player.followId = i;
|
||||
player.followPlayerId = i;
|
||||
player.attackTimer = 0;
|
||||
return;
|
||||
}
|
||||
@@ -865,6 +876,10 @@ public class CombatAssistant {
|
||||
resetPlayerAttack();
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
if (player.usingMagic || player.usingBow || player.usingRangeWeapon) {
|
||||
player.followPlayerId = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!usingCross
|
||||
@@ -937,7 +952,7 @@ public class CombatAssistant {
|
||||
if (checkSpecAmount(equippedWeapon)) {
|
||||
player.lastArrowUsed = player.playerEquipment[player.playerArrows];
|
||||
player.getSpecials().activateSpecial(player.playerEquipment[player.playerWeapon], o, i);
|
||||
player.followId = player.playerIndex;
|
||||
player.followPlayerId = player.playerIndex;
|
||||
return;
|
||||
} else {
|
||||
player.getPacketSender().sendMessage("You don't have the required special energy to use this attack.");
|
||||
@@ -972,7 +987,7 @@ public class CombatAssistant {
|
||||
player.lastArrowUsed = 0;
|
||||
player.rangeItemUsed = 0;
|
||||
if (!player.usingBow && !player.usingMagic && !player.usingRangeWeapon) { // melee hit delay
|
||||
player.followId = PlayerHandler.players[player.playerIndex].playerId;
|
||||
player.followPlayerId = PlayerHandler.players[player.playerIndex].playerId;
|
||||
player.hitDelay = getHitDelay();
|
||||
player.delayedDamage = Misc.random(meleeMaxHit());
|
||||
player.projectileStage = 0;
|
||||
@@ -993,7 +1008,7 @@ public class CombatAssistant {
|
||||
player.usingBow = true;
|
||||
}
|
||||
player.usingBow = true;
|
||||
player.followId = PlayerHandler.players[player.playerIndex].playerId;
|
||||
player.followPlayerId = PlayerHandler.players[player.playerIndex].playerId;
|
||||
player.lastWeaponUsed = player.playerEquipment[player.playerWeapon];
|
||||
player.lastArrowUsed = player.playerEquipment[player.playerArrows];
|
||||
player.gfx100(RangeData.getRangeStartGFX(player));
|
||||
@@ -1006,7 +1021,7 @@ public class CombatAssistant {
|
||||
player.rangeItemUsed = player.playerEquipment[player.playerWeapon];
|
||||
player.getItemAssistant().deleteEquipment();
|
||||
player.usingRangeWeapon = true;
|
||||
player.followId = PlayerHandler.players[player.playerIndex].playerId;
|
||||
player.followPlayerId = PlayerHandler.players[player.playerIndex].playerId;
|
||||
player.gfx100(RangeData.getRangeStartGFX(player));
|
||||
if (player.fightMode == 2) {
|
||||
player.attackTimer--;
|
||||
@@ -1040,7 +1055,8 @@ public class CombatAssistant {
|
||||
MagicSpells.getStartDelay(player));
|
||||
}
|
||||
if (player.autocastId > 0) {
|
||||
player.followId = player.playerIndex;
|
||||
//We don't need to set the followId if they are already autocasting, setting followId here makes a manual cast (when autocast is set) run up to the player.
|
||||
//player.followId = player.playerIndex;
|
||||
player.followDistance = 5;
|
||||
}
|
||||
player.hitDelay = getHitDelay();
|
||||
@@ -1680,7 +1696,7 @@ public class CombatAssistant {
|
||||
}
|
||||
|
||||
public int getRequiredDistance() {
|
||||
if (player.followId > 0 && player.freezeTimer <= 0) {
|
||||
if (player.followPlayerId > 0 && player.freezeTimer <= 0) {
|
||||
return player.isMoving ? 3 : 2;
|
||||
}
|
||||
return 1;
|
||||
@@ -1729,14 +1745,14 @@ public class CombatAssistant {
|
||||
|
||||
public int getBonusAttack(int i) {
|
||||
switch (NpcHandler.npcs[i].npcType) {
|
||||
case 2883:
|
||||
return Misc.random(50) + 30;
|
||||
case 2026:
|
||||
case 2027:
|
||||
case 2029:
|
||||
case 2030:
|
||||
return Misc.random(50) + 30;
|
||||
}
|
||||
case DAGANNOTH_REX:
|
||||
return Misc.random(50) + 30;
|
||||
case DHAROK_THE_WRETCHED:
|
||||
case GUTHAN_THE_INFESTED:
|
||||
case TORAG_THE_CORRUPTED:
|
||||
case VERAC_THE_DEFILED:
|
||||
return Misc.random(50) + 30;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.rs2.game.content.combat.npcs;
|
||||
|
||||
import com.rs2.Constants;
|
||||
import com.rs2.game.content.combat.AttackType;
|
||||
import com.rs2.game.content.combat.CombatConstants;
|
||||
import com.rs2.game.content.combat.melee.MeleeData;
|
||||
import com.rs2.game.content.minigames.FightCaves;
|
||||
@@ -8,6 +9,7 @@ import com.rs2.game.content.minigames.PestControl;
|
||||
import com.rs2.game.content.music.sound.CombatSounds;
|
||||
import com.rs2.game.content.music.sound.SoundList;
|
||||
import com.rs2.game.items.impl.Greegree.MonkeyData;
|
||||
import com.rs2.game.npcs.NPCDefinition;
|
||||
import com.rs2.game.npcs.NpcData;
|
||||
import com.rs2.game.npcs.NpcHandler;
|
||||
import com.rs2.game.players.Client;
|
||||
@@ -16,6 +18,8 @@ import com.rs2.game.players.PlayerHandler;
|
||||
import com.rs2.util.Misc;
|
||||
import com.rs2.world.Boundary;
|
||||
|
||||
import static com.rs2.game.content.StaticNpcList.*;
|
||||
|
||||
public class NpcCombat {
|
||||
|
||||
public static void multiAttackDamage(int i) {
|
||||
@@ -28,7 +32,7 @@ public class NpcCombat {
|
||||
}
|
||||
if (player.goodDistance(c.absX, c.absY,
|
||||
NpcHandler.npcs[i].absX, NpcHandler.npcs[i].absY, 15)) {
|
||||
if (NpcHandler.npcs[i].attackType == 2) {
|
||||
if (NpcHandler.npcs[i].attackType == AttackType.MAGIC.getValue()) {
|
||||
if (!c.getPrayer().prayerActive[16]) {
|
||||
if (Misc.random(500) + 200 > Misc.random(c.getCombatAssistant().mageDef())) {
|
||||
int dam = Misc.random(max);
|
||||
@@ -42,7 +46,7 @@ public class NpcCombat {
|
||||
c.dealDamage(0);
|
||||
c.handleHitMask(0);
|
||||
}
|
||||
} else if (NpcHandler.npcs[i].attackType == 1) {
|
||||
} else if (NpcHandler.npcs[i].attackType == AttackType.RANGE.getValue()) {
|
||||
if (!c.getPrayer().prayerActive[17]) {
|
||||
int dam = Misc.random(max);
|
||||
if (Misc.random(500) + 200 > Misc.random(c
|
||||
@@ -106,28 +110,28 @@ public class NpcCombat {
|
||||
|| NpcHandler.npcs[i].isDead) {
|
||||
return;
|
||||
}
|
||||
if (NpcHandler.npcs[i].npcType == 1532
|
||||
|| NpcHandler.npcs[i].npcType == 1534
|
||||
|| NpcHandler.npcs[i].npcType == 6145
|
||||
if (NpcHandler.npcs[i].npcType == BARRICADE
|
||||
|| NpcHandler.npcs[i].npcType == BARRICADE_1534
|
||||
|| NpcHandler.npcs[i].npcType == 6145 //Unknown NPCs in 6000 range
|
||||
|| NpcHandler.npcs[i].npcType == 6144
|
||||
|| NpcHandler.npcs[i].npcType == 6143
|
||||
|| NpcHandler.npcs[i].npcType == 6142
|
||||
|| NpcHandler.npcs[i].npcType == 752) {
|
||||
|| NpcHandler.npcs[i].npcType == LESSER_DEMON_752) {
|
||||
return;
|
||||
}
|
||||
if (Boundary.isIn(c, Boundary.APE_ATOLL) && MonkeyData.isWearingGreegree(c)) {
|
||||
return;
|
||||
}
|
||||
if (NpcHandler.npcs[i].npcType == 1401 && Boundary.isIn(c, Boundary.TUTORIAL) || c.tutorialProgress < 36) {
|
||||
if (NpcHandler.npcs[i].npcType == CHICKEN_1401 && Boundary.isIn(c, Boundary.TUTORIAL) || c.tutorialProgress < 36) {
|
||||
return;
|
||||
}
|
||||
if (NpcHandler.npcs[i].npcType == 9 && c.absX == 3180 && c.absY > 3433 && c.absY < 3447) {
|
||||
if (NpcHandler.npcs[i].npcType == GUARD && c.absX == 3180 && c.absY > 3433 && c.absY < 3447) {
|
||||
return;
|
||||
}
|
||||
if (NpcHandler.npcs[i].npcType == 374 && c.absY == 3372 && c.absX > 2522 && c.absX < 2532) {
|
||||
if (NpcHandler.npcs[i].npcType == OGRE_374 && c.absY == 3372 && c.absX > 2522 && c.absX < 2532) {
|
||||
return;
|
||||
}
|
||||
if (NpcHandler.npcs[i].npcType > 2462 && NpcHandler.npcs[i].npcType < 2468) {
|
||||
if (NpcHandler.npcs[i].npcType > PHEASANT_2462 && NpcHandler.npcs[i].npcType < FROG_2469) {
|
||||
if (Misc.random(5) == 0) {
|
||||
NpcHandler.npcs[i].forceChat("Flee from me, " + c.playerName + "!");
|
||||
} else if (Misc.random(5) == 1) {
|
||||
@@ -164,7 +168,7 @@ public class NpcCombat {
|
||||
NpcHandler.npcs[i].facePlayer(c);
|
||||
NpcHandler.npcs[i].attackTimer = NpcData.getNpcDelay(i);
|
||||
NpcHandler.npcs[i].hitDelayTimer = NpcData.getHitDelay(i);
|
||||
NpcHandler.npcs[i].attackType = 0;
|
||||
NpcHandler.npcs[i].attackType = AttackType.MELEE.getValue();
|
||||
if (CombatConstants.COMBAT_SOUNDS) {
|
||||
if (PestControl.npcIsPCMonster(NpcHandler.npcs[i].npcType) || PestControl.isPCPortal(NpcHandler.npcs[i].npcType)) {
|
||||
return;
|
||||
@@ -176,7 +180,7 @@ public class NpcCombat {
|
||||
} else {
|
||||
loadSpell(c, i);
|
||||
}
|
||||
if (NpcHandler.npcs[i].attackType == 3) {
|
||||
if (NpcHandler.npcs[i].attackType == AttackType.FIRE_BREATH.getValue()) {
|
||||
NpcHandler.npcs[i].hitDelayTimer += 2;
|
||||
}
|
||||
if (NpcHandler.multiAttacks(i)) {
|
||||
@@ -201,7 +205,7 @@ public class NpcCombat {
|
||||
c.getPlayerAssistant().createPlayersProjectile(nX, nY, offX, offY, 50, NpcHandler.getProjectileSpeed(i), NpcHandler.npcs[i].projectileId, 43, 31, -c.getId() - 1, 65);
|
||||
}
|
||||
int random = Misc.random(10);
|
||||
if (NpcHandler.npcs[i].npcType == 222 && (NpcHandler.npcs[i].killerId > 0 && NpcHandler.npcs[i].underAttack) && !NpcHandler.npcs[i].isDead && (NpcHandler.npcs[i].HP < NpcHandler.npcs[i].MaxHP + 1)) {
|
||||
if (NpcHandler.npcs[i].npcType == MONK && (NpcHandler.npcs[i].killerId > 0 && NpcHandler.npcs[i].underAttack) && !NpcHandler.npcs[i].isDead && (NpcHandler.npcs[i].HP < NpcHandler.npcs[i].MaxHP + 1)) {
|
||||
if (random < 3) {
|
||||
NpcHandler.npcs[i].HP += 2;
|
||||
//NpcHandler.npcs[i].startAnimation(84);
|
||||
@@ -225,7 +229,7 @@ public class NpcCombat {
|
||||
}
|
||||
|
||||
public static void loadSpell2(int i) {
|
||||
NpcHandler.npcs[i].attackType = 3;
|
||||
NpcHandler.npcs[i].attackType = AttackType.FIRE_BREATH.getValue();
|
||||
int random = Misc.random(3);
|
||||
if (random == 0) {
|
||||
NpcHandler.npcs[i].projectileId = 393; // red
|
||||
@@ -243,93 +247,90 @@ public class NpcCombat {
|
||||
}
|
||||
|
||||
public static void loadSpell(Player c, int i) {
|
||||
if (NpcHandler.npcs[i].npcType > 2462 && NpcHandler.npcs[i].npcType < 2469 || NpcHandler.npcs[i].npcType > 3751 && NpcHandler.npcs[i].npcType < 3762) {
|
||||
NpcHandler.npcs[i].attackType = 2;
|
||||
if (NpcHandler.npcs[i].npcType > PHEASANT_2462 && NpcHandler.npcs[i].npcType < FROG_2469 || NpcHandler.npcs[i].npcType > SPINNER_3751 && NpcHandler.npcs[i].npcType < DEFILER) {
|
||||
NpcHandler.npcs[i].attackType = AttackType.MAGIC.getValue();
|
||||
}
|
||||
if (NpcHandler.npcs[i].npcType > 3761 && NpcHandler.npcs[i].npcType < 3772) {
|
||||
NpcHandler.npcs[i].attackType = 1;
|
||||
if (NpcHandler.npcs[i].npcType > TORCHER_3761 && NpcHandler.npcs[i].npcType < BRAWLER) {
|
||||
NpcHandler.npcs[i].attackType = AttackType.RANGE.getValue();
|
||||
}
|
||||
switch (NpcHandler.npcs[i].npcType) {
|
||||
case 1158://kq first form
|
||||
case KALPHITE_QUEEN://kq first form
|
||||
int kqRandom = Misc.random(3);
|
||||
if (kqRandom == 2) {
|
||||
NpcHandler.npcs[i].projectileId = 280; //gfx
|
||||
NpcHandler.npcs[i].attackType = 2;
|
||||
NpcHandler.npcs[i].attackType = AttackType.MAGIC.getValue();
|
||||
NpcHandler.npcs[i].endGfx = 279;
|
||||
} else {
|
||||
NpcHandler.npcs[i].attackType = 0;
|
||||
NpcHandler.npcs[i].attackType = AttackType.MELEE.getValue();
|
||||
}
|
||||
break;
|
||||
case 1160://kq secondform
|
||||
case KALPHITE_QUEEN_1160://kq secondform
|
||||
int kqRandom2 = Misc.random(3);
|
||||
if (kqRandom2 == 2) {
|
||||
NpcHandler.npcs[i].projectileId = 279; //gfx
|
||||
NpcHandler.npcs[i].attackType = 1 + Misc.random(1);
|
||||
NpcHandler.npcs[i].attackType = AttackType.RANGE.getValue() + Misc.random(1);
|
||||
NpcHandler.npcs[i].endGfx = 278;
|
||||
} else {
|
||||
NpcHandler.npcs[i].attackType = 0;
|
||||
NpcHandler.npcs[i].attackType = AttackType.MELEE.getValue();
|
||||
}
|
||||
break;
|
||||
case 2607:
|
||||
NpcHandler.npcs[i].attackType = 1;
|
||||
case 2591:
|
||||
NpcHandler.npcs[i].attackType = 2;
|
||||
case TZHAARXIL_2607:
|
||||
NpcHandler.npcs[i].attackType = AttackType.RANGE.getValue();
|
||||
case TZHAARMEJ:
|
||||
NpcHandler.npcs[i].attackType = AttackType.MAGIC.getValue();
|
||||
break;
|
||||
case 172:
|
||||
case 174:
|
||||
case DARK_WIZARD:
|
||||
case DARK_WIZARD_174:
|
||||
NpcHandler.npcs[i].gfx100(96); // Dark Wizards use earth strike
|
||||
NpcHandler.npcs[i].projectileId = 97;
|
||||
NpcHandler.npcs[i].endGfx = 98;
|
||||
NpcHandler.npcs[i].attackType = 2;
|
||||
NpcHandler.npcs[i].attackType = AttackType.MAGIC.getValue();
|
||||
break;
|
||||
case 3068:
|
||||
if(Misc.random(10) > 7) {
|
||||
NpcHandler.npcs[i].projectileId = 393; //red
|
||||
NpcHandler.npcs[i].endGfx = 430;
|
||||
NpcHandler.npcs[i].attackType = 3;
|
||||
NpcData.startAnimation(2989, i);
|
||||
} else {
|
||||
NpcData.startAnimation(2980, i);
|
||||
NpcHandler.npcs[i].attackType = 0;
|
||||
}
|
||||
break;
|
||||
case 2892:
|
||||
case SKELETAL_WYVERN:
|
||||
if(Misc.random(10) > 7) {
|
||||
NpcHandler.npcs[i].projectileId = 393; //red
|
||||
NpcHandler.npcs[i].endGfx = 430;
|
||||
NpcHandler.npcs[i].attackType = AttackType.FIRE_BREATH.getValue();
|
||||
NpcData.startAnimation(2989, i);
|
||||
} else {
|
||||
NpcData.startAnimation(2980, i);
|
||||
NpcHandler.npcs[i].attackType = AttackType.MELEE.getValue();
|
||||
}
|
||||
break;
|
||||
case SPINOLYP:
|
||||
NpcHandler.npcs[i].projectileId = 94;
|
||||
NpcHandler.npcs[i].attackType = 2;
|
||||
NpcHandler.npcs[i].attackType = AttackType.MAGIC.getValue();
|
||||
NpcHandler.npcs[i].endGfx = 95;
|
||||
break;
|
||||
case 2894:
|
||||
case SPINOLYP_2894:
|
||||
NpcHandler.npcs[i].projectileId = 298;
|
||||
NpcHandler.npcs[i].attackType = 1;
|
||||
NpcHandler.npcs[i].attackType = AttackType.RANGE.getValue();
|
||||
break;
|
||||
/*
|
||||
* Better Dragons
|
||||
*/
|
||||
case 5363: // Mithril-Dragon
|
||||
case 53: // Red Dragon
|
||||
case 54: // Black-Dragon
|
||||
case 55: // Blue-Dragon
|
||||
case 941: // Green-Dragon
|
||||
case 4682:
|
||||
case 5362:
|
||||
case 1590:
|
||||
case 1591:
|
||||
case 1592:
|
||||
case RED_DRAGON: // Red Dragon
|
||||
case BLACK_DRAGON: // Black-Dragon
|
||||
case BLUE_DRAGON: // Blue-Dragon
|
||||
case GREEN_DRAGON: // Green-Dragon
|
||||
case BRONZE_DRAGON:
|
||||
case IRON_DRAGON:
|
||||
case STEEL_DRAGON:
|
||||
int random1 = Misc.random(3);
|
||||
switch (random1) {
|
||||
case 1:
|
||||
NpcHandler.npcs[i].projectileId = 393; // red
|
||||
NpcHandler.npcs[i].endGfx = 430;
|
||||
NpcHandler.npcs[i].attackType = 3;
|
||||
NpcHandler.npcs[i].attackType = AttackType.FIRE_BREATH.getValue();
|
||||
break;
|
||||
default:
|
||||
NpcHandler.npcs[i].projectileId = -1; // melee
|
||||
NpcHandler.npcs[i].endGfx = -1;
|
||||
NpcHandler.npcs[i].attackType = 0;
|
||||
NpcHandler.npcs[i].attackType = AttackType.MELEE.getValue();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 134:
|
||||
case POISON_SPIDER:
|
||||
if (c.playerLevel[Constants.PRAYER] > 0) {
|
||||
c.playerLevel[Constants.PRAYER]--;
|
||||
c.getPlayerAssistant().refreshSkill(Constants.PRAYER);
|
||||
@@ -338,106 +339,40 @@ public class NpcCombat {
|
||||
}
|
||||
break;
|
||||
|
||||
case 3590:
|
||||
case 50:
|
||||
case 742:
|
||||
case STEEL_DRAGON_3590:
|
||||
case KING_BLACK_DRAGON:
|
||||
case ELVARG:
|
||||
int random = Misc.random(4);
|
||||
switch (random) {
|
||||
case 0:
|
||||
NpcHandler.npcs[i].projectileId = 393; // red
|
||||
NpcHandler.npcs[i].endGfx = 430;
|
||||
NpcHandler.npcs[i].attackType = 3;
|
||||
NpcHandler.npcs[i].attackType = AttackType.FIRE_BREATH.getValue();
|
||||
break;
|
||||
case 1:
|
||||
NpcHandler.npcs[i].projectileId = 394; // green
|
||||
NpcHandler.npcs[i].endGfx = 429;
|
||||
NpcHandler.npcs[i].attackType = 3;
|
||||
NpcHandler.npcs[i].attackType = AttackType.FIRE_BREATH.getValue();
|
||||
break;
|
||||
case 2:
|
||||
NpcHandler.npcs[i].projectileId = 395; // white
|
||||
NpcHandler.npcs[i].endGfx = 431;
|
||||
NpcHandler.npcs[i].attackType = 3;
|
||||
NpcHandler.npcs[i].attackType = AttackType.FIRE_BREATH.getValue();
|
||||
break;
|
||||
case 3:
|
||||
NpcHandler.npcs[i].projectileId = 396; // blue
|
||||
NpcHandler.npcs[i].endGfx = 428;
|
||||
NpcHandler.npcs[i].attackType = 3;
|
||||
NpcHandler.npcs[i].attackType = AttackType.FIRE_BREATH.getValue();
|
||||
break;
|
||||
case 4:
|
||||
NpcHandler.npcs[i].projectileId = -1; // melee
|
||||
NpcHandler.npcs[i].endGfx = -1;
|
||||
NpcHandler.npcs[i].attackType = 0;
|
||||
NpcHandler.npcs[i].attackType = AttackType.MELEE.getValue();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
// arma npcs
|
||||
case 2561:
|
||||
NpcHandler.npcs[i].attackType = 0;
|
||||
break;
|
||||
case 2560:
|
||||
NpcHandler.npcs[i].attackType = 1;
|
||||
NpcHandler.npcs[i].projectileId = 1190;
|
||||
break;
|
||||
case 2559:
|
||||
NpcHandler.npcs[i].attackType = 2;
|
||||
NpcHandler.npcs[i].projectileId = 1203;
|
||||
break;
|
||||
case 2558:
|
||||
random = Misc.random(1);
|
||||
NpcHandler.npcs[i].attackType = 1 + random;
|
||||
if (NpcHandler.npcs[i].attackType == 1) {
|
||||
NpcHandler.npcs[i].projectileId = 1197;
|
||||
} else {
|
||||
NpcHandler.npcs[i].attackType = 2;
|
||||
NpcHandler.npcs[i].projectileId = 1198;
|
||||
}
|
||||
break;
|
||||
// sara npcs
|
||||
case 2562: // sara
|
||||
random = Misc.random(1);
|
||||
if (random == 0) {
|
||||
NpcHandler.npcs[i].attackType = 2;
|
||||
NpcHandler.npcs[i].endGfx = 1224;
|
||||
NpcHandler.npcs[i].projectileId = -1;
|
||||
} else if (random == 1) {
|
||||
NpcHandler.npcs[i].attackType = 0;
|
||||
}
|
||||
break;
|
||||
case 2563: // star
|
||||
NpcHandler.npcs[i].attackType = 0;
|
||||
break;
|
||||
case 2564: // growler
|
||||
NpcHandler.npcs[i].attackType = 2;
|
||||
NpcHandler.npcs[i].projectileId = 1203;
|
||||
break;
|
||||
case 2565: // bree
|
||||
NpcHandler.npcs[i].attackType = 1;
|
||||
NpcHandler.npcs[i].projectileId = 9;
|
||||
break;
|
||||
// bandos npcs
|
||||
case 2550:
|
||||
random = Misc.random(2);
|
||||
if (random == 0 || random == 1) {
|
||||
NpcHandler.npcs[i].attackType = 0;
|
||||
} else {
|
||||
NpcHandler.npcs[i].attackType = 1;
|
||||
NpcHandler.npcs[i].endGfx = 1211;
|
||||
NpcHandler.npcs[i].projectileId = 288;
|
||||
}
|
||||
break;
|
||||
case 2551:
|
||||
NpcHandler.npcs[i].attackType = 0;
|
||||
break;
|
||||
case 2552:
|
||||
NpcHandler.npcs[i].attackType = 2;
|
||||
NpcHandler.npcs[i].projectileId = 1203;
|
||||
break;
|
||||
case 2553:
|
||||
NpcHandler.npcs[i].attackType = 1;
|
||||
NpcHandler.npcs[i].projectileId = 1206;
|
||||
break;
|
||||
case 2025:
|
||||
NpcHandler.npcs[i].attackType = 2;
|
||||
case AHRIM_THE_BLIGHTED:
|
||||
NpcHandler.npcs[i].attackType = AttackType.MAGIC.getValue();
|
||||
int r = Misc.random(3);
|
||||
if (r == 0) {
|
||||
NpcHandler.npcs[i].gfx100(158);
|
||||
@@ -459,37 +394,37 @@ public class NpcCombat {
|
||||
NpcHandler.npcs[i].projectileId = 156;
|
||||
}
|
||||
break;
|
||||
case 2881:// supreme
|
||||
NpcHandler.npcs[i].attackType = 1;
|
||||
case DAGANNOTH_SUPREME:// supreme
|
||||
NpcHandler.npcs[i].attackType = AttackType.RANGE.getValue();
|
||||
NpcHandler.npcs[i].projectileId = 298;
|
||||
break;
|
||||
|
||||
case 2882:// prime
|
||||
NpcHandler.npcs[i].attackType = 2;
|
||||
case DAGANNOTH_PRIME:// prime
|
||||
NpcHandler.npcs[i].attackType = AttackType.MAGIC.getValue();
|
||||
NpcHandler.npcs[i].projectileId = 162;
|
||||
NpcHandler.npcs[i].endGfx = 477;
|
||||
break;
|
||||
|
||||
case 2028:
|
||||
NpcHandler.npcs[i].attackType = 1;
|
||||
case KARIL_THE_TAINTED:
|
||||
NpcHandler.npcs[i].attackType = AttackType.RANGE.getValue();
|
||||
NpcHandler.npcs[i].projectileId = 27;
|
||||
break;
|
||||
|
||||
case 3200:
|
||||
case CHAOS_ELEMENTAL:
|
||||
int r2 = Misc.random(1);
|
||||
if (r2 == 0) {
|
||||
NpcHandler.npcs[i].attackType = 1;
|
||||
NpcHandler.npcs[i].attackType = AttackType.RANGE.getValue();
|
||||
NpcHandler.npcs[i].gfx100(550);
|
||||
NpcHandler.npcs[i].projectileId = 551;
|
||||
NpcHandler.npcs[i].endGfx = 552;
|
||||
} else {
|
||||
NpcHandler.npcs[i].attackType = 2;
|
||||
NpcHandler.npcs[i].attackType = AttackType.MAGIC.getValue();
|
||||
NpcHandler.npcs[i].gfx100(553);
|
||||
NpcHandler.npcs[i].projectileId = 554;
|
||||
NpcHandler.npcs[i].endGfx = 555;
|
||||
}
|
||||
break;
|
||||
case 2745:
|
||||
case TZTOKJAD:
|
||||
int r3 = 0;
|
||||
if (NpcHandler
|
||||
.goodDistance(
|
||||
@@ -503,25 +438,25 @@ public class NpcCombat {
|
||||
r3 = Misc.random(1);
|
||||
}
|
||||
if (r3 == 0) {
|
||||
NpcHandler.npcs[i].attackType = 2;
|
||||
NpcHandler.npcs[i].attackType = AttackType.MAGIC.getValue();
|
||||
NpcHandler.npcs[i].endGfx = 157;
|
||||
NpcHandler.npcs[i].projectileId = 448;
|
||||
} else if (r3 == 1) {
|
||||
NpcHandler.npcs[i].attackType = 1;
|
||||
NpcHandler.npcs[i].attackType = AttackType.RANGE.getValue();
|
||||
NpcHandler.npcs[i].projectileId = 451;
|
||||
} else if (r3 == 2) {
|
||||
NpcHandler.npcs[i].attackType = 0;
|
||||
NpcHandler.npcs[i].attackType = AttackType.MELEE.getValue();
|
||||
NpcHandler.npcs[i].projectileId = -1;
|
||||
}
|
||||
break;
|
||||
case 2743:
|
||||
NpcHandler.npcs[i].attackType = 2;
|
||||
case KETZEK:
|
||||
NpcHandler.npcs[i].attackType = AttackType.MAGIC.getValue();
|
||||
NpcHandler.npcs[i].projectileId = 445;
|
||||
NpcHandler.npcs[i].endGfx = 446;
|
||||
break;
|
||||
|
||||
case 2631:
|
||||
NpcHandler.npcs[i].attackType = 1;
|
||||
case TOKXIL:
|
||||
NpcHandler.npcs[i].attackType = AttackType.RANGE.getValue();
|
||||
NpcHandler.npcs[i].projectileId = 443;
|
||||
break;
|
||||
}
|
||||
@@ -550,10 +485,10 @@ public class NpcCombat {
|
||||
}
|
||||
if (c.respawnTimer <= 0) {
|
||||
int damage = 0;
|
||||
if (NpcHandler.npcs[i].attackType == 0) {
|
||||
damage = Misc.random(NpcHandler.npcs[i].maxHit);
|
||||
if (10 + Misc.random(c.getCombatAssistant().calcDef()) > Misc
|
||||
.random(NpcHandler.npcs[i].attack)) {
|
||||
if (NpcHandler.npcs[i].attackType == AttackType.MELEE.getValue()) {
|
||||
damage = Misc.random(NPCDefinition.forId(NpcHandler.npcs[i].npcType).getMaxHit());
|
||||
if (5 + Misc.random(c.getCombatAssistant().calcDef()) > Misc
|
||||
.random(NPCDefinition.forId(NpcHandler.npcs[i].npcType).getAttackBonus())) {
|
||||
damage = 0;
|
||||
}
|
||||
if (NpcData.cantKillYou(NpcHandler.npcs[i].npcType)) {
|
||||
@@ -564,10 +499,10 @@ public class NpcCombat {
|
||||
if (c.getPrayer().prayerActive[18] && !(NpcHandler.npcs[i].npcType == 2030)) { // protect from melee
|
||||
damage = 0;
|
||||
} else if (c.getPrayer().prayerActive[18] && NpcHandler.npcs[i].npcType == 2030) {
|
||||
if (NpcHandler.npcs[i].attackType == 0) {
|
||||
damage = Misc.random(NpcHandler.npcs[i].maxHit);
|
||||
if (NpcHandler.npcs[i].attackType == AttackType.MELEE.getValue()) {
|
||||
damage = Misc.random(NPCDefinition.forId(NpcHandler.npcs[i].npcType).getMaxHit());
|
||||
}
|
||||
if (10 + Misc.random(MeleeData.calculateMeleeDefence(c)) > Misc.random(NpcHandler.npcs[i].attack)) {
|
||||
if (5 + Misc.random(MeleeData.calculateMeleeDefence(c)) > Misc.random(NPCDefinition.forId(NpcHandler.npcs[i].npcType).getAttackBonus())) {
|
||||
if (NpcHandler.npcs[i].npcType == 1158 || NpcHandler.npcs[i].npcType == 1160)
|
||||
damage = (damage / 2);
|
||||
else
|
||||
@@ -579,9 +514,9 @@ public class NpcCombat {
|
||||
}
|
||||
}
|
||||
|
||||
if (NpcHandler.npcs[i].attackType == 1) { // range
|
||||
damage = Misc.random(NpcHandler.npcs[i].maxHit);
|
||||
if (10 + Misc.random(c.getCombatAssistant().calculateRangeDefence()) > Misc.random(NpcHandler.npcs[i].attack)) {
|
||||
if (NpcHandler.npcs[i].attackType == AttackType.RANGE.getValue()) { // range
|
||||
damage = Misc.random(NPCDefinition.forId(NpcHandler.npcs[i].npcType).getMaxHit());
|
||||
if (5 + Misc.random(c.getCombatAssistant().calculateRangeDefence()) > Misc.random(NPCDefinition.forId(NpcHandler.npcs[i].npcType).getAttackBonus())) {
|
||||
if (NpcHandler.npcs[i].npcType == 1158 || NpcHandler.npcs[i].npcType == 1160)
|
||||
damage = (damage / 2);
|
||||
else
|
||||
@@ -600,10 +535,10 @@ public class NpcCombat {
|
||||
}
|
||||
}
|
||||
|
||||
if (NpcHandler.npcs[i].attackType == 2) { // magic
|
||||
damage = Misc.random(NpcHandler.npcs[i].maxHit);
|
||||
if (NpcHandler.npcs[i].attackType == AttackType.MAGIC.getValue()) { // magic
|
||||
damage = Misc.random(NPCDefinition.forId(NpcHandler.npcs[i].npcType).getMaxHit());
|
||||
boolean magicFailed = false;
|
||||
if (10 + Misc.random(c.getCombatAssistant().mageDef()) > Misc.random(NpcHandler.npcs[i].attack)) {
|
||||
if (5 + Misc.random(c.getCombatAssistant().mageDef()) > Misc.random(NPCDefinition.forId(NpcHandler.npcs[i].npcType).getAttackBonus())) {
|
||||
damage = 0;
|
||||
magicFailed = true;
|
||||
}
|
||||
@@ -632,7 +567,7 @@ public class NpcCombat {
|
||||
}
|
||||
}
|
||||
|
||||
if (NpcHandler.npcs[i].attackType == 3) { // fire breath
|
||||
if (NpcHandler.npcs[i].attackType == AttackType.FIRE_BREATH.getValue()) { // fire breath
|
||||
int anti = c.getPlayerAssistant().antiFire();
|
||||
switch (anti) {
|
||||
case 0:// has no shield
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.rs2.game.content.combat.npcs;
|
||||
|
||||
import com.rs2.GameEngine;
|
||||
import com.rs2.game.content.StaticNpcList;
|
||||
import com.rs2.game.content.combat.AttackType;
|
||||
import com.rs2.game.npcs.NpcHandler;
|
||||
import com.rs2.game.players.Player;
|
||||
|
||||
@@ -21,9 +23,9 @@ public enum NpcEmotes {
|
||||
HOB_GOBLIN(new int[] {122, 123}, 164, 165, 167),
|
||||
AHRIM(new int[] {2025}, 729, 404, 2304),
|
||||
DHAROK(new int[] {2026}, 2067, 404, 2304),
|
||||
GUTHAN(new int[] {2027}, 422, 404, 2304),
|
||||
GUTHAN(new int[] {2027}, 2080, 404, 2304),
|
||||
KARIL(new int[] {2028}, 2075, 404, 2304),
|
||||
TORAG(new int[] {2029}, 0x814, 404, 2304),
|
||||
TORAG(new int[] {2029}, 2068, 404, 2304),
|
||||
VERAC(new int[] {2030}, 2062, 404, 2304),
|
||||
BABY_DRAGON(new int[] {51, 52, 1589, 3376}, 25, 26, 28),
|
||||
CHICKEN(new int[] {41}, 55, 56, 57),
|
||||
@@ -39,7 +41,7 @@ public enum NpcEmotes {
|
||||
COW(new int[] {81, 397, 1766, 1767, 1768}, 59, 60, 62),
|
||||
BLOODVELD(new int[] {1618, 1619}, 1552, 1550, 1553),
|
||||
IMP(new int[] {708}, 169, 170, 172),
|
||||
DARK_WIZARD(new int[] {172, 13}, 711, 1834, 836),
|
||||
DARK_WIZARD(new int[] {172, 13, 174}, 711, 1834, 836),
|
||||
DUCK(new int[] {44, 45}, 7, 8, 9),
|
||||
SPINOLYP(new int[] {2892, 2894}, 2868, 2864, 2865),
|
||||
DWARF(new int[] {118, 119}, 99, 100, 102),
|
||||
@@ -137,11 +139,11 @@ public enum NpcEmotes {
|
||||
} else {
|
||||
switch (NpcHandler.npcs[i].npcType) {
|
||||
case 2745:
|
||||
if (NpcHandler.npcs[i].attackType == 2) {
|
||||
if (NpcHandler.npcs[i].attackType == AttackType.MAGIC.getValue()) {
|
||||
return 2656;
|
||||
} else if (NpcHandler.npcs[i].attackType == 1) {
|
||||
} else if (NpcHandler.npcs[i].attackType == AttackType.RANGE.getValue()) {
|
||||
return 2652;
|
||||
} else if (NpcHandler.npcs[i].attackType == 0) {
|
||||
} else if (NpcHandler.npcs[i].attackType == AttackType.MELEE.getValue()) {
|
||||
return 2655;
|
||||
}
|
||||
|
||||
@@ -159,8 +161,8 @@ public enum NpcEmotes {
|
||||
return e.getBlock();
|
||||
} else {
|
||||
switch (NpcHandler.npcs[i].npcType) {
|
||||
case 2745:
|
||||
return 2653;
|
||||
case StaticNpcList.TZTOKJAD:
|
||||
return 2653;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -175,14 +177,14 @@ public enum NpcEmotes {
|
||||
return e.getDead();
|
||||
} else {
|
||||
switch (NpcHandler.npcs[i].npcType) {
|
||||
case 2745:
|
||||
return 2654;
|
||||
case 1158:
|
||||
GameEngine.npcHandler.spawnSecondForm(player, i);
|
||||
return 6242;
|
||||
case 1160:
|
||||
GameEngine.npcHandler.spawnFirstForm(player, i);
|
||||
return 6233;
|
||||
case StaticNpcList.TZTOKJAD:
|
||||
return 2654;
|
||||
case StaticNpcList.KALPHITE_QUEEN:
|
||||
GameEngine.npcHandler.spawnSecondForm(player, i);
|
||||
return 1187;
|
||||
case StaticNpcList.KALPHITE_QUEEN_1160:
|
||||
GameEngine.npcHandler.spawnFirstForm(player, i);
|
||||
return 1182;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.rs2.GameEngine;
|
||||
import com.rs2.event.CycleEvent;
|
||||
import com.rs2.event.CycleEventContainer;
|
||||
import com.rs2.event.CycleEventHandler;
|
||||
import com.rs2.game.content.StaticNpcList;
|
||||
import com.rs2.game.content.combat.CombatConstants;
|
||||
import com.rs2.game.npcs.Npc;
|
||||
import com.rs2.game.npcs.NpcHandler;
|
||||
@@ -450,7 +451,7 @@ public class DwarfCannon {
|
||||
|
||||
|
||||
|
||||
if (!npc.isDead && !npc.isDead && npc.HP != 0 && npc.npcType != 1266 && npc.npcType != 1268 && inDistance(theirX, theirY)) {
|
||||
if (!npc.isDead && !npc.isDead && npc.HP != 0 && npc.npcType != StaticNpcList.ROCKS && npc.npcType != StaticNpcList.ROCKS_1268 && inDistance(theirX, theirY)) {
|
||||
switch (rotation) {
|
||||
case 1:
|
||||
if (theirY > myY && theirX >= myX - 1 && theirX <= myX + 1) {
|
||||
|
||||
@@ -230,6 +230,10 @@ public class Barrows {
|
||||
}
|
||||
if (c.barrowsKillCount > 5 && checkBarrows()) {
|
||||
if (c.getItemAssistant().freeSlots() >= 4) {
|
||||
c.incrementNpcKillCount(100000, 1);
|
||||
if (c.displayBossKcMessages || c.displayRegularKcMessages) {
|
||||
c.getPacketSender().sendMessage("Your Barrows Chest count is now: " + c.getNpcKillCount(100000));
|
||||
}
|
||||
reward();
|
||||
resetBarrows();
|
||||
} else {
|
||||
@@ -277,7 +281,6 @@ public class Barrows {
|
||||
c.barrowsNpcs[4][1] = 0;
|
||||
c.barrowsNpcs[5][1] = 0;
|
||||
c.barrowsKillCount = 0;
|
||||
c.getPlayerAssistant().movePlayer(3565, 3288, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ public class Dueling {
|
||||
o.getPacketSender().sendMessage(player.playerName + ":duelreq:");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Misc.println("Error requesting duel.");
|
||||
System.out.println("Error requesting duel.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -3,6 +3,7 @@ package com.rs2.game.content.minigames.magetrainingarena;
|
||||
import java.util.Random;
|
||||
|
||||
import com.rs2.Constants;
|
||||
import com.rs2.game.content.StaticNpcList;
|
||||
import com.rs2.game.content.combat.magic.MagicData;
|
||||
import com.rs2.game.content.combat.magic.MagicRequirements;
|
||||
import com.rs2.game.content.music.sound.SoundList;
|
||||
@@ -141,7 +142,7 @@ public class Alchemy {
|
||||
// 1 in 4 chance of an item being free to alch
|
||||
freeAlch = random.nextInt(values.length * 4);
|
||||
for (int i = 0; i < NpcHandler.MAX_NPCS; i ++) {
|
||||
if (NpcHandler.npcs[i] != null && NpcHandler.npcs[i].npcType == 3099) {
|
||||
if (NpcHandler.npcs[i] != null && NpcHandler.npcs[i].npcType == StaticNpcList.ALCHEMY_GUARDIAN) {
|
||||
NpcHandler.npcs[i].forceChat("Items are changing!");
|
||||
}
|
||||
}
|
||||
|
||||
+7
-1
@@ -5,7 +5,13 @@ import com.rs2.game.players.Player;
|
||||
public class BlackKnightsFortress {
|
||||
|
||||
public static void showInformation(Player client) {
|
||||
for (int i = 8144; i < 8195; i++) {
|
||||
for (int i = 8144; i < 8196; i++) {
|
||||
client.getPacketSender().sendString("", i);
|
||||
}
|
||||
for (int i = 12174; i < (12174 + 50); i++) {
|
||||
client.getPacketSender().sendString( "", i);
|
||||
}
|
||||
for (int i = 14945; i < (14945 + 100); i++) {
|
||||
client.getPacketSender().sendString("", i);
|
||||
}
|
||||
client.getPacketSender().sendString("Black Knights' Fortress", 8144);
|
||||
|
||||
@@ -14,7 +14,13 @@ public class CooksAssistant {
|
||||
private static final int FLOUR = 1933;
|
||||
|
||||
public static void showInformation(Player client) {
|
||||
for (int i = 8144; i < 8195; i++) {
|
||||
for (int i = 8144; i < 8196; i++) {
|
||||
client.getPacketSender().sendString("", i);
|
||||
}
|
||||
for (int i = 12174; i < (12174 + 50); i++) {
|
||||
client.getPacketSender().sendString( "", i);
|
||||
}
|
||||
for (int i = 14945; i < (14945 + 100); i++) {
|
||||
client.getPacketSender().sendString("", i);
|
||||
}
|
||||
client.getPacketSender().sendString("@dre@Cook's Assistant", 8144);
|
||||
|
||||
@@ -10,7 +10,13 @@ import com.rs2.game.players.Player;
|
||||
public class DoricsQuest {
|
||||
|
||||
public static void showInformation(Player client) {
|
||||
for (int i = 8144; i < 8195; i++) {
|
||||
for (int i = 8144; i < 8196; i++) {
|
||||
client.getPacketSender().sendString("", i);
|
||||
}
|
||||
for (int i = 12174; i < (12174 + 50); i++) {
|
||||
client.getPacketSender().sendString( "", i);
|
||||
}
|
||||
for (int i = 14945; i < (14945 + 100); i++) {
|
||||
client.getPacketSender().sendString("", i);
|
||||
}
|
||||
client.getPacketSender().sendString("@dre@Dorics Quest", 8144);
|
||||
|
||||
@@ -10,7 +10,7 @@ import com.rs2.game.players.Player;
|
||||
public class GertrudesCat {
|
||||
|
||||
public static void showInformation(Player client) {
|
||||
for (int i = 8144; i < 8195; i++) {
|
||||
for (int i = 8144; i < 8196; i++) {
|
||||
client.getPacketSender().sendString("", i);
|
||||
}
|
||||
client.getPacketSender().sendString("@dre@Gertrudes Cat", 8144);
|
||||
|
||||
@@ -10,7 +10,13 @@ import com.rs2.game.players.Player;
|
||||
public class LostCity {
|
||||
|
||||
public static void showInformation(Player client) {
|
||||
for (int i = 8144; i < 8195; i++) {
|
||||
for (int i = 8144; i < 8196; i++) {
|
||||
client.getPacketSender().sendString("", i);
|
||||
}
|
||||
for (int i = 12174; i < (12174 + 50); i++) {
|
||||
client.getPacketSender().sendString( "", i);
|
||||
}
|
||||
for (int i = 14945; i < (14945 + 100); i++) {
|
||||
client.getPacketSender().sendString("", i);
|
||||
}
|
||||
client.getPacketSender().sendString("@dre@Lost City", 8144);
|
||||
|
||||
+7
-1
@@ -11,7 +11,13 @@ public class PiratesTreasure {
|
||||
|
||||
|
||||
public static void showInformation(Player client) {
|
||||
for (int i = 8144; i < 8195; i++) {
|
||||
for (int i = 8144; i < 8196; i++) {
|
||||
client.getPacketSender().sendString("", i);
|
||||
}
|
||||
for (int i = 12174; i < (12174 + 50); i++) {
|
||||
client.getPacketSender().sendString( "", i);
|
||||
}
|
||||
for (int i = 14945; i < (14945 + 100); i++) {
|
||||
client.getPacketSender().sendString("", i);
|
||||
}
|
||||
client.getPacketSender().sendString("@dre@Pirate's Treasure", 8144);
|
||||
|
||||
@@ -11,7 +11,13 @@ public class RestlessGhost {
|
||||
|
||||
|
||||
public static void showInformation(Player client) {
|
||||
for (int i = 8144; i < 8195; i++) {
|
||||
for (int i = 8144; i < 8196; i++) {
|
||||
client.getPacketSender().sendString("", i);
|
||||
}
|
||||
for (int i = 12174; i < (12174 + 50); i++) {
|
||||
client.getPacketSender().sendString( "", i);
|
||||
}
|
||||
for (int i = 14945; i < (14945 + 100); i++) {
|
||||
client.getPacketSender().sendString("", i);
|
||||
}
|
||||
client.getPacketSender().sendString("@dre@Restless Ghost", 8144);
|
||||
|
||||
@@ -10,7 +10,13 @@ import com.rs2.game.players.Player;
|
||||
public class RomeoJuliet {
|
||||
|
||||
public static void showInformation(Player client) {
|
||||
for (int i = 8144; i < 8195; i++) {
|
||||
for (int i = 8144; i < 8196; i++) {
|
||||
client.getPacketSender().sendString("", i);
|
||||
}
|
||||
for (int i = 12174; i < (12174 + 50); i++) {
|
||||
client.getPacketSender().sendString( "", i);
|
||||
}
|
||||
for (int i = 14945; i < (14945 + 100); i++) {
|
||||
client.getPacketSender().sendString("", i);
|
||||
}
|
||||
client.getPacketSender().sendString("@dre@Romeo & Juliet", 8144);
|
||||
|
||||
@@ -10,7 +10,13 @@ import com.rs2.game.players.Player;
|
||||
public class RuneMysteries {
|
||||
|
||||
public static void showInformation(Player client) {
|
||||
for (int i = 8144; i < 8195; i++) {
|
||||
for (int i = 8144; i < 8196; i++) {
|
||||
client.getPacketSender().sendString("", i);
|
||||
}
|
||||
for (int i = 12174; i < (12174 + 50); i++) {
|
||||
client.getPacketSender().sendString( "", i);
|
||||
}
|
||||
for (int i = 14945; i < (14945 + 100); i++) {
|
||||
client.getPacketSender().sendString("", i);
|
||||
}
|
||||
client.getPacketSender().sendString("@dre@Rune Mysteries", 8144);
|
||||
|
||||
@@ -10,7 +10,13 @@ import com.rs2.game.players.Player;
|
||||
public class SheepShearer {
|
||||
|
||||
public static void showInformation(Player client) {
|
||||
for (int i = 8144; i < 8195; i++) {
|
||||
for (int i = 8144; i < 8196; i++) {
|
||||
client.getPacketSender().sendString("", i);
|
||||
}
|
||||
for (int i = 12174; i < (12174 + 50); i++) {
|
||||
client.getPacketSender().sendString( "", i);
|
||||
}
|
||||
for (int i = 14945; i < (14945 + 100); i++) {
|
||||
client.getPacketSender().sendString("", i);
|
||||
}
|
||||
client.getPacketSender().sendString("@dre@Sheep Shearer", 8144);
|
||||
|
||||
@@ -20,7 +20,13 @@ public class ShieldArrav {
|
||||
|
||||
public static void showInformation(Player player) {
|
||||
// Clear all lines
|
||||
for (int i = 8144; i < 8195; i++) player.getPacketSender().sendString("", i);
|
||||
for (int i = 8144; i < 8196; i++) player.getPacketSender().sendString("", i);
|
||||
for (int i = 12174; i < (12174 + 50); i++) {
|
||||
player.getPacketSender().sendString( "", i);
|
||||
}
|
||||
for (int i = 14945; i < (14945 + 100); i++) {
|
||||
player.getPacketSender().sendString("", i);
|
||||
}
|
||||
// Set the title
|
||||
player.getPacketSender().sendString("Shield of Arrav", 8144);
|
||||
// Add content
|
||||
|
||||
@@ -14,7 +14,13 @@ public class VampyreSlayer {
|
||||
|
||||
public static void showInformation(Player client) {
|
||||
// Clear all lines
|
||||
for (int i = 8144; i < 8195; i++) client.getPacketSender().sendString("", i);
|
||||
for (int i = 8144; i < 8196; i++) client.getPacketSender().sendString("", i);
|
||||
for (int i = 12174; i < (12174 + 50); i++) {
|
||||
client.getPacketSender().sendString( "", i);
|
||||
}
|
||||
for (int i = 14945; i < (14945 + 100); i++) {
|
||||
client.getPacketSender().sendString("", i);
|
||||
}
|
||||
// Set the title
|
||||
client.getPacketSender().sendString("Vampyre Slayer", 8144);
|
||||
// Add content
|
||||
|
||||
@@ -10,7 +10,13 @@ import com.rs2.game.players.Player;
|
||||
public class WitchsPotion {
|
||||
|
||||
public static void showInformation(Player client) {
|
||||
for (int i = 8144; i < 8195; i++) {
|
||||
for (int i = 8144; i < 8196; i++) {
|
||||
client.getPacketSender().sendString("", i);
|
||||
}
|
||||
for (int i = 12174; i < (12174 + 50); i++) {
|
||||
client.getPacketSender().sendString( "", i);
|
||||
}
|
||||
for (int i = 14945; i < (14945 + 100); i++) {
|
||||
client.getPacketSender().sendString("", i);
|
||||
}
|
||||
client.getPacketSender().sendString("@dre@Witch's Potion", 8144);
|
||||
|
||||
+9
-5
@@ -50,11 +50,15 @@ public class AgilityShortcut {
|
||||
}
|
||||
break;
|
||||
case 9326:
|
||||
if (player.absX == 2773) {
|
||||
handleAgility(player, 2, 0, 81, 3067, WALK, "You jump over the strange floor.");
|
||||
} else if (player.absX == 2775) {
|
||||
handleAgility(player, -2, 0, 81, 3067, WALK, "You jump over the strange floor.");
|
||||
}
|
||||
if (player.absX == 2770) {
|
||||
handleAgility(player, 2768, 10002, 81, 3067, MOVE, "You jump over the strange floor.");
|
||||
} else if (player.absX == 2768) {
|
||||
handleAgility(player, 2770, 10002, 81, 3067, MOVE, "You jump over the strange floor.");
|
||||
} else if (player.absX == 2773) {
|
||||
handleAgility(player, 2775, 10003, 81, 3067, MOVE, "You jump over the strange floor.");
|
||||
} else if (player.absX == 2775) {
|
||||
handleAgility(player, 2773, 10003, 81, 3067, MOVE, "You jump over the strange floor.");
|
||||
}
|
||||
break;
|
||||
case 9321:
|
||||
if (player.absX == 2735) {
|
||||
|
||||
@@ -436,8 +436,8 @@ public class Slayer {
|
||||
return;
|
||||
}
|
||||
if (c.slayerPoints < 30) {
|
||||
c.getPacketSender().sendMessage("This requires atleast 30 slayer points, which you don't have.");
|
||||
c.getDialogueHandler().sendNpcChat1("This requires atleast 30 slayer points, which you don't have.", c.npcType, NpcHandler.getNpcListName(c.talkingNpc));
|
||||
c.getPacketSender().sendMessage("You need 30 slayer points to cancel a task.");
|
||||
c.getDialogueHandler().sendNpcChat1("You need 30 slayer points to cancel a task.", c.npcType, NpcHandler.getNpcListName(c.talkingNpc));
|
||||
c.nextChat = 0;
|
||||
return;
|
||||
}
|
||||
@@ -454,8 +454,8 @@ public class Slayer {
|
||||
return;
|
||||
}
|
||||
if (c.slayerPoints < 100) {
|
||||
c.getPacketSender().sendMessage("This requires atleast 100 slayer points, which you don't have.");
|
||||
c.getDialogueHandler().sendNpcChat1("This requires atleast 100 slayer points, which you don't have.", c.npcType, NpcHandler.getNpcListName(c.talkingNpc));
|
||||
c.getPacketSender().sendMessage("You need 100 slayer points to remove a task.");
|
||||
c.getDialogueHandler().sendNpcChat1("You need 100 slayer points to remove a task.", c.npcType, NpcHandler.getNpcListName(c.talkingNpc));
|
||||
c.nextChat = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ import com.rs2.game.npcs.NpcHandler;
|
||||
import com.rs2.game.players.Player;
|
||||
import com.rs2.util.Misc;
|
||||
|
||||
import static com.rs2.game.content.StaticNpcList.*;
|
||||
|
||||
public class Stalls {
|
||||
|
||||
|
||||
@@ -221,7 +223,7 @@ public class Stalls {
|
||||
private static void failGuards(final Player p) {
|
||||
for (int i = 1; i < NpcHandler.MAX_NPCS; i ++) {
|
||||
if (NpcHandler.npcs[i] != null) {
|
||||
if (NpcHandler.npcs[i].npcType == 32 || NpcHandler.npcs[i].npcType == 1317 || NpcHandler.npcs[i].npcType == 2236 || NpcHandler.npcs[i].npcType == 2571) {
|
||||
if (NpcHandler.npcs[i].npcType == GUARD_32 || NpcHandler.npcs[i].npcType == MARKET_GUARD || NpcHandler.npcs[i].npcType == MARKET_GUARD_2236 || NpcHandler.npcs[i].npcType == MARKET_GUARD_2571) {
|
||||
if (p.goodDistance(p.absX, p.absY, NpcHandler.npcs[i].absX, NpcHandler.npcs[i].absY, 7)
|
||||
&& p.heightLevel == NpcHandler.npcs[i].heightLevel) {
|
||||
if (!NpcHandler.npcs[i].underAttack) {
|
||||
|
||||
@@ -130,7 +130,13 @@ public class DesertHeat {
|
||||
}
|
||||
|
||||
public static void showWarning(Player player) {
|
||||
for (int i = 8144; i < 8195; i++) {
|
||||
for (int i = 8144; i < 8196; i++) {
|
||||
player.getPacketSender().sendString("", i);
|
||||
}
|
||||
for (int i = 12174; i < (12174 + 50); i++) {
|
||||
player.getPacketSender().sendString( "", i);
|
||||
}
|
||||
for (int i = 14945; i < (14945 + 100); i++) {
|
||||
player.getPacketSender().sendString("", i);
|
||||
}
|
||||
player.getPacketSender().sendString("@dre@DESERT WARNING", 8144);
|
||||
|
||||
@@ -3926,7 +3926,11 @@ public class DialogueHandler {
|
||||
player.dialogueAction = 70;
|
||||
break;
|
||||
case 1009:
|
||||
sendPlayerChat("Yes.");
|
||||
if (player.talkingNpc > 0) {
|
||||
sendPlayerChat("Yes.");
|
||||
} else {
|
||||
player.getPacketSender().closeAllWindows();
|
||||
}
|
||||
player.getPlayerAssistant().movePlayer(1761, 5192, 0);
|
||||
player.nextChat = 0;
|
||||
break;
|
||||
@@ -4024,6 +4028,11 @@ public class DialogueHandler {
|
||||
|
||||
case 1027:
|
||||
player.getDialogueHandler().sendStatement("10 coins are removed from your inventory.");
|
||||
//Fix Al-Kharid gate talking option by setting an object ID required by initKharid
|
||||
player.objectId = 2882;
|
||||
if (player.getY() == 3228) {
|
||||
player.objectId = 2883;
|
||||
}
|
||||
OtherObjects.initKharid(player, player.objectId);
|
||||
player.nextChat = 0;
|
||||
break;
|
||||
|
||||
@@ -487,7 +487,7 @@ public class ItemAssistant {
|
||||
if (item <= 0) {
|
||||
return false;
|
||||
}
|
||||
if ((freeSlots() >= 1 || playerHasItem(item, 1))
|
||||
if ((freeSlots() >= 1 || playerHasItem(item))
|
||||
&& ItemDefinition.lookup(item).isStackable() || freeSlots() > 0
|
||||
&& !ItemDefinition.lookup(item).isStackable()) {
|
||||
for (int i = 0; i < player.playerItems.length; i++) {
|
||||
|
||||
@@ -56,7 +56,7 @@ public class ItemDefinitions {
|
||||
defintions.put(item.id, new Definition(item));
|
||||
}
|
||||
} catch (FileNotFoundException fileex) {
|
||||
Misc.println("items.json: file not found.");
|
||||
System.out.println("items.json: file not found.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ public class UseItem {
|
||||
|
||||
default:
|
||||
if (c.playerRights == 3) {
|
||||
Misc.println("Player At Object id: " + objectID + " objectX: "
|
||||
System.out.println("Player At Object id: " + objectID + " objectX: "
|
||||
+ objectX + " objectY: " + objectY + " with Item id: "
|
||||
+ itemId);
|
||||
}
|
||||
@@ -387,7 +387,7 @@ public class UseItem {
|
||||
}
|
||||
|
||||
if (player.playerRights == 3) {
|
||||
Misc.println("Player used Item id: " + itemUsed + " with Item id: " + useWith);
|
||||
System.out.println("Player used Item id: " + itemUsed + " with Item id: " + useWith);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -396,7 +396,7 @@ public class UseItem {
|
||||
|
||||
default:
|
||||
if (c.playerRights == 3) {
|
||||
Misc.println("Player used Item id: " + itemId
|
||||
System.out.println("Player used Item id: " + itemId
|
||||
+ " with Npc id: " + npcId + " With Slot : " + slot);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -2,25 +2,35 @@ package com.rs2.game.npcs;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.lang.reflect.Type;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.rs2.util.XStreamUtil;
|
||||
|
||||
public class NPCDefinition {
|
||||
|
||||
private static NPCDefinition[] definitions = null;
|
||||
|
||||
private static HashMap<Integer, NPCDefinition> definitions = new HashMap<>();
|
||||
|
||||
public static void init() throws IOException {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<NPCDefinition> defs = (List<NPCDefinition>) XStreamUtil.getXStream().fromXML(new FileInputStream("data/cfg/npcDefinitions.xml"));
|
||||
definitions = new NPCDefinition[3790];
|
||||
Gson gson = new Gson();
|
||||
Type type = new TypeToken<List<NPCDefinition>>(){}.getType();
|
||||
List<NPCDefinition> defs;
|
||||
try (FileReader reader = new FileReader("data/cfg/npcDefinitions.json")) {
|
||||
defs = gson.fromJson(reader, type);
|
||||
}
|
||||
for (NPCDefinition def : defs) {
|
||||
definitions[def.getId()] = def;
|
||||
definitions.put(def.getId(), def);
|
||||
}
|
||||
}
|
||||
|
||||
public static NPCDefinition forId(int id) {
|
||||
NPCDefinition d = definitions[id];
|
||||
NPCDefinition d = definitions.get(id);
|
||||
if (d == null) {
|
||||
d = produceDefinition(id);
|
||||
}
|
||||
|
||||
@@ -65,6 +65,10 @@ public class Npc {
|
||||
transformUpdateRequired = true;
|
||||
updateRequired = true;
|
||||
}
|
||||
|
||||
public String name() {
|
||||
return NpcHandler.getNpcListName(this.npcType);
|
||||
}
|
||||
|
||||
public void shearSheep(Player player, int itemNeeded, int itemGiven, int animation, final int currentId, final int newId, int transformTime) {
|
||||
if (!player.getItemAssistant().playerHasItem(itemNeeded)) {
|
||||
|
||||
@@ -1137,7 +1137,7 @@ public class NpcActions {
|
||||
break;
|
||||
default:
|
||||
if (player.playerRights == 3) {
|
||||
Misc.println("Third Click NPC : " + npcType);
|
||||
System.out.println("Third Click NPC : " + npcType);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.rs2.game.npcs;
|
||||
|
||||
import com.rs2.game.content.combat.AttackType;
|
||||
import com.rs2.game.content.minigames.FightCaves;
|
||||
import com.rs2.game.players.PlayerHandler;
|
||||
import com.rs2.util.Misc;
|
||||
@@ -8,16 +9,18 @@ import com.rs2.world.clip.Region;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static com.rs2.game.content.StaticNpcList.*;
|
||||
|
||||
public class NpcData {
|
||||
|
||||
public static final int[] npcsOnlyMage = { 907, 908, 909, 910, 911, 912,
|
||||
913, 914 };// done
|
||||
public static final int[][] transformNpc = { { 3223, 6006 },
|
||||
{ 3224, 6007 }, { 3225, 6008 }, { 3226, 6009 } };// done
|
||||
public static final int[] npcsCantKillYou = { 41, 951, 1017, 1401, 1402,
|
||||
1692, 2313, 2314, 2315 };// done
|
||||
public static final int[] npcCantAttack = { 1532, 1533, 1534, 1535 };
|
||||
public static final int[] npcDontGiveXp = { 2459, 2460, 2461, 2462 };
|
||||
public static final int[] npcsOnlyMage = { KOLODION_907, KOLODION_908, KOLODION_909, KOLODION_910, KOLODION_911, BATTLE_MAGE,
|
||||
BATTLE_MAGE_913, BATTLE_MAGE_914 };// done
|
||||
public static final int[][] transformNpc = { { MAN_3223, 6006 },
|
||||
{ MAN_3224, 6007 }, { MAN_3225, 6008 }, { WOMAN_3226, 6009 } };// done // this transformNpc array seems to be unused, maybe can be removed? Maybe it's not even accurate? Idk I just fixed the magic numbers.
|
||||
public static final int[] npcsCantKillYou = { CHICKEN, CHICKEN_951, CHICKEN_1017, CHICKEN_1401, CHICKEN_1402,
|
||||
UNDEAD_CHICKEN, CHICKEN_2313, CHICKEN_2314, CHICKEN_2315 };// done
|
||||
public static final int[] npcCantAttack = { BARRICADE, BARRICADE_1533, BARRICADE_1534, BARRICADE_1535 };
|
||||
public static final int[] npcDontGiveXp = { PHEASANT, PHEASANT_2460, PHEASANT_2461, PHEASANT_2462 };
|
||||
|
||||
public static boolean cantKillYou(int npcType) {
|
||||
for (int n : npcsCantKillYou) {
|
||||
@@ -185,23 +188,13 @@ public class NpcData {
|
||||
**/
|
||||
public static int getNpcDelay(int i) {
|
||||
switch (NpcHandler.npcs[i].npcType) {
|
||||
case 2025:
|
||||
case 2028:
|
||||
case AHRIM_THE_BLIGHTED:
|
||||
case KARIL_THE_TAINTED:
|
||||
return 7;
|
||||
|
||||
case 2745:
|
||||
case TZTOKJAD:
|
||||
return 8;
|
||||
|
||||
case 2558:
|
||||
case 2559:
|
||||
case 2560:
|
||||
case 2561:
|
||||
case 2550:
|
||||
return 6;
|
||||
// saradomin gw boss
|
||||
case 2562:
|
||||
return 2;
|
||||
|
||||
default:
|
||||
return 5;
|
||||
}
|
||||
@@ -212,31 +205,28 @@ public class NpcData {
|
||||
**/
|
||||
public static int getHitDelay(int i) {
|
||||
switch (NpcHandler.npcs[i].npcType) {
|
||||
case 2881:
|
||||
case 2882:
|
||||
case 3200:
|
||||
case 2892:
|
||||
case 2894:
|
||||
case DAGANNOTH_SUPREME:
|
||||
case DAGANNOTH_PRIME:
|
||||
case CHAOS_ELEMENTAL:
|
||||
case SPINOLYP:
|
||||
case SPINOLYP_2894:
|
||||
return 3;
|
||||
|
||||
case 2743:
|
||||
case 2631:
|
||||
case 2558:
|
||||
case 2559:
|
||||
case 2560:
|
||||
case KETZEK:
|
||||
case TOKXIL:
|
||||
return 3;
|
||||
|
||||
case 2745:
|
||||
if (NpcHandler.npcs[i].attackType == 1
|
||||
|| NpcHandler.npcs[i].attackType == 2) {
|
||||
case TZTOKJAD:
|
||||
if (NpcHandler.npcs[i].attackType == AttackType.RANGE.getValue()
|
||||
|| NpcHandler.npcs[i].attackType == AttackType.MAGIC.getValue()) {
|
||||
return 5;
|
||||
} else {
|
||||
return 2;
|
||||
}
|
||||
|
||||
case 2025:
|
||||
case AHRIM_THE_BLIGHTED:
|
||||
return 4;
|
||||
case 2028:
|
||||
case KARIL_THE_TAINTED:
|
||||
return 3;
|
||||
|
||||
default:
|
||||
@@ -249,91 +239,75 @@ public class NpcData {
|
||||
**/
|
||||
public static int getRespawnTime(int i) {
|
||||
switch (NpcHandler.npcs[i].npcType) {
|
||||
case 1158:
|
||||
case 1160:
|
||||
return -1;
|
||||
case 2881:
|
||||
case 2882:
|
||||
case 2883:
|
||||
case 2558:
|
||||
case 2559:
|
||||
case 2560:
|
||||
case 2561:
|
||||
case 2562:
|
||||
case 2563:
|
||||
case 2564:
|
||||
case 2550:
|
||||
case 2551:
|
||||
case 2552:
|
||||
case 2553:
|
||||
case KALPHITE_QUEEN:
|
||||
case KALPHITE_QUEEN_1160:
|
||||
return -1;
|
||||
case DAGANNOTH_SUPREME:
|
||||
case DAGANNOTH_PRIME:
|
||||
case DAGANNOTH_REX:
|
||||
return 100;
|
||||
case 3777:
|
||||
case 3778:
|
||||
case 3779:
|
||||
case 3780:
|
||||
case PORTAL:
|
||||
case PORTAL_3778:
|
||||
case PORTAL_3779:
|
||||
case PORTAL_3780:
|
||||
return 500;
|
||||
case 1532:
|
||||
case 1534:
|
||||
case BARRICADE:
|
||||
case BARRICADE_1534:
|
||||
return -1;
|
||||
default:
|
||||
return 25;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Distance required to attack
|
||||
* It's also worth checking {@link NpcHandler#distanceRequired}
|
||||
*/
|
||||
public static int distanceRequired(int i) {
|
||||
int distanceNeeded = 1;
|
||||
if (NpcHandler.npcs[i].attackType == 1) {
|
||||
return distanceNeeded += 7;
|
||||
} else if (NpcHandler.npcs[i].attackType == 2) {
|
||||
return distanceNeeded += 9;
|
||||
} else if (NpcHandler.npcs[i].attackType > 2) {
|
||||
return distanceNeeded += 4;
|
||||
if (NpcHandler.npcs[i].attackType == AttackType.RANGE.getValue()) {
|
||||
return 8;
|
||||
} else if (NpcHandler.npcs[i].attackType == AttackType.MAGIC.getValue()) {
|
||||
return 10;
|
||||
} else if (NpcHandler.npcs[i].attackType > AttackType.MAGIC.getValue()) {
|
||||
return 5;
|
||||
}
|
||||
switch (NpcHandler.npcs[i].npcType) {
|
||||
case 2562:
|
||||
return distanceNeeded += 1;
|
||||
case 2881:// dag kings
|
||||
case 2882:
|
||||
case 3200:// chaos ele
|
||||
return distanceNeeded += 7;
|
||||
case 2552:
|
||||
case 2553:
|
||||
case 2556:
|
||||
case 2557:
|
||||
case 2558:
|
||||
case 2559:
|
||||
case 2560:
|
||||
case 2564:
|
||||
case 2565:
|
||||
return distanceNeeded += 8;
|
||||
case COAL:
|
||||
return 2;
|
||||
case DAGANNOTH_SUPREME:// dag kings
|
||||
case DAGANNOTH_PRIME:
|
||||
case CHAOS_ELEMENTAL:// chaos ele
|
||||
return 8;
|
||||
// things around dags
|
||||
case 2892:
|
||||
case 2894:
|
||||
return distanceNeeded += 9;
|
||||
case 907 : // Kolodian
|
||||
case 908 :
|
||||
case 909 :
|
||||
case 910 :
|
||||
case 911 :
|
||||
case 912 : // Zammy battlemage
|
||||
case 913 : // Sara battlemage
|
||||
case 914 : // Guthix battlemage
|
||||
case 2591 : // TzHaar-Mej (Tzhaar mage guy)
|
||||
case 2743 : // Ket-Zek (Tzhaar mage guy)
|
||||
case 2745 : // TzTok-Jad
|
||||
case 1158 : // Kalphite queen form 1
|
||||
case 1160 : // Kalphite queen form 2
|
||||
case 2025 : // Ahrim
|
||||
return distanceNeeded += 9;
|
||||
case 2028 : // Karil
|
||||
case 2631 : // Tok-Xil (Tzhaar ranging guy)
|
||||
case 1183 : // Elf ranger
|
||||
return distanceNeeded += 7;
|
||||
case 941 : // Green drag
|
||||
case 50 : // Kbd
|
||||
return distanceNeeded += 5;
|
||||
case SPINOLYP:
|
||||
case SPINOLYP_2894:
|
||||
return 10;
|
||||
case KOLODION_907 : // Kolodian
|
||||
case KOLODION_908 :
|
||||
case KOLODION_909 :
|
||||
case KOLODION_910 :
|
||||
case KOLODION_911 :
|
||||
case BATTLE_MAGE : // Zammy battlemage
|
||||
case BATTLE_MAGE_913 : // Sara battlemage
|
||||
case BATTLE_MAGE_914 : // Guthix battlemage
|
||||
case TZHAARMEJ : // TzHaar-Mej (Tzhaar mage guy)
|
||||
case KETZEK : // Ket-Zek (Tzhaar mage guy)
|
||||
case TZTOKJAD : // TzTok-Jad
|
||||
case KALPHITE_QUEEN : // Kalphite queen form 1
|
||||
case KALPHITE_QUEEN_1160 : // Kalphite queen form 2
|
||||
case AHRIM_THE_BLIGHTED : // Ahrim
|
||||
return 10;
|
||||
case KARIL_THE_TAINTED : // Karil
|
||||
case TOKXIL : // Tok-Xil (Tzhaar ranging guy)
|
||||
case ELF_WARRIOR : // Elf ranger
|
||||
case DARK_WIZARD: // dark wizards
|
||||
case DARK_WIZARD_174:
|
||||
return 8;
|
||||
case GREEN_DRAGON : // Green drag
|
||||
case KING_BLACK_DRAGON : // Kbd
|
||||
return 6;
|
||||
}
|
||||
return distanceNeeded;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@ import com.rs2.GameEngine;
|
||||
import com.rs2.event.CycleEvent;
|
||||
import com.rs2.event.CycleEventContainer;
|
||||
import com.rs2.event.CycleEventHandler;
|
||||
import com.rs2.game.content.StaticItemList;
|
||||
import com.rs2.game.content.combat.AttackType;
|
||||
import com.rs2.game.content.combat.CombatConstants;
|
||||
import com.rs2.game.content.combat.npcs.NpcAggressive;
|
||||
import com.rs2.game.content.combat.npcs.NpcCombat;
|
||||
@@ -33,6 +35,8 @@ import org.json.JSONObject;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import static com.rs2.game.content.StaticNpcList.*;
|
||||
|
||||
// Facetypes: 1-Walk, 2-North, 3-South, 4-East, 5-West
|
||||
|
||||
public class NpcHandler {
|
||||
@@ -47,7 +51,7 @@ public class NpcHandler {
|
||||
CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() {
|
||||
@Override
|
||||
public void execute(CycleEventContainer container) {
|
||||
spawnNpc2(1160, npcs[i].absX, npcs[i].absY, 0, 1, 230, 45, 500, 300, true);
|
||||
spawnNpc2(KALPHITE_QUEEN_1160, npcs[i].absX, npcs[i].absY, 0, 1, 230, 45, 500, 300, true);
|
||||
container.stop();
|
||||
}
|
||||
|
||||
@@ -65,7 +69,7 @@ public class NpcHandler {
|
||||
CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() {
|
||||
@Override
|
||||
public void execute(CycleEventContainer container) {
|
||||
spawnNpc2(1158, npcs[i].absX, npcs[i].absY, 0, 1, 230, 45, 500, 300, true);
|
||||
spawnNpc2(KALPHITE_QUEEN, npcs[i].absX, npcs[i].absY, 0, 1, 230, 45, 500, 300, true);
|
||||
container.stop();
|
||||
}
|
||||
|
||||
@@ -82,7 +86,7 @@ public class NpcHandler {
|
||||
if (npcs[i] == null || foundRat != -1) {
|
||||
continue;
|
||||
}
|
||||
if (npcs[i].npcType == 47 && !npcs[i].isDead) {
|
||||
if (npcs[i].npcType == RAT && !npcs[i].isDead) {
|
||||
if (goodDistance(npcs[npcIndex].absX, npcs[npcIndex].absY, npcs[i].absX, npcs[i].absY, 5)) {
|
||||
foundRat = i;
|
||||
continue;
|
||||
@@ -100,13 +104,13 @@ public class NpcHandler {
|
||||
CycleEventHandler.getSingleton().addEvent(this, new CycleEvent() {
|
||||
@Override
|
||||
public void execute(CycleEventContainer container) {
|
||||
if (npcs[npcIndex].absX == npcs[npcs[npcIndex].chasingRat].absX && npcs[npcIndex].absY == npcs[npcs[npcIndex].chasingRat].absY && (beatChance || npcs[npcIndex].npcType >= 768 && npcs[npcIndex].npcType <= 773)) {
|
||||
if (npcs[npcIndex].absX == npcs[npcs[npcIndex].chasingRat].absX && npcs[npcIndex].absY == npcs[npcs[npcIndex].chasingRat].absY && (beatChance || npcs[npcIndex].npcType >= CAT && npcs[npcIndex].npcType <= CAT_773)) {
|
||||
npcs[npcs[npcIndex].chasingRat].isDead = true;
|
||||
npcs[npcs[npcIndex].chasingRat].forceChat("Eek!");
|
||||
npcs[npcIndex].forceChat("Meow!");
|
||||
//startAnimation(9163, npcIndex);
|
||||
slaveOwner.getPacketSender().sendMessage("The " + getNpcListName(NpcHandler.npcs[npcIndex].npcType) + " caught a rat!");
|
||||
if (npcs[npcIndex].npcType >= 761 && npcs[npcIndex].npcType <= 766) {
|
||||
if (npcs[npcIndex].npcType >= KITTEN_761 && npcs[npcIndex].npcType <= KITTEN_766) {
|
||||
slaveOwner.ratsCaught++;
|
||||
}
|
||||
if (slaveOwner.ratsCaught == Pets.RATS_NEEDED_TO_GROW) {
|
||||
@@ -153,7 +157,8 @@ public class NpcHandler {
|
||||
try {
|
||||
NPCDefinition.init();
|
||||
} catch (Exception e) {
|
||||
//System.out.println("npc def error");
|
||||
System.out.println("npc def error: ");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,19 +217,19 @@ public class NpcHandler {
|
||||
npcs[slot] = newNPC;
|
||||
}
|
||||
|
||||
public boolean switchesAttackers(int i) {
|
||||
public boolean switchesAttackers(int i) { // This seems unused, that's probably not good
|
||||
switch (npcs[i].npcType) {
|
||||
case 2551:
|
||||
case 2552:
|
||||
case 2553:
|
||||
case 2559:
|
||||
case 2560:
|
||||
case 2561:
|
||||
case 2563:
|
||||
case 2564:
|
||||
case 2565:
|
||||
case 2892:
|
||||
case 2894:
|
||||
case DWARVEN_MINER_2551:
|
||||
case DWARVEN_MINER_2552:
|
||||
case BLAST_FURNACE_FOREMAN:
|
||||
case RUNITE_ORE:
|
||||
case SILVER_ORE:
|
||||
case GOLD_ORE:
|
||||
case PERFECT_GOLD_ORE:
|
||||
case ORDAN:
|
||||
case JORZIK:
|
||||
case SPINOLYP:
|
||||
case SPINOLYP_2894:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -263,7 +268,7 @@ public class NpcHandler {
|
||||
}
|
||||
}
|
||||
if (slot == -1) {
|
||||
// Misc.println("No Free Slot");
|
||||
// System.out.println("No Free Slot");
|
||||
return; // no free slot found
|
||||
}
|
||||
Npc newNPC = new Npc(slot, npcType);
|
||||
@@ -310,7 +315,7 @@ public class NpcHandler {
|
||||
}
|
||||
}
|
||||
if (slot == -1) {
|
||||
// Misc.println("No Free Slot");
|
||||
// System.out.println("No Free Slot");
|
||||
return; // no free slot found
|
||||
}
|
||||
Npc newNPC = new Npc(slot, npcType);
|
||||
@@ -331,28 +336,34 @@ public class NpcHandler {
|
||||
npcs[slot] = newNPC;
|
||||
}
|
||||
|
||||
private void killedBarrow(int i) {
|
||||
private boolean killedBarrow(int i) {
|
||||
boolean barrows = false;
|
||||
Player c = (Client) PlayerHandler.players[npcs[i].killedBy];
|
||||
if (c != null) {
|
||||
for (int o = 0; o < c.barrowsNpcs.length; o++) {
|
||||
if (npcs[i].npcType == c.barrowsNpcs[o][0]) {
|
||||
c.barrowsNpcs[o][1] = 2; // 2 for dead
|
||||
c.barrowsKillCount++;
|
||||
barrows = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return barrows;
|
||||
}
|
||||
|
||||
private void killedCrypt(int i) {
|
||||
private boolean killedCrypt(int i) {
|
||||
boolean crypt = false;
|
||||
Player c = (Client) PlayerHandler.players[npcs[i].killedBy];
|
||||
if (c != null) {
|
||||
for (int o = 0; o < c.barrowCrypt.length; o++) {
|
||||
if (npcs[i].npcType == c.barrowCrypt[o][0]) {
|
||||
c.barrowsKillCount++;
|
||||
c.getPacketSender().sendString("" + c.barrowsKillCount, 4536);
|
||||
crypt = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return crypt;
|
||||
}
|
||||
|
||||
public void newNPC(int npcType, int x, int y, int heightLevel,
|
||||
@@ -492,7 +503,7 @@ public class NpcHandler {
|
||||
}
|
||||
}
|
||||
|
||||
if (npcs[i].npcType == 162) {
|
||||
if (npcs[i].npcType == GNOME_TRAINER) {
|
||||
if (npcs[i].getX() == 2475 && npcs[i].getY() == 3438) {
|
||||
npcs[i].forceChat("Okay get over that log, quick quick!");
|
||||
} else if (npcs[i].getX() == 2471 && npcs[i].getY() == 3427) {
|
||||
@@ -510,22 +521,22 @@ public class NpcHandler {
|
||||
}
|
||||
}
|
||||
|
||||
if (npcs[i].npcType == 43) {
|
||||
if (npcs[i].npcType == SHEEP_43) {
|
||||
if (Misc.random(20) == 4) {
|
||||
npcs[i].forceChat("Baa!");
|
||||
}
|
||||
}
|
||||
if (npcs[i].npcType == 81 || npcs[i].npcType == 397 || npcs[i].npcType == 1766 || npcs[i].npcType == 1767 || npcs[i].npcType == 1768) {
|
||||
if (npcs[i].npcType == COW || npcs[i].npcType == COW_397 || npcs[i].npcType == COW_CALF || npcs[i].npcType == COW_1767 || npcs[i].npcType == COW_CALF_1768) {
|
||||
if (Misc.random(30) == 4) {
|
||||
npcs[i].forceChat("Moo");
|
||||
}
|
||||
}
|
||||
if (npcs[i].npcType == 45) {
|
||||
if (npcs[i].npcType == DUCK_45) {
|
||||
if (Misc.random(30) == 6) {
|
||||
npcs[i].forceChat("Quack!");
|
||||
}
|
||||
}
|
||||
if (npcs[i].npcType == 1685)
|
||||
if (npcs[i].npcType == GRAVINGAS)
|
||||
{
|
||||
if (Misc.random(25) == 7) {
|
||||
int rand = Misc.random(25);
|
||||
@@ -745,10 +756,16 @@ public class NpcHandler {
|
||||
npcs[i].animUpdateRequired = true;
|
||||
npcs[i].freezeTimer = 0;
|
||||
npcs[i].applyDead = true;
|
||||
killedBarrow(i);
|
||||
killedCrypt(i);
|
||||
boolean barrows = killedBarrow(i);
|
||||
boolean crypt = killedCrypt(i);
|
||||
npcs[i].actionTimer = 4; // delete time
|
||||
resetPlayersInCombat(i);
|
||||
if (!crypt && !barrows && c != null) {
|
||||
c.incrementNpcKillCount(npcs[i].npcType, 1);
|
||||
if (c.displayRegularKcMessages || (c.displayBossKcMessages && Constants.BOSS_NPC_IDS.contains(npcs[i].npcType)) || (c.displaySlayerKcMessages && Constants.SLAYER_NPC_IDS.contains(npcs[i].npcType))) {
|
||||
c.getPacketSender().sendMessage("Your " + npcs[i].name() + " kill count is now: " + c.getNpcKillCount(npcs[i].npcType));
|
||||
}
|
||||
}
|
||||
} else if (npcs[i].actionTimer == 0
|
||||
&& npcs[i].applyDead
|
||||
&& npcs[i].needRespawn == false) {
|
||||
@@ -757,7 +774,7 @@ public class NpcHandler {
|
||||
// time
|
||||
dropItems(i); // npc drops items!
|
||||
FightCaves.tzhaarDeathHandler(i);
|
||||
if (npcs[i].npcType == 2745) {
|
||||
if (npcs[i].npcType == TZTOKJAD) {
|
||||
FightCaves.handleJadDeath(i);
|
||||
if (PlayerHandler.players[npcs[i].killerId] != null) {
|
||||
PlayerHandler.players[npcs[i].killerId].spawnedHealers = 0;
|
||||
@@ -785,36 +802,36 @@ public class NpcHandler {
|
||||
handleratdeath2(i);
|
||||
}
|
||||
}
|
||||
if (npcs[i].npcType > 3726 && npcs[i].npcType < 3732) {
|
||||
if (npcs[i].npcType > RABBIT_3726 && npcs[i].npcType < SHIFTER) {
|
||||
int damage = 10 + Misc.random(10);
|
||||
player.playerLevel[Constants.HITPOINTS] = player.getPlayerAssistant().getLevelForXP(player.playerXP[Constants.HITPOINTS]) - damage;
|
||||
player.getPlayerAssistant().refreshSkill(Constants.HITPOINTS);
|
||||
player.handleHitMask(damage);
|
||||
}
|
||||
if (npcs[i].npcType == 655) {
|
||||
if (npcs[i].npcType == TREE_SPIRIT_655) {
|
||||
player.spiritTree = true;
|
||||
player.getPacketSender().sendMessage(
|
||||
"You have defeated the tree spirit.");
|
||||
}
|
||||
if (npcs[i].npcType > 412 && npcs[i].npcType < 419) {
|
||||
if (npcs[i].npcType > BAT && npcs[i].npcType < ZOMBIE_419) {
|
||||
player.golemSpawned = false;
|
||||
}
|
||||
if (npcs[i].npcType == 757 && player.vampSlayer == 3) {
|
||||
if (npcs[i].npcType == COUNT_DRAYNOR && player.vampSlayer == 3) {
|
||||
player.vampSlayer = 4;
|
||||
}
|
||||
if (npcs[i].npcType > 390 && npcs[i].npcType < 397) {
|
||||
if (npcs[i].npcType > BIG_FISH && npcs[i].npcType < COW_397) {
|
||||
RiverTroll.hasRiverTroll = false;
|
||||
}
|
||||
if (npcs[i].npcType > 418 && npcs[i].npcType < 425) {
|
||||
if (npcs[i].npcType > ROCK_GOLEM_418 && npcs[i].npcType < SHADE) {
|
||||
player.zombieSpawned = false;
|
||||
}
|
||||
if (npcs[i].npcType > 424 && npcs[i].npcType < 431) {
|
||||
if (npcs[i].npcType > ZOMBIE_424 && npcs[i].npcType < WATCHMAN_431) {
|
||||
player.shadeSpawned = false;
|
||||
}
|
||||
if (npcs[i].npcType > 437 && npcs[i].npcType < 444) {
|
||||
if (npcs[i].npcType > CAPN_IZZY_NOBEARD && npcs[i].npcType < GOBLIN_444) {
|
||||
player.treeSpiritSpawned = false;
|
||||
}
|
||||
if (npcs[i].npcType > 2462 && npcs[i].npcType < 2469) {
|
||||
if (npcs[i].npcType > PHEASANT_2462 && npcs[i].npcType < FROG_2469) {
|
||||
player.chickenSpawned = false;
|
||||
}
|
||||
npcs[i].absX = npcs[i].makeX;
|
||||
@@ -823,11 +840,11 @@ public class NpcHandler {
|
||||
npcs[i].animNumber = 0x328;
|
||||
npcs[i].updateRequired = true;
|
||||
npcs[i].animUpdateRequired = true;
|
||||
if (npcs[i].npcType >= 2440 && npcs[i].npcType <= 2446) {
|
||||
if (npcs[i].npcType >= DOORSUPPORT && npcs[i].npcType <= DOORSUPPORT_2446) {
|
||||
GameEngine.objectManager.removeObject(npcs[i].absX,
|
||||
npcs[i].absY);
|
||||
}
|
||||
} else if (npcs[i].actionTimer == 0 && npcs[i].needRespawn && npcs[i].npcType != 1158) {
|
||||
} else if (npcs[i].actionTimer == 0 && npcs[i].needRespawn && npcs[i].npcType != KALPHITE_QUEEN) {
|
||||
if (npcs[i].spawnedBy > 0) {
|
||||
npcs[i] = null;
|
||||
} else {
|
||||
@@ -890,12 +907,12 @@ public class NpcHandler {
|
||||
|
||||
public boolean getsPulled(Player c, int i) {
|
||||
switch (npcs[i].npcType) {
|
||||
case 2550:
|
||||
case DWARVEN_MINER_2550:
|
||||
if (npcs[i].firstAttacker > 0) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 87:
|
||||
case GIANT_RAT_87:
|
||||
if (Boundary.isIn(c, Boundary.TUTORIAL) || c.tutorialProgress < 36) {
|
||||
return false;
|
||||
}
|
||||
@@ -906,24 +923,14 @@ public class NpcHandler {
|
||||
|
||||
public static boolean multiAttacks(int i) {
|
||||
switch (npcs[i].npcType) {
|
||||
case 1158: //kq
|
||||
if (npcs[i].attackType == 2) {
|
||||
case KALPHITE_QUEEN: //kq
|
||||
if (npcs[i].attackType == AttackType.MAGIC.getValue()) {
|
||||
return true;
|
||||
}
|
||||
case 1160: //kq
|
||||
if (npcs[i].attackType == 1) {
|
||||
case KALPHITE_QUEEN_1160: //kq
|
||||
if (npcs[i].attackType == AttackType.RANGE.getValue()) {
|
||||
return true;
|
||||
}
|
||||
case 2558:
|
||||
return true;
|
||||
case 2562:
|
||||
if (npcs[i].attackType == 2) {
|
||||
return true;
|
||||
}
|
||||
case 2550:
|
||||
if (npcs[i].attackType == 1) {
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -1035,15 +1042,15 @@ public class NpcHandler {
|
||||
Player c = (Client) PlayerHandler.players[npcs[i].killedBy];
|
||||
if (c != null) {
|
||||
// These npcs shouldn't have drops
|
||||
if (npcs[i].npcType == 2627 // Tz-Kih
|
||||
|| npcs[i].npcType == 2630 // Tz-Kek
|
||||
|| npcs[i].npcType == 2631 // Tok-Xil
|
||||
|| npcs[i].npcType == 2638 // Neite
|
||||
|| npcs[i].npcType == 2641 // Dragonkin
|
||||
|| npcs[i].npcType == 2643 // R4ng3rNo0b889
|
||||
|| npcs[i].npcType == 2645 // Love Cats
|
||||
|| npcs[i].npcType == 1532 // Barricade
|
||||
|| npcs[i].npcType == 153 // Butterfly
|
||||
if (npcs[i].npcType == TZKIH // Tz-Kih
|
||||
|| npcs[i].npcType == TZKEK_2630 // Tz-Kek
|
||||
|| npcs[i].npcType == TOKXIL // Tok-Xil
|
||||
|| npcs[i].npcType == NEITE_2638 // Neite
|
||||
|| npcs[i].npcType == DRAGONKIN // Dragonkin
|
||||
|| npcs[i].npcType == R4NG3RNO0B889 // R4ng3rNo0b889
|
||||
|| npcs[i].npcType == LOVE_CATS_2645 // Love Cats
|
||||
|| npcs[i].npcType == BARRICADE // Barricade
|
||||
|| npcs[i].npcType == BUTTERFLY // Butterfly
|
||||
|| PestControl.npcIsPCMonster(npcs[i].npcType)
|
||||
|| FightCaves.isFightCaveNpc(i)) {
|
||||
// These npcs shouldn't have drops
|
||||
@@ -1060,36 +1067,36 @@ public class NpcHandler {
|
||||
}
|
||||
}
|
||||
switch (npcs[i].npcType) {
|
||||
case 2459:
|
||||
case PHEASANT:
|
||||
FreakyForester.killedPheasant(c, 0);
|
||||
GameEngine.itemHandler.createGroundItem(c, 6178, npcs[i].absX, npcs[i].absY, 1, c.playerId);
|
||||
GameEngine.itemHandler.createGroundItem(c, StaticItemList.RAW_PHEASANT, npcs[i].absX, npcs[i].absY, 1, c.playerId);
|
||||
break;
|
||||
case 2460:
|
||||
case PHEASANT_2460:
|
||||
FreakyForester.killedPheasant(c, 1);
|
||||
GameEngine.itemHandler.createGroundItem(c, 6178, npcs[i].absX, npcs[i].absY, 1, c.playerId);
|
||||
GameEngine.itemHandler.createGroundItem(c, StaticItemList.RAW_PHEASANT, npcs[i].absX, npcs[i].absY, 1, c.playerId);
|
||||
break;
|
||||
case 2461:
|
||||
case PHEASANT_2461:
|
||||
FreakyForester.killedPheasant(c, 2);
|
||||
GameEngine.itemHandler.createGroundItem(c, 6178, npcs[i].absX, npcs[i].absY, 1, c.playerId);
|
||||
GameEngine.itemHandler.createGroundItem(c, StaticItemList.RAW_PHEASANT, npcs[i].absX, npcs[i].absY, 1, c.playerId);
|
||||
break;
|
||||
case 2462:
|
||||
case PHEASANT_2462:
|
||||
FreakyForester.killedPheasant(c, 3);
|
||||
GameEngine.itemHandler.createGroundItem(c, 6178, npcs[i].absX, npcs[i].absY, 1, c.playerId);
|
||||
GameEngine.itemHandler.createGroundItem(c, StaticItemList.RAW_PHEASANT, npcs[i].absX, npcs[i].absY, 1, c.playerId);
|
||||
break;
|
||||
case 92:
|
||||
case SKELETON_92:
|
||||
if (c.restGhost == 3) {
|
||||
GameEngine.itemHandler.createGroundItem(c, 553, npcs[i].absX, npcs[i].absY, 1, c.playerId);
|
||||
GameEngine.itemHandler.createGroundItem(c, StaticItemList.SKULL, npcs[i].absX, npcs[i].absY, 1, c.playerId);
|
||||
c.restGhost = 4;
|
||||
}
|
||||
break;
|
||||
case 47:
|
||||
case RAT:
|
||||
if (c.witchspot == 1 || c.romeojuliet > 0 && c.romeojuliet < 9) {
|
||||
GameEngine.itemHandler.createGroundItem(c, 300, npcs[i].absX, npcs[i].absY, 1, c.playerId);
|
||||
GameEngine.itemHandler.createGroundItem(c, StaticItemList.RATS_TAIL, npcs[i].absX, npcs[i].absY, 1, c.playerId);
|
||||
}
|
||||
break;
|
||||
case 645:
|
||||
case JONNY_THE_BEARD:
|
||||
if (c.shieldArrav == 5) {
|
||||
GameEngine.itemHandler.createGroundItem(c, 761, npcs[i].absX, npcs[i].absY, 1, c.playerId);
|
||||
GameEngine.itemHandler.createGroundItem(c, StaticItemList.SCROLL, npcs[i].absX, npcs[i].absY, 1, c.playerId);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1138,7 +1145,8 @@ public class NpcHandler {
|
||||
int points = c.getSlayer().getDifficulty(c.slayerTask) * 4;
|
||||
c.slayerTask = -1;
|
||||
c.slayerPoints += points;
|
||||
c.getPacketSender().sendMessage("You completed your slayer task. You obtain " + points + " slayer points. Please talk to your slayer master.");
|
||||
c.getPacketSender().sendMessage("You completed your slayer task. You obtain " + points + " slayer points.");
|
||||
c.getPacketSender().sendMessage("Please talk to your slayer master for a new task.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1187,11 +1195,11 @@ public class NpcHandler {
|
||||
return false;
|
||||
}
|
||||
switch (npcs[i].npcType) {
|
||||
case 1456:
|
||||
case 2892:
|
||||
case 2894:
|
||||
case 1532:
|
||||
case 1534:
|
||||
case MONKEY_ARCHER:
|
||||
case SPINOLYP:
|
||||
case SPINOLYP_2894:
|
||||
case BARRICADE:
|
||||
case BARRICADE_1534:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -1211,11 +1219,11 @@ public class NpcHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if (npcs[i].npcType == 1532 || npcs[i].npcType == 1534) {
|
||||
if (npcs[i].npcType == BARRICADE || npcs[i].npcType == BARRICADE_1534) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!followPlayer(i) && npcs[i].npcType != 1532 && npcs[i].npcType != 1534) {
|
||||
if (!followPlayer(i) && npcs[i].npcType != BARRICADE && npcs[i].npcType != BARRICADE_1534) {
|
||||
npcs[i].facePlayer(player);
|
||||
return;
|
||||
}
|
||||
@@ -1273,37 +1281,31 @@ public class NpcHandler {
|
||||
|
||||
/**
|
||||
* Distanced required to attack
|
||||
* If NPCs are maging in melee distance check that the NPC ID is actually in here.
|
||||
* It's also worth checking {@link NpcData#distanceRequired}
|
||||
**/
|
||||
public static int distanceRequired(int i) {
|
||||
switch (npcs[i].npcType) {
|
||||
case 2025:
|
||||
case 2028:
|
||||
case AHRIM_THE_BLIGHTED:
|
||||
case KARIL_THE_TAINTED:
|
||||
return 6;
|
||||
case 50:
|
||||
case 2562:
|
||||
case KING_BLACK_DRAGON:
|
||||
case COAL:
|
||||
return 2;
|
||||
case 2881:// dag kings
|
||||
case 2882:
|
||||
case 3200:// chaos ele
|
||||
case 2743:
|
||||
case 2631:
|
||||
case 2745:
|
||||
case DARK_WIZARD: // dark wizards
|
||||
case DARK_WIZARD_174:
|
||||
case DAGANNOTH_SUPREME:// dag kings
|
||||
case DAGANNOTH_PRIME:
|
||||
case CHAOS_ELEMENTAL:// chaos ele
|
||||
case KETZEK:
|
||||
case TOKXIL:
|
||||
case TZTOKJAD:
|
||||
return 8;
|
||||
case 2883:// rex
|
||||
case DAGANNOTH_REX:// rex
|
||||
return 1;
|
||||
case 2552:
|
||||
case 2553:
|
||||
case 2556:
|
||||
case 2557:
|
||||
case 2558:
|
||||
case 2559:
|
||||
case 2560:
|
||||
case 2564:
|
||||
case 2565:
|
||||
return 9;
|
||||
// things around dags
|
||||
case 2892:
|
||||
case 2894:
|
||||
case SPINOLYP:
|
||||
case SPINOLYP_2894:
|
||||
return 10;
|
||||
default:
|
||||
return 1;
|
||||
@@ -1312,15 +1314,10 @@ public class NpcHandler {
|
||||
|
||||
public static int followDistance(int i) {
|
||||
switch (npcs[i].npcType) {
|
||||
case 2550:
|
||||
case 2551:
|
||||
case 2562:
|
||||
case 2563:
|
||||
return 8;
|
||||
case 2883:
|
||||
case DAGANNOTH_REX:
|
||||
return 4;
|
||||
case 2881:
|
||||
case 2882:
|
||||
case DAGANNOTH_SUPREME:
|
||||
case DAGANNOTH_PRIME:
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
@@ -1328,21 +1325,21 @@ public class NpcHandler {
|
||||
|
||||
public static int getProjectileSpeed(int i) {
|
||||
switch (npcs[i].npcType) {
|
||||
case 2881:
|
||||
case 2882:
|
||||
case 3200:
|
||||
case DAGANNOTH_SUPREME:
|
||||
case DAGANNOTH_PRIME:
|
||||
case CHAOS_ELEMENTAL:
|
||||
return 85;
|
||||
|
||||
case 2745:
|
||||
case TZTOKJAD:
|
||||
return 130;
|
||||
|
||||
case 50:
|
||||
case KING_BLACK_DRAGON:
|
||||
return 90;
|
||||
|
||||
case 2025:
|
||||
case AHRIM_THE_BLIGHTED:
|
||||
return 85;
|
||||
|
||||
case 2028:
|
||||
case KARIL_THE_TAINTED:
|
||||
return 80;
|
||||
|
||||
default:
|
||||
@@ -1352,22 +1349,22 @@ public class NpcHandler {
|
||||
|
||||
public static int offset(int i) {
|
||||
switch (npcs[i].npcType) {
|
||||
case 50:
|
||||
case 110:
|
||||
case 941:
|
||||
case 1590:
|
||||
case 1591:
|
||||
case 1592:
|
||||
case 2642:
|
||||
case 55:
|
||||
case 54:
|
||||
case 53:
|
||||
case KING_BLACK_DRAGON:
|
||||
case FIRE_GIANT:
|
||||
case GREEN_DRAGON:
|
||||
case BRONZE_DRAGON:
|
||||
case IRON_DRAGON:
|
||||
case STEEL_DRAGON:
|
||||
case KING_BLACK_DRAGON_2642:
|
||||
case BLUE_DRAGON:
|
||||
case BLACK_DRAGON:
|
||||
case RED_DRAGON:
|
||||
return 2;
|
||||
case 2881:
|
||||
case 2882:
|
||||
case DAGANNOTH_SUPREME:
|
||||
case DAGANNOTH_PRIME:
|
||||
return 1;
|
||||
case 2745:
|
||||
case 2743:
|
||||
case TZTOKJAD:
|
||||
case KETZEK:
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
@@ -1384,13 +1381,13 @@ public class NpcHandler {
|
||||
}
|
||||
|
||||
public boolean retaliates(int npcType) {
|
||||
return npcType < 3777 || npcType > 3780
|
||||
&& !(npcType >= 2440 && npcType <= 2446);
|
||||
return npcType < PORTAL || npcType > PORTAL_3780
|
||||
&& !(npcType >= DOORSUPPORT && npcType <= DOORSUPPORT_2446);
|
||||
}
|
||||
|
||||
public static void handleSpecialEffects(Player c, int i, int damage) {
|
||||
if (npcs[i].npcType == 2892 || npcs[i].npcType == 2894 || npcs[i].npcType == 1158
|
||||
|| npcs[i].npcType == 1160) {
|
||||
if (npcs[i].npcType == SPINOLYP || npcs[i].npcType == SPINOLYP_2894 || npcs[i].npcType == KALPHITE_QUEEN
|
||||
|| npcs[i].npcType == KALPHITE_QUEEN_1160) {
|
||||
if (damage > 0) {
|
||||
if (c != null) {
|
||||
if (c.playerLevel[Constants.PRAYER] > 0) {
|
||||
@@ -1417,21 +1414,11 @@ public class NpcHandler {
|
||||
|
||||
public static int getMaxHit(int i) {
|
||||
switch (npcs[i].npcType) {
|
||||
case 1158:
|
||||
case KALPHITE_QUEEN:
|
||||
return 30;
|
||||
case 2558:
|
||||
if (npcs[i].attackType == 2) {
|
||||
return 28;
|
||||
} else {
|
||||
return 68;
|
||||
}
|
||||
case 1265:
|
||||
case 1267:
|
||||
case ROCK_CRAB:
|
||||
case ROCK_CRAB_1267:
|
||||
return 2;
|
||||
case 2562:
|
||||
return 31;
|
||||
case 2550:
|
||||
return 36;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -1467,7 +1454,7 @@ public class NpcHandler {
|
||||
spawn.getStrength());
|
||||
}
|
||||
} catch (FileNotFoundException fileex) {
|
||||
Misc.println("spawns.json: file not found.");
|
||||
System.out.println("spawns.json: file not found.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1484,13 +1471,13 @@ public class NpcHandler {
|
||||
try {
|
||||
characterfile = new BufferedReader(new FileReader(FileName));
|
||||
} catch (FileNotFoundException fileex) {
|
||||
Misc.println(FileName + ": file not found.");
|
||||
System.out.println(FileName + ": file not found.");
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
line = characterfile.readLine();
|
||||
} catch (IOException ioexception) {
|
||||
Misc.println(FileName + ": error loading file.");
|
||||
System.out.println(FileName + ": error loading file.");
|
||||
// return false;
|
||||
}
|
||||
while (EndOfFile == false && line != null) {
|
||||
@@ -1581,7 +1568,7 @@ public class NpcHandler {
|
||||
newNPCList(npc.getId(), npc.getName(), npc.getCombat(), npc.getHitpoints());
|
||||
}
|
||||
} catch (FileNotFoundException fileex) {
|
||||
Misc.println("npc.json: file not found.");
|
||||
System.out.println("npc.json: file not found.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1597,14 +1584,14 @@ public class NpcHandler {
|
||||
try {
|
||||
characterfile = new BufferedReader(new FileReader(FileName));
|
||||
} catch (FileNotFoundException fileex) {
|
||||
Misc.println(FileName + ": file not found.");
|
||||
System.out.println(FileName + ": file not found.");
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
line = characterfile.readLine();
|
||||
// characterfile.close();
|
||||
} catch (IOException ioexception) {
|
||||
Misc.println(FileName + ": error loading file.");
|
||||
System.out.println(FileName + ": error loading file.");
|
||||
// return false;
|
||||
}
|
||||
while (EndOfFile == false && line != null) {
|
||||
|
||||
@@ -28,7 +28,7 @@ public class NPCDropsHandler {
|
||||
try {
|
||||
npcDrops = new Gson().fromJson(new FileReader("./data/cfg/npcdrops.json"), NpcDrop[].class);
|
||||
} catch (FileNotFoundException fileex) {
|
||||
Misc.println("npcdrops.json: file not found.");
|
||||
System.out.println("npcdrops.json: file not found.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -106,10 +106,15 @@ public class ObjectsActions {
|
||||
PassDoor.processDoor(player, objectType);
|
||||
AbyssalHandler.handleAbyssalTeleport(player, objectType);
|
||||
OpenObject.interactObject(player, objectType);
|
||||
if (Stalls.isObject(objectType)) {
|
||||
if (Stalls.isObject(objectType)) {
|
||||
Stalls.attemptStall(player, objectType, objectX, objectY);
|
||||
return;
|
||||
}
|
||||
//Prevent players getting stuck in level 28 wildy
|
||||
if (objectType == 1752 && objectX == 3154 && objectY == 3743) {
|
||||
player.getPacketSender().sendMessage("You find that ladder leads nowhere...");
|
||||
return;
|
||||
}
|
||||
switch (objectType) {
|
||||
case 6969: // Swamp Boaty
|
||||
if (player.objectX == 3523 && player.objectY == 3284)
|
||||
|
||||
@@ -75,6 +75,7 @@ import org.apollo.util.security.IsaacRandom;
|
||||
public abstract class Player {
|
||||
|
||||
public byte buffer[] = null;
|
||||
private long lastHomeTeleport = 0;
|
||||
public String lastConnectedFrom;
|
||||
public int xpRate = 1;
|
||||
public String discordCode;
|
||||
@@ -144,11 +145,37 @@ public abstract class Player {
|
||||
private GateHandler gateHandler = new GateHandler();
|
||||
private SingleGates singleGates = new SingleGates();
|
||||
private DoubleGates doubleGates = new DoubleGates();
|
||||
|
||||
private Map<Integer, Integer> npcKillCounts = new HashMap<>();
|
||||
public boolean displayBossKcMessages = false;
|
||||
public boolean displaySlayerKcMessages = false;
|
||||
public boolean displayRegularKcMessages = false;
|
||||
|
||||
public int getNpcKillCount(int npcId) {
|
||||
return npcKillCounts.getOrDefault(npcId, 0);
|
||||
}
|
||||
|
||||
public Map<Integer, Integer> getNpcKillCounts() {
|
||||
return npcKillCounts;
|
||||
}
|
||||
|
||||
public void incrementNpcKillCount(int npcId, int count) {
|
||||
npcKillCounts.put(npcId, npcKillCounts.getOrDefault(npcId, 0) + count);
|
||||
}
|
||||
|
||||
public int lastMainFrameInterface = -1; //Possibly used in future to prevent packet exploits
|
||||
|
||||
public int getXPRate() { return xpRate; }
|
||||
|
||||
public void setXPRate(int xpRate) { this.xpRate = xpRate; }
|
||||
|
||||
public long getLastHomeTeleport() {
|
||||
return lastHomeTeleport;
|
||||
}
|
||||
|
||||
public void setLastHomeTeleport(long lastHomeTeleport) {
|
||||
this.lastHomeTeleport = lastHomeTeleport;
|
||||
}
|
||||
|
||||
public String getDiscordCode() { return discordCode; }
|
||||
|
||||
@@ -606,7 +633,7 @@ public abstract class Player {
|
||||
System.out.println("EverythingRS API Disabled, highscores not saved!");
|
||||
}
|
||||
|
||||
Misc.println("[DEREGISTERED]: " + playerName + "");
|
||||
System.out.println("[DEREGISTERED]: " + playerName + "");
|
||||
// HostList.getHostList().remove(session);
|
||||
CycleEventHandler.getSingleton().stopEvents(this);
|
||||
disconnected = true;
|
||||
@@ -908,9 +935,9 @@ public abstract class Player {
|
||||
}
|
||||
}
|
||||
|
||||
if (followId > 0) {
|
||||
if (followPlayerId > 0) {
|
||||
getPlayerAssistant().followPlayer();
|
||||
} else if (followId2 > 0) {
|
||||
} else if (followNpcId > 0) {
|
||||
getPlayerAssistant().followNpc();
|
||||
}
|
||||
|
||||
@@ -1342,7 +1369,7 @@ public abstract class Player {
|
||||
|
||||
public int miningAxe = -1, woodcuttingAxe = -1;
|
||||
|
||||
public boolean initialized, musicOn = true, luthas,
|
||||
public boolean initialized, musicOn = true, soundOn = true, luthas,
|
||||
playerIsCooking, disconnected, ruleAgreeButton,
|
||||
rebuildNPCList, isActive, isKicked,
|
||||
isSkulled, friendUpdate, newPlayer,
|
||||
@@ -1378,8 +1405,8 @@ public abstract class Player {
|
||||
dialogueId, randomCoffin, newLocation, specEffect,
|
||||
specBarId, attackLevelReq, defenceLevelReq, strengthLevelReq,
|
||||
rangeLevelReq, magicLevelReq, slayerLevelReq, agilityLevelReq,
|
||||
followId, skullTimer, nextChat = 0, talkingNpc = -1,
|
||||
dialogueAction = 0, autocastId, followDistance, followId2,
|
||||
followPlayerId, skullTimer, nextChat = 0, talkingNpc = -1,
|
||||
dialogueAction = 0, autocastId, followDistance, followNpcId,
|
||||
barrageCount = 0, delayedDamage = 0, delayedDamage2 = 0,
|
||||
pcPoints = 0, magePoints = 0, desertTreasure = 0, skillAmount,
|
||||
lastArrowUsed = -1, autoRet = 1, pcDamage = 0, xInterfaceId = 0,
|
||||
|
||||
@@ -567,7 +567,7 @@ public class PlayerAssistant {
|
||||
|
||||
|
||||
public void stepAway() {
|
||||
player.faceUpdate(player.followId + 32768);
|
||||
player.faceUpdate(player.followPlayerId + 32768);
|
||||
if (Region.getClipping(player.getX() - 1, player.getY(), player.heightLevel, -1, 0)) {
|
||||
walkTo(-1, 0);
|
||||
} else if (Region.getClipping(player.getX() + 1, player.getY(), player.heightLevel, 1, 0)) {
|
||||
@@ -1345,7 +1345,7 @@ public class PlayerAssistant {
|
||||
public void resetFollowers() {
|
||||
for (Player player : PlayerHandler.players) {
|
||||
if (player != null) {
|
||||
if (player.followId == player.playerId) {
|
||||
if (player.followPlayerId == player.playerId) {
|
||||
Client c = (Client) player;
|
||||
c.getPlayerAssistant().resetFollow();
|
||||
}
|
||||
@@ -1623,8 +1623,8 @@ public class PlayerAssistant {
|
||||
}
|
||||
|
||||
public void followPlayer() {
|
||||
if (PlayerHandler.players[player.followId] == null
|
||||
|| PlayerHandler.players[player.followId].isDead) {
|
||||
if (PlayerHandler.players[player.followPlayerId] == null
|
||||
|| PlayerHandler.players[player.followPlayerId].isDead) {
|
||||
resetFollow();
|
||||
return;
|
||||
}
|
||||
@@ -1635,38 +1635,38 @@ public class PlayerAssistant {
|
||||
return;
|
||||
}
|
||||
|
||||
int otherX = PlayerHandler.players[player.followId].getX();
|
||||
int otherY = PlayerHandler.players[player.followId].getY();
|
||||
int otherX = PlayerHandler.players[player.followPlayerId].getX();
|
||||
int otherY = PlayerHandler.players[player.followPlayerId].getY();
|
||||
|
||||
if (!player.goodDistance(otherX, otherY, player.getX(), player.getY(),
|
||||
25)) {
|
||||
player.followId = 0;
|
||||
player.followPlayerId = 0;
|
||||
resetFollow();
|
||||
return;
|
||||
}
|
||||
|
||||
int[] follow = getFollowLocation(otherX, otherY);
|
||||
player.faceUpdate(player.followId + 32768);
|
||||
player.faceUpdate(player.followPlayerId + 32768);
|
||||
PathFinder.getPathFinder().findRoute(player, follow[0], follow[1], false, 1, 1);
|
||||
}
|
||||
|
||||
|
||||
public void followNpc() {
|
||||
Npc npc = NpcHandler.npcs[player.followId2];
|
||||
Npc npc = NpcHandler.npcs[player.followNpcId];
|
||||
if (npc == null || npc.isDead) {
|
||||
return;
|
||||
}
|
||||
|
||||
int x = NpcHandler.npcs[player.followId2].getX();
|
||||
int y = NpcHandler.npcs[player.followId2].getY();
|
||||
int x = NpcHandler.npcs[player.followNpcId].getX();
|
||||
int y = NpcHandler.npcs[player.followNpcId].getY();
|
||||
if (!player.goodDistance(x, y, player.getX(), player.getY(), 25)) {
|
||||
player.followId2 = 0;
|
||||
player.followNpcId = 0;
|
||||
resetFollow();
|
||||
return;
|
||||
}
|
||||
|
||||
int[] follow = getFollowLocation(x, y);
|
||||
player.faceUpdate(player.followId2);
|
||||
player.faceUpdate(player.followNpcId);
|
||||
PathFinder.getPathFinder().findRoute(player, follow[0], follow[1], false, 1, 1);
|
||||
}
|
||||
|
||||
@@ -1681,8 +1681,8 @@ public class PlayerAssistant {
|
||||
}
|
||||
|
||||
public void resetFollow() {
|
||||
player.followId = 0;
|
||||
player.followId2 = 0;
|
||||
player.followPlayerId = 0;
|
||||
player.followNpcId = 0;
|
||||
player.mageFollow = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public class PlayerHandler {
|
||||
players[slot].isActive = true;
|
||||
players[slot].connectedFrom = client1.isBot ? "127.0.0.1" : ((InetSocketAddress) client1.getSession().getRemoteAddress()).getAddress().getHostAddress();
|
||||
if (Constants.SERVER_DEBUG) {
|
||||
Misc.println("Player Slot " + slot + " slot 0 " + players[0]
|
||||
System.out.println("Player Slot " + slot + " slot 0 " + players[0]
|
||||
+ " Player Hit " + players[slot]);
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Base64;
|
||||
import java.util.Map;
|
||||
|
||||
import com.rs2.util.Misc;
|
||||
|
||||
@@ -44,14 +45,14 @@ public class PlayerSave {
|
||||
//it's the .gitignore :P
|
||||
return 0;
|
||||
}
|
||||
Misc.println(playerName + ": character file not found.");
|
||||
System.out.println(playerName + ": character file not found.");
|
||||
player.newPlayer = false;
|
||||
return 0;
|
||||
}
|
||||
try {
|
||||
line = characterfile.readLine();
|
||||
} catch (IOException ioexception) {
|
||||
Misc.println(playerName + ": error loading file.");
|
||||
System.out.println(playerName + ": error loading file.");
|
||||
return 3;
|
||||
}
|
||||
while (EndOfFile == false && line != null) {
|
||||
@@ -209,6 +210,9 @@ public class PlayerSave {
|
||||
case "musicOn":
|
||||
player.musicOn = Boolean.parseBoolean(token2);
|
||||
break;
|
||||
case "soundOn":
|
||||
player.soundOn = Boolean.parseBoolean(token2);
|
||||
break;
|
||||
case "barrowsNpcs":
|
||||
player.barrowsNpcs[Integer.parseInt(token3[0])][1] = Integer.parseInt(token3[1]);
|
||||
break;
|
||||
@@ -436,6 +440,15 @@ public class PlayerSave {
|
||||
case "discord-user-id":
|
||||
player.discordCode = token2;
|
||||
break;
|
||||
case "display-boss-kc-messages":
|
||||
player.displayBossKcMessages = Boolean.parseBoolean(token2);
|
||||
break;
|
||||
case "display-slayer-kc-messages":
|
||||
player.displaySlayerKcMessages = Boolean.parseBoolean(token2);
|
||||
break;
|
||||
case "display-regular-kc-messages":
|
||||
player.displayRegularKcMessages = Boolean.parseBoolean(token2);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
@@ -477,6 +490,16 @@ public class PlayerSave {
|
||||
if (token.equals("character-ignore")) {
|
||||
player.ignores[Integer.parseInt(token3[0])] = Long.parseLong(token3[1]);
|
||||
}
|
||||
case 10:
|
||||
if (token.startsWith("npcid-")) {
|
||||
try {
|
||||
int npcId = Integer.parseInt(token.substring(6));
|
||||
int killCount = Integer.parseInt(token2);
|
||||
player.incrementNpcKillCount(npcId, killCount);
|
||||
} catch (NumberFormatException e) {
|
||||
System.out.println("Error parsing NPC kill count for " + token);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
@@ -508,6 +531,9 @@ public class PlayerSave {
|
||||
case "[IGNORES]":
|
||||
ReadMode = 9;
|
||||
break;
|
||||
case "[NPC-KILLS]":
|
||||
ReadMode = 10;
|
||||
break;
|
||||
case "[EOF]":
|
||||
try {
|
||||
characterfile.close();
|
||||
@@ -728,6 +754,8 @@ public class PlayerSave {
|
||||
characterfile.newLine();
|
||||
characterfile.write("musicOn = " + player.musicOn);
|
||||
characterfile.newLine();
|
||||
characterfile.write("soundOn = " + player.soundOn);
|
||||
characterfile.newLine();
|
||||
characterfile.write("needsNewTask = " + player.needsNewTask);
|
||||
characterfile.newLine();
|
||||
characterfile.write("luthas = " + player.luthas);
|
||||
@@ -828,6 +856,12 @@ public class PlayerSave {
|
||||
characterfile.newLine();
|
||||
characterfile.write("discord-user-id = " + player.discordCode);
|
||||
characterfile.newLine();
|
||||
characterfile.write("display-boss-kc-messages = " + player.displayBossKcMessages);
|
||||
characterfile.newLine();
|
||||
characterfile.write("display-slayer-kc-messages = " + player.displaySlayerKcMessages);
|
||||
characterfile.newLine();
|
||||
characterfile.write("display-regular-kc-messages = " + player.displayRegularKcMessages);
|
||||
characterfile.newLine();
|
||||
characterfile.newLine();
|
||||
|
||||
/* EQUIPMENT */
|
||||
@@ -900,12 +934,20 @@ public class PlayerSave {
|
||||
}
|
||||
characterfile.newLine();
|
||||
|
||||
characterfile.write("[NPC-KILLS]");
|
||||
characterfile.newLine();
|
||||
for (Map.Entry<Integer, Integer> entry : player.getNpcKillCounts().entrySet()) {
|
||||
characterfile.write("npcid-" + entry.getKey() + " = " + entry.getValue());
|
||||
characterfile.newLine();
|
||||
}
|
||||
characterfile.newLine();
|
||||
|
||||
/* EOF */
|
||||
characterfile.write("[EOF]");
|
||||
characterfile.newLine();
|
||||
characterfile.close();
|
||||
} catch (IOException ioexception) {
|
||||
Misc.println(player.playerName + ": error writing file.");
|
||||
System.out.println(player.playerName + ": error writing file.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -70,7 +70,7 @@ public class Trading {
|
||||
player.getPacketSender().sendMessage("Other player is busy at the moment.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Misc.println("Error requesting trade.");
|
||||
System.out.println("Error requesting trade.");
|
||||
}
|
||||
}
|
||||
public boolean isCloseTo(Client tradedPlayer) {
|
||||
|
||||
@@ -142,7 +142,7 @@ public class ShopHandler {
|
||||
totalshops++;
|
||||
}
|
||||
} catch (FileNotFoundException fileex) {
|
||||
Misc.println("shops.json: file not found.");
|
||||
System.out.println("shops.json: file not found.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,13 +157,13 @@ public class ShopHandler {
|
||||
try {
|
||||
characterfile = new BufferedReader(new FileReader("./data/cfg/" + FileName));
|
||||
} catch (FileNotFoundException fileex) {
|
||||
Misc.println(FileName + ": file not found.");
|
||||
System.out.println(FileName + ": file not found.");
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
line = characterfile.readLine();
|
||||
} catch (IOException ioexception) {
|
||||
Misc.println(FileName + ": error loading file.");
|
||||
System.out.println(FileName + ": error loading file.");
|
||||
}
|
||||
while (EndOfFile == false && line != null) {
|
||||
line = line.trim();
|
||||
|
||||
@@ -191,7 +191,7 @@ public class PacketSender {
|
||||
player.getItemAssistant().addSpecialBar(player.playerEquipment[player.playerWeapon]);
|
||||
player.saveTimer = Constants.SAVE_TIMER;
|
||||
player.saveCharacter = true;
|
||||
Misc.println((player.isBot ? "[BOT-REGISTERED]" : "[REGISTERED]") + ": " + player.playerName + " (level-" + player.calculateCombatLevel() + ")");
|
||||
System.out.println((player.isBot ? "[BOT-REGISTERED]" : "[REGISTERED]") + ": " + player.playerName + " (level-" + player.calculateCombatLevel() + ")");
|
||||
player.handler.updatePlayer(player, player.outStream);
|
||||
player.handler.updateNPC(player, player.outStream);
|
||||
player.flushOutStream();
|
||||
@@ -1165,6 +1165,9 @@ public class PacketSender {
|
||||
*/
|
||||
|
||||
public PacketSender sendSound(int id, int volume, int delay) {
|
||||
if (player != null && !player.soundOn) {
|
||||
return this;
|
||||
}
|
||||
frame174(id, volume, delay);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.rs2.net.packets;
|
||||
|
||||
import com.rs2.Constants;
|
||||
import com.rs2.event.impl.ObjectFifthClickEvent;
|
||||
import com.rs2.game.dialogues.Dialogue;
|
||||
import com.rs2.game.players.Player;
|
||||
import com.rs2.net.Packet;
|
||||
@@ -135,6 +136,7 @@ public class PacketHandler {
|
||||
packetId[121] = cr;
|
||||
packetId[210] = cr;
|
||||
packetId[253] = new ItemClick2OnGroundItem();
|
||||
packetId[228] = new ClickObject();
|
||||
// packetId[ContinueDialoguePacketHandler.CONTINUE] = new
|
||||
// ContinueDialoguePacketHandler();
|
||||
}
|
||||
@@ -172,7 +174,7 @@ public class PacketHandler {
|
||||
}
|
||||
} else {
|
||||
player.disconnected = true;
|
||||
System.out.println(player.playerName + "is sending invalid PacketType: " + packetType + ". PacketSize: " + packetSize);
|
||||
System.out.println(player.playerName + " is sending invalid PacketType: " + packetType + ". PacketSize: " + packetSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ public class AttackPlayer implements PacketType {
|
||||
return;
|
||||
}
|
||||
if (player.getCombatAssistant().checkReqs()) {
|
||||
player.followId = player.playerIndex;
|
||||
player.followPlayerId = player.playerIndex;
|
||||
if (!player.usingMagic && !usingBow && !usingOtherRangeWeapons) {
|
||||
player.followDistance = 1;
|
||||
player.getPlayerAssistant().followPlayer();
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.rs2.event.CycleEventHandler;
|
||||
import com.rs2.event.impl.NpcFirstClickEvent;
|
||||
import com.rs2.event.impl.NpcSecondClickEvent;
|
||||
import com.rs2.event.impl.NpcThirdClickEvent;
|
||||
import com.rs2.game.content.StaticNpcList;
|
||||
import com.rs2.game.content.combat.CombatConstants;
|
||||
import com.rs2.game.content.combat.magic.MagicData;
|
||||
import com.rs2.game.content.combat.range.RangeData;
|
||||
@@ -152,7 +153,7 @@ public class ClickNPC implements PacketType {
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.followId > 0) {
|
||||
if (player.followPlayerId > 0) {
|
||||
player.getPlayerAssistant().resetFollow();
|
||||
}
|
||||
if (player.attackTimer <= 0) {
|
||||
@@ -198,7 +199,7 @@ public class ClickNPC implements PacketType {
|
||||
}
|
||||
|
||||
if (NpcHandler.npcs[player.npcIndex].MaxHP == 0
|
||||
|| NpcHandler.npcs[player.npcIndex].npcType == 944) {
|
||||
|| NpcHandler.npcs[player.npcIndex].npcType == StaticNpcList.COMBAT_INSTRUCTOR) {
|
||||
player.getPacketSender().sendMessage(
|
||||
"You can't attack this npc.");
|
||||
break;
|
||||
|
||||
@@ -23,7 +23,7 @@ import com.rs2.world.clip.Region;
|
||||
public class ClickObject implements PacketType {
|
||||
|
||||
public static final int FIRST_CLICK = 132, SECOND_CLICK = 252,
|
||||
THIRD_CLICK = 70, FOURTH_CLICK = 234;
|
||||
THIRD_CLICK = 70, FOURTH_CLICK = 234, FIFTH_CLICK = 228;
|
||||
|
||||
public void onObjectReached(Player player, Consumer<Player> consumer) {
|
||||
if (System.currentTimeMillis() - player.clickDelay < 300)
|
||||
@@ -115,6 +115,12 @@ public class ClickObject implements PacketType {
|
||||
player.objectY = packet.readUnsignedWordBigEndianA();
|
||||
onObjectReached(player, (p) -> completeObjectClick(p, 4));
|
||||
break;
|
||||
case FIFTH_CLICK:
|
||||
player.objectId = packet.readUnsignedWordA();
|
||||
player.objectY = packet.readUnsignedWordA();
|
||||
player.objectX = packet.readUnsignedWord();
|
||||
onObjectReached(player, (p) -> completeObjectClick(p, 5));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +225,13 @@ public class ClickObject implements PacketType {
|
||||
case 8929:
|
||||
player.fade(2442, 10147, 0);
|
||||
break;
|
||||
|
||||
|
||||
case 12230: // Mole lair rope
|
||||
if (player.objectX == 1752 && player.objectY == 5136) {
|
||||
player.getPlayerAssistant().movePlayer(2997, 3375, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1568:
|
||||
if (player.objectX == 2399 && player.objectY == 3099) {
|
||||
player.getPacketSender()
|
||||
|
||||
@@ -32,7 +32,7 @@ public class ClickingStuff implements PacketType {
|
||||
player.tradeConfirmed2 = false;
|
||||
player.getPacketSender().sendMessage("@red@Trade has been declined.");
|
||||
opponent.getPacketSender().sendMessage("@red@Other player has declined the trade.");
|
||||
Misc.println("trade reset");
|
||||
System.out.println("trade reset");
|
||||
player.getTrading().declineTrade();
|
||||
opponent.getTrading().declineTrade();
|
||||
}
|
||||
|
||||
@@ -2,12 +2,13 @@ package com.rs2.net.packets.impl;
|
||||
|
||||
import static com.rs2.util.GameLogger.writeLog;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.*;
|
||||
|
||||
import com.rs2.Connection;
|
||||
import com.rs2.Constants;
|
||||
import com.rs2.GameEngine;
|
||||
import com.rs2.game.bots.BotHandler;
|
||||
import com.rs2.game.npcs.NPCDefinition;
|
||||
import com.rs2.game.npcs.NpcHandler;
|
||||
import com.rs2.game.players.*;
|
||||
import com.rs2.game.players.antimacro.AntiSpam;
|
||||
@@ -19,6 +20,7 @@ import com.rs2.world.clip.Region;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class Commands implements PacketType {
|
||||
|
||||
@@ -48,10 +50,25 @@ public class Commands implements PacketType {
|
||||
switch (playerCommand.toLowerCase()) {
|
||||
case "stuck":
|
||||
if(JavaCord.token != null) {
|
||||
if (JavaCord.api.getTextChannelById(JavaCord.logChannelId).isPresent())
|
||||
if (JavaCord.api != null && JavaCord.api.getTextChannelById(JavaCord.logChannelId).isPresent())
|
||||
JavaCord.api.getTextChannelById(JavaCord.logChannelId).get().sendMessage(player.playerName + " used ::stuck at X/Y: " + player.absX + "/" + player.absY);
|
||||
}
|
||||
System.err.println("Player " + player.playerName + " used ::stuck at X/Y: " + player.absX + "/" + player.absY);
|
||||
player.getPlayerAssistant().spellTeleport(Constants.RESPAWN_X, Constants.RESPAWN_Y, 0);
|
||||
break;
|
||||
case "home":
|
||||
long currentTime = System.currentTimeMillis();
|
||||
long cooldown = 30 * 60 * 1000; // 30 minutes in milliseconds
|
||||
if (player.getLastHomeTeleport() == 0 || (currentTime - player.getLastHomeTeleport() >= cooldown)) {
|
||||
player.getPlayerAssistant().spellTeleport(Constants.RESPAWN_X, Constants.RESPAWN_Y, 0);
|
||||
player.setLastHomeTeleport(currentTime); // Update the last teleport time
|
||||
} else {
|
||||
long remainingTime = cooldown - (currentTime - player.getLastHomeTeleport());
|
||||
long minutesLeft = TimeUnit.MILLISECONDS.toMinutes(remainingTime);
|
||||
long secondsLeft = TimeUnit.MILLISECONDS.toSeconds(remainingTime) - TimeUnit.MINUTES.toSeconds(minutesLeft);
|
||||
player.getPacketSender().sendMessage("You need to wait " + minutesLeft + " minutes and " + secondsLeft + " seconds to use home teleport again.");
|
||||
}
|
||||
break;
|
||||
case "link":
|
||||
player.setDiscordCode(arguments[0]);
|
||||
player.getPacketSender().sendMessage("Your Account has now been linked with Discord User ID:");
|
||||
@@ -65,6 +82,10 @@ public class Commands implements PacketType {
|
||||
}
|
||||
case "xprate":
|
||||
if(Constants.VARIABLE_XP_RATE) {
|
||||
if (arguments.length < 1 || !arguments[0].equals("confirm")) {
|
||||
player.getPacketSender().sendMessage("You must type \"::xprate confirm\" to view the dialogue to change your XP rate.");
|
||||
return;
|
||||
}
|
||||
if (player.getXPRate() == Constants.VARIABLE_XP_RATES[0]) {
|
||||
player.getDialogueHandler().sendDialogues(10005, 2244);
|
||||
return;
|
||||
@@ -190,7 +211,7 @@ public class Commands implements PacketType {
|
||||
if (count != 1) {
|
||||
player.getPacketSender().sendMessage("There are currently " + count + " " + (playerCommand.equalsIgnoreCase("players") ? "players" : "player shops") + " online (" + PlayerHandler.getNonPlayerCount() + " staff member online).");
|
||||
} else {
|
||||
player.getPacketSender().sendMessage("There is currently " + count + " " + (playerCommand.equalsIgnoreCase("players") ? "player" : "player shop") + " online (\" + PlayerHandler.getNonPlayerCount() + \" staff member online).");
|
||||
player.getPacketSender().sendMessage("There is currently " + count + " " + (playerCommand.equalsIgnoreCase("players") ? "player" : "player shop") + " online (" + PlayerHandler.getNonPlayerCount() + " staff member online).");
|
||||
}
|
||||
String[] players = new String[count];
|
||||
|
||||
@@ -205,7 +226,13 @@ public class Commands implements PacketType {
|
||||
|
||||
|
||||
// Clear all lines
|
||||
for (int i = 8144; i < 8195; i++) player.getPacketSender().sendString("", i);
|
||||
for (int i = 8144; i < 8196; i++) player.getPacketSender().sendString("", i);
|
||||
for (int i = 12174; i < (12174 + 50); i++) {
|
||||
player.getPacketSender().sendString( "", i);
|
||||
}
|
||||
for (int i = 14945; i < (14945 + 100); i++) {
|
||||
player.getPacketSender().sendString("", i);
|
||||
}
|
||||
|
||||
player.getPacketSender().sendString("@dre@" + (playerCommand.equalsIgnoreCase("players") ? "Players" : "Player Shops"), 8144);
|
||||
|
||||
@@ -219,6 +246,135 @@ public class Commands implements PacketType {
|
||||
case "prayer":
|
||||
player.getPacketSender().sendMessage(String.format("Prayer points: %d", player.playerLevel[Constants.PRAYER]));
|
||||
break;
|
||||
case "togglenpckillmsgs":
|
||||
case "togglenpckillmsg":
|
||||
case "togglenpckcmsgs":
|
||||
case "togglenpckcmsg":
|
||||
player.displayRegularKcMessages = !player.displayRegularKcMessages;
|
||||
player.getPacketSender().sendMessage("You now have regular NPC kill count messages: " + (player.displayRegularKcMessages ? "enabled" : "disabled"));
|
||||
break;
|
||||
case "togglebosskillmsgs":
|
||||
case "togglebosskillmsg":
|
||||
case "togglebossksmsgs":
|
||||
case "togglebossksmsg":
|
||||
player.displayBossKcMessages = !player.displayBossKcMessages;
|
||||
player.getPacketSender().sendMessage("You now have boss NPC kill count messages: " + (player.displayBossKcMessages ? "enabled" : "disabled"));
|
||||
break;
|
||||
case "toggleslayerkillmsgs":
|
||||
case "toggleslayerkillmsg":
|
||||
case "toggleslayerkcmsgs":
|
||||
case "toggleslayerkcmsg":
|
||||
player.displaySlayerKcMessages = !player.displaySlayerKcMessages;
|
||||
player.getPacketSender().sendMessage("You now have slayer NPC kill count messages: " + (player.displaySlayerKcMessages ? "enabled" : "disabled"));
|
||||
break;
|
||||
case "kc":
|
||||
case "kills":
|
||||
case "checknpckill":
|
||||
case "checknpckills":
|
||||
if (arguments.length > 0) {
|
||||
// Combine all arguments into a single string, assuming space-separated
|
||||
String npcNameInput = String.join(" ", arguments).toLowerCase();
|
||||
try {
|
||||
// Try to parse as an ID
|
||||
int npcId = Integer.parseInt(arguments[0]);
|
||||
int killCount = player.getNpcKillCounts().getOrDefault(npcId, 0);
|
||||
String npcName = NPCDefinition.forId(npcId).getName();
|
||||
player.getPacketSender().sendMessage("Kill count for " + npcName + ": " + killCount);
|
||||
} catch (NumberFormatException e) {
|
||||
// If not an ID, treat as a name
|
||||
List<NPCDefinition> matchingDefs = new ArrayList<>();
|
||||
for (int id = 0; id <= 3789; id++) {
|
||||
try {
|
||||
NPCDefinition def = NPCDefinition.forId(id);
|
||||
if (def.getName().toLowerCase().startsWith(npcNameInput)) {
|
||||
matchingDefs.add(def);
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
System.err.println("Exception during kc command: " + exception.getMessage());
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (matchingDefs.isEmpty()) {
|
||||
player.getPacketSender().sendMessage("No NPCs found with the name: " + npcNameInput);
|
||||
} else {
|
||||
boolean empty = true;
|
||||
for (NPCDefinition def : matchingDefs) {
|
||||
int killCount = player.getNpcKillCounts().getOrDefault(def.getId(), 0);
|
||||
if (killCount > 0) {
|
||||
empty = false;
|
||||
player.getPacketSender().sendMessage("Kill count for " + def.getName() + " (ID: " + def.getId() + "): " + killCount);
|
||||
}
|
||||
}
|
||||
if (empty) {
|
||||
player.getPacketSender().sendMessage("Kill count for " + npcNameInput + ": 0");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
player.getPacketSender().sendMessage("Please provide an NPC ID or name.");
|
||||
}
|
||||
break;
|
||||
case "bosskillcounts":
|
||||
case "bosskillcount":
|
||||
case "bosskc":
|
||||
case "kcboss":
|
||||
// Clear all lines
|
||||
for (int i = 8144; i < 8196; i++) {
|
||||
player.getPacketSender().sendString("", i);
|
||||
}
|
||||
for (int i = 12174; i < (12174 + 50); i++) {
|
||||
player.getPacketSender().sendString("", i);
|
||||
}
|
||||
for (int i = 14945; i < (14945 + 100); i++) {
|
||||
player.getPacketSender().sendString("", i);
|
||||
}
|
||||
|
||||
player.getPacketSender().sendString("@dre@Boss Kill Counts", 8144);
|
||||
int bossLineId = 8147; // Starting line for display
|
||||
player.getPacketSender().sendString("Barrows Chests: " + player.getNpcKillCounts().getOrDefault(100000, 0), bossLineId++);
|
||||
for (Integer bossId : Constants.BOSS_NPC_IDS) {
|
||||
int killCount = player.getNpcKillCounts().getOrDefault(bossId, 0);
|
||||
String npcName = NPCDefinition.forId(bossId).getName();
|
||||
player.getPacketSender().sendString(npcName + ": " + killCount, bossLineId++);
|
||||
}
|
||||
|
||||
player.getPacketSender().showInterface(8134);
|
||||
break;
|
||||
case "slayerkillcounts":
|
||||
case "slayerkillcount":
|
||||
case "slayerkc":
|
||||
case "kcslayer":
|
||||
// Clear all lines
|
||||
for (int i = 8144; i < 8196; i++) {
|
||||
player.getPacketSender().sendString("", i);
|
||||
}
|
||||
for (int i = 12174; i < (12174 + 50); i++) {
|
||||
player.getPacketSender().sendString("", i);
|
||||
}
|
||||
for (int i = 14945; i < (14945 + 100); i++) {
|
||||
player.getPacketSender().sendString("", i);
|
||||
}
|
||||
|
||||
player.getPacketSender().sendString("@dre@Slayer Kill Counts", 8144);
|
||||
int slayerLineId = 8147; // Starting line for display
|
||||
|
||||
// LinkedHashMap to store cumulative kills by NPC name
|
||||
LinkedHashMap<String, Integer> nameToKills = new LinkedHashMap<>();
|
||||
|
||||
// Populate the HashMap
|
||||
for (Integer npcId : Constants.SLAYER_NPC_IDS) {
|
||||
String npcName = NPCDefinition.forId(npcId).getName();
|
||||
int killCount = player.getNpcKillCounts().getOrDefault(npcId, 0);
|
||||
nameToKills.put(npcName, nameToKills.getOrDefault(npcName, 0) + killCount);
|
||||
}
|
||||
|
||||
// Display the results
|
||||
for (Map.Entry<String, Integer> entry : nameToKills.entrySet()) {
|
||||
player.getPacketSender().sendString(entry.getKey() + ": " + entry.getValue(), slayerLineId++);
|
||||
}
|
||||
|
||||
player.getPacketSender().showInterface(8134);
|
||||
break;
|
||||
case "snow":
|
||||
Calendar date = new GregorianCalendar();
|
||||
if ((date.get(Calendar.MONTH) + 1) == 12 && !player.inWild()) {
|
||||
@@ -261,6 +417,9 @@ public class Commands implements PacketType {
|
||||
else
|
||||
player.gfx0(Integer.parseInt(arguments[0]));
|
||||
break;
|
||||
case "uptime":
|
||||
player.getPacketSender().sendMessage("The server has now been online for: " + Misc.getServerUptime(GameEngine.getServerStartTime()));
|
||||
break;
|
||||
case "tele":
|
||||
if (player.connectedFrom.equals("127.0.0.1")) {
|
||||
try {
|
||||
@@ -315,6 +474,24 @@ public class Commands implements PacketType {
|
||||
"::withdrawshop(::wshop)",
|
||||
"Withdraw profits from player owned shop",
|
||||
"",
|
||||
"::togglenpckillmsgs(::togglenpckcmsgs)",
|
||||
"Toggle regular NPC kill count message display","",
|
||||
"",
|
||||
"::togglebosskillmsgs(::togglebosskcmsgs)",
|
||||
"Toggle regular Boss kill count message display","",
|
||||
"",
|
||||
"::toggleslayerkillmsgs(::toggleslayerkcmsgs)",
|
||||
"Toggle regular Slayer kill count message display",
|
||||
"",
|
||||
"::kc(::checknpckills)",
|
||||
"Search for your NPC kills for an NPC name or ID",
|
||||
"",
|
||||
"::bosskc(::toggleslayerkcmsgs)",
|
||||
"View your boss kills",
|
||||
"",
|
||||
"::slayerkc(::toggleslayerkcmsgs)",
|
||||
"View your slayer kills",
|
||||
"",
|
||||
"::snow",
|
||||
"Add some snow in your mainscreen(works only in december)",
|
||||
(Constants.VARIABLE_XP_RATE ? "\\n" + "::xprate\\n" + "Opens dialogue for the player to set/increase their XP rate." : ""),
|
||||
@@ -322,9 +499,14 @@ public class Commands implements PacketType {
|
||||
};
|
||||
|
||||
// Clear all lines
|
||||
for (int i = 8144; i < 8195; i++)
|
||||
for (int i = 8144; i < 8196; i++)
|
||||
player.getPacketSender().sendString("", i);
|
||||
|
||||
for (int i = 12174; i < (12174 + 50); i++) {
|
||||
player.getPacketSender().sendString( "", i);
|
||||
}
|
||||
for (int i = 14945; i < (14945 + 100); i++) {
|
||||
player.getPacketSender().sendString("", i);
|
||||
}
|
||||
player.getPacketSender().sendString("@dre@Commands", 8144);
|
||||
|
||||
int commandsLineNumber = 8147;
|
||||
@@ -396,7 +578,13 @@ public class Commands implements PacketType {
|
||||
};
|
||||
|
||||
// Clear all lines
|
||||
for (int i = 8144; i < 8195; i++) player.getPacketSender().sendString("", i);
|
||||
for (int i = 8144; i < 8196; i++) player.getPacketSender().sendString("", i);
|
||||
for (int i = 12174; i < (12174 + 50); i++) {
|
||||
player.getPacketSender().sendString( "", i);
|
||||
}
|
||||
for (int i = 14945; i < (14945 + 100); i++) {
|
||||
player.getPacketSender().sendString("", i);
|
||||
}
|
||||
|
||||
player.getPacketSender().sendString("@dre@Highscores", 8144);
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ public class FollowPlayer implements PacketType {
|
||||
player.usingBow = false;
|
||||
player.usingRangeWeapon = false;
|
||||
player.followDistance = 1;
|
||||
player.followId = followPlayer;
|
||||
player.followPlayerId = followPlayer;
|
||||
player.endCurrentTask();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ public class ItemClick3 implements PacketType {
|
||||
default:
|
||||
|
||||
if (player.playerRights == 3) {
|
||||
Misc.println(player.playerName + " - Item3rdOption: " + itemId
|
||||
System.out.println(player.playerName + " - Item3rdOption: " + itemId
|
||||
+ " : " + itemId11 + " : " + itemId1);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -36,7 +36,7 @@ public class ItemOnGroundItem implements PacketType {
|
||||
|
||||
default:
|
||||
if (player.playerRights == 3) {
|
||||
Misc.println("ItemUsed " + itemUsed + " on Ground Item "
|
||||
System.out.println("ItemUsed " + itemUsed + " on Ground Item "
|
||||
+ groundItem);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -23,6 +23,10 @@ public class RemoveItem implements PacketType {
|
||||
if (!RareProtection.removeItem(player, removeId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (interfaceId == 1688 && removeSlot == 3) {
|
||||
player.getPlayerAssistant().resetAutocast();
|
||||
}
|
||||
|
||||
player.endCurrentTask();
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ public class Walking implements PacketType {
|
||||
if (player.canWalkTutorial == false && player.tutorialProgress < 36) {
|
||||
return;
|
||||
}
|
||||
if (player.followId > 0 || player.followId2 > 0) {
|
||||
if (player.followPlayerId > 0 || player.followNpcId > 0) {
|
||||
player.getPlayerAssistant().resetFollow();
|
||||
}
|
||||
if (player.getPlayerAction().checkWalking() == false) {
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
package com.rs2.util;
|
||||
|
||||
import java.io.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
public class CustomPrintStream extends PrintStream {
|
||||
private final SimpleDateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy hh:mm:ss a");
|
||||
private final String logType;
|
||||
private final FileWriter fileWriter;
|
||||
|
||||
private final boolean fileOutput;
|
||||
private final ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||
|
||||
public CustomPrintStream(OutputStream out, String logType, boolean fileOutput) throws IOException {
|
||||
super(out);
|
||||
this.fileOutput = fileOutput;
|
||||
StackTraceElement[] stackTrace = new Throwable().getStackTrace();
|
||||
boolean throwable = false;
|
||||
if (stackTrace.length > 2) {
|
||||
throwable = stackTrace[2].getFileName() != null && stackTrace[2].getFileName().replace(".java", "").equals("Throwable");
|
||||
}
|
||||
this.logType = throwable ? "ERROR" : logType;
|
||||
String date = new SimpleDateFormat("MM_dd_yyyy").format(new Date());
|
||||
String logFileName = "data/logs/server_" + logType.toLowerCase() + "_" + date + ".log";
|
||||
File logFile = this.fileOutput ? new File(logFileName) : null;
|
||||
if (logFile != null) {
|
||||
logFile.getParentFile().mkdirs(); // Ensure the directory exists
|
||||
}
|
||||
this.fileWriter = logFile != null ? new FileWriter(logFile, true) : null;
|
||||
}
|
||||
|
||||
private void log(String message) {
|
||||
// Get calling class and method
|
||||
StackTraceElement[] stack = Thread.currentThread().getStackTrace();
|
||||
// Set the default caller if we can't find the class for some reason
|
||||
String caller = "Unknown";
|
||||
if (stack.length > 3) {
|
||||
StackTraceElement elem = stack[3];
|
||||
String className = elem.getClassName();
|
||||
// Remove instance from class name since we care about files, not objects
|
||||
className = className.replaceAll("\\$.*", "");
|
||||
String simpleClassName = className.substring(className.lastIndexOf('.') + 1); // Get simple class name
|
||||
String methodName = elem.getMethodName();
|
||||
caller = simpleClassName + "." + methodName + "()";
|
||||
}
|
||||
|
||||
// Construct log message
|
||||
String logMessage = String.format("[%s] [%s] [%s] %s", dateFormat.format(new Date()), logType.toUpperCase(), caller, message);
|
||||
|
||||
// Print to console and file
|
||||
super.println(logMessage);
|
||||
if (this.fileOutput) {
|
||||
executor.submit(() -> {
|
||||
try {
|
||||
fileWriter.write(logMessage + "\n");
|
||||
fileWriter.flush();
|
||||
} catch (IOException e) {
|
||||
super.println("Failed to write to log file: " + e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(String x) {
|
||||
log(x);
|
||||
}
|
||||
|
||||
public void close() {
|
||||
this.executor.shutdown();
|
||||
if (fileWriter != null) {
|
||||
try {
|
||||
fileWriter.close();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void test() throws IOException {
|
||||
CustomPrintStream infoPrintStream = new CustomPrintStream(System.out, "INFO", true);
|
||||
System.setOut(infoPrintStream);
|
||||
CustomPrintStream errorPrintStream = new CustomPrintStream(System.err, "ERROR", true);
|
||||
System.setErr(errorPrintStream);
|
||||
|
||||
System.out.println("This is a test message.");
|
||||
System.out.println("This is another test message.");
|
||||
System.err.println("This is an error message.");
|
||||
System.err.println("This is another error message.");
|
||||
|
||||
infoPrintStream.close();
|
||||
errorPrintStream.close();
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
CustomPrintStream.test();
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,16 @@
|
||||
package com.rs2.util;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import com.google.gson.Gson;
|
||||
import com.rs2.game.players.Player;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.text.*;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class Misc {
|
||||
|
||||
@@ -76,9 +85,194 @@ public class Misc {
|
||||
return new String(ac, 12 - i, i);
|
||||
}
|
||||
|
||||
public static String format(int num) {
|
||||
return NumberFormat.getInstance().format(num);
|
||||
}
|
||||
/**
|
||||
* Formats digits for integers.
|
||||
*
|
||||
* @param amount
|
||||
* @return
|
||||
*/
|
||||
public static String format(final int num) {
|
||||
String string = Integer.toString(num);
|
||||
return string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a number into a string with commas.
|
||||
*/
|
||||
public static String formatValue(int value) {
|
||||
return new DecimalFormat("#, ###").format(value);
|
||||
}
|
||||
|
||||
/** Formats digits for longs. */
|
||||
public static String format(final long num) {
|
||||
String string = Long.toString(num);
|
||||
return string;
|
||||
}
|
||||
|
||||
/** Formats a price for longs.
|
||||
* @param amount*/
|
||||
public static String formatPrice(final int amount) {
|
||||
if (amount >= 0 && amount < 1_000) {
|
||||
return "" + amount;
|
||||
}
|
||||
if (amount >= 1_000 && amount < 1_000_000) {
|
||||
return (amount / 1_000) + "K";
|
||||
}
|
||||
if (amount >= 1_000_000 && amount < 1_000_000_000) {
|
||||
return (amount / 1_000_000) + "M";
|
||||
}
|
||||
if (amount >= 1_000_000_000 && amount < Integer.MAX_VALUE) {
|
||||
return (amount / 1_000_000_000) + "B";
|
||||
}
|
||||
return "<col=fc2a2a>Lots!";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 5.5 for example.
|
||||
*/
|
||||
public static double roundDoubleToNearestOneDecimalPlace(double number) {
|
||||
DecimalFormat df = new DecimalFormat("#.#");
|
||||
return Double.parseDouble(df.format(number));
|
||||
}
|
||||
|
||||
/**
|
||||
* Shorted to 5.66 for example.
|
||||
*/
|
||||
public static double roundDoubleToNearestTwoDecimalPlaces(double number) {
|
||||
DecimalFormat df = new DecimalFormat("#.##");
|
||||
return Double.parseDouble(df.format(number));
|
||||
}
|
||||
|
||||
public static double getDoubleRoundedUp(double doubleNumber) {
|
||||
return Math.ceil(doubleNumber);
|
||||
}
|
||||
|
||||
public static double getDoubleRoundedDown(double doubleNumber) {
|
||||
return (double) ((int) doubleNumber);
|
||||
}
|
||||
|
||||
public static String formatRunescapeStyle(long num) {
|
||||
boolean negative = false;
|
||||
if (num < 0) {
|
||||
num = -num;
|
||||
negative = true;
|
||||
}
|
||||
int length = String.valueOf(num).length();
|
||||
String number = Long.toString(num);
|
||||
String numberString = number;
|
||||
String end = "";
|
||||
if (length == 4) {
|
||||
numberString = number.substring(0, 1) + "k";
|
||||
//6400
|
||||
double doubleVersion = 0.0;
|
||||
doubleVersion = num / 1000.0;
|
||||
if (doubleVersion != getDoubleRoundedUp(doubleVersion)) {
|
||||
if (num - (1000 * getDoubleRoundedDown(doubleVersion)) > 100) {
|
||||
numberString = number.substring(0, 1) + "." + number.substring(1, 2) + "k";
|
||||
}
|
||||
}
|
||||
} else if (length == 5) {
|
||||
numberString = number.substring(0, 2) + "k";
|
||||
} else if (length == 6) {
|
||||
numberString = number.substring(0, 3) + "k";
|
||||
} else if (length == 7) {
|
||||
String sub = number.substring(1, 2);
|
||||
if (sub.equals("0")) {
|
||||
numberString = number.substring(0, 1) + "m";
|
||||
} else {
|
||||
numberString = number.substring(0, 1) + "." + number.substring(1, 2) + "m";
|
||||
}
|
||||
} else if (length == 8) {
|
||||
end = "." + number.substring(2, 3);
|
||||
if (end.equals(".0")) {
|
||||
end = "";
|
||||
}
|
||||
numberString = number.substring(0, 2) + end + "m";
|
||||
} else if (length == 9) {
|
||||
end = "." + number.substring(3, 4);
|
||||
if (end.equals(".0")) {
|
||||
end = "";
|
||||
}
|
||||
numberString = number.substring(0, 3) + end + "m";
|
||||
} else if (length == 10) {
|
||||
numberString = number.substring(0, 4) + "m";
|
||||
} else if (length == 11) {
|
||||
numberString = number.substring(0, 2) + "." + number.substring(2, 5) + "b";
|
||||
} else if (length == 12) {
|
||||
numberString = number.substring(0, 3) + "." + number.substring(3, 6) + "b";
|
||||
} else if (length == 13) {
|
||||
numberString = number.substring(0, 4) + "." + number.substring(4, 7) + "b";
|
||||
}
|
||||
if (negative) {
|
||||
numberString = "-" + numberString;
|
||||
}
|
||||
return numberString;
|
||||
}
|
||||
|
||||
public static String formatText(String s) {
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
if (i == 0) {
|
||||
s = String.format("%s%s", Character.toUpperCase(s.charAt(0)),
|
||||
s.substring(1));
|
||||
}
|
||||
if (!Character.isLetterOrDigit(s.charAt(i))) {
|
||||
if (i + 1 < s.length()) {
|
||||
s = String.format("%s%s%s", s.subSequence(0, i + 1),
|
||||
Character.toUpperCase(s.charAt(i + 1)),
|
||||
s.substring(i + 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
return s.replace("_", " ");
|
||||
}
|
||||
|
||||
public static String formatTextUnderscore(String s) {
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
if (i == 0) {
|
||||
s = String.format("%s%s", Character.toUpperCase(s.charAt(0)),
|
||||
s.substring(1));
|
||||
}
|
||||
if (!Character.isLetterOrDigit(s.charAt(i))) {
|
||||
if (i + 1 < s.length()) {
|
||||
s = String.format("%s%s%s", s.subSequence(0, i + 1),
|
||||
Character.toUpperCase(s.charAt(i + 1)),
|
||||
s.substring(i + 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
return s.replace(" ", "_");
|
||||
}
|
||||
|
||||
public static String optimizeTextNew(String text) {
|
||||
for (int index = 0; index < text.length(); index++) {
|
||||
if (index == 0) {
|
||||
text = String.format("%s%s", Character.toUpperCase(text.charAt(0)), text.substring(1));
|
||||
}
|
||||
if (!Character.isLetterOrDigit(text.charAt(index))) {
|
||||
if (index + 1 < text.length()) {
|
||||
text = String.format("%s%s%s", text.subSequence(0, index + 1), Character.toUpperCase(text.charAt(index + 1)), text.substring(index + 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
public static String getTotalAmount(int j) {
|
||||
if (j >= 10000 && j < 1000000) {
|
||||
return j / 1000 + "K";
|
||||
} else if (j >= 1000000 && j <= Integer.MAX_VALUE) {
|
||||
return j / 1000000 + "M";
|
||||
} else {
|
||||
return "" + j;
|
||||
}
|
||||
}
|
||||
|
||||
public static String insertCommasToNumber(String number) {
|
||||
return number.length() < 4 ? number : insertCommasToNumber(number
|
||||
.substring(0, number.length() - 3))
|
||||
+ ","
|
||||
+ number.substring(number.length() - 3, number.length());
|
||||
}
|
||||
|
||||
public static String ucFirst(String str) {
|
||||
str = str.toLowerCase();
|
||||
@@ -89,22 +283,41 @@ public class Misc {
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format number into for example: 357,555
|
||||
*/
|
||||
public static String formatNumber(long number) {
|
||||
// Do not use return NumberFormat.getIntegerInstance().format(number);. It is 9 times slower.
|
||||
String string = Long.toString(number);
|
||||
if (number < 1000) {
|
||||
return string;
|
||||
}
|
||||
if (number >= 1000 && number < 10000) {
|
||||
return string.substring(0, 1) + "," + string.substring(1);
|
||||
}
|
||||
if (number < 100000) {
|
||||
return string.substring(0, 2) + "," + string.substring(2);
|
||||
}
|
||||
if (number < 1000000) {
|
||||
return string.substring(0, 3) + "," + string.substring(3);
|
||||
}
|
||||
if (number < 10000000) {
|
||||
return string.substring(0, 1) + "," + string.substring(1, 4) + "," + string.substring(4, 7);
|
||||
}
|
||||
if (number < 100000000) {
|
||||
return string.substring(0, 2) + "," + string.substring(2, 5) + "," + string.substring(5, 8);
|
||||
}
|
||||
if (number < 1000000000) {
|
||||
return string.substring(0, 3) + "," + string.substring(3, 6) + "," + string.substring(6, 9);
|
||||
}
|
||||
if (number <= Integer.MAX_VALUE) {
|
||||
return string.substring(0, 1) + "," + string.substring(1, 4) + "," + string.substring(4, 7) + "," + string.substring(7, 10);
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
public static void print_debug(String str) {
|
||||
System.out.print(str);
|
||||
}
|
||||
|
||||
public static void println_debug(String str) {
|
||||
System.out.println(str);
|
||||
}
|
||||
|
||||
public static void print(String str) {
|
||||
System.out.print(str);
|
||||
}
|
||||
|
||||
public static void println(String str) {
|
||||
System.out.println(str);
|
||||
}
|
||||
|
||||
|
||||
public static String Hex(byte data[]) {
|
||||
return Hex(data, 0, data.length);
|
||||
@@ -303,4 +516,508 @@ public class Misc {
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
public static int toCyclesOrDefault(long time, int def, TimeUnit unit) {
|
||||
if (time > Integer.MAX_VALUE) {
|
||||
time = def;
|
||||
}
|
||||
return (int) TimeUnit.MILLISECONDS.convert(time, unit) / 600;
|
||||
}
|
||||
|
||||
public static <K, V extends Comparable<? super V>> List<Map.Entry<K, V>> sortEntries(Map<K, V> map) {
|
||||
List<Map.Entry<K, V>> sortedEntries = new ArrayList<Map.Entry<K, V>>(map.entrySet());
|
||||
Collections.sort(sortedEntries, (e1, e2) -> e2.getValue().compareTo(e1.getValue()));
|
||||
return sortedEntries;
|
||||
}
|
||||
|
||||
public static Map<String, Long> sortByComparator(Map<String, Long> unsortMap, final boolean ascending)
|
||||
{
|
||||
List<Map.Entry<String, Long>> list = new LinkedList<Map.Entry<String, Long>>(unsortMap.entrySet());
|
||||
// Sorting the list based on values
|
||||
list.sort(new Comparator<Map.Entry<String, Long>>() {
|
||||
public int compare(Map.Entry<String, Long> o1,
|
||||
Map.Entry<String, Long> o2) {
|
||||
if (ascending) {
|
||||
return o1.getValue().compareTo(o2.getValue());
|
||||
} else {
|
||||
return o2.getValue().compareTo(o1.getValue());
|
||||
}
|
||||
}
|
||||
});
|
||||
// Maintaining insertion order with the help of LinkedList
|
||||
Map<String, Long> sortedMap = new LinkedHashMap<String, Long>();
|
||||
for (Map.Entry<String, Long> entry : list)
|
||||
{
|
||||
sortedMap.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return sortedMap;
|
||||
}
|
||||
|
||||
public static <T> List<T> jsonArrayToList(Path path, Class<T[]> clazz) {
|
||||
try {
|
||||
T[] collection = new Gson().fromJson(Files.newBufferedReader(path), clazz);
|
||||
return new ArrayList<T>(Arrays.asList(collection));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String kOrMil(int amount) {
|
||||
if (amount < 100_000)
|
||||
return String.valueOf(amount);
|
||||
if (amount < 10_000_000)
|
||||
return amount / 1_000 + "K";
|
||||
else
|
||||
return amount / 1_000_000 + "M";
|
||||
}
|
||||
|
||||
public static int[] convertRollRangeStringToIntArray(String input)
|
||||
{
|
||||
String[] strArray = input.split("-");
|
||||
int[] intArray = new int[strArray.length];
|
||||
for (int i = 0; i < strArray.length; i++) {
|
||||
intArray[i] = Integer.parseInt(strArray[i]);
|
||||
}
|
||||
return intArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Random instance, used to generate pseudo-random primitive types.
|
||||
*/
|
||||
public static final Random RANDOM = new Random();
|
||||
|
||||
/**
|
||||
* Finds out if a certain event should happen, and if it should, return
|
||||
* true;
|
||||
*
|
||||
* @param chance
|
||||
* The chance of the event happening
|
||||
* @return If the event should happen
|
||||
*/
|
||||
public static boolean percentageChance(int chance) {
|
||||
return RANDOM.nextInt(100) < chance;
|
||||
}
|
||||
|
||||
public static String getFractionFromPercentage(float percentage) {
|
||||
return "1 / " + (int) Math.round((1 / percentage) * 100); //Was ceil is now round
|
||||
}
|
||||
|
||||
public static int getDenominatorFromPercentage(float percentage) {
|
||||
return (int) Math.round((1 / percentage) * 100); //Was ceil is now round
|
||||
}
|
||||
|
||||
public static String getCurrentServerTime() {
|
||||
ZonedDateTime zonedDateTime = ZonedDateTime.now();
|
||||
int hour = zonedDateTime.getHour();
|
||||
String hourPrefix = hour < 10 ? "0" + hour + "" : "" + hour + "";
|
||||
int minute = zonedDateTime.getMinute();
|
||||
String minutePrefix = minute < 10 ? "0" + minute + "" : "" + minute + "";
|
||||
return "" + hourPrefix + ":" + minutePrefix + "";
|
||||
}
|
||||
public static String getCurrentServerDateTime() {
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMM yyyy, h:mm:ss a");
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
return dateFormat.format(calendar.getTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the formatted time played.
|
||||
*
|
||||
* @return The time played formatted as a string.
|
||||
*/
|
||||
public static String getFormattedPlayTime(Player player, long creationTime) {
|
||||
long different = System.currentTimeMillis() - creationTime;
|
||||
|
||||
|
||||
long secondsInMilli = 1000;
|
||||
long minutesInMilli = secondsInMilli * 60;
|
||||
long hoursInMilli = minutesInMilli * 60;
|
||||
long daysInMilli = hoursInMilli * 24;
|
||||
|
||||
long elapsedDays = different / daysInMilli;
|
||||
different = different % daysInMilli;
|
||||
|
||||
long elapsedHours = different / hoursInMilli;
|
||||
different = different % hoursInMilli;
|
||||
|
||||
long elapsedMinutes = different / minutesInMilli;
|
||||
different = different % minutesInMilli;
|
||||
|
||||
long elapsedSeconds = different / secondsInMilli;
|
||||
|
||||
/* long days = (long) elapsedJoinDate / 86400; // 86,400
|
||||
long daysRemainder = (long) elapsedJoinDate - (days * 86400);
|
||||
long hours = (long) daysRemainder / 3600; // 3,600
|
||||
long hoursRemainder = (long) daysRemainder - (hours * 3600);
|
||||
long minutes = (long) hoursRemainder / 60; // 60
|
||||
long seconds = (long) hoursRemainder - (minutes * 60); // remainder*/
|
||||
|
||||
return elapsedDays + "d " + elapsedHours + "h " + elapsedMinutes + "m " + elapsedSeconds + "s";
|
||||
|
||||
}
|
||||
|
||||
public static String getTimePlayed(long totalPlayTime) {
|
||||
final int sec = (int) (totalPlayTime / 1000), h = sec / 3600, m = sec / 60 % 60, s = sec % 60;
|
||||
return (h < 10 ? "0" + h : h) + ":" + (m < 10 ? "0" + m : m) + ":" + (s < 10 ? "0" + s : s);
|
||||
}
|
||||
|
||||
public static String getHoursPlayed(long totalPlayTime) {
|
||||
final int sec = (int) (totalPlayTime / 1000), h = sec / 3600;
|
||||
return (h < 10 ? "0" + h : h) + "h";
|
||||
}
|
||||
|
||||
public static String asMinutesLeft(int ticksLeft) {
|
||||
long ms = ticksLeft * 600;
|
||||
int minutes = (int) TimeUnit.MILLISECONDS.toMinutes(ms);
|
||||
String str = "";
|
||||
|
||||
if (minutes > 0) {
|
||||
if (minutes > 1) {
|
||||
str = minutes + " mins";
|
||||
} else {
|
||||
str = "One min";
|
||||
}
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
public static String asSeconds(int ticksLeft) {
|
||||
long ms = ticksLeft * 600;
|
||||
int seconds = (int) TimeUnit.MILLISECONDS.toSeconds(ms);
|
||||
String str = "";
|
||||
|
||||
|
||||
if (seconds > 1) {
|
||||
str = seconds + " seconds";
|
||||
} else {
|
||||
str = "One second";
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
public static int getMinutesPassed(long t) {
|
||||
int seconds = (int) ((t / 1000) % 60);
|
||||
int minutes = (int) (((t - seconds) / 1000) / 60);
|
||||
return minutes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Useful method for getting the stack trace where some code
|
||||
* was executed without throwing an exception.
|
||||
* This method basically makes it so that we don't have to throw new RuntimeException
|
||||
* in order to get a stack trace.
|
||||
* @return the stack trace
|
||||
*/
|
||||
public static String getStackTrace() {
|
||||
final StringWriter writer = new StringWriter();
|
||||
new Exception("Stack trace").printStackTrace(new PrintWriter(writer));
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
public static float getPercentageFromDecimal(float decimal) {
|
||||
return decimal * 100;
|
||||
}
|
||||
|
||||
public static float getPercentageFromDenominator(float denominator) {
|
||||
return (1 / denominator) * 100;
|
||||
}
|
||||
|
||||
public static float getDecimalFromFraction(int numerator, int denominator) {
|
||||
return (float) numerator / denominator;
|
||||
}
|
||||
|
||||
public static float getDecimalFromDenominator(int denominator) {
|
||||
return (float) 1 / denominator;
|
||||
}
|
||||
|
||||
/** Gets the date of server. */
|
||||
public static String getDate() {
|
||||
return new SimpleDateFormat("EE MMM dd yyyy").format(new Date());
|
||||
}
|
||||
|
||||
/** Gets the date of server. */
|
||||
public static String getSimpleDate() {
|
||||
return new SimpleDateFormat("yyyy/MM/dd").format(new Date());
|
||||
}
|
||||
|
||||
public static String pluralOrNot(String word, int count) {
|
||||
String value = "";
|
||||
if (count == 0 || count > 1) {
|
||||
value = word + "s";
|
||||
} else {
|
||||
value = word;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static float ticksToSeconds(int tick) {
|
||||
int ticksInMillis = tick * 600;
|
||||
float tickToSecs = ticksInMillis / 1000f;
|
||||
return tickToSecs;
|
||||
}
|
||||
|
||||
public static float ticksToMinutes(int tick) {
|
||||
int ticksInMillis = tick * 600;
|
||||
float tickToMin = ticksInMillis / 60000f;
|
||||
return tickToMin;
|
||||
}
|
||||
|
||||
public static float ticksToHours(int tick) {
|
||||
int ticksInMillis = tick * 600;
|
||||
float tickToHour = ticksInMillis / 3_600_000f;
|
||||
return tickToHour;
|
||||
}
|
||||
|
||||
public static String convertLongToDateTime(long time) {
|
||||
Date date = new Date(time);
|
||||
//Format format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Format format = new SimpleDateFormat("dd MMM yyyy h:mm:ss a");
|
||||
return format.format(date);
|
||||
}
|
||||
|
||||
public static String convertLongToTime(long time) {
|
||||
Date date = new Date(time);
|
||||
Format format = new SimpleDateFormat("h:mm:ss a");
|
||||
return format.format(date);
|
||||
}
|
||||
|
||||
public static String convertLongToDate(long time) {
|
||||
Date date = new Date(time);
|
||||
//Format format = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Format format = new SimpleDateFormat("dd MMM yyyy");
|
||||
return format.format(date);
|
||||
}
|
||||
|
||||
public static String convertLongToDuration(long time) {
|
||||
if (time < 0) {
|
||||
throw new IllegalArgumentException("Duration must be greater than zero!");
|
||||
}
|
||||
|
||||
long days = TimeUnit.MILLISECONDS.toDays(time);
|
||||
time -= TimeUnit.DAYS.toMillis(days);
|
||||
long hours = TimeUnit.MILLISECONDS.toHours(time);
|
||||
time -= TimeUnit.HOURS.toMillis(hours);
|
||||
long minutes = TimeUnit.MILLISECONDS.toMinutes(time);
|
||||
time -= TimeUnit.MINUTES.toMillis(minutes);
|
||||
long seconds = TimeUnit.MILLISECONDS.toSeconds(time);
|
||||
|
||||
StringBuilder sb = new StringBuilder(64);
|
||||
sb.append(days);
|
||||
sb.append((days > 1 || days == 0) ? " days " : " day ");
|
||||
sb.append(hours);
|
||||
sb.append((hours > 1 || hours == 0) ? " hours " : " hour ");
|
||||
sb.append(minutes);
|
||||
sb.append((minutes > 1 || minutes == 0) ? " minutes " : " minute ");
|
||||
sb.append(seconds);
|
||||
sb.append((seconds > 1 || seconds == 0) ? " seconds" : " second");
|
||||
|
||||
return (sb.toString());
|
||||
}
|
||||
|
||||
public static String convertLongToShortDuration(long time, boolean useSeconds) {
|
||||
if (time < 0) {
|
||||
throw new IllegalArgumentException("Duration must be greater than zero!");
|
||||
}
|
||||
long days = TimeUnit.MILLISECONDS.toDays(time);
|
||||
time -= TimeUnit.DAYS.toMillis(days);
|
||||
long hours = TimeUnit.MILLISECONDS.toHours(time);
|
||||
time -= TimeUnit.HOURS.toMillis(hours);
|
||||
long minutes = TimeUnit.MILLISECONDS.toMinutes(time);
|
||||
time -= TimeUnit.MINUTES.toMillis(minutes);
|
||||
long seconds = TimeUnit.MILLISECONDS.toSeconds(time);
|
||||
|
||||
|
||||
StringBuilder sb = new StringBuilder(64);
|
||||
sb.append(days);
|
||||
sb.append("d ");
|
||||
sb.append(hours);
|
||||
sb.append("h ");
|
||||
sb.append(minutes);
|
||||
sb.append("m ");
|
||||
if (useSeconds) {
|
||||
sb.append(seconds);
|
||||
sb.append("s ");
|
||||
}
|
||||
|
||||
|
||||
return (sb.toString());
|
||||
}
|
||||
|
||||
public static String convertSecondsToShortDuration(long time, boolean useSeconds) {
|
||||
if (time < 0) {
|
||||
throw new IllegalArgumentException("Duration must be greater than zero!");
|
||||
}
|
||||
|
||||
long days = (int)TimeUnit.SECONDS.toDays(time);
|
||||
long hours = TimeUnit.SECONDS.toHours(time) - (days *24);
|
||||
long minutes = TimeUnit.SECONDS.toMinutes(time) - (TimeUnit.SECONDS.toHours(time)* 60);
|
||||
long seconds = TimeUnit.SECONDS.toSeconds(time) - (TimeUnit.SECONDS.toMinutes(time) *60);
|
||||
|
||||
|
||||
StringBuilder sb = new StringBuilder(64);
|
||||
sb.append(days);
|
||||
sb.append("d ");
|
||||
sb.append(hours);
|
||||
sb.append("h ");
|
||||
sb.append(minutes);
|
||||
sb.append("m ");
|
||||
if (useSeconds) {
|
||||
sb.append(seconds);
|
||||
sb.append("s ");
|
||||
}
|
||||
|
||||
return (sb.toString());
|
||||
}
|
||||
|
||||
public static String convertSecondsToDuration(long time, boolean showDaysAndHours) {
|
||||
if (time < 0) {
|
||||
throw new IllegalArgumentException("Duration must be greater than zero!");
|
||||
}
|
||||
|
||||
long days = (int)TimeUnit.SECONDS.toDays(time);
|
||||
long hours = TimeUnit.SECONDS.toHours(time) - (days *24);
|
||||
long minutes = TimeUnit.SECONDS.toMinutes(time) - (TimeUnit.SECONDS.toHours(time)* 60);
|
||||
long seconds = TimeUnit.SECONDS.toSeconds(time) - (TimeUnit.SECONDS.toMinutes(time) *60);
|
||||
|
||||
StringBuilder sb = new StringBuilder(64);
|
||||
if (showDaysAndHours) {
|
||||
sb.append(days);
|
||||
sb.append((days > 1 || days == 0) ? " days " : " day ");
|
||||
sb.append(hours);
|
||||
sb.append((hours > 1 || hours == 0) ? " hours " : " hour ");
|
||||
sb.append(minutes);
|
||||
sb.append((minutes > 1 || minutes == 0) ? " minutes " : " minute ");
|
||||
sb.append(seconds);
|
||||
sb.append((seconds > 1 || seconds == 0) ? " seconds" : " second");
|
||||
} else {
|
||||
sb.append(minutes);
|
||||
sb.append((minutes > 1 || minutes == 0) ? " minutes " : " minute ");
|
||||
sb.append(seconds);
|
||||
sb.append((seconds > 1 || seconds == 0) ? " seconds" : " second");
|
||||
}
|
||||
|
||||
return (sb.toString());
|
||||
}
|
||||
|
||||
public static int getMinutesElapsed(int minute, int hour, int day, int year) {
|
||||
Calendar i = Calendar.getInstance();
|
||||
|
||||
if (i.get(1) == year) {
|
||||
if (i.get(6) == day) {
|
||||
if (hour == i.get(11)) {
|
||||
return i.get(12) - minute;
|
||||
}
|
||||
return (i.get(11) - hour) * 60 + (59 - i.get(12));
|
||||
}
|
||||
|
||||
int ela = (i.get(6) - day) * 24 * 60 * 60;
|
||||
return ela > 2147483647 ? 2147483647 : ela;
|
||||
}
|
||||
|
||||
int ela = getElapsed(day, year) * 24 * 60 * 60;
|
||||
|
||||
return ela > 2147483647 ? 2147483647 : ela;
|
||||
}
|
||||
|
||||
public static int getDayOfYear() {
|
||||
Calendar c = Calendar.getInstance();
|
||||
int year = c.get(Calendar.YEAR);
|
||||
int month = c.get(Calendar.MONTH);
|
||||
int days = 0;
|
||||
int[] daysOfTheMonth = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
||||
if ((year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0)) {
|
||||
daysOfTheMonth[1] = 29;
|
||||
}
|
||||
days += c.get(Calendar.DAY_OF_MONTH);
|
||||
for (int i = 0; i < daysOfTheMonth.length; i++) {
|
||||
if (i < month) {
|
||||
days += daysOfTheMonth[i];
|
||||
}
|
||||
}
|
||||
return days;
|
||||
}
|
||||
|
||||
public static int getYear() {
|
||||
Calendar c = Calendar.getInstance();
|
||||
return c.get(Calendar.YEAR);
|
||||
}
|
||||
|
||||
public static int getElapsed(int day, int year) {
|
||||
if (year < 2013) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int elapsed = 0;
|
||||
int currentYear = Misc.getYear();
|
||||
int currentDay = Misc.getDayOfYear();
|
||||
|
||||
if (currentYear == year) {
|
||||
elapsed = currentDay - day;
|
||||
} else {
|
||||
elapsed = currentDay;
|
||||
|
||||
for (int i = 1; i < 5; i++) {
|
||||
if (currentYear - i == year) {
|
||||
elapsed += 365 - day;
|
||||
break;
|
||||
} else {
|
||||
elapsed += 365;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return elapsed;
|
||||
}
|
||||
|
||||
public static boolean isWeekend() {
|
||||
int day = Calendar.getInstance().get(7);
|
||||
return (day == 1) || (day == 6) || (day == 7);
|
||||
}
|
||||
|
||||
public static int getTicks(int seconds) {
|
||||
return (int) (seconds / 0.6);
|
||||
}
|
||||
|
||||
public static int getSeconds(int ticks) {
|
||||
return (int) (ticks * 0.6);
|
||||
}
|
||||
public static String getServerUptime(long serverStartTime) {
|
||||
long currentTime = System.currentTimeMillis();
|
||||
long uptimeMillis = currentTime - serverStartTime;
|
||||
|
||||
long seconds = (uptimeMillis / 1000) % 60;
|
||||
long minutes = (uptimeMillis / (1000 * 60)) % 60;
|
||||
long hours = (uptimeMillis / (1000 * 60 * 60)) % 24;
|
||||
long days = uptimeMillis / (1000 * 60 * 60 * 24);
|
||||
|
||||
return String.format("%d days, %d hours, %d minutes, %d seconds", days, hours, minutes, seconds);
|
||||
}
|
||||
|
||||
public static double roundOneDecimal(double number_to_format) {
|
||||
DecimalFormat decimal_format = new DecimalFormat("#.#");
|
||||
return Double.parseDouble(decimal_format.format(number_to_format).replace(",", "."));
|
||||
}
|
||||
|
||||
public static double round(double number_to_format) {
|
||||
DecimalFormat decimal_format = new DecimalFormat("#.##");
|
||||
return Double.parseDouble(decimal_format.format(number_to_format).replace(",", "."));
|
||||
}
|
||||
|
||||
public static boolean rollDie(int dieSides, int chance) {
|
||||
return random(dieSides) < chance;
|
||||
}
|
||||
|
||||
public static String capitalizeJustFirst(String str) {
|
||||
str = str.toLowerCase();
|
||||
if (str.length() > 1) {
|
||||
str = str.substring(0, 1).toUpperCase() + str.substring(1);
|
||||
} else {
|
||||
return str.toUpperCase();
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public class GlobalDropsHandler {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Misc.println("Loaded " + globalDrops.size() + " global drops.");
|
||||
System.out.println("Loaded " + globalDrops.size() + " global drops.");
|
||||
|
||||
for (Player player : PlayerHandler.players) {
|
||||
Client player2 = (Client) player;
|
||||
|
||||
@@ -56,7 +56,7 @@ public final class ApolloHandler extends ChannelInboundHandlerAdapter {
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable e) {
|
||||
if (!e.getMessage().contains("An existing connection was forcibly closed by the remote host")) {
|
||||
if (!e.getMessage().contains("An existing connection was forcibly closed by the remote host") && !e.getMessage().contains("Connection reset by peer")) {
|
||||
logger.log(Level.WARNING, "Exception occured for channel: " + ctx.channel() + ", closing...", e);
|
||||
}
|
||||
ctx.channel().close();
|
||||
|
||||
Reference in New Issue
Block a user