diff --git a/Management-Server/src/main/java/ms/Management.java b/Management-Server/src/main/java/ms/Management.java index d7280e488..2c9863111 100644 --- a/Management-Server/src/main/java/ms/Management.java +++ b/Management-Server/src/main/java/ms/Management.java @@ -13,8 +13,10 @@ import ms.world.WorldDatabase; import java.io.File; import java.io.IOException; +import java.io.InputStreamReader; import java.net.InetAddress; import java.net.NetworkInterface; +import java.nio.charset.StandardCharsets; import java.util.Scanner; /** @@ -138,7 +140,7 @@ public final class Management { Runtime.getRuntime().addShutdownHook(new ShutdownSequence()); System.out.println("Status: ready."); System.out.println("Use -commands for a list of commands!"); - Scanner s = new Scanner(System.in); + Scanner s = new Scanner(new InputStreamReader(System.in, StandardCharsets.UTF_8)); while (s.hasNext()) { try { String command = s.nextLine(); diff --git a/Management-Server/src/main/java/ms/classloader/ClassLoadServer.java b/Management-Server/src/main/java/ms/classloader/ClassLoadServer.java index cfbae574a..ef35db3eb 100644 --- a/Management-Server/src/main/java/ms/classloader/ClassLoadServer.java +++ b/Management-Server/src/main/java/ms/classloader/ClassLoadServer.java @@ -30,7 +30,7 @@ public class ClassLoadServer extends Thread { /** * Holds classes and resources already added in the server */ - protected static HashMap resourceCache = new HashMap(); + protected final static HashMap resourceCache = new HashMap(); /** * New socket @@ -60,7 +60,9 @@ public class ClassLoadServer extends Thread { //System.out.println("New Connection from : " + clientSocket.getInetAddress()); WorkerThread wcs = new WorkerThread(clientSocket); wcs.start(); - } catch (Exception e) {} + } catch (Exception e) { + e.printStackTrace(); + } } } diff --git a/Management-Server/src/main/java/ms/net/IoSession.java b/Management-Server/src/main/java/ms/net/IoSession.java index 3ea1a3be3..dd722db17 100644 --- a/Management-Server/src/main/java/ms/net/IoSession.java +++ b/Management-Server/src/main/java/ms/net/IoSession.java @@ -55,7 +55,7 @@ public class IoSession { /** * The writing lock. */ - private Lock writingLock = new ReentrantLock(); + private final Lock writingLock = new ReentrantLock(); /** * The name hash. @@ -137,15 +137,15 @@ public class IoSession { */ public void queue(ByteBuffer buffer) { try { - writingLock.tryLock(1000L, TimeUnit.MILLISECONDS); + if(writingLock.tryLock(1000L, TimeUnit.MILLISECONDS)){ + writingQueue.add(buffer); + writingLock.unlock(); + write(); + } } catch (Exception e){ - System.out.println(e); + e.printStackTrace(); writingLock.unlock(); - return; } - writingQueue.add(buffer); - writingLock.unlock(); - write(); } /** @@ -168,10 +168,11 @@ public class IoSession { } writingQueue.remove(0); } + writingLock.unlock(); } catch (IOException e) { disconnect(); + writingLock.unlock(); } - writingLock.unlock(); } /** diff --git a/Management-Server/src/main/java/ms/net/packet/IoBuffer.java b/Management-Server/src/main/java/ms/net/packet/IoBuffer.java index 4e4a7e682..8bd8199b7 100644 --- a/Management-Server/src/main/java/ms/net/packet/IoBuffer.java +++ b/Management-Server/src/main/java/ms/net/packet/IoBuffer.java @@ -1,6 +1,7 @@ package ms.net.packet; import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; import ms.system.util.ByteBufferUtils; @@ -301,7 +302,7 @@ public class IoBuffer { * @return */ public IoBuffer putString(String val) { - buf.put(val.getBytes()); + buf.put(val.getBytes(StandardCharsets.UTF_8)); buf.put((byte) 0); return this; } @@ -313,7 +314,7 @@ public class IoBuffer { */ public IoBuffer putJagString(String val) { buf.put((byte) 0); - buf.put(val.getBytes()); + buf.put(val.getBytes(StandardCharsets.UTF_8)); buf.put((byte) 0); return this; } @@ -557,18 +558,6 @@ public class IoBuffer { return buf.getLong(); } - /** - * - * @return - */ - public int getSmart() { - int peek = buf.get(buf.position()); - if (peek <= Byte.MAX_VALUE) { - return buf.get() & 0xFF; - } - return (buf.getShort() & 0xFFFF) - 32768; - } - /** * * @return diff --git a/Management-Server/src/main/java/ms/net/packet/WorldPacketRepository.kt b/Management-Server/src/main/java/ms/net/packet/WorldPacketRepository.kt index 4645259e2..6b9233cae 100644 --- a/Management-Server/src/main/java/ms/net/packet/WorldPacketRepository.kt +++ b/Management-Server/src/main/java/ms/net/packet/WorldPacketRepository.kt @@ -42,7 +42,7 @@ object WorldPacketRepository { * @param message The message to send. */ @JvmStatic - fun sendPlayerMessage(player: PlayerSession?, message: String?) { + fun sendPlayerMessage(player: PlayerSession?, message: String) { if (player == null) { return } @@ -52,7 +52,7 @@ object WorldPacketRepository { player.world.session.write(buffer) } - fun sendPlayerMessage(player: PlayerSession?, messages: Array) { + fun sendPlayerMessage(player: PlayerSession?, messages: Array) { if (player == null) { return } @@ -98,7 +98,7 @@ object WorldPacketRepository { @JvmStatic fun sendContactUpdate( player: PlayerSession, - contact: String?, + contact: String, block: Boolean, remove: Boolean, worldId: Int, @@ -127,7 +127,7 @@ object WorldPacketRepository { * @param type The message type. */ @JvmStatic - fun sendMessage(player: PlayerSession, p: PlayerSession, type: Int, message: String?) { + fun sendMessage(player: PlayerSession, p: PlayerSession, type: Int, message: String) { val buffer = IoBuffer(5, PacketHeader.BYTE) buffer.putString(player.username) buffer.putString(p.username) @@ -184,7 +184,7 @@ object WorldPacketRepository { * @param names The names. */ @JvmStatic - fun notifyPlayers(server: GameServer, player: PlayerSession, names: List) { + fun notifyPlayers(server: GameServer, player: PlayerSession, names: List) { val buffer = IoBuffer(8, PacketHeader.SHORT) buffer.putString(player.username) buffer.put(player.worldId) @@ -227,7 +227,7 @@ object WorldPacketRepository { * @param duration The duration of the punishment. */ @JvmStatic - fun sendPunishUpdate(world: GameServer, key: String?, type: Int, duration: Long) { + fun sendPunishUpdate(world: GameServer, key: String, type: Int, duration: Long) { val buffer = IoBuffer(11, PacketHeader.BYTE) buffer.putString(key) buffer.put(type) diff --git a/Management-Server/src/main/java/ms/system/PunishmentStorage.java b/Management-Server/src/main/java/ms/system/PunishmentStorage.java index 8bbcfd6c8..a82dad781 100644 --- a/Management-Server/src/main/java/ms/system/PunishmentStorage.java +++ b/Management-Server/src/main/java/ms/system/PunishmentStorage.java @@ -79,8 +79,9 @@ public final class PunishmentStorage { e.printStackTrace(); SQLManager.close(connection); return; + } finally { + SQLManager.close(connection); } - SQLManager.close(connection); return; case 2: ban(player.getIpAddress(), type); @@ -152,8 +153,9 @@ public final class PunishmentStorage { e.printStackTrace(); SQLManager.close(connection); return false; + } finally { + SQLManager.close(connection); } - SQLManager.close(connection); return true; } @@ -175,8 +177,9 @@ public final class PunishmentStorage { e.printStackTrace(); SQLManager.close(connection); return false; + } finally { + SQLManager.close(connection); } - SQLManager.close(connection); return true; } @@ -239,8 +242,9 @@ public final class PunishmentStorage { e.printStackTrace(); SQLManager.close(connection); return false; + } finally { + SQLManager.close(connection); } - SQLManager.close(connection); return true; } @@ -252,9 +256,9 @@ public final class PunishmentStorage { private static String getDuration(long end) { String time = "indefinite time"; if (end != Long.MAX_VALUE) { - int days = (int) ((end -= System.currentTimeMillis()) / (24 * 60 * 60_000)); - int hours = (int) ((end -= (days * 24 * 60 * 60_000)) / (60 * 60_000)); - int minutes = (int) ((end -= (hours * (60 * 60_000))) / 60_000); + int days = (int) ((System.currentTimeMillis()) / (24 * 60 * 60_000)); + int hours = (int) (((24L * days * 60 * 60_000)) / (60 * 60_000)); + int minutes = (int) (((hours * (60 * 60_000))) / 60_000); time = days + "d, " + hours + "h, " + minutes + "m"; } return time; diff --git a/Management-Server/src/main/java/ms/system/communication/CommunicationInfo.java b/Management-Server/src/main/java/ms/system/communication/CommunicationInfo.java index 4f9c2f3be..1fd106fd3 100644 --- a/Management-Server/src/main/java/ms/system/communication/CommunicationInfo.java +++ b/Management-Server/src/main/java/ms/system/communication/CommunicationInfo.java @@ -141,14 +141,20 @@ public final class CommunicationInfo { public void save(PreparedStatement statement) throws SQLException { String contacts = ""; String blocked = ""; + StringBuilder blockedBuilder = new StringBuilder(); for (int i = 0; i < this.blocked.size(); i++) { - blocked += (i == 0 ? "" : ",") + this.blocked.get(i); + String blockline = (i == 0 ? "" : ",") + this.blocked.get(i); + blockedBuilder.append(blockline); } + blocked = blockedBuilder.toString(); int count = 0; + StringBuilder contactBuilder = new StringBuilder(); for (Entry entry : this.contacts.entrySet()) { - contacts += "{" + entry.getKey() + "," + entry.getValue().ordinal() + "}" + (count == this.contacts.size() - 1 ? "" : "~"); + String contactLine = "{" + entry.getKey() + "," + entry.getValue().ordinal() + "}" + (count == this.contacts.size() - 1 ? "" : "~"); + contactBuilder.append(contactLine); count++; } + contacts = contactBuilder.toString(); statement.setString(3, contacts); statement.setString(4, blocked); statement.setString(5, clanName); @@ -211,6 +217,8 @@ public final class CommunicationInfo { case 3: lootRequirement = rank; break; + default: + break; } } } @@ -239,9 +247,9 @@ public final class CommunicationInfo { */ public void save(ByteBuffer buffer) { buffer.put((byte) contacts.size()); - for (String name : contacts.keySet()) { - ByteBufferUtils.putString(name, buffer); - buffer.put((byte) contacts.get(name).ordinal()); + for(Entry contact : contacts.entrySet()){ + ByteBufferUtils.putString(contact.getKey(), buffer); + buffer.put((byte) contact.getValue().ordinal()); } buffer.put((byte) blocked.size()); for (String name : blocked) { diff --git a/Management-Server/src/main/java/ms/system/mysql/SQLTable.java b/Management-Server/src/main/java/ms/system/mysql/SQLTable.java index f30499f2b..3447edb23 100644 --- a/Management-Server/src/main/java/ms/system/mysql/SQLTable.java +++ b/Management-Server/src/main/java/ms/system/mysql/SQLTable.java @@ -52,12 +52,4 @@ public final class SQLTable { return updated; } - /** - * Gets the columns. - * @return The columns. - */ - public SQLColumn[] getColumns() { - return columns; - } - } \ No newline at end of file diff --git a/Management-Server/src/main/java/ms/system/mysql/WorldListSQLHandler.java b/Management-Server/src/main/java/ms/system/mysql/WorldListSQLHandler.java index 54a91c6c3..cf5eb4674 100644 --- a/Management-Server/src/main/java/ms/system/mysql/WorldListSQLHandler.java +++ b/Management-Server/src/main/java/ms/system/mysql/WorldListSQLHandler.java @@ -31,12 +31,16 @@ public final class WorldListSQLHandler extends SQLEntryHandler { * Clears the world list. */ public static void clearWorldList() { + Connection connection = SQLManager.getConnection(); + if(connection == null) return; try { - Connection connection = SQLManager.getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM " + TABLE); statement.executeUpdate(); - } catch (SQLException e) { + } catch (Exception e) { e.printStackTrace(); + SQLManager.close(connection); + } finally { + SQLManager.close(connection); } } diff --git a/Management-Server/src/main/java/ms/system/util/ByteBufferUtils.java b/Management-Server/src/main/java/ms/system/util/ByteBufferUtils.java index a45abe289..e60e3b2eb 100644 --- a/Management-Server/src/main/java/ms/system/util/ByteBufferUtils.java +++ b/Management-Server/src/main/java/ms/system/util/ByteBufferUtils.java @@ -1,6 +1,7 @@ package ms.system.util; import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; /** @@ -30,7 +31,7 @@ public final class ByteBufferUtils { * @param buffer The byte buffer. */ public static void putString(String s, ByteBuffer buffer) { - buffer.put(s.getBytes()).put((byte) 0); + buffer.put(s.getBytes(StandardCharsets.UTF_8)).put((byte) 0); } /** diff --git a/Management-Server/src/main/java/ms/system/util/EncryptionManager.java b/Management-Server/src/main/java/ms/system/util/EncryptionManager.java index 91e154fc0..f5ee249c0 100644 --- a/Management-Server/src/main/java/ms/system/util/EncryptionManager.java +++ b/Management-Server/src/main/java/ms/system/util/EncryptionManager.java @@ -484,7 +484,7 @@ public class EncryptionManager { * @return the decoded value of x */ private static byte char64(char x) { - if ((int)x < 0 || (int)x > index_64.length) + if ((int)x > index_64.length) return -1; return index_64[(int)x]; } diff --git a/Management-Server/src/main/java/ms/system/util/StringUtils.java b/Management-Server/src/main/java/ms/system/util/StringUtils.java index d5cc34991..2d997bb9a 100644 --- a/Management-Server/src/main/java/ms/system/util/StringUtils.java +++ b/Management-Server/src/main/java/ms/system/util/StringUtils.java @@ -14,26 +14,16 @@ public final class StringUtils { /** * The valid characters to be used in names/messages/... */ - public static final char[] VALID_CHARS = { + private static final char[] VALID_CHARS = { '_', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }; - /** - * Character mapping. - */ - public static char[] mapping = { - '\n', - 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', - 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', - 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ' ' }; /** * The an int array241. */ - public static int[] anIntArray241 = { 215, 203, 83, 158, 104, 101, 93, 84, + private final static int[] anIntArray241 = { 215, 203, 83, 158, 104, 101, 93, 84, 107, 103, 109, 95, 94, 98, 89, 86, 70, 41, 32, 27, 24, 23, -1, -2, 26, -3, -4, 31, 30, -5, -6, -7, 37, 38, 36, -8, -9, -10, 40, -11, -12, 55, 48, 46, 47, -13, -14, -15, 52, 51, -16, -17, 54, -18, -19, @@ -173,7 +163,7 @@ public final class StringUtils { boolean wasSpace = true; for (int i = 0; i < name.length(); i++) { if (wasSpace) { - newName.append((new String() + name.charAt(i)).toUpperCase()); + newName.append(("" + name.charAt(i)).toUpperCase()); wasSpace = false; } else { newName.append(name.charAt(i)); @@ -306,9 +296,8 @@ public final class StringUtils { * @return The string value. */ public static String getString(String s) { - String string = s.replaceAll("\\<.*?>", "").replaceAll(" ", "") + return s.replaceAll("\\<.*?>", "").replaceAll(" ", "") .replaceAll("Discontinued Item:", ""); - return string; } /** * Characters used to convert a String to a Long. @@ -319,7 +308,7 @@ public final class StringUtils { 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }; - public static int[] anIntArray233 = { + private final static int[] anIntArray233 = { 0, 1024, 2048, 3072, 4096, 5120, 6144, 8192, 9216, 12288, 10240, 11264, 16384, 18432, 17408, 20480, 21504, 22528, 23552, 24576, 25600, 26624, 27648, 28672, 29696, @@ -362,7 +351,7 @@ public final class StringUtils { 301188096, 301189120, 301190144, 301191168, 301193216, 301195264, 301194240, 301197312, 301198336, 301199360, 301201408, 301202432 }; - public static byte[] aByteArray235 = { + private final static byte[] aByteArray235 = { 22, 22, 22, 22, 22, 22, 21, 22, 22, 20, 22, 22, 22, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 3, 8, 22, 16, 22, 16, 17, 7, 13, 13, 13, @@ -387,16 +376,16 @@ public final class StringUtils { try { i_27_ += i_25_; int i_29_ = 0; - int i_30_ = i_26_ << -2116795453; + int i_30_ = i_26_ << 3; for (; i_27_ > i_25_; i_25_++) { int i_31_ = 0xff & is_28_[i_25_]; int i_32_ = anIntArray233[i_31_]; int i_33_ = aByteArray235[i_31_]; - int i_34_ = i_30_ >> -1445887805; + int i_34_ = i_30_ >> 3; int i_35_ = i_30_ & 0x7; - i_29_ &= (-i_35_ >> 473515839); + i_29_ &= (-i_35_ >> 31); i_30_ += i_33_; - int i_36_ = ((-1 + (i_35_ - -i_33_)) >> -1430991229) + i_34_; + int i_36_ = ((-1 + (i_35_ - -i_33_)) >> 3) + i_34_; i_35_ += 24; is[i_34_] = (byte) (i_29_ = (i_29_ | (i_32_ >>> i_35_))); if ((i_36_ ^ 0xffffffff) < (i_34_ ^ 0xffffffff)) { diff --git a/Management-Server/src/main/java/ms/world/PlayerSession.java b/Management-Server/src/main/java/ms/world/PlayerSession.java index 4cfa02f66..cccb91cf1 100644 --- a/Management-Server/src/main/java/ms/world/PlayerSession.java +++ b/Management-Server/src/main/java/ms/world/PlayerSession.java @@ -132,6 +132,8 @@ public final class PlayerSession { ex.printStackTrace(); SQLManager.close(connection); return false; + } finally { + SQLManager.close(connection); } return true; } @@ -160,6 +162,8 @@ public final class PlayerSession { } catch (SQLException e) { e.printStackTrace(); SQLManager.close(connection); + } finally { + SQLManager.close(connection); } communication.clear(); } @@ -201,6 +205,8 @@ public final class PlayerSession { } catch (SQLException e) { e.printStackTrace(); SQLManager.close(connection); + } finally { + SQLManager.close(connection); } } @@ -459,7 +465,9 @@ public final class PlayerSession { @Override public boolean equals(Object o) { - return username.equals(((PlayerSession) o).username); + if(o instanceof PlayerSession) { + return username.equals(((PlayerSession) o).username); + } else return false; } @Override diff --git a/Management-Server/src/main/java/ms/world/WorldDatabase.java b/Management-Server/src/main/java/ms/world/WorldDatabase.java index 6df1e48fc..e23e17f17 100644 --- a/Management-Server/src/main/java/ms/world/WorldDatabase.java +++ b/Management-Server/src/main/java/ms/world/WorldDatabase.java @@ -19,7 +19,7 @@ public class WorldDatabase { /** * The game servers. */ - public static final GameServer[] DATABASE = new GameServer[ServerConstants.WORLD_LIMIT]; + private static final GameServer[] DATABASE = new GameServer[ServerConstants.WORLD_LIMIT]; /** * The update time stamp. diff --git a/Management-Server/src/main/java/ms/world/info/UIDInfo.java b/Management-Server/src/main/java/ms/world/info/UIDInfo.java index d5122c792..3bcf2d9d6 100644 --- a/Management-Server/src/main/java/ms/world/info/UIDInfo.java +++ b/Management-Server/src/main/java/ms/world/info/UIDInfo.java @@ -102,6 +102,8 @@ public class UIDInfo { case 4: serial = ByteBufferUtils.getString(buffer); break; + default: + break; } } } @@ -112,7 +114,7 @@ public class UIDInfo { * @return the string. */ private String parseFormat(String string) { - if (string == null || string == "") { + if (string == null || string.equals("")) { return null; } StringTokenizer token = new StringTokenizer(string, "|"); diff --git a/Server/build.gradle b/Server/build.gradle index 07adf3761..e41dee3f0 100644 --- a/Server/build.gradle +++ b/Server/build.gradle @@ -12,7 +12,7 @@ compileJava { compileKotlin { kotlinOptions { jvmTarget = JavaVersion.VERSION_1_8 - freeCompilerArgs = ['-Xjsr305=strict', '-XXLanguage:-NewInference','-Xms2560m','-Xmx4096m', '-XX:MaxPermSize=350m','-XX:ReservedCodeCacheSize=225m','-XX:+UseCompressedOops'] + freeCompilerArgs += '-XXLanguage:-NewInference' } } @@ -21,16 +21,18 @@ repositories { } dependencies { - implementation("com.github.ajalt.mordant:mordant:2.0.0-alpha2") - implementation "org.jetbrains:markdown-jvm:0.2.4" - implementation 'com.google.guava:guava:29.0-jre' - implementation 'mysql:mysql-connector-java:8.0.21' - implementation 'io.github.classgraph:classgraph:4.8.98' - implementation 'org.jetbrains.kotlin:kotlin-reflect' + implementation 'org.jetbrains.kotlin:kotlin-reflect:1.5.20' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2' - implementation files("libs/ConstLib-1.2.jar") - implementation files("libs/PrimitiveExtensions-1.0.jar") - + implementation files( + "libs/PrimitiveExtensions-1.0.jar", + "libs/ConstLib-1.2.jar", + "libs/json-simple-1.1.1.jar", + "libs/markdown-jvm-0.2.4.jar", + "libs/classgraph-4.8.98.jar", + "libs/mysql-connector-java-8.0.21.jar", + "libs/mordant-jvm-2.0.0-alpha2.jar", + "libs/colormath-jvm-2.0.0.jar" + ) } /*sourceSets { diff --git a/Server/data/configs/drop_tables.json b/Server/data/configs/drop_tables.json index 471b300f8..31122cbd6 100644 --- a/Server/data/configs/drop_tables.json +++ b/Server/data/configs/drop_tables.json @@ -7863,7 +7863,32 @@ "maxAmount": "1" } ], - "charm": [], + "charm": [ + { + "minAmount": "1", + "weight": "85.0", + "id": "12158", + "maxAmount": "1" + }, + { + "minAmount": "1", + "weight": "7.0", + "id": "12159", + "maxAmount": "1" + }, + { + "minAmount": "1", + "weight": "7.0", + "id": "12160", + "maxAmount": "1" + }, + { + "minAmount": "1", + "weight": "1.0", + "id": "12163", + "maxAmount": "1" + } + ], "ids": "117,4689,4690,4691,4692,4693", "description": "", "main": [ @@ -8552,7 +8577,7 @@ }, { "minAmount": "1", - "weight": "50.0", + "weight": "8.0", "id": "1207", "maxAmount": "1" }, @@ -8576,13 +8601,13 @@ }, { "minAmount": "1", - "weight": "25.0", + "weight": "8.0", "id": "1241", "maxAmount": "1" }, { "minAmount": "1", - "weight": "25.0", + "weight": "8.0", "id": "1295", "maxAmount": "1" }, @@ -8606,13 +8631,13 @@ }, { "minAmount": "2", - "weight": "25.0", + "weight": "8.0", "id": "564", "maxAmount": "2" }, { "minAmount": "3", - "weight": "25.0", + "weight": "8.0", "id": "562", "maxAmount": "3" }, @@ -8624,7 +8649,7 @@ }, { "minAmount": "2", - "weight": "25.0", + "weight": "8.0", "id": "563", "maxAmount": "2" }, @@ -8632,7 +8657,7 @@ "minAmount": "4", "weight": "50.0", "id": "5318", - "maxAmount": "8" + "maxAmount": "4" }, { "minAmount": "4", @@ -8648,25 +8673,25 @@ }, { "minAmount": "3", - "weight": "50.0", + "weight": "25.0", "id": "5320", "maxAmount": "3" }, { "minAmount": "1", - "weight": "50.0", + "weight": "25.0", "id": "5323", "maxAmount": "2" }, { "minAmount": "1", - "weight": "50.0", + "weight": "8.0", "id": "5294", "maxAmount": "1" }, { "minAmount": "1", - "weight": "50.0", + "weight": "8.0", "id": "5293", "maxAmount": "1" }, @@ -8684,85 +8709,85 @@ }, { "minAmount": "1", - "weight": "25.0", + "weight": "8.0", "id": "5306", "maxAmount": "1" }, { "minAmount": "1", - "weight": "25.0", + "weight": "8.0", "id": "5311", "maxAmount": "1" }, { "minAmount": "1", - "weight": "25.0", + "weight": "8.0", "id": "5104", "maxAmount": "1" }, { "minAmount": "1", - "weight": "25.0", + "weight": "8.0", "id": "5105", "maxAmount": "2" }, { "minAmount": "1", - "weight": "25.0", + "weight": "8.0", "id": "5106", "maxAmount": "1" }, { "minAmount": "1", - "weight": "25.0", + "weight": "8.0", "id": "5280", "maxAmount": "1" }, { "minAmount": "1", - "weight": "25.0", + "weight": "8.0", "id": "5281", "maxAmount": "1" }, { "minAmount": "1", - "weight": "25.0", + "weight": "8.0", "id": "5100", "maxAmount": "1" }, { "minAmount": "1", - "weight": "25.0", + "weight": "8.0", "id": "5296", "maxAmount": "1" }, { "minAmount": "1", - "weight": "25.0", + "weight": "8.0", "id": "12176", "maxAmount": "1" }, { "minAmount": "1", - "weight": "25.0", + "weight": "8.0", "id": "5292", "maxAmount": "1" }, { "minAmount": "1", - "weight": "25.0", + "weight": "8.0", "id": "5297", "maxAmount": "1" }, { "minAmount": "1", - "weight": "25.0", + "weight": "8.0", "id": "5299", "maxAmount": "1" }, { "minAmount": "1", - "weight": "5.0", + "weight": "8.0", "id": "5301", "maxAmount": "1" }, @@ -8774,7 +8799,7 @@ }, { "minAmount": "1", - "weight": "5.0", + "weight": "8.0", "id": "5295", "maxAmount": "1" }, @@ -8804,37 +8829,37 @@ }, { "minAmount": "1", - "weight": "50.0", + "weight": "25.0", "id": "205", "maxAmount": "1" }, { "minAmount": "1", - "weight": "25.0", + "weight": "8.0", "id": "211", "maxAmount": "1" }, { "minAmount": "1", - "weight": "25.0", + "weight": "8.0", "id": "209", "maxAmount": "1" }, { "minAmount": "1", - "weight": "5.0", + "weight": "8.0", "id": "207", "maxAmount": "1" }, { "minAmount": "1", - "weight": "5.0", + "weight": "8.0", "id": "213", "maxAmount": "1" }, { "minAmount": "1", - "weight": "5.0", + "weight": "8.0", "id": "215", "maxAmount": "1" }, @@ -8873,6 +8898,36 @@ "weight": "5.0", "id": "31", "maxAmount": "1" + }, + { + "minAmount": "1", + "weight": "5.0", + "id": "5300", + "maxAmount": "1" + }, + { + "minAmount": "1", + "weight": "5.0", + "id": "5304", + "maxAmount": "1" + }, + { + "minAmount": "1", + "weight": "8.0", + "id": "1987", + "maxAmount": "3" + }, + { + "minAmount": "1", + "weight": "8.0", + "id": "1", + "maxAmount": "1" + }, + { + "minAmount": "1", + "weight": "50.0", + "id": "995", + "maxAmount": "62" } ] }, @@ -26189,16 +26244,10 @@ }, { "minAmount": "1", - "weight": "25.0", + "weight": "8.0", "id": "4131", "maxAmount": "1" }, - { - "minAmount": "1", - "weight": "5.0", - "id": "1185", - "maxAmount": "1" - }, { "minAmount": "1", "weight": "50.0", @@ -26217,63 +26266,45 @@ "id": "1353", "maxAmount": "1" }, - { - "minAmount": "1", - "weight": "5.0", - "id": "1303", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "5.0", - "id": "1373", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "5.0", - "id": "1319", - "maxAmount": "1" - }, { "minAmount": "5", - "weight": "50.0", + "weight": "25.0", "id": "560", "maxAmount": "5" }, { "minAmount": "10", - "weight": "50.0", + "weight": "25.0", "id": "560", "maxAmount": "10" }, { "minAmount": "3", - "weight": "25.0", + "weight": "12.5", "id": "562", "maxAmount": "3" }, { "minAmount": "37", - "weight": "25.0", + "weight": "12.5", "id": "562", "maxAmount": "37" }, { "minAmount": "1", - "weight": "50.0", + "weight": "25.0", "id": "5281", "maxAmount": "1" }, { "minAmount": "1", - "weight": "50.0", + "weight": "25.0", "id": "5297", "maxAmount": "1" }, { "minAmount": "1", - "weight": "50.0", + "weight": "25.0", "id": "5280", "maxAmount": "1" }, @@ -26309,27 +26340,21 @@ }, { "minAmount": "1", - "weight": "5.0", + "weight": "8.0", "id": "5303", "maxAmount": "1" }, { "minAmount": "1", - "weight": "5.0", + "weight": "8.0", "id": "5302", "maxAmount": "1" }, { - "minAmount": "1144", + "minAmount": "10", "weight": "50.0", "id": "995", - "maxAmount": "1144" - }, - { - "minAmount": "132", - "weight": "50.0", - "id": "995", - "maxAmount": "132" + "maxAmount": "460" }, { "minAmount": "1", @@ -26351,19 +26376,13 @@ }, { "minAmount": "1", - "weight": "5.0", - "id": "2363", + "weight": "8.0", + "id": "12070", "maxAmount": "1" }, { "minAmount": "1", - "weight": "5.0", - "id": "2723", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "5.0", + "weight": "16.0", "id": "31", "maxAmount": "1" }, @@ -26372,6 +26391,24 @@ "weight": "100.0", "id": "0", "maxAmount": "1" + }, + { + "minAmount": "1", + "weight": "8.0", + "id": "5300", + "maxAmount": "1" + }, + { + "minAmount": "1", + "weight": "8.0", + "id": "5304", + "maxAmount": "1" + }, + { + "minAmount": "1", + "weight": "25.0", + "id": "5295", + "maxAmount": "1" } ] }, @@ -37532,7 +37569,7 @@ { "minAmount": "1", "weight": "5.0", - "id": "13467", + "id": "5680", "maxAmount": "1" }, { diff --git a/Server/data/configs/item_configs.json b/Server/data/configs/item_configs.json index 6005b67b0..5ba72f572 100644 --- a/Server/data/configs/item_configs.json +++ b/Server/data/configs/item_configs.json @@ -45809,6 +45809,7 @@ "low_alchemy": "34000", "turn90ccw_anim": "1208", "attack_speed": "6", + "two_handed": "true", "turn180_anim": "1206", "defence_anim": "420", "equipment_slot": "3", @@ -45945,7 +45946,7 @@ "high_alchemy": "124800", "weight": "13", "weapon_interface": "2", - "render_anim": "1426", + "render_anim": "134", "name": "Dharok's greataxe" }, { @@ -47597,7 +47598,7 @@ "high_alchemy": "124800", "weight": "13", "weapon_interface": "2", - "render_anim": "1426", + "render_anim": "134", "attack_audios": "1320,0,0,0", "name": "Dharok's axe 100" }, @@ -47625,7 +47626,7 @@ "high_alchemy": "124800", "weight": "13", "weapon_interface": "2", - "render_anim": "1426", + "render_anim": "134", "attack_audios": "1320,0,0,0", "name": "Dharok's axe 75" }, @@ -47653,7 +47654,7 @@ "high_alchemy": "124800", "weight": "13", "weapon_interface": "2", - "render_anim": "1426", + "render_anim": "134", "attack_audios": "1320,0,0,0", "name": "Dharok's axe 50" }, @@ -47681,7 +47682,7 @@ "high_alchemy": "124800", "weight": "13", "weapon_interface": "2", - "render_anim": "1426", + "render_anim": "134", "attack_audios": "1320,0,0,0", "name": "Dharok's axe 25" }, @@ -47708,7 +47709,7 @@ "high_alchemy": "124800", "weight": "13", "weapon_interface": "2", - "render_anim": "1426", + "render_anim": "134", "attack_audios": "1320,0,0,0", "name": "Dharok's axe 0" }, diff --git a/Server/data/configs/npc_configs.json b/Server/data/configs/npc_configs.json index a64ea1344..ba9df7e53 100644 --- a/Server/data/configs/npc_configs.json +++ b/Server/data/configs/npc_configs.json @@ -12136,7 +12136,7 @@ "id": "1158", "aggressive": "true", "bonuses": "0,0,0,0,0,50,50,10,100,100,0,0,0,0,0", - "range_level": "1", + "range_level": "1000", "attack_level": "300" }, { @@ -12160,7 +12160,7 @@ "id": "1160", "aggressive": "true", "bonuses": "0,0,0,0,0,100,100,100,10,10,0,0,0,0,0", - "range_level": "1", + "range_level": "1000", "attack_level": "300" }, { @@ -34989,7 +34989,7 @@ "strength_level": "1", "id": "3835", "aggressive": "true", - "range_level": "1", + "range_level": "1000", "attack_level": "1" }, { @@ -35006,7 +35006,7 @@ "strength_level": "1", "id": "3836", "aggressive": "true", - "range_level": "1", + "range_level": "1000", "attack_level": "1" }, { @@ -57802,6 +57802,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6610", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -57811,6 +57812,7 @@ "examine": "A ghost of a knight slain during the god wars.", "melee_animation": "7441", "range_animation": "7522", + "poisonous": "true", "magic_level": "80", "poisonous": "true", "defence_animation": "7443", @@ -57896,6 +57898,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6615", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -57948,6 +57951,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6618", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -58065,6 +58069,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6624", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -58097,6 +58102,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6626", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -58153,6 +58159,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6629", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -58228,6 +58235,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6633", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -58527,6 +58535,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6648", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -58621,6 +58630,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6653", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -58837,6 +58847,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6664", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -58953,6 +58964,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6670", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -58986,6 +58998,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6672", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -59346,6 +59359,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6690", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -59461,6 +59475,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6696", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -59573,6 +59588,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6702", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -59787,6 +59803,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6713", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -60023,6 +60040,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6725", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -60097,6 +60115,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6729", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -86429,7 +86448,7 @@ "id": "1158", "aggressive": "true", "bonuses": "0,0,0,0,0,50,50,10,100,100,0,0,0,0,0", - "range_level": "1", + "range_level": "1000", "attack_level": "300" }, { @@ -86453,7 +86472,7 @@ "id": "1160", "aggressive": "true", "bonuses": "0,0,0,0,0,100,100,100,10,10,0,0,0,0,0", - "range_level": "1", + "range_level": "1000", "attack_level": "300" }, { @@ -109282,7 +109301,7 @@ "strength_level": "1", "id": "3835", "aggressive": "true", - "range_level": "1", + "range_level": "1000", "attack_level": "1" }, { @@ -109299,7 +109318,7 @@ "strength_level": "1", "id": "3836", "aggressive": "true", - "range_level": "1", + "range_level": "1000", "attack_level": "1" }, { @@ -132343,6 +132362,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6610", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -132352,6 +132372,7 @@ "examine": "A ghost of a knight slain during the god wars.", "melee_animation": "7441", "range_animation": "7522", + "poisonous": "true", "magic_level": "80", "poisonous": "true", "defence_animation": "7443", @@ -132437,6 +132458,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6615", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -132489,6 +132511,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6618", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -132606,6 +132629,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6624", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -132638,6 +132662,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6626", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -132694,6 +132719,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6629", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -132769,6 +132795,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6633", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -133068,6 +133095,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6648", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -133162,6 +133190,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6653", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -133378,6 +133407,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6664", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -133494,6 +133524,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6670", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -133527,6 +133558,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6672", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -133887,6 +133919,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6690", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -134002,6 +134035,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6696", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -134114,6 +134148,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6702", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -134328,6 +134363,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6713", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -134564,6 +134600,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6725", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -134638,6 +134675,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6729", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -160978,7 +161016,7 @@ "id": "1158", "aggressive": "true", "bonuses": "0,0,0,0,0,50,50,10,100,100,0,0,0,0,0", - "range_level": "1", + "range_level": "1000", "attack_level": "300" }, { @@ -161002,7 +161040,7 @@ "id": "1160", "aggressive": "true", "bonuses": "0,0,0,0,0,100,100,100,10,10,0,0,0,0,0", - "range_level": "1", + "range_level": "1000", "attack_level": "300" }, { @@ -183831,7 +183869,7 @@ "strength_level": "1", "id": "3835", "aggressive": "true", - "range_level": "1", + "range_level": "1000", "attack_level": "1" }, { @@ -183848,7 +183886,7 @@ "strength_level": "1", "id": "3836", "aggressive": "true", - "range_level": "1", + "range_level": "1000", "attack_level": "1" }, { @@ -206644,6 +206682,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6610", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -206653,6 +206692,7 @@ "examine": "A ghost of a knight slain during the god wars.", "melee_animation": "7441", "range_animation": "7522", + "poisonous": "true", "magic_level": "80", "poisonous": "true", "defence_animation": "7443", @@ -206738,6 +206778,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6615", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -206790,6 +206831,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6618", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -206907,6 +206949,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6624", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -206939,6 +206982,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6626", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -206995,6 +207039,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6629", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -207070,6 +207115,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6633", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -207369,6 +207415,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6648", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -207463,6 +207510,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6653", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -207679,6 +207727,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6664", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -207795,6 +207844,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6670", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -207828,6 +207878,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6672", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -208188,6 +208239,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6690", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -208303,6 +208355,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6696", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -208415,6 +208468,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6702", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -208629,6 +208683,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6713", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -208865,6 +208920,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6725", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -208939,6 +208995,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6729", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -235271,7 +235328,7 @@ "id": "1158", "aggressive": "true", "bonuses": "0,0,0,0,0,50,50,10,100,100,0,0,0,0,0", - "range_level": "1", + "range_level": "1000", "attack_level": "300" }, { @@ -235295,7 +235352,7 @@ "id": "1160", "aggressive": "true", "bonuses": "0,0,0,0,0,100,100,100,10,10,0,0,0,0,0", - "range_level": "1", + "range_level": "1000", "attack_level": "300" }, { @@ -258124,7 +258181,7 @@ "strength_level": "1", "id": "3835", "aggressive": "true", - "range_level": "1", + "range_level": "1000", "attack_level": "1" }, { @@ -258141,7 +258198,7 @@ "strength_level": "1", "id": "3836", "aggressive": "true", - "range_level": "1", + "range_level": "1000", "attack_level": "1" }, { @@ -281185,6 +281242,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6610", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -281194,6 +281252,7 @@ "examine": "A ghost of a knight slain during the god wars.", "melee_animation": "7441", "range_animation": "7522", + "poisonous": "true", "magic_level": "80", "poisonous": "true", "defence_animation": "7443", @@ -281279,6 +281338,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6615", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -281331,6 +281391,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6618", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -281448,6 +281509,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6624", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -281480,6 +281542,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6626", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -281536,6 +281599,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6629", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -281611,6 +281675,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6633", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -281910,6 +281975,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6648", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -282004,6 +282070,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6653", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -282220,6 +282287,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6664", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -282336,6 +282404,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6670", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -282369,6 +282438,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6672", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -282729,6 +282799,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6690", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -282844,6 +282915,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6696", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -282956,6 +283028,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6702", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -283170,6 +283243,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6713", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -283406,6 +283480,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6725", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" @@ -283480,6 +283555,7 @@ "lifepoints": "105", "strength_level": "70", "id": "6729", + "magic_level": "70", "clue_level": "2", "range_level": "70", "attack_level": "70" diff --git a/Server/data/configs/npc_spawns.json b/Server/data/configs/npc_spawns.json index 6e30e2cbf..e657c50e1 100644 --- a/Server/data/configs/npc_spawns.json +++ b/Server/data/configs/npc_spawns.json @@ -6281,7 +6281,7 @@ }, { "npc_id": "4383", - "loc_data": "{2321,5225,0,0,3}-{2321,5223,0,0,4}-{2317,5229,0,0,7}-{2322,5225,0,0,1}-{2325,5231,0,0,6}-{2321,5225,0,0,1}-{2314,5227,0,0,2}-{2312,5229,0,0,2}-{2330,5229,0,0,1}-{2324,5233,0,0,4}-{2320,5232,0,0,3}-{2324,5237,0,0,1}-{2329,5229,0,0,6}-{2315,5227,0,0,7}-{2318,5226,0,0,6}-{2322,5222,0,0,6}" + "loc_data": "{2321,5225,0,1,3}-{2321,5223,0,1,4}-{2317,5229,0,1,7}-{2322,5225,0,1,1}-{2325,5231,0,1,6}-{2321,5225,0,1,1}-{2314,5227,0,1,2}-{2312,5229,0,1,2}-{2330,5229,0,1,1}-{2324,5233,0,1,4}-{2320,5232,0,1,3}-{2324,5237,0,1,1}-{2329,5229,0,1,6}-{2315,5227,0,1,7}-{2318,5226,0,1,6}-{2322,5222,0,1,6}" }, { "npc_id": "4384", diff --git a/Server/data/configs/shops.json b/Server/data/configs/shops.json index 60f8eb0ff..930720c4d 100644 --- a/Server/data/configs/shops.json +++ b/Server/data/configs/shops.json @@ -666,7 +666,7 @@ "stock": "{5376,10}-{6032,300}-{5418,10}-{6036,10}-{5354,100}-{5341,10}-{5329,10}-{5343,10}-{952,10}-{5325,10}-{1925,100}-{5331,30}-{12622,10}-{5996,0}-{6006,0}-{1965,0}-{5994,0}-{5931,0}-{6000,0}-{1957,0}-{5504,0}-{5986,0}-{1982,0}-{5982,0}-{6002,0}-{5998,0}" }, { - "npcs": "1783", + "npcs": "2306", "high_alch": "0", "currency": "995", "general_store": "false", diff --git a/Server/libs/classgraph-4.8.98.jar b/Server/libs/classgraph-4.8.98.jar new file mode 100644 index 000000000..240e6daca Binary files /dev/null and b/Server/libs/classgraph-4.8.98.jar differ diff --git a/Server/libs/colormath-jvm-2.0.0.jar b/Server/libs/colormath-jvm-2.0.0.jar new file mode 100644 index 000000000..d66ecc3f9 Binary files /dev/null and b/Server/libs/colormath-jvm-2.0.0.jar differ diff --git a/Server/libs/json-simple-1.1.1.jar b/Server/libs/json-simple-1.1.1.jar new file mode 100644 index 000000000..dfd5856d0 Binary files /dev/null and b/Server/libs/json-simple-1.1.1.jar differ diff --git a/Server/libs/kotlin-reflect-1.5.20.jar b/Server/libs/kotlin-reflect-1.5.20.jar new file mode 100644 index 000000000..1d16a63cb Binary files /dev/null and b/Server/libs/kotlin-reflect-1.5.20.jar differ diff --git a/Server/libs/markdown-jvm-0.2.4.jar b/Server/libs/markdown-jvm-0.2.4.jar new file mode 100644 index 000000000..19cbfcfd9 Binary files /dev/null and b/Server/libs/markdown-jvm-0.2.4.jar differ diff --git a/Server/libs/mordant-jvm-2.0.0-alpha2.jar b/Server/libs/mordant-jvm-2.0.0-alpha2.jar new file mode 100644 index 000000000..7f15957db Binary files /dev/null and b/Server/libs/mordant-jvm-2.0.0-alpha2.jar differ diff --git a/Server/libs/mysql-connector-java-8.0.21.jar b/Server/libs/mysql-connector-java-8.0.21.jar new file mode 100644 index 000000000..51e270c46 Binary files /dev/null and b/Server/libs/mysql-connector-java-8.0.21.jar differ diff --git a/Server/src/main/java/core/cache/ServerStore.java b/Server/src/main/java/core/cache/AriosStore.java similarity index 99% rename from Server/src/main/java/core/cache/ServerStore.java rename to Server/src/main/java/core/cache/AriosStore.java index 207c511c6..45980957f 100644 --- a/Server/src/main/java/core/cache/ServerStore.java +++ b/Server/src/main/java/core/cache/AriosStore.java @@ -15,7 +15,7 @@ import core.cache.misc.buffer.ByteBufferUtils; * The server data storage. * @author Emperor */ -public final class ServerStore { +public final class AriosStore { /** * The storage. diff --git a/Server/src/main/java/core/cache/bzip2/BZip2Decompressor.java b/Server/src/main/java/core/cache/bzip2/BZip2Decompressor.java index 0af0ddc5a..f62ec1145 100644 --- a/Server/src/main/java/core/cache/bzip2/BZip2Decompressor.java +++ b/Server/src/main/java/core/cache/bzip2/BZip2Decompressor.java @@ -100,10 +100,6 @@ public class BZip2Decompressor { i1++; j1--; } while (true); - if (j1 == 0) { - i = 1; - break; - } abyte0[i1] = byte4; i1++; j1--; diff --git a/Server/src/main/java/core/cache/def/Definition.java b/Server/src/main/java/core/cache/def/Definition.java index 40b227a2e..c6a4d5f8d 100644 --- a/Server/src/main/java/core/cache/def/Definition.java +++ b/Server/src/main/java/core/cache/def/Definition.java @@ -139,8 +139,11 @@ public class Definition { public String getExamine() { if (examine == null) { try { - examine = handlers.get("examine").toString(); - } catch (Exception e){} + if(handlers.get("examine") != null) + examine = handlers.get("examine").toString(); + } catch (Exception e){ + e.printStackTrace(); + } if(examine == null) { if (name.length() > 0) { examine = "It's a" + (StringUtils.isPlusN(name) ? "n " : " ") + name + "."; diff --git a/Server/src/main/java/core/cache/def/impl/CS2Mapping.java b/Server/src/main/java/core/cache/def/impl/CS2Mapping.java index b5b7b9d5f..cc1914b50 100644 --- a/Server/src/main/java/core/cache/def/impl/CS2Mapping.java +++ b/Server/src/main/java/core/cache/def/impl/CS2Mapping.java @@ -3,6 +3,8 @@ package core.cache.def.impl; import java.io.BufferedWriter; import java.io.FileWriter; import java.nio.ByteBuffer; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.HashMap; import java.util.Map; @@ -71,7 +73,7 @@ public final class CS2Mapping { */ public static void main(String... args) throws Throwable { GameWorld.prompt(false); - BufferedWriter bw = new BufferedWriter(new FileWriter("./cs2.txt")); + BufferedWriter bw = Files.newBufferedWriter(Paths.get("./cs2.txt")); for (int i = 0; i < 10000; i++) { CS2Mapping mapping = forId(i); if (mapping == null) { diff --git a/Server/src/main/java/core/cache/def/impl/GraphicDefinition.java b/Server/src/main/java/core/cache/def/impl/GraphicDefinition.java index e10933de5..e554a3b1e 100644 --- a/Server/src/main/java/core/cache/def/impl/GraphicDefinition.java +++ b/Server/src/main/java/core/cache/def/impl/GraphicDefinition.java @@ -48,7 +48,7 @@ public class GraphicDefinition { if (def != null) { return def; } - byte[] data = Cache.getIndexes()[21].getFileData(gfxId >>> 735411752, gfxId & 0xff); + byte[] data = Cache.getIndexes()[21].getFileData(gfxId >>> 8, gfxId & 0xff); def = new GraphicDefinition(); def.graphicsId = gfxId; if (data != null) { diff --git a/Server/src/main/java/core/cache/def/impl/NPCDefinition.java b/Server/src/main/java/core/cache/def/impl/NPCDefinition.java index 4a118143f..e2105888f 100644 --- a/Server/src/main/java/core/cache/def/impl/NPCDefinition.java +++ b/Server/src/main/java/core/cache/def/impl/NPCDefinition.java @@ -57,10 +57,8 @@ public final class NPCDefinition extends Definition { */ public boolean isVisibleOnMap; - /** - * The examine option value - */ - public String examine; + +/* public String examine;*/ /** * The drop tables. @@ -201,7 +199,7 @@ public final class NPCDefinition extends Definition { NPCDefinition def = DEFINITIONS.get(id); if (def == null) { def = new NPCDefinition(id); - byte[] data = Cache.getIndexes()[18].getFileData(id >>> 134238215, id & 0x7f); + byte[] data = Cache.getIndexes()[18].getFileData(id >>> 7, id & 0x7f); if (data == null) { if (id != -1) { // System.out.println("Failed loading NPC " + id + "."); @@ -625,6 +623,8 @@ public final class NPCDefinition extends Definition { case 4: name = NPCConfigParser.DEATH_ANIMATION; break; + default: + break; } return getConfiguration(name, null); } diff --git a/Server/src/main/java/core/cache/def/impl/RenderAnimationDefinition.java b/Server/src/main/java/core/cache/def/impl/RenderAnimationDefinition.java index 9c3128595..08d1c97bc 100644 --- a/Server/src/main/java/core/cache/def/impl/RenderAnimationDefinition.java +++ b/Server/src/main/java/core/cache/def/impl/RenderAnimationDefinition.java @@ -64,12 +64,11 @@ public class RenderAnimationDefinition { * @return The render animation definitions. */ public static RenderAnimationDefinition forId(int animId) { - RenderAnimationDefinition defs = new RenderAnimationDefinition(); if (animId == -1) { return null; } byte[] data = Cache.getIndexes()[2].getFileData(32, animId); - defs = new RenderAnimationDefinition(); + RenderAnimationDefinition defs = new RenderAnimationDefinition(); if (data != null) { defs.parse(ByteBuffer.wrap(data)); } else { diff --git a/Server/src/main/java/core/cache/def/impl/SceneryDefinition.java b/Server/src/main/java/core/cache/def/impl/SceneryDefinition.java index 1e55ae82f..d2342d415 100644 --- a/Server/src/main/java/core/cache/def/impl/SceneryDefinition.java +++ b/Server/src/main/java/core/cache/def/impl/SceneryDefinition.java @@ -1670,6 +1670,6 @@ public class SceneryDefinition extends Definition { * @return The container id. */ public static int getContainerId(int id) { - return id >>> 1998118472; + return id >>> 8; } } \ No newline at end of file diff --git a/Server/src/main/java/core/cache/gzip/GZipDecompressor.java b/Server/src/main/java/core/cache/gzip/GZipDecompressor.java index 021751497..0b4506456 100644 --- a/Server/src/main/java/core/cache/gzip/GZipDecompressor.java +++ b/Server/src/main/java/core/cache/gzip/GZipDecompressor.java @@ -7,7 +7,7 @@ public class GZipDecompressor { private static final Inflater inflaterInstance = new Inflater(true); - public static final void decompress(ByteBuffer buffer, byte data[]) { + public static final void decompress(ByteBuffer buffer, byte[] data) { synchronized (inflaterInstance) { if (~buffer.get(buffer.position()) != -32 || buffer.get(buffer.position() + 1) != -117) { data = null; diff --git a/Server/src/main/java/core/cache/misc/buffer/ByteBufferUtils.java b/Server/src/main/java/core/cache/misc/buffer/ByteBufferUtils.java index c481ffd6c..6c08a9db1 100644 --- a/Server/src/main/java/core/cache/misc/buffer/ByteBufferUtils.java +++ b/Server/src/main/java/core/cache/misc/buffer/ByteBufferUtils.java @@ -2,6 +2,7 @@ package core.cache.misc.buffer; import java.io.ObjectInputStream; import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; /** * Holds utility methods for reading/writing a byte buffer. @@ -29,7 +30,7 @@ public final class ByteBufferUtils { * @param buffer The byte buffer. */ public static void putString(String s, ByteBuffer buffer) { - buffer.put(s.getBytes()).put((byte) 0); + buffer.put(s.getBytes(StandardCharsets.UTF_8)).put((byte) 0); } /** diff --git a/Server/src/main/java/core/game/container/Container.java b/Server/src/main/java/core/game/container/Container.java index 44857663c..d21244289 100644 --- a/Server/src/main/java/core/game/container/Container.java +++ b/Server/src/main/java/core/game/container/Container.java @@ -521,7 +521,7 @@ public class Container { int id = buffer.getShort() & 0xFFFF; int amount = buffer.getInt(); int charge = buffer.getInt(); - if (id >= ItemDefinition.getDefinitions().size() || id < 0 || slot >= items.length || slot < 0) { + if (id >= ItemDefinition.getDefinitions().size() || slot >= items.length || slot < 0) { continue; } Item item = items[slot] = new Item(id, amount, charge); diff --git a/Server/src/main/java/core/game/content/activity/bountyhunter/BHScoreBoard.java b/Server/src/main/java/core/game/content/activity/bountyhunter/BHScoreBoard.java index 30613f9c5..5f3c1718b 100644 --- a/Server/src/main/java/core/game/content/activity/bountyhunter/BHScoreBoard.java +++ b/Server/src/main/java/core/game/content/activity/bountyhunter/BHScoreBoard.java @@ -2,7 +2,7 @@ package core.game.content.activity.bountyhunter; import java.nio.ByteBuffer; -import core.cache.ServerStore; +import core.cache.AriosStore; import core.cache.StoreFile; import core.cache.misc.buffer.ByteBufferUtils; import core.game.component.Component; @@ -53,7 +53,7 @@ public final class BHScoreBoard { * Initializes the score boards data. */ public static void init() { - StoreFile file = ServerStore.get("bh_scores"); + StoreFile file = AriosStore.get("bh_scores"); if (file == null) { // Indicates no cache exists yet. return; } @@ -82,7 +82,7 @@ public final class BHScoreBoard { ByteBufferUtils.putString(ROGUES.names[i], buffer); } buffer.flip(); - ServerStore.setArchive("bh_scores", buffer); + AriosStore.setArchive("bh_scores", buffer); } /** diff --git a/Server/src/main/java/core/game/content/activity/duel/DuelRule.java b/Server/src/main/java/core/game/content/activity/duel/DuelRule.java index cdcfb8fb2..88de3f9d7 100644 --- a/Server/src/main/java/core/game/content/activity/duel/DuelRule.java +++ b/Server/src/main/java/core/game/content/activity/duel/DuelRule.java @@ -69,12 +69,4 @@ public enum DuelRule { public int getEquipmentSlot() { return equipmentSlot; } - - /** - * Sets the equipmentSlot. - * @param equipmentSlot the equipmentSlot to set - */ - public void setEquipmentSlot(int equipmentSlot) { - this.equipmentSlot = equipmentSlot; - } } \ No newline at end of file diff --git a/Server/src/main/java/core/game/content/activity/guild/RangingGuildPlugin.java b/Server/src/main/java/core/game/content/activity/guild/RangingGuildPlugin.java index 9d7216344..e3c156830 100644 --- a/Server/src/main/java/core/game/content/activity/guild/RangingGuildPlugin.java +++ b/Server/src/main/java/core/game/content/activity/guild/RangingGuildPlugin.java @@ -1164,7 +1164,7 @@ public final class RangingGuildPlugin extends OptionHandler { cumulativeStr += 1; }*/ cumulativeStr *= 1.0; - int hit = (int) ((14 + cumulativeStr + (bonus / 8) + ((cumulativeStr * bonus) * 0.016865)) * 1.0) / 10 + 1; + int hit = (int) ((14 + cumulativeStr + (bonus / 8) + ((cumulativeStr * bonus) * 0.016865))) / 10 + 1; hit = hit + RandomFunction.randomSign(RandomFunction.random(3)); int target = Math.max(0, 13 - hit); diff --git a/Server/src/main/java/core/game/content/activity/gwd/GWDGraardorSwingHandler.java b/Server/src/main/java/core/game/content/activity/gwd/GWDGraardorSwingHandler.java index ba97fef05..8d5fbf21b 100644 --- a/Server/src/main/java/core/game/content/activity/gwd/GWDGraardorSwingHandler.java +++ b/Server/src/main/java/core/game/content/activity/gwd/GWDGraardorSwingHandler.java @@ -6,6 +6,7 @@ import java.util.List; import core.game.node.entity.Entity; import core.game.node.entity.combat.BattleState; import core.game.node.entity.combat.CombatStyle; +import org.jetbrains.annotations.NotNull; import rs09.game.node.entity.combat.CombatSwingHandler; import core.game.node.entity.combat.InteractionType; import core.game.node.entity.combat.equipment.ArmourSet; @@ -76,7 +77,7 @@ public final class GWDGraardorSwingHandler extends CombatSwingHandler { } BattleState[] targets; state.setStyle(CombatStyle.RANGE); - state.setTargets(targets = list.toArray(new BattleState[list.size()])); + state.setTargets(targets = list.toArray(new BattleState[0])); for (BattleState s : targets) { s.setStyle(CombatStyle.RANGE); int hit = 0; @@ -93,41 +94,46 @@ public final class GWDGraardorSwingHandler extends CombatSwingHandler { @Override public void visualize(Entity entity, Entity victim, BattleState state) { - switch (state.getStyle()) { - case MELEE: - entity.animate(MELEE_ATTACK); - break; - default: - entity.animate(RANGE_ATTACK); - for (BattleState s : state.getTargets()) { - Projectile.ranged(entity, s.getVictim(), 1200, 0, 0, 46, 1).send(); + if(state != null) { + if (state.getStyle() == CombatStyle.MELEE) { + entity.animate(MELEE_ATTACK); + } else { + entity.animate(RANGE_ATTACK); + for (BattleState s : state.getTargets()) { + Projectile.ranged(entity, s.getVictim(), 1200, 0, 0, 46, 1).send(); + } } - break; } } @Override public ArmourSet getArmourSet(Entity e) { - return getType().getSwingHandler().getArmourSet(e); + if(getType() != null) + return getType().getSwingHandler().getArmourSet(e); + else return ArmourSet.AHRIM; } @Override public double getSetMultiplier(Entity e, int skillId) { - return getType().getSwingHandler().getSetMultiplier(e, skillId); + if(getType() != null) + return getType().getSwingHandler().getSetMultiplier(e, skillId); + else return 0.0; } @Override public void impact(Entity entity, Entity victim, BattleState state) { - if (state.getStyle() == CombatStyle.MELEE) { + if (state != null && state.getStyle() != null && state.getStyle() == CombatStyle.MELEE) { state.getStyle().getSwingHandler().impact(entity, victim, state); return; } - for (BattleState s : state.getTargets()) { - if (s == null || s.getEstimatedHit() < 0) { - continue; + if(state != null && state.getTargets() != null) { + for (BattleState s : state.getTargets()) { + if (s == null || s.getEstimatedHit() < 0) { + continue; + } + int hit = s.getEstimatedHit(); + s.getVictim().getImpactHandler().handleImpact(entity, hit, CombatStyle.RANGE, s); } - int hit = s.getEstimatedHit(); - s.getVictim().getImpactHandler().handleImpact(entity, hit, CombatStyle.RANGE, s); } } @@ -155,17 +161,23 @@ public final class GWDGraardorSwingHandler extends CombatSwingHandler { @Override public int calculateAccuracy(Entity entity) { - return getType().getSwingHandler().calculateAccuracy(entity); + if(getType() != null) + return getType().getSwingHandler().calculateAccuracy(entity); + else return -1; } @Override - public int calculateDefence(Entity entity, Entity attacker) { - return getType().getSwingHandler().calculateDefence(entity, attacker); + public int calculateDefence(Entity victim, Entity attacker) { + if(getType() != null) + return getType().getSwingHandler().calculateDefence(victim, attacker); + else return -1; } @Override public int calculateHit(Entity entity, Entity victim, double modifier) { - return getType().getSwingHandler().calculateHit(entity, victim, modifier); + if(getType() != null) + return getType().getSwingHandler().calculateHit(entity, victim, modifier); + else return -1; } } \ No newline at end of file diff --git a/Server/src/main/java/core/game/content/activity/gwd/GWDKreeArraSwingHandler.java b/Server/src/main/java/core/game/content/activity/gwd/GWDKreeArraSwingHandler.java index 01d6de51b..77d0a50a8 100644 --- a/Server/src/main/java/core/game/content/activity/gwd/GWDKreeArraSwingHandler.java +++ b/Server/src/main/java/core/game/content/activity/gwd/GWDKreeArraSwingHandler.java @@ -61,11 +61,11 @@ public final class GWDKreeArraSwingHandler extends CombatSwingHandler { @Override public int swing(Entity entity, Entity victim, BattleState state) { int ticks = 1; - int distance = entity.size() >> 1; - if (!entity.inCombat()) { + int distance = entity != null ? entity.size() >> 1 : 0; + if (entity != null && !entity.inCombat()) { distance++; } - if (victim.getLocation().withinDistance(entity.getCenterLocation(), distance) && RandomFunction.RANDOM.nextBoolean()) { + if (entity != null && victim.getLocation().withinDistance(entity.getCenterLocation(), distance) && RandomFunction.RANDOM.nextBoolean()) { int hit = 0; int max = CombatStyle.MELEE.getSwingHandler().calculateHit(entity, victim, 1.0); if (CombatStyle.MELEE.getSwingHandler().isAccurateImpact(entity, victim, CombatStyle.MELEE)) { @@ -80,7 +80,7 @@ public final class GWDKreeArraSwingHandler extends CombatSwingHandler { state.setMaximumHit(max); state.setStyle(CombatStyle.MELEE); } else { - ticks += (int) Math.ceil(entity.getLocation().getDistance(victim.getLocation()) * 0.3); + ticks += (int) Math.ceil(entity != null ? entity.getLocation().getDistance(victim.getLocation()) : 0.0 * 0.3); NPC npc = (NPC) entity; List list = new ArrayList<>(20); for (Entity t : RegionManager.getLocalPlayers(npc, 28)) { @@ -93,7 +93,7 @@ public final class GWDKreeArraSwingHandler extends CombatSwingHandler { } BattleState[] targets; state.setStyle(CombatStyle.RANGE); - state.setTargets(targets = list.toArray(new BattleState[list.size()])); + state.setTargets(targets = list.toArray(new BattleState[0])); for (BattleState s : targets) { CombatStyle style = RandomFunction.randomize(10) < 3 ? CombatStyle.MAGIC : CombatStyle.RANGE; s.setStyle(style); @@ -114,62 +114,69 @@ public final class GWDKreeArraSwingHandler extends CombatSwingHandler { @Override public void visualize(Entity entity, Entity victim, BattleState state) { - switch (state.getStyle()) { - case MELEE: - entity.animate(MELEE_ATTACK); - break; - default: - entity.animate(RANGE_ATTACK); - for (BattleState s : state.getTargets()) { - int gfxId = 1197; - if (s.getStyle() == CombatStyle.MAGIC) { - gfxId = 1198; + if(state != null) { + if (state.getStyle() == CombatStyle.MELEE) { + entity.animate(MELEE_ATTACK); + } else { + entity.animate(RANGE_ATTACK); + for (BattleState s : state.getTargets()) { + int gfxId = 1197; + if (s.getStyle() == CombatStyle.MAGIC) { + gfxId = 1198; + } + Projectile.ranged(entity, s.getVictim(), gfxId, 92, 36, 46, 5).send(); } - Projectile.ranged(entity, s.getVictim(), gfxId, 92, 36, 46, 5).send(); } - break; } } @Override public ArmourSet getArmourSet(Entity e) { - return getType().getSwingHandler().getArmourSet(e); + if(getType() != null) + return getType().getSwingHandler().getArmourSet(e); + else return ArmourSet.AHRIM; } @Override public double getSetMultiplier(Entity e, int skillId) { - return getType().getSwingHandler().getSetMultiplier(e, skillId); + if(getType() != null) + return getType().getSwingHandler().getSetMultiplier(e, skillId); + else return 0.0; } @Override public void impact(Entity entity, Entity victim, BattleState state) { - if (state.getStyle() == CombatStyle.MELEE) { + if (state != null && state.getStyle() == CombatStyle.MELEE) { state.getStyle().getSwingHandler().impact(entity, victim, state); return; } - for (BattleState s : state.getTargets()) { - if (s == null || s.getEstimatedHit() < 0) { - continue; + if(state != null) { + for (BattleState s : state.getTargets()) { + if (s == null || s.getEstimatedHit() < 0) { + continue; + } + int hit = s.getEstimatedHit(); + s.getVictim().getImpactHandler().handleImpact(entity, hit, s.getStyle(), s); } - int hit = s.getEstimatedHit(); - s.getVictim().getImpactHandler().handleImpact(entity, hit, s.getStyle(), s); } } @Override public void visualizeImpact(Entity entity, Entity victim, BattleState state) { - if (state.getStyle() == CombatStyle.MELEE) { + if (state != null && state.getStyle() == CombatStyle.MELEE) { victim.animate(victim.getProperties().getDefenceAnimation()); return; } - for (BattleState s : state.getTargets()) { - s.getVictim().animate(s.getVictim().getProperties().getDefenceAnimation()); - if (RandomFunction.randomize(10) < 8) { - Direction dir = Direction.getLogicalDirection(entity.getLocation(), s.getVictim().getLocation()); - Location destination = s.getVictim().getLocation().transform(dir.getStepX(), dir.getStepY(), 0); - if (CHAMBER.insideBorder(destination)) { - s.getVictim().getProperties().setTeleportLocation(destination); - s.getVictim().graphics(END_GRAPHIC); + if(state != null) { + for (BattleState s : state.getTargets()) { + s.getVictim().animate(s.getVictim().getProperties().getDefenceAnimation()); + if (RandomFunction.randomize(10) < 8) { + Direction dir = Direction.getLogicalDirection(entity.getLocation(), s.getVictim().getLocation()); + Location destination = s.getVictim().getLocation().transform(dir.getStepX(), dir.getStepY(), 0); + if (CHAMBER.insideBorder(destination)) { + s.getVictim().getProperties().setTeleportLocation(destination); + s.getVictim().graphics(END_GRAPHIC); + } } } } @@ -188,17 +195,23 @@ public final class GWDKreeArraSwingHandler extends CombatSwingHandler { @Override public int calculateAccuracy(Entity entity) { - return getType().getSwingHandler().calculateAccuracy(entity); + if(getType() != null) + return getType().getSwingHandler().calculateAccuracy(entity); + else return -1; } @Override - public int calculateDefence(Entity entity, Entity attacker) { - return getType().getSwingHandler().calculateDefence(entity, attacker); + public int calculateDefence(Entity victim, Entity attacker) { + if(getType() != null) + return getType().getSwingHandler().calculateDefence(victim, attacker); + else return -1; } @Override public int calculateHit(Entity entity, Entity victim, double modifier) { - return getType().getSwingHandler().calculateHit(entity, victim, modifier); + if(getType() != null) + return getType().getSwingHandler().calculateHit(entity, victim, modifier); + else return -1; } } \ No newline at end of file diff --git a/Server/src/main/java/core/game/content/activity/gwd/GWDTsutsarothSwingHandler.java b/Server/src/main/java/core/game/content/activity/gwd/GWDTsutsarothSwingHandler.java index a21b634db..57032f817 100644 --- a/Server/src/main/java/core/game/content/activity/gwd/GWDTsutsarothSwingHandler.java +++ b/Server/src/main/java/core/game/content/activity/gwd/GWDTsutsarothSwingHandler.java @@ -75,7 +75,7 @@ public final class GWDTsutsarothSwingHandler extends CombatSwingHandler { victim.getStateManager().register(EntityState.POISONED, false, 168, entity); } if (special) { - ((Player) victim).getSkills().decrementPrayerPoints(hit / 2); + ((Player) victim).getSkills().decrementPrayerPoints((double) hit / 2); } } state.setEstimatedHit(hit); @@ -85,14 +85,14 @@ public final class GWDTsutsarothSwingHandler extends CombatSwingHandler { @Override public void visualize(Entity entity, Entity victim, BattleState state) { - switch (state.getStyle()) { - case MELEE: + if(entity == null || state == null || state.getStyle() == null){ + return; + } + if (state.getStyle() == CombatStyle.MELEE) { entity.animate(MELEE_ATTACK); - break; - default: + } else { entity.visualize(MAGIC_ATTACK, MAGIC_START); Projectile.magic(entity, victim, 1211, 0, 0, 46, 1).send(); - break; } } @@ -143,8 +143,8 @@ public final class GWDTsutsarothSwingHandler extends CombatSwingHandler { } @Override - public int calculateDefence(Entity entity, Entity attacker) { - return getType().getSwingHandler().calculateDefence(entity, attacker); + public int calculateDefence(Entity victim, Entity attacker) { + return getType().getSwingHandler().calculateDefence(victim, attacker); } @Override diff --git a/Server/src/main/java/core/game/content/activity/gwd/GWDZilyanaSwingHandler.java b/Server/src/main/java/core/game/content/activity/gwd/GWDZilyanaSwingHandler.java index 03e692898..1dec4fb03 100644 --- a/Server/src/main/java/core/game/content/activity/gwd/GWDZilyanaSwingHandler.java +++ b/Server/src/main/java/core/game/content/activity/gwd/GWDZilyanaSwingHandler.java @@ -64,7 +64,7 @@ public class GWDZilyanaSwingHandler extends CombatSwingHandler { list.add(new BattleState(entity, t)); } } - state.setTargets(targets = list.toArray(new BattleState[list.size()])); + state.setTargets(targets = list.toArray(new BattleState[0])); state.setStyle(CombatStyle.MAGIC); setType(CombatStyle.MAGIC); } @@ -83,31 +83,38 @@ public class GWDZilyanaSwingHandler extends CombatSwingHandler { @Override public void visualize(Entity entity, Entity victim, BattleState state) { - switch (getType()) { - case MELEE: - entity.animate(MELEE_ATTACK); - break; - case MAGIC: - entity.animate(MAGIC_ATTACK); - break; - default: - break; + if(getType() != null) { + switch (getType()) { + case MELEE: + entity.animate(MELEE_ATTACK); + break; + case MAGIC: + entity.animate(MAGIC_ATTACK); + break; + default: + break; + } } } @Override public ArmourSet getArmourSet(Entity e) { - return getType().getSwingHandler().getArmourSet(e); + if(getType() != null) + return getType().getSwingHandler().getArmourSet(e); + else return ArmourSet.AHRIM; } @Override public double getSetMultiplier(Entity e, int skillId) { - return getType().getSwingHandler().getSetMultiplier(e, skillId); + if(getType() != null) + return getType().getSwingHandler().getSetMultiplier(e, skillId); + else return -1; } @Override public void impact(Entity entity, Entity victim, BattleState state) { - state.getStyle().getSwingHandler().impact(entity, victim, state); + if(state != null) + state.getStyle().getSwingHandler().impact(entity, victim, state); } @Override @@ -117,22 +124,28 @@ public class GWDZilyanaSwingHandler extends CombatSwingHandler { @Override public int calculateAccuracy(Entity entity) { - return getType().getSwingHandler().calculateAccuracy(entity); + if(getType() != null) + return getType().getSwingHandler().calculateAccuracy(entity); + else return -1; } @Override - public int calculateDefence(Entity entity, Entity attacker) { - return getType().getSwingHandler().calculateDefence(entity, attacker); + public int calculateDefence(Entity victim, Entity attacker) { + if(getType() != null) + return getType().getSwingHandler().calculateDefence(victim, attacker); + else return -1; } @Override public int calculateHit(Entity entity, Entity victim, double modifier) { - return getType().getSwingHandler().calculateHit(entity, victim, modifier); + if(getType() != null) + return getType().getSwingHandler().calculateHit(entity, victim, modifier); + else return -1; } @Override public void visualizeImpact(Entity entity, Entity victim, BattleState state) { - if (state.getStyle() == CombatStyle.MAGIC) { + if (state != null && state.getStyle() == CombatStyle.MAGIC) { for (BattleState s : state.getTargets()) { if (s.getEstimatedHit() > 0) { s.getVictim().graphics(MAGIC_END_GRAPHIC); @@ -140,7 +153,8 @@ public class GWDZilyanaSwingHandler extends CombatSwingHandler { } return; } - state.getStyle().getSwingHandler().visualizeImpact(entity, victim, state); + if(state != null) + state.getStyle().getSwingHandler().visualizeImpact(entity, victim, state); } } \ No newline at end of file diff --git a/Server/src/main/java/core/game/content/activity/mta/impl/AlchemistZone.java b/Server/src/main/java/core/game/content/activity/mta/impl/AlchemistZone.java index 8ee51fb65..cdb4c2021 100644 --- a/Server/src/main/java/core/game/content/activity/mta/impl/AlchemistZone.java +++ b/Server/src/main/java/core/game/content/activity/mta/impl/AlchemistZone.java @@ -305,7 +305,7 @@ public class AlchemistZone extends MTAZone { int alchIndex = indexer + index; if (indexer != 0) { if (indexer >= 4 && index < 4) { - if (indexer == 4 && indexer - index < 4 || indexer - index < 4) { + if (indexer == 4 && indexer - index < 4) { return null; } if (indexer == 4) { @@ -430,7 +430,7 @@ public class AlchemistZone extends MTAZone { * Sets the cost. * @param cost the cost to set. */ - public void setCost(int cost) { + private void setCost(int cost) { this.cost = cost; } diff --git a/Server/src/main/java/core/game/content/activity/puropuro/ImpDefenderNPC.java b/Server/src/main/java/core/game/content/activity/puropuro/ImpDefenderNPC.java index 0dadcd0c4..26288bb34 100644 --- a/Server/src/main/java/core/game/content/activity/puropuro/ImpDefenderNPC.java +++ b/Server/src/main/java/core/game/content/activity/puropuro/ImpDefenderNPC.java @@ -95,7 +95,7 @@ public final class ImpDefenderNPC extends AbstractNPC { thievingLevel += 15; } int currentLevel = RandomFunction.random(thievingLevel) + 1; - double ratio = currentLevel / (new Random().nextInt(level + 5) + 1); + double ratio = (double) currentLevel / (new Random().nextInt(level + 5) + 1); return Math.round(ratio * thievingLevel) < level; } diff --git a/Server/src/main/java/core/game/content/activity/pyramidplunder/PlunderZones.java b/Server/src/main/java/core/game/content/activity/pyramidplunder/PlunderZones.java index 0749c1373..55eebc501 100644 --- a/Server/src/main/java/core/game/content/activity/pyramidplunder/PlunderZones.java +++ b/Server/src/main/java/core/game/content/activity/pyramidplunder/PlunderZones.java @@ -199,6 +199,7 @@ public class PlunderZones implements Plugin { } PlunderObject object = target instanceof NPC ? null : new PlunderObject(target.asScenery()); //PlunderObject(target.getId(),target.getLocation()); PlunderObjectManager manager = player.getPlunderObjectManager(); + if(manager == null) return super.interact(e, target, option); boolean alreadyOpened = manager.openedMap.getOrDefault(object.getLocation(),false); boolean charmed = manager.charmedMap.getOrDefault(object.getLocation(),false); boolean success = success(player, Skills.THIEVING); diff --git a/Server/src/main/java/core/game/content/activity/pyramidplunder/PyramidPlunderNPC.java b/Server/src/main/java/core/game/content/activity/pyramidplunder/PyramidPlunderNPC.java index c3b89ee1d..4b062cb62 100644 --- a/Server/src/main/java/core/game/content/activity/pyramidplunder/PyramidPlunderNPC.java +++ b/Server/src/main/java/core/game/content/activity/pyramidplunder/PyramidPlunderNPC.java @@ -56,7 +56,6 @@ public abstract class PyramidPlunderNPC extends AbstractNPC { public PyramidPlunderNPC(int id, Location location, Player player) { super(id, location); this.player = player; - this.quotes = quotes; this.endTime = (int) (GameWorld.getTicks() + (1000 / 0.6)); } diff --git a/Server/src/main/java/core/game/content/activity/pyramidplunder/PyramidPlunderRoom.java b/Server/src/main/java/core/game/content/activity/pyramidplunder/PyramidPlunderRoom.java index 4f76e6564..18cc081c3 100644 --- a/Server/src/main/java/core/game/content/activity/pyramidplunder/PyramidPlunderRoom.java +++ b/Server/src/main/java/core/game/content/activity/pyramidplunder/PyramidPlunderRoom.java @@ -17,9 +17,9 @@ public enum PyramidPlunderRoom { ROOM_7(7, 81, 0, 2,new Location(1927, 4424), new Location[] {Location.create(1923, 4432, 0),Location.create(1925, 4440, 0),Location.create(1929, 4440, 0),Location.create(1931, 4432, 0)}), ROOM_8(8, 91, -2, 0,new Location(1965,4444), new Location[] {Location.create(1952, 4447, 0),Location.create(1953, 4445, 0),Location.create(1957, 4444, 0),Location.create(1962, 4448, 0)}); - public int roomNum, reqLevel, spearX, spearY; + public final int roomNum, reqLevel, spearX, spearY; Location entrance; - public List doorLocations; + public final List doorLocations; PyramidPlunderRoom(int roomNum, int reqLevel, int spearX, int spearY, Location entrance, Location[] door_locations){ this.roomNum = roomNum; this.reqLevel = reqLevel; diff --git a/Server/src/main/java/core/game/content/activity/tzhaar/TzhaarFightCaveNPC.java b/Server/src/main/java/core/game/content/activity/tzhaar/TzhaarFightCaveNPC.java index 262367320..6fd478e16 100644 --- a/Server/src/main/java/core/game/content/activity/tzhaar/TzhaarFightCaveNPC.java +++ b/Server/src/main/java/core/game/content/activity/tzhaar/TzhaarFightCaveNPC.java @@ -217,12 +217,15 @@ public final class TzhaarFightCaveNPC extends AbstractNPC { } return InteractionType.NO_INTERACT; } - return getType().getSwingHandler().canSwing(entity, victim); + if(getType() != null) + return getType().getSwingHandler().canSwing(entity, victim); + else return InteractionType.NO_INTERACT; } @Override public int swing(Entity entity, Entity victim, BattleState state) { - style = super.getType(); + if(super.getType() != null) + style = super.getType(); int ticks = 1; if (jad) { main = CombatStyle.values()[1 + RandomFunction.RANDOM.nextInt(2)]; @@ -262,7 +265,7 @@ public final class TzhaarFightCaveNPC extends AbstractNPC { @Override public void visualize(Entity entity, Entity victim, BattleState state) { - if (state.getStyle() == null) { + if (state == null || state.getStyle() == null) { return; } switch (state.getStyle()) { @@ -291,19 +294,19 @@ public final class TzhaarFightCaveNPC extends AbstractNPC { @Override public void impact(Entity entity, Entity victim, BattleState state) { - if (state.getStyle() != null && victim.hasProtectionPrayer(state.getStyle())) { + if (state != null && state.getStyle() != null && victim.hasProtectionPrayer(state.getStyle())) { state.setEstimatedHit(0); } - if (state.getStyle() == null) { + if (state != null && state.getStyle() == null) { NPC n = victim instanceof NPC ? ((NPC) victim) : (NPC) npc.activity.getPlayer().getProperties().getCombatPulse().getVictim(); - if (n == null || !(n instanceof TzhaarFightCaveNPC)) { + if (!(n instanceof TzhaarFightCaveNPC)) { n = npc; } ((TzhaarFightCaveNPC) n).heal(state.getEstimatedHit()); n.graphics(new Graphics(444, 96)); return; } - if (state.getEstimatedHit() > 0) { + if (state != null && state.getEstimatedHit() > 0) { state.setEstimatedHit(formatHit(victim, state.getEstimatedHit())); if (((NPC) entity).getId() == 2734 || ((NPC) entity).getId() == 2735) { victim.getSkills().decrementPrayerPoints(state.getEstimatedHit()); @@ -316,11 +319,11 @@ public final class TzhaarFightCaveNPC extends AbstractNPC { @Override public void visualizeImpact(Entity entity, Entity victim, BattleState state) { - if (state.getStyle() == null) { + if (state != null && state.getStyle() == null) { return; - } else if (state.getStyle() == CombatStyle.MAGIC && !jad) { + } else if (state != null && state.getStyle() == CombatStyle.MAGIC && !jad) { victim.graphics(Graphics.create(1624)); - } else if (jad && state.getStyle() == CombatStyle.RANGE) { + } else if (state != null && jad && state.getStyle() == CombatStyle.RANGE) { victim.graphics(Graphics.create(451)); } style.getSwingHandler().visualizeImpact(entity, victim, state); @@ -332,8 +335,8 @@ public final class TzhaarFightCaveNPC extends AbstractNPC { } @Override - public int calculateDefence(Entity entity, Entity attacker) { - return style.getSwingHandler().calculateDefence(entity, attacker); + public int calculateDefence(Entity victim, Entity attacker) { + return style.getSwingHandler().calculateDefence(victim, attacker); } @Override diff --git a/Server/src/main/java/core/game/content/activity/tzhaar/TzhaarFightPitsPlugin.java b/Server/src/main/java/core/game/content/activity/tzhaar/TzhaarFightPitsPlugin.java index 07f671b52..79482f29d 100644 --- a/Server/src/main/java/core/game/content/activity/tzhaar/TzhaarFightPitsPlugin.java +++ b/Server/src/main/java/core/game/content/activity/tzhaar/TzhaarFightPitsPlugin.java @@ -138,12 +138,12 @@ public final class TzhaarFightPitsPlugin extends ActivityPlugin { // Become the Champion of the Fight Pits if (lastVictor != null) { lastVictor.getAchievementDiaryManager().finishTask(lastVictor, DiaryType.KARAMJA, 2, 0); + addTokkul(lastVictor); + lastVictor.getAppearance().setSkullIcon(SKULL_ID); + lastVictor.getUpdateMasks().register(new AppearanceFlag(lastVictor)); + lastVictor.getPacketDispatch().sendString("Current Champion: " + getChampionName(), INTERFACE_ID, 0); + resetDamagePulse(lastVictor); } - addTokkul(lastVictor); - lastVictor.getAppearance().setSkullIcon(SKULL_ID); - lastVictor.getUpdateMasks().register(new AppearanceFlag(lastVictor)); - lastVictor.getPacketDispatch().sendString("Current Champion: " + getChampionName(), INTERFACE_ID, 0); - resetDamagePulse(lastVictor); RegionManager.forId(9552).getPlanes()[0].getNpcs().get(0).setAttribute("fp_champn", getChampionName()); } minutes = 0; diff --git a/Server/src/main/java/core/game/content/activity/wguild/animator/AnimationRoom.java b/Server/src/main/java/core/game/content/activity/wguild/animator/AnimationRoom.java index 64399996a..f091efbd4 100644 --- a/Server/src/main/java/core/game/content/activity/wguild/animator/AnimationRoom.java +++ b/Server/src/main/java/core/game/content/activity/wguild/animator/AnimationRoom.java @@ -181,7 +181,9 @@ public final class AnimationRoom extends MapZone implements Plugin { } } } - animateArmour(event.getPlayer(), (Scenery) event.getUsedWith(), set); + if(set != null) { + animateArmour(event.getPlayer(), (Scenery) event.getUsedWith(), set); + } return true; } diff --git a/Server/src/main/java/core/game/content/activity/wguild/catapult/CatapultRoom.java b/Server/src/main/java/core/game/content/activity/wguild/catapult/CatapultRoom.java index 9cd0f92f7..f2633d42b 100644 --- a/Server/src/main/java/core/game/content/activity/wguild/catapult/CatapultRoom.java +++ b/Server/src/main/java/core/game/content/activity/wguild/catapult/CatapultRoom.java @@ -144,7 +144,8 @@ public final class CatapultRoom extends MapZone implements Plugin { }); Projectile.create(Location.create(2842, 3554, 1), Location.create(2842, 3545, 1), attack.graphicId, 70, 32, 80, 220, 20, 11).send(); Scenery object = RegionManager.getObject(Location.create(2840, 3552, 1)); - SceneryBuilder.replace(object, object.transform(attack.objectId), 4); + if(object != null) + SceneryBuilder.replace(object, object.transform(attack.objectId), 4); Audio sound = new Audio(1911); for (Player p : players) { p.getAudioManager().send(sound); diff --git a/Server/src/main/java/core/game/content/consumable/effects/SkillEffect.java b/Server/src/main/java/core/game/content/consumable/effects/SkillEffect.java index 9e0f460f3..5fae1c422 100644 --- a/Server/src/main/java/core/game/content/consumable/effects/SkillEffect.java +++ b/Server/src/main/java/core/game/content/consumable/effects/SkillEffect.java @@ -16,7 +16,6 @@ public class SkillEffect extends ConsumableEffect { @Override public void activate(Player p) { Skills skills = p.getSkills(); - int level = skills.getLevel(skill_slot); int slevel = skills.getStaticLevel(skill_slot); skills.updateLevel(skill_slot,(int)(base + (bonus * slevel)),slevel + (int)(base + (bonus * slevel))); } diff --git a/Server/src/main/java/core/game/content/cutscene/DBRCutscenePlugin.java b/Server/src/main/java/core/game/content/cutscene/DBRCutscenePlugin.java index 2a07b37a6..ebc79438b 100644 --- a/Server/src/main/java/core/game/content/cutscene/DBRCutscenePlugin.java +++ b/Server/src/main/java/core/game/content/cutscene/DBRCutscenePlugin.java @@ -392,7 +392,7 @@ public final class DBRCutscenePlugin extends CutscenePlugin { getWiseOldMan().animate(CAST_ANIMATION); getWiseOldMan().graphics(new Graphics(433)); if (target instanceof Entity) { - Projectile.create(getWiseOldMan(), target instanceof Entity ? ((Entity) target) : null, 434).send(); + Projectile.create(getWiseOldMan(), (Entity) target, 434).send(); } else { Projectile projectile = Projectile.create(getWiseOldMan(), null, 434, 30, 30, 41, 140, 0, 0); projectile.setEndLocation((Location) target); @@ -603,10 +603,13 @@ public final class DBRCutscenePlugin extends CutscenePlugin { break; case 55: Scenery wall = RegionManager.getObject(base.transform(16, 46, 0)); - SceneryBuilder.replace(wall, wall.transform(9151, 0, 10)); - getWiseOldMan().getWalkingQueue().reset(); - getWiseOldMan().getWalkingQueue().addPath(base.getX() + 16, base.getY() + 46); - getWiseOldMan().getWalkingQueue().addPath(base.getX() + 17, base.getY() + 46); + if(wall != null) + SceneryBuilder.replace(wall, wall.transform(9151, 0, 10)); + if(getWiseOldMan() != null) { + getWiseOldMan().getWalkingQueue().reset(); + getWiseOldMan().getWalkingQueue().addPath(base.getX() + 16, base.getY() + 46); + getWiseOldMan().getWalkingQueue().addPath(base.getX() + 17, base.getY() + 46); + } break; case 58: camera(21, 38, -36, 43, 495, 99); diff --git a/Server/src/main/java/core/game/content/dialogue/ChemistDialogue.java b/Server/src/main/java/core/game/content/dialogue/ChemistDialogue.java index d7c1c6130..bf8c99c57 100644 --- a/Server/src/main/java/core/game/content/dialogue/ChemistDialogue.java +++ b/Server/src/main/java/core/game/content/dialogue/ChemistDialogue.java @@ -45,7 +45,7 @@ public final class ChemistDialogue extends DialoguePlugin { public boolean open(Object... args) { interpreter.sendOptions("Do you want to talk about lamps?", "Yes.", "No.", "No, I'm more interested in impling jars.", "Falador Achievement Diary"); stage = 0; - AchievementDiary diary = player.getAchievementDiaryManager().getDiary(DiaryType.FALADOR); + diary = player.getAchievementDiaryManager().getDiary(DiaryType.FALADOR); replacementReward = diary.isLevelRewarded(level) && diary.isComplete(level, true) && !player.hasItem(diary.getType().getRewards(level)[0]); diff --git a/Server/src/main/java/core/game/content/dialogue/DialogueInterpreter.java b/Server/src/main/java/core/game/content/dialogue/DialogueInterpreter.java index efbd1c487..80556cc23 100644 --- a/Server/src/main/java/core/game/content/dialogue/DialogueInterpreter.java +++ b/Server/src/main/java/core/game/content/dialogue/DialogueInterpreter.java @@ -111,6 +111,7 @@ public final class DialogueInterpreter { npc.getWalkingQueue().reset(); npc.getPulseManager().clear(); } catch(Exception e){ + e.printStackTrace(); } } else if (args.length < 1) { args = new Object[] { dialogueKey }; @@ -163,7 +164,7 @@ public final class DialogueInterpreter { public void startScript(int dialogueKey, ScriptContext script, Object... args) { key = dialogueKey; (dialogueStage = script).execute(args); - if (script != null && script.isInstant()) { + if (script.isInstant()) { dialogueStage = script = ScriptManager.run(script, args); } } diff --git a/Server/src/main/java/core/game/content/dialogue/EblisDialogue.java b/Server/src/main/java/core/game/content/dialogue/EblisDialogue.java index c3ff24464..fbeacdc74 100644 --- a/Server/src/main/java/core/game/content/dialogue/EblisDialogue.java +++ b/Server/src/main/java/core/game/content/dialogue/EblisDialogue.java @@ -39,7 +39,7 @@ public class EblisDialogue extends DialoguePlugin { @Override public boolean open(Object... args) { //TODO: Add proper dialogue once DT is implemented - NPC npc = (NPC) args[0]; + npc = (NPC) args[0]; if(!player.getAttribute("DT:staff-bought",false)) { player("Hey."); stage = 0; diff --git a/Server/src/main/java/core/game/content/dialogue/ReadbeardFrankDialogue.java b/Server/src/main/java/core/game/content/dialogue/ReadbeardFrankDialogue.java index bf91fdd0a..10fb6eb9f 100644 --- a/Server/src/main/java/core/game/content/dialogue/ReadbeardFrankDialogue.java +++ b/Server/src/main/java/core/game/content/dialogue/ReadbeardFrankDialogue.java @@ -59,7 +59,7 @@ public class ReadbeardFrankDialogue extends DialoguePlugin { quest = player.getQuestRepository().getQuest("Pirate's Treasure"); npc("Arr, Matey!"); stage = 0; - AchievementDiary diary = player.getAchievementDiaryManager().getDiary(DiaryType.FALADOR); + diary = player.getAchievementDiaryManager().getDiary(DiaryType.FALADOR); replacementReward = diary.isLevelRewarded(level) && diary.isComplete(level, true) && !player.hasItem(diary.getType().getRewards(level)[0]); diff --git a/Server/src/main/java/core/game/content/dialogue/SirReniteeDialogue.java b/Server/src/main/java/core/game/content/dialogue/SirReniteeDialogue.java index e35eac522..e8fb7db64 100644 --- a/Server/src/main/java/core/game/content/dialogue/SirReniteeDialogue.java +++ b/Server/src/main/java/core/game/content/dialogue/SirReniteeDialogue.java @@ -85,6 +85,7 @@ public class SirReniteeDialogue extends DialoguePlugin { stage = 500; break; } + break; case 200: interpreter.sendDialogues(npc, FacialExpression.HALF_GUILTY, "What is your name?"); stage = 210; diff --git a/Server/src/main/java/core/game/content/dialogue/StankersDialogue.java b/Server/src/main/java/core/game/content/dialogue/StankersDialogue.java index 6e20d5b3e..ea022144d 100644 --- a/Server/src/main/java/core/game/content/dialogue/StankersDialogue.java +++ b/Server/src/main/java/core/game/content/dialogue/StankersDialogue.java @@ -158,6 +158,7 @@ public class StankersDialogue extends DialoguePlugin { case 90: npc("Your headband will help you get experience when", "woodcutting maple trees, and an extra log or two when", "cutting normal trees. I've also told Geoff to increase"); stage++; + break; case 91: npc("your flax allowance in acknowledgement of your", "standing."); stage = 999; diff --git a/Server/src/main/java/core/game/content/dialogue/TownCrierDialogue.java b/Server/src/main/java/core/game/content/dialogue/TownCrierDialogue.java index 583bfceb6..821533502 100644 --- a/Server/src/main/java/core/game/content/dialogue/TownCrierDialogue.java +++ b/Server/src/main/java/core/game/content/dialogue/TownCrierDialogue.java @@ -154,12 +154,11 @@ public final class TownCrierDialogue extends DialoguePlugin { npc("Beware of players trying to lue you into the wilderness.", "Your items cannot be returned if you lose them!"); stage = 2; break; - case 5: + default: npc("" + GameWorld.getSettings().getName() + " will never email you asking for your log-in details."); stage = 2; break; } - stage = 2; break; case 150: npc("Player Moderators are normal players of the game, just", "like you. However, since they have shown themselves to be", "trustworthy and active reporters, they have been invited", "by Jagex to monitor the game and take appropriate"); diff --git a/Server/src/main/java/core/game/content/global/action/DoorActionHandler.java b/Server/src/main/java/core/game/content/global/action/DoorActionHandler.java index f444338f1..d175a1b62 100644 --- a/Server/src/main/java/core/game/content/global/action/DoorActionHandler.java +++ b/Server/src/main/java/core/game/content/global/action/DoorActionHandler.java @@ -166,7 +166,6 @@ public final class DoorActionHandler { } public static Location getEndLocation(Entity entity, Scenery object, Boolean isAutoWalk) { Location l = object.getLocation(); - Location end = DestinationFlag.OBJECT.getDestination(entity,object); switch (object.getRotation()) { case 0: if (entity.getLocation().getX() >= l.getX()) { @@ -183,7 +182,7 @@ public final class DoorActionHandler { l = l.transform(1, 0, 0); } break; - case 3: + default: if (entity.getLocation().getY() >= l.getY()) { l = l.transform(0, -1, 0); } diff --git a/Server/src/main/java/core/game/content/global/presets/PresetManager.java b/Server/src/main/java/core/game/content/global/presets/PresetManager.java index e1c4bb96a..59726bce3 100644 --- a/Server/src/main/java/core/game/content/global/presets/PresetManager.java +++ b/Server/src/main/java/core/game/content/global/presets/PresetManager.java @@ -12,7 +12,7 @@ public class PresetManager { private Player player; - private Map current_presets; + private final Map current_presets; public PresetManager() { current_presets = new HashMap<>(); diff --git a/Server/src/main/java/core/game/content/global/travel/canoe/Canoe.java b/Server/src/main/java/core/game/content/global/travel/canoe/Canoe.java index 3ee0e6a22..b77baf349 100644 --- a/Server/src/main/java/core/game/content/global/travel/canoe/Canoe.java +++ b/Server/src/main/java/core/game/content/global/travel/canoe/Canoe.java @@ -26,9 +26,9 @@ public enum Canoe { this.maxDist = ordinal() + 1; } - public int silhouetteChild; - public int textChild; - public int maxDist; + public final int silhouetteChild; + public final int textChild; + public final int maxDist; /** * Represents the woodcutting level requirement to craft the canoe. diff --git a/Server/src/main/java/core/game/content/holiday/ItemLimitation.java b/Server/src/main/java/core/game/content/holiday/ItemLimitation.java index 3c85a07a0..187ea676c 100644 --- a/Server/src/main/java/core/game/content/holiday/ItemLimitation.java +++ b/Server/src/main/java/core/game/content/holiday/ItemLimitation.java @@ -1,6 +1,6 @@ package core.game.content.holiday; -import core.cache.ServerStore; +import core.cache.AriosStore; import core.cache.def.impl.ItemDefinition; import java.nio.ByteBuffer; @@ -32,10 +32,10 @@ public final class ItemLimitation { * @return {@code True} if parsed. */ public boolean parse() { - if (ServerStore.get("hir_limits") == null) { + if (AriosStore.get("hir_limits") == null) { return true; } - ByteBuffer buffer = ServerStore.getArchive("hir_limits"); + ByteBuffer buffer = AriosStore.getArchive("hir_limits"); int length = buffer.get() & 0xFF; for (int i = 0; i < length; i++) { int itemId = buffer.getShort() & 0xFFFF; @@ -56,7 +56,7 @@ public final class ItemLimitation { buffer.putShort((short) (int) ITEMS.get(itemId)); } buffer.flip(); - ServerStore.setArchive("hir_limits", buffer); + AriosStore.setArchive("hir_limits", buffer); } /** diff --git a/Server/src/main/java/core/game/content/holiday/christmas/ChristmasEvent.java b/Server/src/main/java/core/game/content/holiday/christmas/ChristmasEvent.java index c4378fa17..f71db693f 100644 --- a/Server/src/main/java/core/game/content/holiday/christmas/ChristmasEvent.java +++ b/Server/src/main/java/core/game/content/holiday/christmas/ChristmasEvent.java @@ -1099,7 +1099,6 @@ public class ChristmasEvent extends HolidayEvent { final Item other = args.length == 2 ? null : (Item) args[2]; if (other != null) { identifier = "equip"; - item = other; } switch (identifier) { case "equip": diff --git a/Server/src/main/java/core/game/content/quest/free/dragonslayer/DragonSlayerPlugin.java b/Server/src/main/java/core/game/content/quest/free/dragonslayer/DragonSlayerPlugin.java index 681d87eca..0d1a639d2 100644 --- a/Server/src/main/java/core/game/content/quest/free/dragonslayer/DragonSlayerPlugin.java +++ b/Server/src/main/java/core/game/content/quest/free/dragonslayer/DragonSlayerPlugin.java @@ -150,7 +150,7 @@ public final class DragonSlayerPlugin extends OptionHandler { InteractionListeners.run(node.getId(),0,"equip",player,node); break; case 742: - if (player.getQuestRepository().getQuest("Dragon Slayer").getStage(player) == 40 && (player.getInventory().containsItem(DragonSlayer.ELVARG_HEAD) || player.getInventory().containsItem(DragonSlayer.ELVARG_HEAD))) { + if (player.getQuestRepository().getQuest("Dragon Slayer").getStage(player) == 40 && (player.getInventory().containsItem(DragonSlayer.ELVARG_HEAD))) { player.getPacketDispatch().sendMessage("You have already slain the dragon. Now you just need to return to Oziach for"); player.getPacketDispatch().sendMessage("your reward!"); return true; @@ -169,7 +169,7 @@ public final class DragonSlayerPlugin extends OptionHandler { movement.run(player, 10); return true; } - if (player.getQuestRepository().getQuest("Dragon Slayer").getStage(player) == 40 && (player.getInventory().containsItem(DragonSlayer.ELVARG_HEAD) || player.getInventory().containsItem(DragonSlayer.ELVARG_HEAD))) { + if (player.getQuestRepository().getQuest("Dragon Slayer").getStage(player) == 40 && (player.getInventory().containsItem(DragonSlayer.ELVARG_HEAD))) { player.getPacketDispatch().sendMessage("You have already slain the dragon. Now you just need to return to Oziach for"); player.getPacketDispatch().sendMessage("your reward!"); return true; @@ -318,7 +318,7 @@ public final class DragonSlayerPlugin extends OptionHandler { case 2604: switch (option) { case "search": - if (!player.getInventory().containsItem(DragonSlayer.MAZE_PIECE) && !player.getInventory().containsItem(DragonSlayer.MAZE_PIECE)) { + if (!player.getInventory().containsItem(DragonSlayer.MAZE_PIECE)) { if (!player.getInventory().add(DragonSlayer.MAZE_PIECE)) { GroundItemManager.create(DragonSlayer.MAZE_PIECE, player); } diff --git a/Server/src/main/java/core/game/content/quest/free/dragonslayer/ElvargNPC.java b/Server/src/main/java/core/game/content/quest/free/dragonslayer/ElvargNPC.java index 631cc6f60..8a8376c1c 100644 --- a/Server/src/main/java/core/game/content/quest/free/dragonslayer/ElvargNPC.java +++ b/Server/src/main/java/core/game/content/quest/free/dragonslayer/ElvargNPC.java @@ -148,7 +148,7 @@ public final class ElvargNPC extends AbstractNPC { return super.isAttackable(entity, style); } final Player player = (Player) entity; - if (player.getQuestRepository().getQuest("Dragon Slayer").getStage(player) == 40 && (player.getInventory().containsItem(DragonSlayer.ELVARG_HEAD) || player.getInventory().containsItem(DragonSlayer.ELVARG_HEAD))) { + if (player.getQuestRepository().getQuest("Dragon Slayer").getStage(player) == 40 && (player.getInventory().containsItem(DragonSlayer.ELVARG_HEAD))) { player.getPacketDispatch().sendMessage("You have already slain the dragon. Now you just need to return to Oziach for"); player.getPacketDispatch().sendMessage("your reward!"); return true; @@ -216,8 +216,8 @@ public final class ElvargNPC extends AbstractNPC { } @Override - public int calculateDefence(Entity entity, Entity attacker) { - return style.getSwingHandler().calculateDefence(entity, attacker); + public int calculateDefence(Entity victim, Entity attacker) { + return style.getSwingHandler().calculateDefence(victim, attacker); } @Override diff --git a/Server/src/main/java/core/game/content/quest/free/dragonslayer/MeldarMadNPC.java b/Server/src/main/java/core/game/content/quest/free/dragonslayer/MeldarMadNPC.java index 1fd06c5f2..cd1d91d91 100644 --- a/Server/src/main/java/core/game/content/quest/free/dragonslayer/MeldarMadNPC.java +++ b/Server/src/main/java/core/game/content/quest/free/dragonslayer/MeldarMadNPC.java @@ -169,8 +169,8 @@ public final class MeldarMadNPC extends AbstractNPC { } @Override - public int calculateDefence(Entity entity, Entity attacker) { - return style.getSwingHandler().calculateDefence(entity, attacker); + public int calculateDefence(Entity victim, Entity attacker) { + return style.getSwingHandler().calculateDefence(victim, attacker); } @Override diff --git a/Server/src/main/java/core/game/content/quest/free/princealirescue/LadyKeliDialogue.java b/Server/src/main/java/core/game/content/quest/free/princealirescue/LadyKeliDialogue.java index d416caf68..0284cc9a6 100644 --- a/Server/src/main/java/core/game/content/quest/free/princealirescue/LadyKeliDialogue.java +++ b/Server/src/main/java/core/game/content/quest/free/princealirescue/LadyKeliDialogue.java @@ -187,6 +187,7 @@ public final class LadyKeliDialogue extends DialoguePlugin { case 56: interpreter.sendDialogues(npc, null, "As you put it that way I am sure you can see it. You", "cannot steal the key, it is on a Runite chain."); stage = 57; + break; case 57: interpreter.sendDialogue("Keli shows you a small key on a strong looking chain."); stage = 58; diff --git a/Server/src/main/java/core/game/content/quest/free/therestlessghost/RestlessGhostPlugin.java b/Server/src/main/java/core/game/content/quest/free/therestlessghost/RestlessGhostPlugin.java index 2b2c99f1e..508bc9222 100644 --- a/Server/src/main/java/core/game/content/quest/free/therestlessghost/RestlessGhostPlugin.java +++ b/Server/src/main/java/core/game/content/quest/free/therestlessghost/RestlessGhostPlugin.java @@ -80,7 +80,7 @@ public final class RestlessGhostPlugin extends OptionHandler { switch (option) { case "open": switch (id) { - case 2145: + default: toggleCoffin(player, object); break; } diff --git a/Server/src/main/java/core/game/content/quest/members/fishingcontest/VineInteraction.java b/Server/src/main/java/core/game/content/quest/members/fishingcontest/VineInteraction.java index e047d096f..000061652 100644 --- a/Server/src/main/java/core/game/content/quest/members/fishingcontest/VineInteraction.java +++ b/Server/src/main/java/core/game/content/quest/members/fishingcontest/VineInteraction.java @@ -23,7 +23,6 @@ public class VineInteraction extends PluginInteraction { @Override public boolean handle(Player player, Node node) { if(node instanceof Scenery){ - Scenery obj = node.asScenery(); if(player.getQuestRepository().getStage("Fishing Contest") > 0 && player.getQuestRepository().getStage("Fishing Contest") < 100){ player.getPulseManager().run(new MovementPulse(player, node.asScenery().getLocation().transform(0, 0, 0)) { @Override diff --git a/Server/src/main/java/core/game/content/quest/members/merlinscrystal/MerlinCrystalPlugin.java b/Server/src/main/java/core/game/content/quest/members/merlinscrystal/MerlinCrystalPlugin.java index 8cf7ffd26..b5a5ca2fc 100644 --- a/Server/src/main/java/core/game/content/quest/members/merlinscrystal/MerlinCrystalPlugin.java +++ b/Server/src/main/java/core/game/content/quest/members/merlinscrystal/MerlinCrystalPlugin.java @@ -529,7 +529,7 @@ public final class MerlinCrystalPlugin extends OptionHandler { @Override public void handleTickActions() { - if (player != null && !player.isActive() || !player.getLocation().withinDistance(getLocation(), 20)) { + if (player != null && !player.isActive() || player != null && !player.getLocation().withinDistance(getLocation(), 20)) { clear(); } super.handleTickActions(); @@ -545,10 +545,7 @@ public final class MerlinCrystalPlugin extends OptionHandler { @Override public boolean canAttack(Entity entity) { - if (getAttribute("thrantax_owner", entity) == entity) { - return true; - } - return false; + return getAttribute("thrantax_owner", entity) == entity; } @Override @@ -591,20 +588,20 @@ public final class MerlinCrystalPlugin extends OptionHandler { Item useditem = event.getUsedItem(); final Scenery object = (Scenery) event.getUsedWith(); - if (player.getAttribute("cleared-beehives", false) && useditem.getId() == REPELLENT.getId() && object.getId() == 68) { + if (useditem != null && player.getAttribute("cleared-beehives", false) && useditem.getId() == REPELLENT.getId() && object.getId() == 68) { player.getDialogueInterpreter().sendDialogue("You have already cleared the hive of its bees.", "You can now safely collect wax from the hive."); } - if (useditem.getId() == REPELLENT.getId() && object.getId() == 68 && player.getAttribute("cleared-beehives", false)) { + if (useditem != null && useditem.getId() == REPELLENT.getId() && object.getId() == 68 && player.getAttribute("cleared-beehives", false)) { player.getDialogueInterpreter().sendDialogue("You pour insect repellent on the beehive. You see the bees leaving the", "hive."); player.setAttribute("cleared-beehives", true); } - if (useditem.getId() == BUCKET.getId() && player.getAttribute("cleared-beehives", false)) { + if (useditem != null && useditem.getId() == BUCKET.getId() && player.getAttribute("cleared-beehives", false)) { player.getDialogueInterpreter().sendDialogue("You get some wax from the beehive."); player.getInventory().remove(new Item(BUCKET.getId(), 1)); player.getInventory().add(new Item(BUCKET_OF_WAX.getId(), 1)); - } else if (useditem.getId() == BUCKET.getId() && !player.getAttribute("cleared-beehives", false)) { + } else if (useditem != null && useditem.getId() == BUCKET.getId() && !player.getAttribute("cleared-beehives", false)) { player.getDialogueInterpreter().sendDialogue("It would be dangerous to stick the bucket into the hive while", "the bees are still in it. Perhaps you can clear them out", "somehow."); } diff --git a/Server/src/main/java/core/game/content/quest/members/merlinscrystal/SirKayDialogue.java b/Server/src/main/java/core/game/content/quest/members/merlinscrystal/SirKayDialogue.java index 327a87636..9492f6580 100644 --- a/Server/src/main/java/core/game/content/quest/members/merlinscrystal/SirKayDialogue.java +++ b/Server/src/main/java/core/game/content/quest/members/merlinscrystal/SirKayDialogue.java @@ -161,6 +161,7 @@ public final class SirKayDialogue extends DialoguePlugin { case 90: npc("Your headband will help you get experience when", "woodcutting maple trees, and an extra log or two when", "cutting normal trees. I've also told Geoff to increase"); stage++; + break; case 91: npc("your flax allowance in acknowledgement of your", "standing."); stage = 999; diff --git a/Server/src/main/java/core/game/content/quest/members/sheepherder/SheepPoisonHandler.java b/Server/src/main/java/core/game/content/quest/members/sheepherder/SheepPoisonHandler.java index 6371dd680..147f16a92 100644 --- a/Server/src/main/java/core/game/content/quest/members/sheepherder/SheepPoisonHandler.java +++ b/Server/src/main/java/core/game/content/quest/members/sheepherder/SheepPoisonHandler.java @@ -28,7 +28,6 @@ public class SheepPoisonHandler extends PluginInteraction { @Override public boolean handle(Player player, NodeUsageEvent event) { Node n = event.getUsedWith(); - Item i = event.getUsedItem(); if(n instanceof HerderSheepNPC){ if (withinBorders(n.getLocation(),Location.create(2595, 3364, 0),Location.create(2609, 3351, 0))){ handlePoisoning(player,(HerderSheepNPC) n); diff --git a/Server/src/main/java/core/game/content/quest/members/witchshouse/WitchsHousePlugin.java b/Server/src/main/java/core/game/content/quest/members/witchshouse/WitchsHousePlugin.java index c8309e225..823d634ad 100644 --- a/Server/src/main/java/core/game/content/quest/members/witchshouse/WitchsHousePlugin.java +++ b/Server/src/main/java/core/game/content/quest/members/witchshouse/WitchsHousePlugin.java @@ -42,7 +42,6 @@ public class WitchsHousePlugin extends OptionHandler { @Override public boolean handle(Player player, Node node, String option) { final Quest quest = player.getQuestRepository().getQuest("Witch's House"); - final GroundItem ball = GroundItemManager.get(2407, new Location(2935, 3460, 0), null); final int id = node instanceof Item ? ((Item) node).getId() : node instanceof Scenery ? ((Scenery) node).getId() : node instanceof NPC ? ((NPC) node).getId() : node.getId(); // boolean killedExperiment = player.getAttribute("witchs_house:experiment_killed",false); // boolean experimentAlive = !player.getAttribute("witchs_house:experiment_killed", false); diff --git a/Server/src/main/java/core/game/content/quest/tutorials/tutorialisland/TutorialStage.java b/Server/src/main/java/core/game/content/quest/tutorials/tutorialisland/TutorialStage.java index 0f1a71c17..382954f98 100644 --- a/Server/src/main/java/core/game/content/quest/tutorials/tutorialisland/TutorialStage.java +++ b/Server/src/main/java/core/game/content/quest/tutorials/tutorialisland/TutorialStage.java @@ -967,10 +967,9 @@ public enum TutorialStage { /** * Represents if it is a login stage. * @param login the login value. - * @return {@code True} if so. */ - public boolean isLogin(boolean login) { - return this.login = login; + private void isLogin(boolean login) { + this.login = login; } /** diff --git a/Server/src/main/java/core/game/ge/GEItemSet.java b/Server/src/main/java/core/game/ge/GEItemSet.java index 0042c1e3a..dd7a55df7 100644 --- a/Server/src/main/java/core/game/ge/GEItemSet.java +++ b/Server/src/main/java/core/game/ge/GEItemSet.java @@ -2,6 +2,7 @@ package core.game.ge; import core.game.node.item.Item; +import java.util.Arrays; import java.util.HashMap; import java.util.Map; @@ -75,28 +76,12 @@ public enum GEItemSet { return itemId; } - /** - * Sets the itemId. - * @param itemId The itemId to set. - */ - public void setItemId(int itemId) { - this.itemId = itemId; - } - /** * Gets the components. * @return The components. */ public int[] getComponents() { - return components; - } - - /** - * Sets the components. - * @param components The components to set. - */ - public void setComponents(int[] components) { - this.components = components; + return Arrays.copyOf(components, components.length); } /** @@ -104,6 +89,6 @@ public enum GEItemSet { * @return The item array. */ public static Item[] getItemArray() { - return itemArray; + return Arrays.copyOf(itemArray, itemArray.length); } } \ No newline at end of file diff --git a/Server/src/main/java/core/game/ge/GrandExchangeDatabase.java b/Server/src/main/java/core/game/ge/GrandExchangeDatabase.java index c914cc778..cd930bc31 100644 --- a/Server/src/main/java/core/game/ge/GrandExchangeDatabase.java +++ b/Server/src/main/java/core/game/ge/GrandExchangeDatabase.java @@ -97,6 +97,7 @@ public final class GrandExchangeDatabase { } initialized = true; } catch (Exception e){ + e.printStackTrace(); initNewDB(); } } diff --git a/Server/src/main/java/core/game/interaction/Interaction.java b/Server/src/main/java/core/game/interaction/Interaction.java index b51eb87d4..7fa46b7ff 100644 --- a/Server/src/main/java/core/game/interaction/Interaction.java +++ b/Server/src/main/java/core/game/interaction/Interaction.java @@ -112,7 +112,7 @@ public class Interaction { if (option.getHandler() == null || !option.getHandler().handle(player, node, option.getName().toLowerCase())) { player.getPacketDispatch().sendMessage("Nothing interesting happens."); } - if (option != null && option.getHandler() != null) { + if (option.getHandler() != null) { player.debug("Using item handler " + option.getHandler().getClass().getSimpleName()); } } catch (Exception e){ diff --git a/Server/src/main/java/core/game/interaction/city/LumbridgeNodePlugin.java b/Server/src/main/java/core/game/interaction/city/LumbridgeNodePlugin.java index 7b9d63629..bc4247ea7 100644 --- a/Server/src/main/java/core/game/interaction/city/LumbridgeNodePlugin.java +++ b/Server/src/main/java/core/game/interaction/city/LumbridgeNodePlugin.java @@ -188,7 +188,7 @@ public final class LumbridgeNodePlugin extends OptionHandler { cumulativeStr += 1; } cumulativeStr *= 1.0; - int hit = (int) ((14 + cumulativeStr + (bonus / 8) + ((cumulativeStr * bonus) * 0.016865)) * 1.0) / 10 + 1; + int hit = (int) ((14.0 + cumulativeStr + ((double) bonus / 8) + ((cumulativeStr * bonus) * 0.016865))) / 10 + 1; player.getSkills().addExperience(Skills.RANGE, ((hit * 1.33) / 10)); return !player.getEquipment().contains(9706, 1) || !player.getEquipment().contains(9705, 1); } else { diff --git a/Server/src/main/java/core/game/interaction/city/TrollheimPlugin.java b/Server/src/main/java/core/game/interaction/city/TrollheimPlugin.java index d93f33949..302858f2c 100644 --- a/Server/src/main/java/core/game/interaction/city/TrollheimPlugin.java +++ b/Server/src/main/java/core/game/interaction/city/TrollheimPlugin.java @@ -270,17 +270,13 @@ public final class TrollheimPlugin extends OptionHandler { bandaid(player, player.getLocation(), object.getLocation().transform(0, -3, 0), CLIMB_DOWN, CLIMB_DOWN, object.getDirection()); break; case 3790:// rock scalling. - xOffset = player.getLocation().getX() < loc.getX() ? 2 : -2; - direction = getOpposite(ForceMovement.direction(player.getLocation(), object.getLocation().transform(xOffset, yOffset, 0))); + case 3791: + xOffset = player.getLocation().getX() < loc.getX() ? 2 : -2; //bandaid(player, player.getLocation(), object.getLocation().transform(xOffset, yOffset, 0), CLIMB_DOWN, CLIMB_DOWN, direction); player.getProperties().setTeleportLocation(object.getLocation().transform(xOffset, yOffset, 0)); break; - case 3791:// rock scalling. - xOffset = player.getLocation().getX() < loc.getX() ? 2 : -2; //bandaid(player, player.getLocation(), object.getLocation().transform(xOffset, yOffset, 0), CLIMB_UP); - player.getProperties().setTeleportLocation(object.getLocation().transform(xOffset, yOffset, 0)); - break; - case 3748: + case 3748: player.getPacketDispatch().sendMessage("You climb onto the rock..."); if (loc.equals(new Location(2821, 3635, 0))) { bandaid(player, player.getLocation(), loc.transform(player.getLocation().getX() > loc.getX() ? -1 : 1, 0, 0), JUMP); diff --git a/Server/src/main/java/core/game/interaction/inter/BoltEnchantingInterface.java b/Server/src/main/java/core/game/interaction/inter/BoltEnchantingInterface.java index 86f6e40b3..37056b445 100644 --- a/Server/src/main/java/core/game/interaction/inter/BoltEnchantingInterface.java +++ b/Server/src/main/java/core/game/interaction/inter/BoltEnchantingInterface.java @@ -185,14 +185,6 @@ public final class BoltEnchantingInterface extends ComponentPlugin { return button; } - /** - * Sets the button. - * @param button The button to set. - */ - public void setButton(int button) { - this.button = button; - } - /** * Gets the bolt. * @return The bolt. @@ -201,14 +193,6 @@ public final class BoltEnchantingInterface extends ComponentPlugin { return bolt; } - /** - * Sets the bolt. - * @param bolt The bolt to set. - */ - public void setBolt(int bolt) { - this.bolt = bolt; - } - /** * Gets the level. * @return The level. @@ -217,30 +201,14 @@ public final class BoltEnchantingInterface extends ComponentPlugin { return level; } - /** - * Sets the level. - * @param level The level to set. - */ - public void setLevel(int level) { - this.level = level; - } - /** * Gets the runes. * @return The runes. */ - public Item[] getRunes() { + private Item[] getRunes() { return runes; } - /** - * Sets the runes. - * @param runes The runes to set. - */ - public void setRunes(Item[] runes) { - this.runes = runes; - } - /** * Gets the exp. * @return The exp. @@ -249,14 +217,6 @@ public final class BoltEnchantingInterface extends ComponentPlugin { return exp; } - /** - * Sets the exp. - * @param exp The exp to set. - */ - public void setExp(double exp) { - this.exp = exp; - } - /** * Gets the enchanted. * @return The enchanted. @@ -265,14 +225,6 @@ public final class BoltEnchantingInterface extends ComponentPlugin { return enchanted; } - /** - * Sets the enchanted. - * @param enchanted The enchanted to set. - */ - public void setEnchanted(int enchanted) { - this.enchanted = enchanted; - } - /** * Gets the bolt by the id. * @param button the button. diff --git a/Server/src/main/java/core/game/interaction/inter/GliderInterface.java b/Server/src/main/java/core/game/interaction/inter/GliderInterface.java index 5ea3aa3c2..16653f84b 100644 --- a/Server/src/main/java/core/game/interaction/inter/GliderInterface.java +++ b/Server/src/main/java/core/game/interaction/inter/GliderInterface.java @@ -1,5 +1,6 @@ package core.game.interaction.inter; +import api.ContentAPI; import core.game.component.Component; import core.game.component.ComponentDefinition; import core.game.component.ComponentPlugin; @@ -30,7 +31,7 @@ public final class GliderInterface extends ComponentPlugin { if (glider == null) { return true; } - player.getPulseManager().run(new GliderPulse(1, player, glider)); + ContentAPI.submitWorldPulse(new GliderPulse(1, player, glider)); return true; } } diff --git a/Server/src/main/java/core/game/interaction/item/ExplorersRingPlugin.kt b/Server/src/main/java/core/game/interaction/item/ExplorersRingPlugin.kt index 811bdb0bb..46ab2b00e 100644 --- a/Server/src/main/java/core/game/interaction/item/ExplorersRingPlugin.kt +++ b/Server/src/main/java/core/game/interaction/item/ExplorersRingPlugin.kt @@ -14,7 +14,11 @@ import core.game.node.entity.player.link.TeleportManager.TeleportType import core.game.world.map.Location import core.game.world.update.flag.context.Animation import core.game.world.update.flag.context.Graphics +import org.json.simple.JSONObject import org.rs09.consts.Items +import rs09.ServerStore +import rs09.ServerStore.getBoolean +import rs09.ServerStore.getInt import rs09.game.interaction.InteractionListener /** @@ -30,17 +34,15 @@ class ExplorersRingPlugin : InteractionListener() { override fun defineListeners() { on(RINGS, ITEM, "run-replenish"){player, node -> - if (player.savedData.globalData.runReplenishDelay < System.currentTimeMillis()) { - player.savedData.globalData.runReplenishCharges = 0 - player.savedData.globalData.runReplenishDelay = Util.nextMidnight(System.currentTimeMillis()) - } - val charges = player.savedData.globalData.runReplenishCharges + val charges = getStoreFile().getInt(player.username.toLowerCase() + ":run") if (charges >= getRingLevel(node.id)) { ContentAPI.sendMessage(player,"You have used all the charges you can for one day.") return@on true } player.settings.updateRunEnergy(-50.0) - player.savedData.globalData.runReplenishCharges = charges + 1 + + getStoreFile()[player.username.toLowerCase() + ":run"] = charges + 1 + ContentAPI.sendMessage(player,"You feel refreshed as the ring revitalises you and a charge is used up.") ContentAPI.visualize(player, 9988, 1733) return@on true @@ -51,16 +53,13 @@ class ExplorersRingPlugin : InteractionListener() { ContentAPI.sendMessage(player,"You need a Magic level of 21 in order to do that.") return@on true } - if (player.savedData.globalData.lowAlchemyDelay < System.currentTimeMillis()) { - player.savedData.globalData.lowAlchemyCharges = 0 - player.savedData.globalData.lowAlchemyDelay = Util.nextMidnight(System.currentTimeMillis()) - } - if (player.savedData.globalData.lowAlchemyCharges <= 0 && player.savedData.globalData.lowAlchemyDelay > System.currentTimeMillis()) { - ContentAPI.sendMessage(player,"You have used all the charges you can for one day.") + if(getStoreFile().getBoolean(player.username.toLowerCase() + ":alchs")){ + ContentAPI.sendMessage(player, "You have claimed all the charges you can for one day.") return@on true } ContentAPI.sendMessage(player,"You grant yourself with 30 free low alchemy charges.") // todo this implementation is not correct, see https://www.youtube.com/watch?v=UbUIF2Kw_Dw - player.savedData.globalData.lowAlchemyCharges = 30 + + getStoreFile()[player.username.toLowerCase() + ":alchs"] = true return@on true } @@ -93,4 +92,8 @@ class ExplorersRingPlugin : InteractionListener() { else -> -1 } } + + fun getStoreFile(): JSONObject{ + return ServerStore.getArchive("daily-explorer-ring") + } } \ No newline at end of file diff --git a/Server/src/main/java/core/game/interaction/item/TeleTabsOptionPlugin.java b/Server/src/main/java/core/game/interaction/item/TeleTabsOptionPlugin.java index 96e014141..92b3b450e 100644 --- a/Server/src/main/java/core/game/interaction/item/TeleTabsOptionPlugin.java +++ b/Server/src/main/java/core/game/interaction/item/TeleTabsOptionPlugin.java @@ -101,14 +101,14 @@ public class TeleTabsOptionPlugin extends OptionHandler { /** * @param item the item to set */ - public void setItem(int item) { + private void setItem(int item) { this.item = item; } /** * @param location the location to set */ - public void setLocation(Location location) { + private void setLocation(Location location) { this.location = location; } @@ -122,7 +122,7 @@ public class TeleTabsOptionPlugin extends OptionHandler { /** * @param exp the exp to set. */ - public void setExp(double exp) { + private void setExp(double exp) { this.exp = exp; } } diff --git a/Server/src/main/java/core/game/interaction/item/TeleportCrystalPlugin.java b/Server/src/main/java/core/game/interaction/item/TeleportCrystalPlugin.java index 08e17a0cd..3be8ba0cd 100644 --- a/Server/src/main/java/core/game/interaction/item/TeleportCrystalPlugin.java +++ b/Server/src/main/java/core/game/interaction/item/TeleportCrystalPlugin.java @@ -32,7 +32,7 @@ public final class TeleportCrystalPlugin extends OptionHandler { @Override public boolean handle(Player player, Node node, String option) { - if (!WildernessZone.checkTeleport(player, 20)) { + if (true) { player.getPacketDispatch().sendMessage("The crystal is unresponsive."); return true; } diff --git a/Server/src/main/java/core/game/interaction/item/brawling_gloves/BrawlingGlovesManager.java b/Server/src/main/java/core/game/interaction/item/brawling_gloves/BrawlingGlovesManager.java index f6cef6e7e..3e4c9ec0d 100644 --- a/Server/src/main/java/core/game/interaction/item/brawling_gloves/BrawlingGlovesManager.java +++ b/Server/src/main/java/core/game/interaction/item/brawling_gloves/BrawlingGlovesManager.java @@ -21,7 +21,7 @@ public class BrawlingGlovesManager { try { registerGlove(id, Objects.requireNonNull(BrawlingGloves.forId(id)).getCharges()); } catch (Exception e){ - System.out.println(e); + e.printStackTrace(); } } public void registerGlove(int id, int charges) {GloveCharges.putIfAbsent(id,charges);} diff --git a/Server/src/main/java/core/game/interaction/item/withitem/PoisonRemovePlugin.java b/Server/src/main/java/core/game/interaction/item/withitem/PoisonRemovePlugin.java index bdcc200ee..73fb90051 100644 --- a/Server/src/main/java/core/game/interaction/item/withitem/PoisonRemovePlugin.java +++ b/Server/src/main/java/core/game/interaction/item/withitem/PoisonRemovePlugin.java @@ -287,34 +287,6 @@ public class PoisonRemovePlugin extends UseWithHandler { return third; } - /** - * @param first the first to set. - */ - public void setFirst(int first) { - this.first = first; - } - - /** - * @param item the item to set. - */ - public void setItem(int item) { - this.item = item; - } - - /** - * @param second the second to set. - */ - public void setSecond(int second) { - this.second = second; - } - - /** - * @param third the third to set. - */ - public void setThird(int third) { - this.third = third; - } - /** * Method used to get the poisioned weapon for the id. * @param i the id. diff --git a/Server/src/main/java/core/game/interaction/item/withitem/PoisonWeaponPlugin.java b/Server/src/main/java/core/game/interaction/item/withitem/PoisonWeaponPlugin.java index c14a6dc77..09b3e0af6 100644 --- a/Server/src/main/java/core/game/interaction/item/withitem/PoisonWeaponPlugin.java +++ b/Server/src/main/java/core/game/interaction/item/withitem/PoisonWeaponPlugin.java @@ -261,34 +261,6 @@ public class PoisonWeaponPlugin extends UseWithHandler { return third; } - /** - * @param first the first to set. - */ - public void setFirst(int first) { - this.first = first; - } - - /** - * @param item the item to set. - */ - public void setItem(int item) { - this.item = item; - } - - /** - * @param second the second to set. - */ - public void setSecond(int second) { - this.second = second; - } - - /** - * @param third the third to set. - */ - public void setThird(int third) { - this.third = third; - } - /** * Method used to get the poisioned weapon for the id. * @param i the id. @@ -320,8 +292,10 @@ public class PoisonWeaponPlugin extends UseWithHandler { product = weapon.getThird(); player.getInventory().remove(new Item(5940, 1)); break; + default: + break; } - int amt = weaponItem.getAmount() > 5 ? 5 : weaponItem.getAmount(); + int amt = Math.min(weaponItem.getAmount(), 5); player.getInventory().remove(new Item(weaponItem.getId(), amt)); player.getInventory().add(new Item(229, 1)); player.getInventory().add(new Item(product, amt)); diff --git a/Server/src/main/java/core/game/interaction/item/withobject/IncubatorPlugin.java b/Server/src/main/java/core/game/interaction/item/withobject/IncubatorPlugin.java index 233518142..d031d1bff 100644 --- a/Server/src/main/java/core/game/interaction/item/withobject/IncubatorPlugin.java +++ b/Server/src/main/java/core/game/interaction/item/withobject/IncubatorPlugin.java @@ -44,20 +44,20 @@ public class IncubatorPlugin extends OptionHandler { player.sendMessage("You don't have enough inventory space."); return true; } - if (egg != null) { - String name = egg.getProduct().getName().toLowerCase(); - player.varpManager.get(1160).setVarbit(4,0).send(player); - player.sendMessage("You take your " + name + " out of the incubator."); - if(!player.getInventory().add(egg.getProduct())){ - GroundItemManager.create(egg.getProduct(),player); - } - player.removeAttribute("inc"); + { + String name = egg.getProduct().getName().toLowerCase(); + player.varpManager.get(1160).setVarbit(4,0).send(player); + player.sendMessage("You take your " + name + " out of the incubator."); + if(!player.getInventory().add(egg.getProduct())){ + GroundItemManager.create(egg.getProduct(),player); } + player.removeAttribute("inc"); + } return true; case "inspect": if (player.states.get("incubator") != null || inc != -1) { IncubatorState p = (IncubatorState) player.states.get("incubator"); - if(p.getPulse() == null){ + if(p != null && p.getPulse() == null){ player.varpManager.get(1160).setVarbit(4,0).send(player); return true; } diff --git a/Server/src/main/java/core/game/interaction/npc/ZaffPlugin.java b/Server/src/main/java/core/game/interaction/npc/ZaffPlugin.java deleted file mode 100644 index 757f2dfac..000000000 --- a/Server/src/main/java/core/game/interaction/npc/ZaffPlugin.java +++ /dev/null @@ -1,396 +0,0 @@ -package core.game.interaction.npc; - -import core.cache.def.impl.NPCDefinition; -import core.plugin.Initializable; -import core.game.content.dialogue.DialoguePlugin; -import core.game.content.dialogue.FacialExpression; -import core.game.interaction.OptionHandler; -import core.game.node.Node; -import core.game.node.entity.npc.NPC; -import core.game.node.entity.player.Player; -import core.game.node.entity.player.link.RunScript; -import core.game.node.entity.player.link.diary.DiaryType; -import core.game.node.entity.player.link.quest.Quest; -import core.game.node.item.Item; -import core.plugin.Plugin; - -/** - * Represents the plugin used for buying a battle staff from zeke. - * @author 'Vexia - * @version 1.0 - */ -@Initializable -public final class ZaffPlugin extends OptionHandler { - - /** - * The bacon ring. - */ - public static final Item BEACON_RING = new Item(11014); - - @Override - public Plugin newInstance(Object arg) throws Throwable { - NPCDefinition.setOptionHandler("buy-battlestaves", this); - new ZaffDialogue().init(); - new ZaffStaveDialogue().init(); - return this; - } - - @Override - public boolean handle(Player player, Node node, String option) { - player.getDialogueInterpreter().open(9679); - return true; - } - - /** - * Represents the dialogue plugin used for the zaff npc. - * @author 'Vexia - * @version 1.0 - */ - public static final class ZaffDialogue extends DialoguePlugin { - - /** - * Represents the staff item. - */ - @SuppressWarnings("unused") - private static final Item STAFF = new Item(11014, 1); - - /** - * The quest. - */ - private Quest quest; - - /** - * Constructs a new {@code ZaffDialogue} {@code Object}. - */ - public ZaffDialogue() { - /** - * empty. - */ - } - - /** - * Constructs a new {@code ZaffDialogue} {@code Object}. - * @param player the player. - */ - public ZaffDialogue(Player player) { - super(player); - } - - @Override - public DialoguePlugin newInstance(Player player) { - return new ZaffDialogue(player); - } - - @Override - public boolean open(Object... args) { - npc = (NPC) args[0]; - quest = player.getQuestRepository().getQuest("What Lies Below"); - interpreter.sendDialogues(npc, FacialExpression.HALF_GUILTY, "Would you like to buy or sell some staves or is there", "something else you need?"); - stage = 0; - return true; - } - - @Override - public boolean handle(int interfaceId, int buttonId) { - switch (stage) { - case 0: - if (quest.getStage(player) == 60) { - interpreter.sendOptions("Select an Option", "Yes, please.", "No, thank you.", "Rat Burgiss sent me."); - stage = 1; - break; - } else if (quest.getStage(player) == 80) { - interpreter.sendOptions("Select an Option", "Yes, please.", "No, thank you.", "We did it! We beat Surok!"); - stage = 1; - break; - } else if (quest.getStage(player) >= 70) { - interpreter.sendOptions("Select an Option", "Yes, please.", "No, thank you.", "Can I have another ring?"); - stage = 1; - break; - } - interpreter.sendOptions("Select an Option", "Yes, please.", "No, thank you."); - stage = 1; - break; - case 1: - switch (buttonId) { - case 1: - interpreter.sendDialogues(player, FacialExpression.HALF_GUILTY, "Yes, please."); - stage = 10; - break; - case 2: - interpreter.sendDialogues(player, FacialExpression.HALF_GUILTY, "No, thank you."); - stage = 20; - break; - case 3: - if (quest.getStage(player) == 60) { - player("Rat Burgiss sent me!"); - stage = 70; - break; - } else if (quest.getStage(player) == 80) { - player("We did it! We beat Surok!"); - stage = 200; - break; - } - interpreter.sendDialogues(player, FacialExpression.HALF_GUILTY, "Can I have another ring?"); - stage = 50; - break; - } - - break; - case 10: - end(); - npc.openShop(player); - break; - case 20: - interpreter.sendDialogues(npc, FacialExpression.HALF_GUILTY, "Well, 'stick' your head in again if you change your mind."); - stage = 21; - break; - case 21: - interpreter.sendDialogues(player, FacialExpression.HALF_GUILTY, "Huh, terrible pun. You just can't get the 'staff' these", "days!"); - stage = 22; - break; - case 22: - end(); - break; - case 50: - if (player.getInventory().contains(11014, 1)) - interpreter.sendDialogues(npc, FacialExpression.HALF_GUILTY, "Go and get the one that's in your inventory " + player.getUsername() + "!"); - else if (player.getBank().contains(11014, 1)) - interpreter.sendDialogues(npc, FacialExpression.HALF_GUILTY, "Go and get the one that's in your bank" + player.getUsername() + "!"); - else if (player.getEquipment().contains(11014, 1)) - interpreter.sendDialogues(npc, FacialExpression.HALF_GUILTY, "Go and get the one that's on your finger " + player.getUsername() + "!"); - else { - interpreter.sendDialogues(npc, FacialExpression.HALF_GUILTY, "Of course you can! Here you go " + player.getUsername() + "!"); - player.getInventory().add(BEACON_RING); - } - stage = 51; - break; - case 51: - end(); - break; - case 70: - npc("Ah, yes; You must be " + player.getUsername() + "! Rat sent word that you", "would be coming. Everything is prepared. I have created", "a spell that will remove the mind control spell."); - stage++; - break; - case 71: - player("Okay, what's the plan?"); - stage++; - break; - case 72: - npc("Listen carefully. For the spell to succeed, the king must", "be made very weak, if his mind is controlled, you will", "need to fight him until he is all but dead."); - stage++; - break; - case 73: - npc("Then and ONLY then, use your ring to summon me.", "I will teleport to you and cast the spell that will", "cure the king."); - stage++; - break; - case 74: - player("Why must I summon you? Can't you come with me?"); - stage++; - break; - case 75: - npc("I cannot. I must look after my shop here and", "I have lots to do. Rest assured, I will come when you", "summon me."); - stage++; - break; - case 76: - player("Okay, so what do I do now?"); - stage++; - break; - case 77: - npc("Take this beacon ring and some instructions."); - stage++; - break; - case 78: - npc("Once you have read the instructions. It will be time for", "you to arrest Surok."); - stage++; - break; - case 79: - player("Won't he be disinclined to acquiesce to that request?"); - stage++; - break; - case 80: - npc("Won't he what?"); - stage++; - break; - case 81: - player("Won't he refuse?"); - stage++; - break; - case 82: - npc("I very much expect so. It may turn nasty, so be on your", "guard. I hope we can stop him before he can cast his", "spell!", "Make sure you have that ring I gave you."); - stage++; - break; - case 83: - player("Okay, thanks, Zaff!"); - stage++; - break; - case 84: - player.getInventory().add(BEACON_RING); - quest.setStage(player, 70); - end(); - break; - case 200: - npc("Yes. You have done well, " + player.getUsername() + ". You are to be", "commended for you actions!"); - stage++; - break; - case 201: - player("It was all in the call of duty!"); - stage++; - break; - case 202: - player("What will happen with Surok now?"); - stage++; - break; - case 203: - npc("Well, when I disrupted Surok's spell, he will have been", "sealed in the library, but we still need to keep an", "eye on him, just in case."); - stage++; - break; - case 204: - npc("When you are ready, report back to Rat and he will", "reward you."); - stage++; - break; - case 205: - player("Okay, I will."); - stage++; - break; - case 206: - quest.setStage(player, 90); - end(); - break; - } - return true; - } - - @Override - public int[] getIds() { - return new int[] { 546 }; - } - } - - /** - * Represents the dialogue used to buy staves from zaff. - * @author 'Vexia - * @version 1.0 - */ - public final class ZaffStaveDialogue extends DialoguePlugin { - - /** - * The ammount of battlestaves. - */ - private int ammount; - - /** - * Constructs a new {@code ZaffBuyStavesDialogue} {@code Object}. - */ - public ZaffStaveDialogue() { - /** - * empty. - */ - } - - /** - * Constructs a new {@code ZaffBuyStavesDialogue} {@code Object}. - * @param player the player. - */ - public ZaffStaveDialogue(Player player) { - super(player); - } - - @Override - public DialoguePlugin newInstance(Player player) { - return new ZaffStaveDialogue(player); - } - - @Override - public boolean open(Object... args) { - interpreter.sendDialogues(player, FacialExpression.HALF_GUILTY, "Do you have any battlestaves?"); - stage = 0; - return true; - } - - @Override - public boolean handle(int interfaceId, int buttonId) { - switch (stage) { - case 0: - ammount = player.getSavedData().getGlobalData().getZaffAmount(); - if (player.getSavedData().getGlobalData().getZafTime() < System.currentTimeMillis()) { - ammount = getMaxStaffs(); - } - if (player.getSavedData().getGlobalData().getZafTime() > System.currentTimeMillis() && ammount <= 0) { - interpreter.sendDialogues(546, FacialExpression.HALF_GUILTY, "I'm very sorry! I seem to be out of battlestaves at the", "moment! I expect I'll get some more in by tomorrow,", "though."); - stage = 2; - break; - } - interpreter.sendDialogues(546, FacialExpression.HALF_GUILTY, "Battlestaves cost 8,000 gold pieces each. I have " + ammount + " left.", "How many would you like to buy?"); - stage = 1; - break; - case 1: - end(); - /*player.setAttribute("runscript", new RunScript() { - @Override - public boolean handle() { - int amt = (int) value; - if (amt > ammount) { - amt = ammount; - } - if (amt > player.getInventory().freeSlots()) { - amt = player.getInventory().freeSlots(); - } - if (amt == 0) { - return true; - } - if (7000 * amt > player.getInventory().getAmount(new Item(995))) { - player.getPacketDispatch().sendMessage("You don't have enough money to buy that many."); - return true; - } else { - Item remove = new Item(995, 7000 * amt); - if (!player.getInventory().containsItem(remove)) { - end(); - return true; - } - player.getInventory().remove(remove); - if (player.getInventory().add(new Item(1391, amt))) { - player.getSavedData().getGlobalData().setZafTime(System.currentTimeMillis() + (24 * 60 * 60 * 1000)); - player.getSavedData().getGlobalData().setZaffAmount(ammount - amt); - } - } - return true; - } - }); - interpreter.sendInput(false, "Zaff has " + ammount + " battlestaves..."); -*/ break; - //TODO: Come back and fix this later when achievement diaries can actually be completed kekkekekeke - case 2: - interpreter.sendDialogues(player, FacialExpression.HALF_GUILTY, "Oh, okay then. I'll try again another time."); - stage = 3; - break; - case 3: - end(); - break; - } - return true; - } - - /** - * Gets the max staffs to buy. - * @return the max staffs to buy. - */ - public int getMaxStaffs() { - int level = player.getAchievementDiaryManager().getDiary(DiaryType.VARROCK).getLevel(); - switch (level) { - case 2: - return 64; - case 1: - return 32; - case 0: - return 16; - default: - return 8; - } - } - - @Override - public int[] getIds() { - return new int[] { 9679 }; - } - } -} diff --git a/Server/src/main/java/core/game/interaction/npc/ZaffPlugin.kt b/Server/src/main/java/core/game/interaction/npc/ZaffPlugin.kt new file mode 100644 index 000000000..cf459799a --- /dev/null +++ b/Server/src/main/java/core/game/interaction/npc/ZaffPlugin.kt @@ -0,0 +1,456 @@ +package core.game.interaction.npc + +import api.Container +import api.ContentAPI +import api.InputType +import core.cache.def.impl.NPCDefinition +import core.plugin.Initializable +import core.game.interaction.OptionHandler +import core.plugin.Plugin +import core.game.interaction.npc.ZaffPlugin.ZaffDialogue +import core.game.interaction.npc.ZaffPlugin.ZaffStaveDialogue +import core.game.content.dialogue.DialoguePlugin +import core.game.node.entity.player.link.quest.Quest +import core.game.content.dialogue.FacialExpression +import core.game.interaction.npc.ZaffPlugin +import core.game.node.Node +import core.game.node.entity.npc.NPC +import core.game.node.entity.player.Player +import core.game.node.entity.player.link.diary.DiaryType +import core.game.node.item.Item +import org.json.simple.JSONObject +import org.rs09.consts.Items +import rs09.ServerStore +import rs09.ServerStore.getInt +import rs09.game.system.SystemLogger + +/** + * Represents the plugin used for buying a battle staff from zeke. + * @author 'Vexia + * @version 1.0 + */ +@Initializable +class ZaffPlugin : OptionHandler() { + @Throws(Throwable::class) + override fun newInstance(arg: Any?): Plugin { + NPCDefinition.setOptionHandler("buy-battlestaves", this) + ZaffDialogue().init() + ZaffStaveDialogue().init() + return this + } + + override fun handle(player: Player, node: Node, option: String): Boolean { + player.dialogueInterpreter.open(9679) + return true + } + + /** + * Represents the dialogue plugin used for the zaff npc. + * @author 'Vexia + * @version 1.0 + */ + class ZaffDialogue : DialoguePlugin { + /** + * The quest. + */ + private var quest: Quest? = null + + /** + * Constructs a new `ZaffDialogue` `Object`. + */ + constructor() { + /** + * empty. + */ + } + + /** + * Constructs a new `ZaffDialogue` `Object`. + * @param player the player. + */ + constructor(player: Player?) : super(player) {} + + override fun newInstance(player: Player?): DialoguePlugin { + return ZaffDialogue(player) + } + + override fun open(vararg args: Any): Boolean { + npc = args[0] as NPC + quest = player.questRepository.getQuest("What Lies Below") + interpreter.sendDialogues( + npc, + FacialExpression.HALF_GUILTY, + "Would you like to buy or sell some staves or is there", + "something else you need?" + ) + stage = 0 + return true + } + + override fun handle(interfaceId: Int, buttonId: Int): Boolean { + when (stage) { + 0 -> { + if (quest!!.getStage(player) == 60) { + interpreter.sendOptions( + "Select an Option", + "Yes, please.", + "No, thank you.", + "Rat Burgiss sent me." + ) + stage = 1 + } else if (quest!!.getStage(player) == 80) { + interpreter.sendOptions( + "Select an Option", + "Yes, please.", + "No, thank you.", + "We did it! We beat Surok!" + ) + stage = 1 + } else if (quest!!.getStage(player) >= 70) { + interpreter.sendOptions( + "Select an Option", + "Yes, please.", + "No, thank you.", + "Can I have another ring?" + ) + stage = 1 + } + interpreter.sendOptions("Select an Option", "Yes, please.", "No, thank you.") + stage = 1 + } + 1 -> when (buttonId) { + 1 -> { + interpreter.sendDialogues(player, FacialExpression.HALF_GUILTY, "Yes, please.") + stage = 10 + } + 2 -> { + interpreter.sendDialogues(player, FacialExpression.HALF_GUILTY, "No, thank you.") + stage = 20 + } + 3 -> { + if (quest!!.getStage(player) == 60) { + player("Rat Burgiss sent me!") + stage = 70 + } else if (quest!!.getStage(player) == 80) { + player("We did it! We beat Surok!") + stage = 200 + } + interpreter.sendDialogues(player, FacialExpression.HALF_GUILTY, "Can I have another ring?") + stage = 50 + } + } + 10 -> { + if(player.achievementDiaryManager.getDiary(DiaryType.VARROCK).levelRewarded.contains(true)){ + npcl(FacialExpression.FRIENDLY, "Would you like to hear about my battlestaves?") + stage = 1000 + } else { + end() + npc.openShop(player) + } + } + 20 -> { + interpreter.sendDialogues( + npc, + FacialExpression.HALF_GUILTY, + "Well, 'stick' your head in again if you change your mind." + ) + stage = 21 + } + 21 -> { + interpreter.sendDialogues( + player, + FacialExpression.HALF_GUILTY, + "Huh, terrible pun. You just can't get the 'staff' these", + "days!" + ) + stage = 22 + } + 22 -> end() + 50 -> { + if (player.inventory.contains(11014, 1)) interpreter.sendDialogues( + npc, + FacialExpression.HALF_GUILTY, + "Go and get the one that's in your inventory " + player.username + "!" + ) else if (player.bank.contains(11014, 1)) interpreter.sendDialogues( + npc, + FacialExpression.HALF_GUILTY, + "Go and get the one that's in your bank" + player.username + "!" + ) else if (player.equipment.contains(11014, 1)) interpreter.sendDialogues( + npc, + FacialExpression.HALF_GUILTY, + "Go and get the one that's on your finger " + player.username + "!" + ) else { + interpreter.sendDialogues( + npc, + FacialExpression.HALF_GUILTY, + "Of course you can! Here you go " + player.username + "!" + ) + player.inventory.add(BEACON_RING) + } + stage = 51 + } + 51 -> end() + 70 -> { + npc( + "Ah, yes; You must be " + player.username + "! Rat sent word that you", + "would be coming. Everything is prepared. I have created", + "a spell that will remove the mind control spell." + ) + stage++ + } + 71 -> { + player("Okay, what's the plan?") + stage++ + } + 72 -> { + npc( + "Listen carefully. For the spell to succeed, the king must", + "be made very weak, if his mind is controlled, you will", + "need to fight him until he is all but dead." + ) + stage++ + } + 73 -> { + npc( + "Then and ONLY then, use your ring to summon me.", + "I will teleport to you and cast the spell that will", + "cure the king." + ) + stage++ + } + 74 -> { + player("Why must I summon you? Can't you come with me?") + stage++ + } + 75 -> { + npc( + "I cannot. I must look after my shop here and", + "I have lots to do. Rest assured, I will come when you", + "summon me." + ) + stage++ + } + 76 -> { + player("Okay, so what do I do now?") + stage++ + } + 77 -> { + npc("Take this beacon ring and some instructions.") + stage++ + } + 78 -> { + npc("Once you have read the instructions. It will be time for", "you to arrest Surok.") + stage++ + } + 79 -> { + player("Won't he be disinclined to acquiesce to that request?") + stage++ + } + 80 -> { + npc("Won't he what?") + stage++ + } + 81 -> { + player("Won't he refuse?") + stage++ + } + 82 -> { + npc( + "I very much expect so. It may turn nasty, so be on your", + "guard. I hope we can stop him before he can cast his", + "spell!", + "Make sure you have that ring I gave you." + ) + stage++ + } + 83 -> { + player("Okay, thanks, Zaff!") + stage++ + } + 84 -> { + player.inventory.add(BEACON_RING) + quest!!.setStage(player, 70) + end() + } + 200 -> { + npc("Yes. You have done well, " + player.username + ". You are to be", "commended for you actions!") + stage++ + } + 201 -> { + player("It was all in the call of duty!") + stage++ + } + 202 -> { + player("What will happen with Surok now?") + stage++ + } + 203 -> { + npc( + "Well, when I disrupted Surok's spell, he will have been", + "sealed in the library, but we still need to keep an", + "eye on him, just in case." + ) + stage++ + } + 204 -> { + npc("When you are ready, report back to Rat and he will", "reward you.") + stage++ + } + 205 -> { + player("Okay, I will.") + stage++ + } + 206 -> { + quest!!.setStage(player, 90) + end() + } + + 1000 -> options("Yes, please.", "No, thanks.").also { stage++ } + 1001 -> when(buttonId){ + 1 -> { + end() + ContentAPI.openDialogue(player, 9679, npc) + } + 2 -> { + end() + npc.openShop(player) + } + } + } + return true + } + + override fun getIds(): IntArray { + return intArrayOf(546) + } + + companion object { + /** + * Represents the staff item. + */ + private val STAFF = Item(11014, 1) + } + } + + /** + * Represents the dialogue used to buy staves from zaff. + * @author 'Vexia + * @version 1.0 + */ + inner class ZaffStaveDialogue : DialoguePlugin { + /** + * The ammount of battlestaves. + */ + private var ammount = 0 + + /** + * Constructs a new `ZaffBuyStavesDialogue` `Object`. + */ + constructor() { + /** + * empty. + */ + } + + /** + * Constructs a new `ZaffBuyStavesDialogue` `Object`. + * @param player the player. + */ + constructor(player: Player?) : super(player) {} + + override fun newInstance(player: Player?): DialoguePlugin { + return ZaffStaveDialogue(player) + } + + override fun open(vararg args: Any): Boolean { + ammount = getStoreFile().getInt(player.username.toLowerCase()) + interpreter.sendDialogues(player, FacialExpression.HALF_GUILTY, "Do you have any battlestaves?") + stage = 0 + return true + } + + override fun handle(interfaceId: Int, buttonId: Int): Boolean { + when (stage) { + 0 -> { + if (ammount >= maxStaffs) { + interpreter.sendDialogues( + 546, + FacialExpression.HALF_GUILTY, + "I'm very sorry! I seem to be out of battlestaves at the", + "moment! I expect I'll get some more in by tomorrow,", + "though." + ) + stage = 2 + return true + } + interpreter.sendDialogues( + 546, + FacialExpression.HALF_GUILTY, + "Battlestaves cost 8,000 gold pieces each. I have ${maxStaffs - ammount} left.", + "How many would you like to buy?" + ) + stage = 1 + } + 1 -> end().also { ContentAPI.sendInputDialogue(player, InputType.NUMERIC, "Enter an amount:"){ value -> + ammount = getStoreFile().getInt(player.username.toLowerCase()) + var amt = value as Int + if(amt > maxStaffs - ammount) amt = maxStaffs - ammount + val coinage = amt * 8000 + if(!ContentAPI.inInventory(player, Items.COINS_995, coinage)){ + ContentAPI.sendDialogue(player, "You can't afford that many.") + return@sendInputDialogue + } + + if(amt == 0){ + return@sendInputDialogue + } + + if(ContentAPI.removeItem(player, Item(Items.COINS_995, coinage), Container.INVENTORY)){ + ContentAPI.addItem(player, Items.BATTLESTAFF_1392, amt) + ZaffPlugin.getStoreFile()[player.username.toLowerCase()] = amt + ammount + } + } } + 2 -> { + interpreter.sendDialogues( + player, + FacialExpression.HALF_GUILTY, + "Oh, okay then. I'll try again another time." + ) + stage = 3 + } + 3 -> end() + } + return true + } + + /** + * Gets the max staffs to buy. + * @return the max staffs to buy. + */ + val maxStaffs: Int + get() { + val level = player.achievementDiaryManager.getDiary(DiaryType.VARROCK).level + return when (level) { + 2 -> 64 + 1 -> 32 + 0 -> 16 + else -> 0 + } + } + + override fun getIds(): IntArray { + return intArrayOf(9679) + } + } + + companion object { + /** + * The bacon ring. + */ + val BEACON_RING = Item(11014) + + fun getStoreFile(): JSONObject { + return ServerStore.getArchive("daily-zaff") + } + } +} \ No newline at end of file diff --git a/Server/src/main/java/core/game/interaction/object/ReadSignPostPlugin.java b/Server/src/main/java/core/game/interaction/object/ReadSignPostPlugin.java index 1b8a077ef..0248ef077 100644 --- a/Server/src/main/java/core/game/interaction/object/ReadSignPostPlugin.java +++ b/Server/src/main/java/core/game/interaction/object/ReadSignPostPlugin.java @@ -70,7 +70,6 @@ public class ReadSignPostPlugin extends OptionHandler { return true; } }); - player.getPacketDispatch(); final Scenery object = (Scenery) node; Signs sign = Signs.forId(object.getId()); if (sign == null) { diff --git a/Server/src/main/java/core/game/interaction/object/sorceress/GardenObjectsPlugin.java b/Server/src/main/java/core/game/interaction/object/sorceress/GardenObjectsPlugin.java deleted file mode 100644 index 979a97496..000000000 --- a/Server/src/main/java/core/game/interaction/object/sorceress/GardenObjectsPlugin.java +++ /dev/null @@ -1,1343 +0,0 @@ -package core.game.interaction.object.sorceress; - -import core.cache.def.impl.SceneryDefinition; -import core.game.component.Component; -import core.plugin.Initializable; -import core.game.content.dialogue.DialoguePlugin; -import core.game.content.dialogue.FacialExpression; -import core.game.node.entity.skill.Skills; -import core.game.interaction.NodeUsageEvent; -import core.game.interaction.OptionHandler; -import core.game.interaction.UseWithHandler; -import core.game.node.Node; -import core.game.node.entity.npc.NPC; -import core.game.node.entity.player.Player; -import core.game.node.entity.player.link.quest.Quest; -import core.game.node.item.Item; -import core.game.node.object.Scenery; -import core.game.system.task.LocationLogoutTask; -import core.game.system.task.LogoutTask; -import core.game.system.task.Pulse; -import rs09.game.world.GameWorld; -import core.game.world.map.Location; -import core.game.world.update.flag.context.Animation; -import core.game.world.update.flag.context.Graphics; -import core.net.packet.PacketRepository; -import core.net.packet.context.MinimapStateContext; -import core.net.packet.out.MinimapState; -import core.plugin.Plugin; -import rs09.plugin.PluginManager; -import core.tools.RandomFunction; - -/** - * Represents the plugin used for the garden object plugin. - * @author SonicForce41 - * @author 'Vexia - * @version 1.0 - */ -@Initializable -public final class GardenObjectsPlugin extends OptionHandler { - - /** - * Represents the animation to use. - */ - private static final Animation ANIMATION = new Animation(827); - - /** - * Represents the herbs items used for the elemental garden picking. - */ - private static final int[] HERBS = { 199, 201, 203, 205, 207, 209, 211, 213, 215, 217, 219, 2485, 3049, 3051, 199, 201, 203, 205 }; - - /** - * Represents the drinking animation. - */ - private static final Animation DRINK_ANIM = new Animation(5796); - - /** - * Represents the teleport anim. - */ - private static final Animation TELE = new Animation(714); - - /** - * Represents the graphics to use. - */ - private static final Graphics GRAPHICS = new Graphics(111, 100, 1); - - /** - * Represents the picking fruit anim. - */ - private static final Animation PICK_FRUIT = new Animation(2280); - - @Override - public Plugin newInstance(Object arg) throws Throwable { - SceneryDefinition.setOptionHandler("pick-fruit", this); - SceneryDefinition.setOptionHandler("drink-from", this); - SceneryDefinition.forId(21794).getHandlers().put("option:search", this); - for (HerbDefinition h : HerbDefinition.values()) { - SceneryDefinition.forId(h.getId()).getHandlers().put("option:pick", this); - } - new SqirkJuicePlugin().newInstance(arg); - new OsmanDialogue().init(); - new SqirkMakingDialogue().init(); - PluginManager.definePlugin(new SorceressGardenObject()); - return this; - } - - @Override - public boolean handle(final Player player, Node node, String option) { - Scenery object = (Scenery) node; - if (option.equals("pick")) { - final HerbDefinition herbDef = HerbDefinition.forId(object.getId()); - if (herbDef != null) { - handleElementalGarden(player, object, herbDef); - return true; - } - } else if (option.equals("search")) { - if (object.getId() == 21794) { - if (player.getInventory().freeSlots() < 1) { - player.sendMessage("You don't have enough space in your inventory to take a beer glass."); - } else { - player.sendMessage("You take an empty beer glass off the shelves."); - player.getInventory().add(new Item(1919, 1)); - } - } - } else if (option.equals("pick-fruit")) { - final SeasonDefinitions def = SeasonDefinitions.forTreeId(object.getId()); - if (def != null) { - player.lock(); - player.addExtension(LogoutTask.class, new LocationLogoutTask(99, def.getRespawn())); - player.animate(PICK_FRUIT); - player.getSkills().addExperience(Skills.THIEVING, def.getExp(), true); - player.getSkills().addExperience(Skills.FARMING, def.getFarmExp(), true); - GameWorld.getPulser().submit(new Pulse(2, player) { - int delay = 0; - - @Override - public boolean pulse() { - if (delay == 1) { - player.getInventory().add(new Item(def.getFruitId())); - player.getInterfaceManager().openOverlay(new Component(115)); - PacketRepository.send(MinimapState.class, new MinimapStateContext(player, 2)); - } else if (delay == 3) - player.getProperties().setTeleportLocation(def.getRespawn()); - else if (delay == 4) { - player.unlock(); - player.removeExtension(LogoutTask.class); - player.getPacketDispatch().sendMessage("An elemental force emanating from the garden teleports you away."); - PacketRepository.send(MinimapState.class, new MinimapStateContext(player, 0)); - player.getInterfaceManager().close(); - player.getInterfaceManager().closeOverlay(); - player.unlock(); - return true; - } - delay++; - return false; - } - }); - } - } else if (option.equals("drink-from")) { - player.lock(); - GameWorld.getPulser().submit(new Pulse(1, player) { - int counter = 0; - - @Override - public boolean pulse() { - switch (counter++) { - case 1: - player.animate(DRINK_ANIM); - break; - case 4: - player.graphics(GRAPHICS); - break; - case 5: - player.animate(TELE); - break; - case 6: - player.getInterfaceManager().openOverlay(new Component(115)); - break; - case 7: - PacketRepository.send(MinimapState.class, new MinimapStateContext(player, 2)); - break; - case 9: - player.getProperties().setTeleportLocation(new Location(3321, 3141, 0)); - break; - case 11: - player.unlock(); - player.animate(new Animation(-1)); - player.getInterfaceManager().close(); - player.getInterfaceManager().closeOverlay(); - PacketRepository.send(MinimapState.class, new MinimapStateContext(player, 0)); - return true; - } - return false; - } - }); - } - return true; - } - - /** - * Method used to handle the elemental garden picking. - * @param player the player. - * @param object the object. - * @param herbDef the herbdef. - */ - private void handleElementalGarden(final Player player, Scenery object, final HerbDefinition herbDef) { - player.lock(); - player.addExtension(LogoutTask.class, new LocationLogoutTask(99, herbDef.getRespawn())); - player.animate(ANIMATION); - player.getSkills().addExperience(Skills.FARMING, herbDef.getExp(), true); - GameWorld.getPulser().submit(new Pulse(2, player) { - int delay = 0; - - @Override - public boolean pulse() { - if (delay == 1) { - player.getInventory().add(new Item(HERBS[RandomFunction.random(0, HERBS.length - 1)], + (1))); - player.getInventory().add(new Item(HERBS[RandomFunction.random(0, HERBS.length - 1)], + (1))); - player.getPacketDispatch().sendMessage("You pick up a herb."); - player.getInterfaceManager().openOverlay(new Component(115)); - PacketRepository.send(MinimapState.class, new MinimapStateContext(player, 2)); - } else if (delay == 3) - player.getProperties().setTeleportLocation(Location.create(herbDef.getRespawn())); - else if (delay == 4) { - player.unlock(); - player.getPacketDispatch().sendMessage("An elemental force emanating from the garden teleports you away."); - PacketRepository.send(MinimapState.class, new MinimapStateContext(player, 0)); - player.getInterfaceManager().close(); - player.getInterfaceManager().closeOverlay(); - player.removeExtension(LogoutTask.class); - player.unlock(); - return true; - } - delay++; - return false; - } - }); - } - - /** - * Represents the herb definitions. - * @author SonicForce41 - * @version 1.0 - */ - public enum HerbDefinition { - WINTER(21671, 30, new Location(2907, 5470, 0)), SPRING(21668, 40, new Location(2916, 5473, 0)), AUTUMN(21670, 50, new Location(2913, 5467, 0)), SUMMER(21669, 60, new Location(2910, 5476, 0)); - - /** - * Represents the id. - */ - private int id; - - /** - * Represents the experience. - */ - private double exp; - - /** - * Represents the respawn location. - */ - private Location respawn; - - /** - * Constructs a new {@code GardenObjectsPlugin} {@code Object}. - * @param id the id. - * @param exp the exp. - * @param respawn the respawn. - */ - HerbDefinition(int id, double exp, Location respawn) { - this.id = id; - this.exp = exp; - this.respawn = respawn; - } - - /** - * Gets the exp - * @return the Exp - */ - public double getExp() { - return exp; - } - - /** - * Gets the Id - * @return the Id - */ - public int getId() { - return id; - } - - /** - * Gets the respawn Location - * @return the Location. - */ - public Location getRespawn() { - return respawn; - } - - /** - * Gets the herb definition by the id. - * @param id the objectId - * @return the definition. - */ - public static HerbDefinition forId(int id) { - for (HerbDefinition def : HerbDefinition.values()) { - if (def.getId() == id) { - return def; - } - } - return null; - } - } - - /** - * Represents the season definitions. - * @author SonicForce41 - * @version 1.0 - */ - public enum SeasonDefinitions { - WINTER(21769, 1, 30, 70.0, 10847, 10851, 5, 0, 10, 350, 21709, new Location(2907, 5470, 0)), SPRING(21767, 25, 40, 337.5, 10844, 10848, 4, 1, 20, 1350, 21753, new Location(2916, 5473, 0)), AUTUMN(21768, 45, 50, 783.3, 10846, 10850, 3, 2, 30, 2350, 21731, new Location(2913, 5467, 0)), SUMMER(21766, 65, 60, 1500, 10845, 10849, 2, 3, 40, 3000, 21687, new Location(2910, 5476, 0)); - - /** - * The treeId - */ - private int treeId; - - /** - * The level - */ - private int level; - - /** - * The farming experience recieved from picking - */ - private double farmExp; - - /** - * The thieving experience recieved from picking - */ - private double treeExp; - - /** - * The fruitId id - */ - private int fruitId; - - /** - * The juice id - */ - private int juiceId; - - /** - * The fruit amt - */ - private int fruitAmt; - - /** - * The boost - */ - private int boost; - - /** - * The energy - */ - private int energy; - - /** - * The experience recieved from osman - */ - private double osmanExp; - - /** - * The gate id - */ - private int gateId; - - /** - * The respawn location - */ - private Location respawn; - - /** - * Constructs a new {@code GardenObjectsPlugin.java} {@code Object}. - * @param treeId the tree id. - * @param level the level. - * @param farmExp the farm exp. - * @param treeExp the tree exp. - * @param fruitId the fruit id. - * @param juiceId the juice id. - * @param fruitAmt the fruit amt. - * @param boost the boost. - * @param energy the energy. - * @param osmanExp the osman exp. - * @param gateId the gate id. - * @param respawn the respawn. - */ - SeasonDefinitions(int treeId, int level, double farmExp, double treeExp, int fruitId, int juiceId, int fruitAmt, int boost, int energy, double osmanExp, int gateId, Location respawn) { - this.treeId = treeId; - this.level = level; - this.farmExp = farmExp; - this.treeExp = treeExp; - this.fruitId = fruitId; - this.juiceId = juiceId; - this.fruitAmt = fruitAmt; - this.boost = boost; - this.energy = energy; - this.osmanExp = osmanExp; - this.gateId = gateId; - this.respawn = respawn; - } - - /** - * Gets the theiving boost - * @return the boost - */ - public int getBoost() { - return boost; - } - - /** - * Gets the run energy restoring - * @return the energy - */ - public int getEnergy() { - return energy; - } - - /** - * Gets the exp from tree - * @return the treeExp - */ - public double getExp() { - return treeExp; - } - - /** - * Gets the farmExp - * @return the farmExp - */ - public double getFarmExp() { - return farmExp; - } - - /** - * Gets the fruid amt - * @return the fruitAmt - */ - public int getFruitAmt() { - return fruitAmt; - } - - /** - * Gets the fruit Id - * @return the fruitId - */ - public int getFruitId() { - return fruitId; - } - - /** - * Gets the gate Id - * @return the gateId - */ - public int getGateId() { - return gateId; - } - - /** - * Gets the juice Id - * @return the juiceId - */ - public int getJuiceId() { - return juiceId; - } - - /** - * Gets the level - * @return the Level - */ - public int getLevel() { - return level; - } - - /** - * Gets the experience recieved from osman - * @return the osmanExp - */ - public double getOsmanExp() { - return osmanExp; - } - - /** - * Gets the respawn location - * @return the respawn Location - */ - public Location getRespawn() { - return respawn; - } - - /** - * Gets the treeId - * @return the treeId - */ - public int getTreeId() { - return treeId; - } - - /** - * Gets the def by the fruit id. - * @param fruitId the fruit id. - * @return the definition. - */ - public static SeasonDefinitions forFruitId(int fruitId) { - for (SeasonDefinitions def : SeasonDefinitions.values()) { - if (def == null) - continue; - if (fruitId == def.getFruitId()) - return def; - } - return null; - } - - /** - * Gets the def by the gate Id. - * @param gateId the gateId - * @return the def. - */ - public static SeasonDefinitions forGateId(int gateId) { - for (SeasonDefinitions def : SeasonDefinitions.values()) { - if (gateId == def.getGateId()) - return def; - } - return null; - } - - /** - * Gets the def by the juice id. - * @param juiceId the juice id. - * @return the def. - */ - public static SeasonDefinitions forJuiceId(int juiceId) { - for (SeasonDefinitions def : SeasonDefinitions.values()) { - if (def == null) - continue; - if (juiceId == def.getJuiceId()) - return def; - } - return null; - } - - /** - * Gets the season def by the tree id. - * @param treeId the tree id. - * @return the def. - */ - public static SeasonDefinitions forTreeId(int treeId) { - for (SeasonDefinitions def : SeasonDefinitions.values()) { - if (def == null) - continue; - if (treeId == def.getTreeId()) - return def; - } - return null; - } - } - - /** - * Use with Plugin for Sq'irk Juice making - * @author SonicForce41 - */ - public static final class SqirkJuicePlugin extends UseWithHandler { - - /** - * The crushing an item with pestle and mortar animation. - */ - private static final Animation CRUSH_ITEM = new Animation(364); - - public SqirkJuicePlugin() { - super(10844, 10845, 10846, 10847); - } - - @Override - public boolean handle(NodeUsageEvent event) { - Item item = event.getUsedItem(); - Item with = event.getBaseItem(); - Player player = event.getPlayer(); - SeasonDefinitions def = SeasonDefinitions.forFruitId(item.getId()); - if (item == null || with == null || player == null || def == null) - return true; - int amt = player.getInventory().getAmount(item); - if (!player.getInventory().containItems(1919)) { - player.getDialogueInterpreter().open(43382, 0); - return true; - } - if (amt < def.getFruitAmt()) { - player.getDialogueInterpreter().open(43382, 1, item.getId()); - return true; - } - player.animate(CRUSH_ITEM); - player.getSkills().addExperience(Skills.COOKING, 5, true); - player.getInventory().remove(new Item(item.getId(), def.getFruitAmt())); - player.getInventory().remove(new Item(1919)); - player.getInventory().add(new Item(def.getJuiceId())); - player.getDialogueInterpreter().sendDialogue("You squeeze " + def.getFruitAmt() + " sq'irks into an empty glass."); - return true; - } - - @Override - public Plugin newInstance(Object arg) throws Throwable { - addHandler(233, ITEM_TYPE, this); - return this; - } - - } - - /** - * Represents the dialougue of the osman NPC. - * @author 'Vexia - * @author SonicForce41 - * @date 31/12/2013 - */ - public static final class OsmanDialogue extends DialoguePlugin { - - /** - * Represents the key print item. - */ - private static final Item KEY_PRINT = new Item(2423); - - /** - * Represents the bronze bar item. - */ - private static final Item BRONZE_BAR = new Item(2349); - - /** - * Represents the rope item. - */ - private static final Item ROPE = new Item(954); - - /** - * Represents the pink skirt item. - */ - private static final Item SKIRT = new Item(1013); - - /** - * Represents the yellow wig item. - */ - private static final Item YELLOW_WIG = new Item(2419); - - /** - * Represents the skin paste item. - */ - private static final Item PASTE = new Item(2424); - - /** - * Represents the juices. - */ - private static final int[] JUICES = new int[] { 10848, 10849, 10850, 10851 }; - - /** - * Represents the fruits. - */ - private static final int[] FRUITS = new int[] { 10844, 10845, 10846, 10847 }; - - /** - * Represents the quest instance. - */ - private Quest quest; - - /** - * Represents the count of materials you have gathered. - */ - private int itemCount; - - /** - * Constructs a new {@code OsmanDialogue} {@code Object}. - */ - public OsmanDialogue() { - /** - * empty. - */ - } - - /** - * Constructs a new {@code OsmanDialogue} {@code Object}. - * @param player the Player - */ - public OsmanDialogue(Player player) { - super(player); - } - - @Override - public DialoguePlugin newInstance(Player player) { - return new OsmanDialogue(player); - } - - @Override - public boolean open(Object... args) { - npc = (NPC) args[0]; - quest = player.getQuestRepository().getQuest("Prince Ali Rescue"); - switch (quest.getStage(player)) { - case 100: - interpreter.sendDialogues(player, null, "I'd like to talk about sq'irks."); - stage = 0; - return true; - case 60: - interpreter.sendDialogues(npc, null, "The prince is safe on his way home with Leela.", "You can pick up your payment from the chancellor."); - stage = 0; - return true; - case 40: - case 50: - interpreter.sendDialogues(npc, null, "Speak to Leela for any further instructions."); - stage = 0; - break; - case 30: - interpreter.sendDialogues(player, null, "Can you tell me what I still need to get?"); - stage = 0; - break; - case 20: - if (!player.getInventory().containsItem(KEY_PRINT)) { - interpreter.sendDialogues(player, null, "Can you tell me what I need to get?"); - } else if (!player.getInventory().containsItem(BRONZE_BAR) && player.getInventory().containsItem(KEY_PRINT)) { - interpreter.sendDialogues(npc, null, "Good, you have the print of the key. Get a bar of", "bronze, too, and I can get the key mad."); - stage = 70; - } else { - interpreter.sendDialogues(npc, null, "Well done; we can make the key now."); - stage = 80; - } - return true; - case 10: - interpreter.sendDialogues(player, null, "The chancellor trusts me. I have come for instructions."); - break; - case 0: - interpreter.sendDialogues(player, null, "I'd like to talk about sq'irks."); - break; - default: - break; - } - stage = 0; - return true; - } - - @Override - public boolean handle(int interfaceId, int buttonId) { - switch (quest.getStage(player)) { - case 100: - switch (stage) { - default: - handleSqirks(buttonId); - break; - } - break; - case 60: - end(); - break; - case 40: - case 50: - end(); - break; - case 30: - switch (stage) { - case 82: - end(); - break; - case 0: - interpreter.sendDialogues(npc, null, "You can collect the key from Leela."); - stage = 11; - break; - case 11: - if (player.getInventory().containsItem(YELLOW_WIG)) { - interpreter.sendDialogues(npc, null, "The wig you have got, well done."); - itemCount++; - } else { - interpreter.sendDialogues(npc, null, "You need a wig, maybe made from wool. If you find", "someone who can work with wool ask them about it.", "There's a witch nearby may be able to help you dye it."); - } - stage = 12; - break; - case 12: - if (player.getInventory().containsItem(SKIRT)) { - interpreter.sendDialogues(npc, null, "You have got the skirt, good."); - itemCount++; - } else { - interpreter.sendDialogues(npc, null, "You will need to get a pink skirt, same as Keli's."); - } - stage = 13; - break; - case 13: - if (player.getInventory().containsItem(PASTE)) { - interpreter.sendDialogues(npc, null, "You have the skin paint, well done. I thought you would", "struggle to make that."); - itemCount++; - } else { - interpreter.sendDialogues(npc, null, "We still need something to colour the Prince's skin", "lighter. There's a witch close to here. She knows about", "many things. She may know some way to make the", "skin lighter."); - } - stage = itemCount == 3 ? 14 : 15; - break; - case 14: - interpreter.sendDialogues(npc, null, "You do have everything for the disguise."); - stage = 15; - break; - case 15: - if (player.getInventory().containsItem(ROPE)) { - interpreter.sendDialogues(npc, null, "You have the rope I see, to tie up Keli. That will be the", "most dangerous part of the plan."); - stage = 16; - } else { - interpreter.sendDialogues(npc, null, "You will still need some rope to tie up Keli, of course. I", "heard that there's a good rope maker around here."); - stage = 16; - } - break; - case 16: - end(); - break; - case 20: - interpreter.sendDialogues(npc, null, "Yes, that is most important. There is no way you can", "get the real key. It is on a chain around Keli's neck.", "Almost impossible to steal."); - stage = 21; - break; - case 21: - end(); - break; - } - break; - case 0: - switch (stage) { - default: - handleSqirks(buttonId); - break; - } - break; - case 20: - switch (stage) { - case 80: - interpreter.sendDialogue("Osman takes the key imprint and the bronze bar."); - stage = 81; - break; - case 81: - if (player.getInventory().remove(BRONZE_BAR) && player.getInventory().remove(KEY_PRINT)) { - interpreter.sendDialogues(npc, null, "Pick the key up from Leela."); - quest.setStage(player, 30); - stage = 82; - } - break; - case 82: - end(); - break; - case 70: - interpreter.sendDialogues(player, null, "I will get one and come back."); - stage = 71; - break; - case 71: - end(); - break; - case 0: - interpreter.sendDialogues(npc, null, "A print of the key in soft clay and a bronze bar.", "Then, collect the key from Leela."); - stage = 1; - break; - case 1: - interpreter.sendDialogues(npc, null, "When you have the full disguise talk to", "Leela and she will help you with the rest."); - stage = 2; - break; - case 2: - end(); - break; - case 10: - interpreter.sendDialogues(npc, null, "The prince is guarded by some stupid guards and a", "clever woman. The woman is our only way to get the", "prince out. Only she can walk freely about the area."); - stage = 11; - break; - case 11: - interpreter.sendDialogues(npc, null, "I think you will need to tie her up. One coil of rope", "should do for that. Then, disguise the prince as her to", "get him out without suspicion."); - stage = 12; - break; - case 12: - interpreter.sendDialogues(player, null, "How good must the disguise be?"); - stage = 13; - break; - case 13: - interpreter.sendDialogues(npc, null, "Only enough to fool the guards at a distance. Get a", "skirt like hers. Same colour, same style. We will only", "have a short time."); - stage = 14; - break; - case 14: - interpreter.sendDialogues(npc, null, "Get a blonde wig, too. that is up to you to make or", "find. Something to colour the skin of the prince."); - stage = 15; - break; - case 15: - interpreter.sendDialogues(npc, null, "My daughter and top spy, Leela, can help you. She has", "sent word that she has discovered where they are", "keeping the prince."); - stage = 16; - break; - case 16: - interpreter.sendDialogues(npc, null, "It's near Draynor Village. She is lurking somewhere", "near there now."); - stage = 17; - break; - case 17: - quest.setStage(player, 20); - interpreter.sendOptions("Select an Option", "Explain the first thing again.", "What is the second thing you need?", "Okay, I better go find some things."); - stage = 50; - break; - case 20: - interpreter.sendDialogues(npc, null, "We need the key, or we need a copy made. If you can", "get some soft clay then you can copy the key..."); - stage = 21; - break; - case 21: - interpreter.sendDialogues(npc, null, "...If you can convince Lady Keli to show it to you", "for a moment. She is very boastful.", "It should not be too hard."); - stage = 22; - break; - case 22: - interpreter.sendDialogues(npc, null, "Bring the imprint to me, with a bar of bronze."); - stage = 23; - break; - case 23: - quest.setStage(player, 20); - interpreter.sendOptions("Select an Option", "What is the first thing I must do?", "What exactly is the second thing you need?", "Okay, I better go find some things."); - stage = 24; - break; - case 24: - switch (buttonId) { - case 1: - interpreter.sendDialogues(player, null, "What is the first thing I must do?"); - stage = 10; - break; - case 2: - interpreter.sendDialogues(player, null, "What exactly is the second thing I must do?"); - stage = 20; - break; - case 3: - interpreter.sendDialogues(player, null, "Okay, I better go find some things."); - stage = 25; - break; - } - break; - case 25: - interpreter.sendDialogues(npc, null, "May good luck travel with you. Don't forget to find", "Leela. It can't be done without her help."); - stage = 26; - break; - case 26: - end(); - break; - case 50: - switch (buttonId) { - case 1: - interpreter.sendDialogues(player, null, "Explain the first thing again."); - stage = 10; - break; - case 2: - interpreter.sendDialogues(player, null, "What is th second thing you need?"); - stage = 20; - break; - case 3: - interpreter.sendDialogues(player, null, "Okay, I better go find some things."); - stage = 25; - break; - } - break; - } - break; - case 10: - switch (stage) { - case 0: - interpreter.sendDialogues(npc, null, "Our prince is captive by the Lady Keli. We just need", "to make the rescue. There are two things we need", "you to do."); - stage = 1; - break; - case 1: - interpreter.sendOptions("Select an Option", "What is the first thing I must do?", "What is the second thing you need?"); - stage = 3; - break; - case 3: - switch (buttonId) { - case 1: - interpreter.sendDialogues(player, null, "What is the first thing I must do?"); - stage = 10; - break; - case 2: - interpreter.sendDialogues(player, null, "What is the second thing you need?"); - stage = 20; - break; - } - break; - case 10: - interpreter.sendDialogues(npc, null, "The prince is guarded by some stupid guards and a", "clever woman. The woman is our only way to get the", "prince out. Only she can walk freely about the area."); - stage = 11; - break; - case 11: - interpreter.sendDialogues(npc, null, "I think you will need to tie her up. One coil of rope", "should do for that. Then, disguise the prince as her to", "get him out without suspicion."); - stage = 12; - break; - case 12: - interpreter.sendDialogues(player, null, "How good must the disguise be?"); - stage = 13; - break; - case 13: - interpreter.sendDialogues(npc, null, "Only enough to fool the guards at a distance. Get a", "skirt like hers. Same colour, same style. We will only", "have a short time."); - stage = 14; - break; - case 14: - interpreter.sendDialogues(npc, null, "Get a blonde wig, too. that is up to you to make or", "find. Something to colour the skin of the prince."); - stage = 15; - break; - case 15: - interpreter.sendDialogues(npc, null, "My daughter and top spy, Leela, can help you. She has", "sent word that she has discovered where they are", "keeping the prince."); - stage = 16; - break; - case 16: - interpreter.sendDialogues(npc, null, "It's near Draynor Village. She is lurking somewhere", "near there now."); - stage = 17; - break; - case 17: - quest.setStage(player, 20); - interpreter.sendOptions("Select an Option", "Explain the first thing again.", "What is the second thing you need?", "Okay, I better go find some things."); - stage = 50; - break; - case 20: - interpreter.sendDialogues(npc, null, "We need the key, or we need a copy made. If you can", "get some soft clay then you can copy the key..."); - stage = 21; - break; - case 21: - interpreter.sendDialogues(npc, null, "...If you can convince Lady Keli to show it to you", "for a moment. She is very boastful.", "It should not be too hard."); - stage = 22; - break; - case 22: - interpreter.sendDialogues(npc, null, "Bring the imprint to me, with a bar of bronze."); - stage = 23; - break; - case 23: - quest.setStage(player, 20); - interpreter.sendOptions("Select an Option", "What is the first thing I must do?", "What exactly is the second thing you need?", "Okay, I better go find some things."); - stage = 24; - break; - case 24: - switch (buttonId) { - case 1: - interpreter.sendDialogues(player, null, "What is the first thing I must do?"); - stage = 10; - break; - case 2: - interpreter.sendDialogues(player, null, "What exactly is the second thing I must do?"); - stage = 20; - break; - case 3: - interpreter.sendDialogues(player, null, "Okay, I better go find some things."); - stage = 25; - break; - } - break; - case 25: - interpreter.sendDialogues(npc, null, "May good luck travel with you. Don't forget to find", "Leela. It can't be done without her help."); - stage = 26; - break; - case 26: - end(); - break; - } - default: - break; - } - return true; - } - - /** - * Method used to handle the sqirk juice dials. - * @param buttonId the buttonId. - */ - public void handleSqirks(int buttonId) { - switch (stage) { - case 0: - if (!hasSqirks()) { - interpreter.sendOptions("Select an Option", "Where do I get sq'irks?", "Why can't you get the sq'irks yourself?", "How should I squeeze the fruit?", "Is there a reward for getting these sq'irks?", "What's so good about sq'irk juice then?"); - stage = 200; - } else { - player(hasSqirkJuice() ? "I have some sq'riks juice for you." : "I have some sq'irks for you."); - stage = 300; - } - break; - case 300: - if (hasSqirkJuice()) { - double exp = getExperience(); - player.getSkills().addExperience(Skills.THIEVING, exp, true); - interpreter.sendDialogue("Osman imparts some Thieving advice to", "you ( " + (exp) + " Thieving experience points )", "as a reward for the sq'irk juice."); - stage = 304; - } else { - npc("Uh, thanks, but is there any chance that you", "could squeeze the fruit into a glass for me?"); - stage = 301; - } - break; - case 301: - interpreter.sendOptions("Select an Option", "How should I squeeze the fruit?", "Can't you do that yourself?"); - stage = 302; - break; - case 302: - switch (buttonId) { - case 1: - player("How should I squeeze the fruit?"); - stage = 130; - break; - case 2: - player("Can't you do that yourself?"); - stage = 303; - break; - } - break; - case 304: - end(); - break; - case 303: - player("I only carry knives or other such devices on me", "when I'm on the job."); - stage = 119; - break; - case 200: - switch (buttonId) { - case 1: - interpreter.sendDialogues(player, null, "Where do I get sq'irks?"); - stage = 110; - break; - case 2: - interpreter.sendDialogues(player, null, "Why can't you get the sq'irks yourself?"); - stage = 120; - break; - case 3: - interpreter.sendDialogues(player, null, "How should I squeeze the fruit?"); - stage = 130; - break; - case 4: - interpreter.sendDialogues(player, null, "Is there a reward for getting these sq'irks?"); - stage = 140; - break; - case 5: - interpreter.sendDialogues(player, null, "What's so good about sq'irk juice then?"); - stage = 150; - break; - } - break; - case 110: - npc("There is a sorceress near the south-eastern edge of Al", "Kharid who grows them. Once upon a time, we", "considered each other friends."); - stage = 111; - break; - case 111: - player("What happened?"); - stage = 112; - break; - case 112: - npc("We fell out, and now she won't give me any more", "fruit."); - stage = 113; - break; - case 113: - player("So all I have to do is ask her for some fruit for you?"); - stage = 114; - break; - case 114: - npc("I doubt it will be that easy. She is not renowned for", "her generosity and is very secretive about her garden's", "location."); - stage = 115; - break; - case 115: - player("Oh come on, it should be easy enough to find."); - stage = 116; - break; - case 116: - npc("Her garden has remained hidden even to me - the chief", "spy of Al Kharid. I believe her garden must be hidden", "by magical means."); - stage = 117; - break; - case 117: - player("This should be an interesting task. How many sq'irks do", "you want?"); - stage = 118; - break; - case 118: - npc("I'll reward you for as many as you can get your", "hands on, but could you please squeeze the fruit into a", "glass first?"); - stage = 119; - break; - case 119: - interpreter.sendOptions("Select an Option", "I've another question about sq'irks.", "Thanks for the information."); - stage = 98; - break; - case 98: - switch (buttonId) { - case 1: - interpreter.sendOptions("Select an Option", "Where do I get sq'irks?", "Why can't you get the sq'irks yourself?", "How should I squeeze the fruit?", "Is there a reward for getting these sq'irks?", "What's so good about sq'irk juice then?"); - stage = 200; - break; - case 2: - player("Thanks for the information."); - stage = 99; - break; - } - break; - case 99: - end(); - break; - case 120: - npc("I may have mentioned that I had a falling out with the", "Sorceress. Well, unsurprisingly, she refuses to give me", "any more of her garden's produce."); - stage = 119; - break; - case 130: - npc("Use a pestle and mortar to squeeze the sr'irks. Make", "sure you have an empty glass with you to collect the", "juice."); - stage = 119; - break; - case 140: - npc("Of course there is. I am a generous man. I'll teach", "you the art of Thieving for your troubles."); - stage = 141; - break; - case 141: - player("How much training will you give?"); - stage = 142; - break; - case 142: - npc("That depends on the quantity and ripeness of the", "sq'irks you put into the juice."); - stage = 143; - break; - case 143: - player("That sounds fair enough."); - stage = 119; - break; - case 150: - npc("Ah it's sweet, sweet nectar for a thief or spy; it makes", "light fingers lighter, fleet feet flightier and comes in four", "different colours for those who are easily amused."); - stage = 151; - break; - case 151: - interpreter.sendDialogue("Osman starts salivating at the thought of sq'irk juice."); - stage = 152; - break; - case 152: - player("It wouldn't have addictive properties, would it?"); - stage = 153; - break; - case 153: - npc("It only holds power over those with poor self-control,", "something which I have an abundance of."); - stage = 154; - break; - case 154: - player("I see."); - stage = 119; - break; - } - } - - /** - * Gets the experience the player can recieve. - * @return the experience. - */ - public double getExperience() { - double total = 0; - for (int juiceId : JUICES) { - SeasonDefinitions def = SeasonDefinitions.forJuiceId(juiceId); - if (def == null) { - continue; - } - int amount = player.getInventory().getAmount(new Item(juiceId)); - total += (amount * def.getOsmanExp()); - player.getInventory().remove(new Item(juiceId, amount)); - } - player.getInventory().refresh(); - return total; - } - - /** - * Checks wether the Player has sq'irk. - * @return {@code True}: Player has sq'irk. - */ - public boolean hasSqirkFruit() { - for (int i : FRUITS) { - if (player.getInventory().contains(i, 1)) { - return true; - } - } - return false; - } - - /** - * Checks wether the Player has sq'irk juice - * @return {@code True}: Player has sq'irk juice. - */ - public boolean hasSqirkJuice() { - for (int i : JUICES) { - if (player.getInventory().contains(i, 1)) { - return true; - } - } - return false; - } - - /** - * Checks wether the Player has sq'irks (fruit/juice). - * @return {@code True}: Player has either a fruit or squeezed juice. - */ - public boolean hasSqirks() { - return hasSqirkFruit() || hasSqirkJuice(); - } - - @Override - public int[] getIds() { - return new int[] { 924, 5282 }; - } - } - - /** - * Dialogue for Sqirk making - * @author SonicForce41 - */ - public class SqirkMakingDialogue extends DialoguePlugin { - - private int dialogueId; - - private SeasonDefinitions definition; - - /** - * Constructs a new {@code SqirkMakingDialogue.java} {@code Object}. - */ - public SqirkMakingDialogue() { - - } - - /** - * Constructs a new {@code SqirkMakingDialogue.java} {@code Object}. - * @param player the Player - */ - public SqirkMakingDialogue(Player player) { - super(player); - } - - @Override - public int[] getIds() { - return new int[] { 43382 }; - } - - @Override - public boolean handle(int interfaceId, int buttonId) { - switch (dialogueId) { - case 0: - end(); - break; - case 1: - switch (stage) { - case 0: - interpreter.sendDialogue("You need " + definition.getFruitAmt() + " sq'irks of this kind to fill a glass of juice."); - stage = 1; - break; - case 1: - end(); - break; - } - break; - } - return true; - } - - @Override - public DialoguePlugin newInstance(Player player) { - return new SqirkMakingDialogue(player); - } - - @Override - public boolean open(Object... args) { - dialogueId = (int) args[0]; - switch (dialogueId) { - case 0: - interpreter.sendDialogues(player, FacialExpression.THINKING, "I should get an empty beer glass to", "hold the juice before I squeeze the fruit."); - break; - case 1: - definition = SeasonDefinitions.forFruitId((int) args[1]); - if (definition == null) - end(); - interpreter.sendDialogues(player, FacialExpression.THINKING, "I think I should wait till I have", "enough fruits to make a full glass."); - break; - } - stage = 0; - return true; - } - - } - -} diff --git a/Server/src/main/java/core/game/interaction/object/sorceress/GardenObjectsPlugin.kt b/Server/src/main/java/core/game/interaction/object/sorceress/GardenObjectsPlugin.kt new file mode 100644 index 000000000..fbd14fac5 --- /dev/null +++ b/Server/src/main/java/core/game/interaction/object/sorceress/GardenObjectsPlugin.kt @@ -0,0 +1,1423 @@ +package core.game.interaction.`object`.sorceress + +import rs09.plugin.PluginManager.definePlugin +import rs09.game.world.GameWorld.Pulser +import core.plugin.Initializable +import core.game.interaction.OptionHandler +import core.plugin.Plugin +import core.cache.def.impl.SceneryDefinition +import core.game.component.Component +import core.game.content.dialogue.DialoguePlugin +import core.game.content.dialogue.FacialExpression +import core.game.interaction.NodeUsageEvent +import core.game.interaction.UseWithHandler +import core.game.node.Node +import core.game.node.`object`.Scenery +import core.game.node.entity.npc.NPC +import core.game.node.entity.player.Player +import core.game.node.entity.player.link.quest.Quest +import core.game.node.entity.skill.Skills +import core.game.node.item.Item +import core.game.system.task.LocationLogoutTask +import core.game.system.task.LogoutTask +import core.game.system.task.Pulse +import core.game.world.map.Location +import core.game.world.update.flag.context.Animation +import core.game.world.update.flag.context.Graphics +import core.net.packet.PacketRepository +import core.net.packet.context.MinimapStateContext +import core.net.packet.out.MinimapState +import core.tools.RandomFunction +import rs09.game.interaction.InteractionListener +import rs09.game.world.GameWorld +import rs09.plugin.PluginManager + + +class GardenObjectsPlugin : InteractionListener() { + + val SQIRK_TREES = intArrayOf(21767, 21768, 21769, 21766) + val FOUNTAIN = 21764 + val HERBS = HerbDefinition.values().map { it.id }.toIntArray() + val SHELVES = 21794 + private val HERBS_ITEMS = intArrayOf(199, 201, 203, 205, 207, 209, 211, 213, 215, 217, 219, 2485, 3049, 3051, 199, 201, 203, 205) + + override fun defineListeners() { + SqirkJuicePlugin().newInstance(null) + SqirkMakingDialogue().init() + PluginManager.definePlugin(SorceressGardenObject()) + + on(SQIRK_TREES, SCENERY, "pick-fruit"){player, node -> + val def = SeasonDefinitions.forTreeId(node.id) + if (def != null) { + player.lock() + player.addExtension(LogoutTask::class.java, LocationLogoutTask(99, def.respawn)) + player.animate(PICK_FRUIT) + player.skills.addExperience(Skills.THIEVING, def.exp, true) + player.skills.addExperience(Skills.FARMING, def.farmExp, true) + GameWorld.Pulser.submit(object : Pulse(2, player) { + var counter = 0 + override fun pulse(): Boolean { + if (counter == 1) { + player.inventory.add(Item(def.fruitId)) + player.interfaceManager.openOverlay(Component(115)) + PacketRepository.send(MinimapState::class.java, MinimapStateContext(player, 2)) + } else if (counter == 3) player.properties.teleportLocation = def.respawn else if (counter == 4) { + player.unlock() + player.removeExtension(LogoutTask::class.java) + player.packetDispatch.sendMessage("An elemental force emanating from the garden teleports you away.") + PacketRepository.send(MinimapState::class.java, MinimapStateContext(player, 0)) + player.interfaceManager.close() + player.interfaceManager.closeOverlay() + player.unlock() + return true + } + counter++ + return false + } + }) + } + return@on true + } + + + on(FOUNTAIN, SCENERY, "drink-from"){player, _ -> + player.lock() + GameWorld.Pulser.submit(object : Pulse(1, player) { + var counter = 0 + override fun pulse(): Boolean { + when (counter++) { + 1 -> player.animate(DRINK_ANIM) + 4 -> player.graphics(GRAPHICS) + 5 -> player.animate(TELE) + 6 -> player.interfaceManager.openOverlay(Component(115)) + 7 -> PacketRepository.send(MinimapState::class.java, MinimapStateContext(player, 2)) + 9 -> player.properties.teleportLocation = Location(3321, 3141, 0) + 11 -> { + player.unlock() + player.animate(Animation(-1)) + player.interfaceManager.close() + player.interfaceManager.closeOverlay() + PacketRepository.send(MinimapState::class.java, MinimapStateContext(player, 0)) + return true + } + } + return false + } + }) + + return@on true + } + + on(SHELVES, SCENERY, "search"){player, node -> + if (player.inventory.freeSlots() < 1) { + player.sendMessage("You don't have enough space in your inventory to take a beer glass.") + } else { + player.sendMessage("You take an empty beer glass off the shelves.") + player.inventory.add(Item(1919, 1)) + } + + return@on true + } + + on(HERBS, SCENERY, "pick"){player, node -> + val herbDef = HerbDefinition.forId(node.getId()) + if (herbDef != null) { + handleElementalGarden(player, node.asScenery(), herbDef) + } + return@on true + } + + } + + /** + * Method used to handle the elemental garden picking. + * @param player the player. + * @param object the object. + * @param herbDef the herbdef. + */ + private fun handleElementalGarden(player: Player, `object`: Scenery, herbDef: HerbDefinition) { + player.lock() + player.addExtension(LogoutTask::class.java, LocationLogoutTask(99, herbDef.respawn)) + player.animate(ANIMATION) + player.skills.addExperience(Skills.FARMING, herbDef.exp, true) + GameWorld.Pulser.submit(object : Pulse(2, player) { + var counter = 0 + override fun pulse(): Boolean { + if (counter == 1) { + player.inventory.add(Item(HERBS_ITEMS[RandomFunction.random(0, HERBS_ITEMS.size)], +1)) + player.inventory.add(Item(HERBS_ITEMS[RandomFunction.random(0, HERBS_ITEMS.size)], +1)) + player.packetDispatch.sendMessage("You pick up a herb.") + player.interfaceManager.openOverlay(Component(115)) + PacketRepository.send(MinimapState::class.java, MinimapStateContext(player, 2)) + } else if (counter == 3) player.properties.teleportLocation = + Location.create(herbDef.respawn) else if (counter == 4) { + player.unlock() + player.packetDispatch.sendMessage("An elemental force emanating from the garden teleports you away.") + PacketRepository.send(MinimapState::class.java, MinimapStateContext(player, 0)) + player.interfaceManager.close() + player.interfaceManager.closeOverlay() + player.removeExtension(LogoutTask::class.java) + player.unlock() + return true + } + counter++ + return false + } + }) + } + + /** + * Represents the herb definitions. + * @author SonicForce41 + * @version 1.0 + */ + enum class HerbDefinition + /** + * Constructs a new `GardenObjectsPlugin` `Object`. + * @param id the id. + * @param exp the exp. + * @param respawn the respawn. + */( + /** + * Represents the id. + */ + val id: Int, + /** + * Represents the experience. + */ + val exp: Double, + /** + * Represents the respawn location. + */ + val respawn: Location + ) { + WINTER(21671, 30.0, Location(2907, 5470, 0)), SPRING(21668, 40.0, Location(2916, 5473, 0)), AUTUMN( + 21670, + 50.0, + Location(2913, 5467, 0) + ), + SUMMER(21669, 60.0, Location(2910, 5476, 0)); + /** + * Gets the Id + * @return the Id + */ + /** + * Gets the exp + * @return the Exp + */ + /** + * Gets the respawn Location + * @return the Location. + */ + + companion object { + /** + * Gets the herb definition by the id. + * @param id the objectId + * @return the definition. + */ + fun forId(id: Int): HerbDefinition? { + for (def in values()) { + if (def.id == id) { + return def + } + } + return null + } + } + } + + /** + * Represents the season definitions. + * @author SonicForce41 + * @version 1.0 + */ + enum class SeasonDefinitions + /** + * Constructs a new `GardenObjectsPlugin.java` `Object`. + * @param treeId the tree id. + * @param level the level. + * @param farmExp the farm exp. + * @param treeExp the tree exp. + * @param fruitId the fruit id. + * @param juiceId the juice id. + * @param fruitAmt the fruit amt. + * @param boost the boost. + * @param energy the energy. + * @param osmanExp the osman exp. + * @param gateId the gate id. + * @param respawn the respawn. + */( + /** + * The treeId + */ + val treeId: Int, + /** + * The level + */ + val level: Int, + /** + * The farming experience recieved from picking + */ + val farmExp: Double, + /** + * The thieving experience recieved from picking + */ + val exp: Double, + /** + * The fruitId id + */ + val fruitId: Int, + /** + * The juice id + */ + val juiceId: Int, + /** + * The fruit amt + */ + val fruitAmt: Int, + /** + * The boost + */ + val boost: Int, + /** + * The energy + */ + val energy: Int, + /** + * The experience recieved from osman + */ + val osmanExp: Double, + /** + * The gate id + */ + val gateId: Int, + /** + * The respawn location + */ + val respawn: Location + ) { + WINTER(21769, 1, 30.0, 70.0, 10847, 10851, 5, 0, 10, 350.0, 21709, Location(2907, 5470, 0)), SPRING( + 21767, + 25, + 40.0, + 337.5, + 10844, + 10848, + 4, + 1, + 20, + 1350.0, + 21753, + Location(2916, 5473, 0) + ), + AUTUMN(21768, 45, 50.0, 783.3, 10846, 10850, 3, 2, 30, 2350.0, 21731, Location(2913, 5467, 0)), SUMMER( + 21766, + 65, + 60.0, + 1500.0, + 10845, + 10849, + 2, + 3, + 40, + 3000.0, + 21687, + Location(2910, 5476, 0) + ); + /** + * Gets the treeId + * @return the treeId + */ + /** + * Gets the level + * @return the Level + */ + /** + * Gets the farmExp + * @return the farmExp + */ + /** + * Gets the exp from tree + * @return the treeExp + */ + /** + * Gets the fruit Id + * @return the fruitId + */ + /** + * Gets the juice Id + * @return the juiceId + */ + /** + * Gets the fruid amt + * @return the fruitAmt + */ + /** + * Gets the theiving boost + * @return the boost + */ + /** + * Gets the run energy restoring + * @return the energy + */ + /** + * Gets the experience recieved from osman + * @return the osmanExp + */ + /** + * Gets the gate Id + * @return the gateId + */ + /** + * Gets the respawn location + * @return the respawn Location + */ + + companion object { + /** + * Gets the def by the fruit id. + * @param fruitId the fruit id. + * @return the definition. + */ + fun forFruitId(fruitId: Int): SeasonDefinitions? { + for (def in values()) { + if (def == null) continue + if (fruitId == def.fruitId) return def + } + return null + } + + /** + * Gets the def by the gate Id. + * @param gateId the gateId + * @return the def. + */ + @JvmStatic + fun forGateId(gateId: Int): SeasonDefinitions? { + for (def in values()) { + if (gateId == def.gateId) return def + } + return null + } + + /** + * Gets the def by the juice id. + * @param juiceId the juice id. + * @return the def. + */ + fun forJuiceId(juiceId: Int): SeasonDefinitions? { + for (def in values()) { + if (def == null) continue + if (juiceId == def.juiceId) return def + } + return null + } + + /** + * Gets the season def by the tree id. + * @param treeId the tree id. + * @return the def. + */ + fun forTreeId(treeId: Int): SeasonDefinitions? { + for (def in values()) { + if (def == null) continue + if (treeId == def.treeId) return def + } + return null + } + } + } + + /** + * Use with Plugin for Sq'irk Juice making + * @author SonicForce41 + */ + class SqirkJuicePlugin : UseWithHandler(10844, 10845, 10846, 10847) { + override fun handle(event: NodeUsageEvent): Boolean { + val item: Item = event.getUsedItem() + val with: Item = event.getBaseItem() + val player: Player = event.getPlayer() + val def = SeasonDefinitions.forFruitId(item.id) + if (with == null || player == null || def == null) return true + val amt = player.inventory.getAmount(item) + if (!player.inventory.containItems(1919)) { + player.dialogueInterpreter.open(43382, 0) + return true + } + if (amt < def.fruitAmt) { + player.dialogueInterpreter.open(43382, 1, item.id) + return true + } + player.animate(CRUSH_ITEM) + player.skills.addExperience(Skills.COOKING, 5.0, true) + player.inventory.remove(Item(item.id, def.fruitAmt)) + player.inventory.remove(Item(1919)) + player.inventory.add(Item(def.juiceId)) + player.dialogueInterpreter.sendDialogue("You squeeze " + def.fruitAmt + " sq'irks into an empty glass.") + return true + } + + @Throws(Throwable::class) + override fun newInstance(arg: Any?): Plugin { + UseWithHandler.addHandler(233, UseWithHandler.ITEM_TYPE, this) + return this + } + + companion object { + /** + * The crushing an item with pestle and mortar animation. + */ + private val CRUSH_ITEM = Animation(364) + } + } + + /** + * Represents the dialougue of the osman NPC. + * @author 'Vexia + * @author SonicForce41 + * @date 31/12/2013 + */ + class OsmanDialogue : DialoguePlugin { + /** + * Represents the quest instance. + */ + private var quest: Quest? = null + + /** + * Represents the count of materials you have gathered. + */ + private var itemCount = 0 + + /** + * Constructs a new `OsmanDialogue` `Object`. + */ + constructor() { + /** + * empty. + */ + } + + /** + * Constructs a new `OsmanDialogue` `Object`. + * @param player the Player + */ + constructor(player: Player?) : super(player) {} + + override fun newInstance(player: Player): DialoguePlugin { + return OsmanDialogue(player) + } + + override fun open(vararg args: Any): Boolean { + npc = args[0] as NPC + quest = player.questRepository.getQuest("Prince Ali Rescue") + when (quest!!.getStage(player)) { + 100 -> { + interpreter.sendDialogues(player, null, "I'd like to talk about sq'irks.") + stage = 0 + return true + } + 60 -> { + interpreter.sendDialogues( + npc, + null, + "The prince is safe on his way home with Leela.", + "You can pick up your payment from the chancellor." + ) + stage = 0 + return true + } + 40, 50 -> { + interpreter.sendDialogues(npc, null, "Speak to Leela for any further instructions.") + stage = 0 + } + 30 -> { + interpreter.sendDialogues(player, null, "Can you tell me what I still need to get?") + stage = 0 + } + 20 -> { + if (!player.getInventory().containsItem(KEY_PRINT)) { + interpreter.sendDialogues(player, null, "Can you tell me what I need to get?") + } else if (!player.getInventory().containsItem(BRONZE_BAR) && player.getInventory().containsItem( + KEY_PRINT + ) + ) { + interpreter.sendDialogues( + npc, + null, + "Good, you have the print of the key. Get a bar of", + "bronze, too, and I can get the key mad." + ) + stage = 70 + } else { + interpreter.sendDialogues(npc, null, "Well done; we can make the key now.") + stage = 80 + } + return true + } + 10 -> interpreter.sendDialogues(player, null, "The chancellor trusts me. I have come for instructions.") + 0 -> interpreter.sendDialogues(player, null, "I'd like to talk about sq'irks.") + else -> { + } + } + stage = 0 + return true + } + + override fun handle(interfaceId: Int, buttonId: Int): Boolean { + when (quest!!.getStage(player)) { + 100 -> when (stage) { + else -> handleSqirks(buttonId) + } + 60 -> end() + 40, 50 -> end() + 30 -> when (stage) { + 82 -> end() + 0 -> { + interpreter.sendDialogues(npc, null, "You can collect the key from Leela.") + stage = 11 + } + 11 -> { + if (player.getInventory().containsItem(YELLOW_WIG)) { + interpreter.sendDialogues(npc, null, "The wig you have got, well done.") + itemCount++ + } else { + interpreter.sendDialogues( + npc, + null, + "You need a wig, maybe made from wool. If you find", + "someone who can work with wool ask them about it.", + "There's a witch nearby may be able to help you dye it." + ) + } + stage = 12 + } + 12 -> { + if (player.getInventory().containsItem(SKIRT)) { + interpreter.sendDialogues(npc, null, "You have got the skirt, good.") + itemCount++ + } else { + interpreter.sendDialogues(npc, null, "You will need to get a pink skirt, same as Keli's.") + } + stage = 13 + } + 13 -> { + if (player.getInventory().containsItem(PASTE)) { + interpreter.sendDialogues( + npc, + null, + "You have the skin paint, well done. I thought you would", + "struggle to make that." + ) + itemCount++ + } else { + interpreter.sendDialogues( + npc, + null, + "We still need something to colour the Prince's skin", + "lighter. There's a witch close to here. She knows about", + "many things. She may know some way to make the", + "skin lighter." + ) + } + stage = if (itemCount == 3) 14 else 15 + } + 14 -> { + interpreter.sendDialogues(npc, null, "You do have everything for the disguise.") + stage = 15 + } + 15 -> if (player.getInventory().containsItem(ROPE)) { + interpreter.sendDialogues( + npc, + null, + "You have the rope I see, to tie up Keli. That will be the", + "most dangerous part of the plan." + ) + stage = 16 + } else { + interpreter.sendDialogues( + npc, + null, + "You will still need some rope to tie up Keli, of course. I", + "heard that there's a good rope maker around here." + ) + stage = 16 + } + 16 -> end() + 20 -> { + interpreter.sendDialogues( + npc, + null, + "Yes, that is most important. There is no way you can", + "get the real key. It is on a chain around Keli's neck.", + "Almost impossible to steal." + ) + stage = 21 + } + 21 -> end() + } + 0 -> when (stage) { + else -> handleSqirks(buttonId) + } + 20 -> when (stage) { + 80 -> { + interpreter.sendDialogue("Osman takes the key imprint and the bronze bar.") + stage = 81 + } + 81 -> if (player.getInventory().remove(BRONZE_BAR) && player.getInventory().remove(KEY_PRINT)) { + interpreter.sendDialogues(npc, null, "Pick the key up from Leela.") + quest!!.setStage(player, 30) + stage = 82 + } + 82 -> end() + 70 -> { + interpreter.sendDialogues(player, null, "I will get one and come back.") + stage = 71 + } + 71 -> end() + 0 -> { + interpreter.sendDialogues( + npc, + null, + "A print of the key in soft clay and a bronze bar.", + "Then, collect the key from Leela." + ) + stage = 1 + } + 1 -> { + interpreter.sendDialogues( + npc, + null, + "When you have the full disguise talk to", + "Leela and she will help you with the rest." + ) + stage = 2 + } + 2 -> end() + 10 -> { + interpreter.sendDialogues( + npc, + null, + "The prince is guarded by some stupid guards and a", + "clever woman. The woman is our only way to get the", + "prince out. Only she can walk freely about the area." + ) + stage = 11 + } + 11 -> { + interpreter.sendDialogues( + npc, + null, + "I think you will need to tie her up. One coil of rope", + "should do for that. Then, disguise the prince as her to", + "get him out without suspicion." + ) + stage = 12 + } + 12 -> { + interpreter.sendDialogues(player, null, "How good must the disguise be?") + stage = 13 + } + 13 -> { + interpreter.sendDialogues( + npc, + null, + "Only enough to fool the guards at a distance. Get a", + "skirt like hers. Same colour, same style. We will only", + "have a short time." + ) + stage = 14 + } + 14 -> { + interpreter.sendDialogues( + npc, + null, + "Get a blonde wig, too. that is up to you to make or", + "find. Something to colour the skin of the prince." + ) + stage = 15 + } + 15 -> { + interpreter.sendDialogues( + npc, + null, + "My daughter and top spy, Leela, can help you. She has", + "sent word that she has discovered where they are", + "keeping the prince." + ) + stage = 16 + } + 16 -> { + interpreter.sendDialogues( + npc, + null, + "It's near Draynor Village. She is lurking somewhere", + "near there now." + ) + stage = 17 + } + 17 -> { + quest!!.setStage(player, 20) + interpreter.sendOptions( + "Select an Option", + "Explain the first thing again.", + "What is the second thing you need?", + "Okay, I better go find some things." + ) + stage = 50 + } + 20 -> { + interpreter.sendDialogues( + npc, + null, + "We need the key, or we need a copy made. If you can", + "get some soft clay then you can copy the key..." + ) + stage = 21 + } + 21 -> { + interpreter.sendDialogues( + npc, + null, + "...If you can convince Lady Keli to show it to you", + "for a moment. She is very boastful.", + "It should not be too hard." + ) + stage = 22 + } + 22 -> { + interpreter.sendDialogues(npc, null, "Bring the imprint to me, with a bar of bronze.") + stage = 23 + } + 23 -> { + quest!!.setStage(player, 20) + interpreter.sendOptions( + "Select an Option", + "What is the first thing I must do?", + "What exactly is the second thing you need?", + "Okay, I better go find some things." + ) + stage = 24 + } + 24 -> when (buttonId) { + 1 -> { + interpreter.sendDialogues(player, null, "What is the first thing I must do?") + stage = 10 + } + 2 -> { + interpreter.sendDialogues(player, null, "What exactly is the second thing I must do?") + stage = 20 + } + 3 -> { + interpreter.sendDialogues(player, null, "Okay, I better go find some things.") + stage = 25 + } + } + 25 -> { + interpreter.sendDialogues( + npc, + null, + "May good luck travel with you. Don't forget to find", + "Leela. It can't be done without her help." + ) + stage = 26 + } + 26 -> end() + 50 -> when (buttonId) { + 1 -> { + interpreter.sendDialogues(player, null, "Explain the first thing again.") + stage = 10 + } + 2 -> { + interpreter.sendDialogues(player, null, "What is th second thing you need?") + stage = 20 + } + 3 -> { + interpreter.sendDialogues(player, null, "Okay, I better go find some things.") + stage = 25 + } + } + } + 10 -> when (stage) { + 0 -> { + interpreter.sendDialogues( + npc, + null, + "Our prince is captive by the Lady Keli. We just need", + "to make the rescue. There are two things we need", + "you to do." + ) + stage = 1 + } + 1 -> { + interpreter.sendOptions( + "Select an Option", + "What is the first thing I must do?", + "What is the second thing you need?" + ) + stage = 3 + } + 3 -> when (buttonId) { + 1 -> { + interpreter.sendDialogues(player, null, "What is the first thing I must do?") + stage = 10 + } + 2 -> { + interpreter.sendDialogues(player, null, "What is the second thing you need?") + stage = 20 + } + } + 10 -> { + interpreter.sendDialogues( + npc, + null, + "The prince is guarded by some stupid guards and a", + "clever woman. The woman is our only way to get the", + "prince out. Only she can walk freely about the area." + ) + stage = 11 + } + 11 -> { + interpreter.sendDialogues( + npc, + null, + "I think you will need to tie her up. One coil of rope", + "should do for that. Then, disguise the prince as her to", + "get him out without suspicion." + ) + stage = 12 + } + 12 -> { + interpreter.sendDialogues(player, null, "How good must the disguise be?") + stage = 13 + } + 13 -> { + interpreter.sendDialogues( + npc, + null, + "Only enough to fool the guards at a distance. Get a", + "skirt like hers. Same colour, same style. We will only", + "have a short time." + ) + stage = 14 + } + 14 -> { + interpreter.sendDialogues( + npc, + null, + "Get a blonde wig, too. that is up to you to make or", + "find. Something to colour the skin of the prince." + ) + stage = 15 + } + 15 -> { + interpreter.sendDialogues( + npc, + null, + "My daughter and top spy, Leela, can help you. She has", + "sent word that she has discovered where they are", + "keeping the prince." + ) + stage = 16 + } + 16 -> { + interpreter.sendDialogues( + npc, + null, + "It's near Draynor Village. She is lurking somewhere", + "near there now." + ) + stage = 17 + } + 17 -> { + quest!!.setStage(player, 20) + interpreter.sendOptions( + "Select an Option", + "Explain the first thing again.", + "What is the second thing you need?", + "Okay, I better go find some things." + ) + stage = 50 + } + 20 -> { + interpreter.sendDialogues( + npc, + null, + "We need the key, or we need a copy made. If you can", + "get some soft clay then you can copy the key..." + ) + stage = 21 + } + 21 -> { + interpreter.sendDialogues( + npc, + null, + "...If you can convince Lady Keli to show it to you", + "for a moment. She is very boastful.", + "It should not be too hard." + ) + stage = 22 + } + 22 -> { + interpreter.sendDialogues(npc, null, "Bring the imprint to me, with a bar of bronze.") + stage = 23 + } + 23 -> { + quest!!.setStage(player, 20) + interpreter.sendOptions( + "Select an Option", + "What is the first thing I must do?", + "What exactly is the second thing you need?", + "Okay, I better go find some things." + ) + stage = 24 + } + 24 -> when (buttonId) { + 1 -> { + interpreter.sendDialogues(player, null, "What is the first thing I must do?") + stage = 10 + } + 2 -> { + interpreter.sendDialogues(player, null, "What exactly is the second thing I must do?") + stage = 20 + } + 3 -> { + interpreter.sendDialogues(player, null, "Okay, I better go find some things.") + stage = 25 + } + } + 25 -> { + interpreter.sendDialogues( + npc, + null, + "May good luck travel with you. Don't forget to find", + "Leela. It can't be done without her help." + ) + stage = 26 + } + 26 -> end() + } + else -> { + } + } + return true + } + + /** + * Method used to handle the sqirk juice dials. + * @param buttonId the buttonId. + */ + fun handleSqirks(buttonId: Int) { + when (stage) { + 0 -> if (!hasSqirks()) { + interpreter.sendOptions( + "Select an Option", + "Where do I get sq'irks?", + "Why can't you get the sq'irks yourself?", + "How should I squeeze the fruit?", + "Is there a reward for getting these sq'irks?", + "What's so good about sq'irk juice then?" + ) + stage = 200 + } else { + player(if (hasSqirkJuice()) "I have some sq'riks juice for you." else "I have some sq'irks for you.") + stage = 300 + } + 300 -> if (hasSqirkJuice()) { + val exp = experience + player.getSkills().addExperience(Skills.THIEVING, exp, true) + interpreter.sendDialogue( + "Osman imparts some Thieving advice to", + "you ( $exp Thieving experience points )", + "as a reward for the sq'irk juice." + ) + stage = 304 + } else { + npc("Uh, thanks, but is there any chance that you", "could squeeze the fruit into a glass for me?") + stage = 301 + } + 301 -> { + interpreter.sendOptions( + "Select an Option", + "How should I squeeze the fruit?", + "Can't you do that yourself?" + ) + stage = 302 + } + 302 -> when (buttonId) { + 1 -> { + player("How should I squeeze the fruit?") + stage = 130 + } + 2 -> { + player("Can't you do that yourself?") + stage = 303 + } + } + 304 -> end() + 303 -> { + player("I only carry knives or other such devices on me", "when I'm on the job.") + stage = 119 + } + 200 -> when (buttonId) { + 1 -> { + interpreter.sendDialogues(player, null, "Where do I get sq'irks?") + stage = 110 + } + 2 -> { + interpreter.sendDialogues(player, null, "Why can't you get the sq'irks yourself?") + stage = 120 + } + 3 -> { + interpreter.sendDialogues(player, null, "How should I squeeze the fruit?") + stage = 130 + } + 4 -> { + interpreter.sendDialogues(player, null, "Is there a reward for getting these sq'irks?") + stage = 140 + } + 5 -> { + interpreter.sendDialogues(player, null, "What's so good about sq'irk juice then?") + stage = 150 + } + } + 110 -> { + npc( + "There is a sorceress near the south-eastern edge of Al", + "Kharid who grows them. Once upon a time, we", + "considered each other friends." + ) + stage = 111 + } + 111 -> { + player("What happened?") + stage = 112 + } + 112 -> { + npc("We fell out, and now she won't give me any more", "fruit.") + stage = 113 + } + 113 -> { + player("So all I have to do is ask her for some fruit for you?") + stage = 114 + } + 114 -> { + npc( + "I doubt it will be that easy. She is not renowned for", + "her generosity and is very secretive about her garden's", + "location." + ) + stage = 115 + } + 115 -> { + player("Oh come on, it should be easy enough to find.") + stage = 116 + } + 116 -> { + npc( + "Her garden has remained hidden even to me - the chief", + "spy of Al Kharid. I believe her garden must be hidden", + "by magical means." + ) + stage = 117 + } + 117 -> { + player("This should be an interesting task. How many sq'irks do", "you want?") + stage = 118 + } + 118 -> { + npc( + "I'll reward you for as many as you can get your", + "hands on, but could you please squeeze the fruit into a", + "glass first?" + ) + stage = 119 + } + 119 -> { + interpreter.sendOptions( + "Select an Option", + "I've another question about sq'irks.", + "Thanks for the information." + ) + stage = 98 + } + 98 -> when (buttonId) { + 1 -> { + interpreter.sendOptions( + "Select an Option", + "Where do I get sq'irks?", + "Why can't you get the sq'irks yourself?", + "How should I squeeze the fruit?", + "Is there a reward for getting these sq'irks?", + "What's so good about sq'irk juice then?" + ) + stage = 200 + } + 2 -> { + player("Thanks for the information.") + stage = 99 + } + } + 99 -> end() + 120 -> { + npc( + "I may have mentioned that I had a falling out with the", + "Sorceress. Well, unsurprisingly, she refuses to give me", + "any more of her garden's produce." + ) + stage = 119 + } + 130 -> { + npc( + "Use a pestle and mortar to squeeze the sr'irks. Make", + "sure you have an empty glass with you to collect the", + "juice." + ) + stage = 119 + } + 140 -> { + npc( + "Of course there is. I am a generous man. I'll teach", + "you the art of Thieving for your troubles." + ) + stage = 141 + } + 141 -> { + player("How much training will you give?") + stage = 142 + } + 142 -> { + npc("That depends on the quantity and ripeness of the", "sq'irks you put into the juice.") + stage = 143 + } + 143 -> { + player("That sounds fair enough.") + stage = 119 + } + 150 -> { + npc( + "Ah it's sweet, sweet nectar for a thief or spy; it makes", + "light fingers lighter, fleet feet flightier and comes in four", + "different colours for those who are easily amused." + ) + stage = 151 + } + 151 -> { + interpreter.sendDialogue("Osman starts salivating at the thought of sq'irk juice.") + stage = 152 + } + 152 -> { + player("It wouldn't have addictive properties, would it?") + stage = 153 + } + 153 -> { + npc( + "It only holds power over those with poor self-control,", + "something which I have an abundance of." + ) + stage = 154 + } + 154 -> { + player("I see.") + stage = 119 + } + } + } + + /** + * Gets the experience the player can recieve. + * @return the experience. + */ + val experience: Double + get() { + var total = 0.0 + for (juiceId in JUICES) { + val def = SeasonDefinitions.forJuiceId(juiceId) ?: continue + val amount: Int = player.getInventory().getAmount(Item(juiceId)) + total += amount * def.osmanExp + player.getInventory().remove(Item(juiceId, amount)) + } + player.getInventory().refresh() + return total + } + + /** + * Checks wether the **Player** has sq'irk. + * @return `True`: Player has sq'irk. + */ + fun hasSqirkFruit(): Boolean { + for (i in FRUITS) { + if (player.getInventory().contains(i, 1)) { + return true + } + } + return false + } + + /** + * Checks wether the **Player** has sq'irk juice + * @return `True`: Player has sq'irk juice. + */ + fun hasSqirkJuice(): Boolean { + for (i in JUICES) { + if (player.getInventory().contains(i, 1)) { + return true + } + } + return false + } + + /** + * Checks wether the **Player** has sq'irks (fruit/juice). + * @return `True`: Player has either a fruit or squeezed juice. + */ + fun hasSqirks(): Boolean { + return hasSqirkFruit() || hasSqirkJuice() + } + + override fun getIds(): IntArray { + return intArrayOf(924, 5282) + } + + companion object { + /** + * Represents the key print item. + */ + private val KEY_PRINT = Item(2423) + + /** + * Represents the bronze bar item. + */ + private val BRONZE_BAR = Item(2349) + + /** + * Represents the rope item. + */ + private val ROPE = Item(954) + + /** + * Represents the pink skirt item. + */ + private val SKIRT = Item(1013) + + /** + * Represents the yellow wig item. + */ + private val YELLOW_WIG = Item(2419) + + /** + * Represents the skin paste item. + */ + private val PASTE = Item(2424) + + /** + * Represents the juices. + */ + private val JUICES = intArrayOf(10848, 10849, 10850, 10851) + + /** + * Represents the fruits. + */ + private val FRUITS = intArrayOf(10844, 10845, 10846, 10847) + } + } + + companion object { + /** + * Represents the animation to use. + */ + private val ANIMATION = Animation(827) + + /** + * Represents the herbs items used for the elemental garden picking. + */ + private val HERBS = + intArrayOf(199, 201, 203, 205, 207, 209, 211, 213, 215, 217, 219, 2485, 3049, 3051, 199, 201, 203, 205) + + /** + * Represents the drinking animation. + */ + private val DRINK_ANIM = Animation(5796) + + /** + * Represents the teleport anim. + */ + private val TELE = Animation(714) + + /** + * Represents the graphics to use. + */ + private val GRAPHICS = Graphics(111, 100, 1) + + /** + * Represents the picking fruit anim. + */ + private val PICK_FRUIT = Animation(2280) + } +} + + /** + * Dialogue for Sqirk making + * @author SonicForce41 + */ + class SqirkMakingDialogue : DialoguePlugin { + private var dialogueId = 0 + private var definition: GardenObjectsPlugin.SeasonDefinitions? = null + + /** + * Constructs a new `SqirkMakingDialogue.java` `Object`. + */ + constructor() {} + + /** + * Constructs a new `SqirkMakingDialogue.java` `Object`. + * @param player the Player + */ + constructor(player: Player?) : super(player) {} + + override fun getIds(): IntArray { + return intArrayOf(43382) + } + + override fun handle(interfaceId: Int, buttonId: Int): Boolean { + when (dialogueId) { + 0 -> end() + 1 -> when (stage) { + 0 -> { + interpreter.sendDialogue("You need " + definition!!.fruitAmt + " sq'irks of this kind to fill a glass of juice.") + stage = 1 + } + 1 -> end() + } + } + return true + } + + override fun newInstance(player: Player): DialoguePlugin { + return SqirkMakingDialogue(player) + } + + override fun open(vararg args: Any): Boolean { + dialogueId = args[0] as Int + when (dialogueId) { + 0 -> interpreter.sendDialogues( + player, + FacialExpression.THINKING, + "I should get an empty beer glass to", + "hold the juice before I squeeze the fruit." + ) + 1 -> { + definition = GardenObjectsPlugin.SeasonDefinitions.forFruitId(args[1] as Int) + if (definition == null) end() + interpreter.sendDialogues( + player, + FacialExpression.THINKING, + "I think I should wait till I have", + "enough fruits to make a full glass." + ) + } + } + stage = 0 + return true + } + } diff --git a/Server/src/main/java/core/game/node/entity/combat/equipment/BoltEffect.java b/Server/src/main/java/core/game/node/entity/combat/equipment/BoltEffect.java index 8b3e30008..7fe5fb221 100644 --- a/Server/src/main/java/core/game/node/entity/combat/equipment/BoltEffect.java +++ b/Server/src/main/java/core/game/node/entity/combat/equipment/BoltEffect.java @@ -237,9 +237,8 @@ public enum BoltEffect { */ @SuppressWarnings("unused") public void impact(BattleState state) { - Entity entity = state.getAttacker(); Entity victim = state.getVictim(); - if (sound != null && victim != null && victim instanceof Player) { + if (sound != null && victim instanceof Player) { sound.send(victim.asPlayer(), true); } if (graphics != null) { diff --git a/Server/src/main/java/core/game/node/entity/combat/handlers/DragonfireSwingHandler.java b/Server/src/main/java/core/game/node/entity/combat/handlers/DragonfireSwingHandler.java index 40340c0f2..6ac038ad2 100644 --- a/Server/src/main/java/core/game/node/entity/combat/handlers/DragonfireSwingHandler.java +++ b/Server/src/main/java/core/game/node/entity/combat/handlers/DragonfireSwingHandler.java @@ -208,8 +208,8 @@ public class DragonfireSwingHandler extends CombatSwingHandler { } @Override - public int calculateDefence(Entity entity, Entity attacker) { - return CombatStyle.MAGIC.getSwingHandler().calculateDefence(entity, attacker); + public int calculateDefence(Entity victim, Entity attacker) { + return CombatStyle.MAGIC.getSwingHandler().calculateDefence(victim, attacker); } @Override diff --git a/Server/src/main/java/core/game/node/entity/combat/special/RampageSpecialHandler.java b/Server/src/main/java/core/game/node/entity/combat/special/RampageSpecialHandler.java index 8a75bc4fa..81b14cd26 100644 --- a/Server/src/main/java/core/game/node/entity/combat/special/RampageSpecialHandler.java +++ b/Server/src/main/java/core/game/node/entity/combat/special/RampageSpecialHandler.java @@ -69,7 +69,6 @@ public final class RampageSpecialHandler extends MeleeSwingHandler implements Pl boost += drain; p.getSkills().updateLevel(i, (int) -drain, (int) (p.getSkills().getStaticLevel(i) - drain)); } - boost *= 0.25; p.getSkills().updateLevel(Skills.STRENGTH, (int) (p.getSkills().getStaticLevel(Skills.STRENGTH) * 0.20)); p.getAudioManager().send(new Audio(386), true); return -1; diff --git a/Server/src/main/java/core/game/node/entity/combat/special/SliceAndDiceSpecialHandler.java b/Server/src/main/java/core/game/node/entity/combat/special/SliceAndDiceSpecialHandler.java index 511f9dc8e..2d0ed1c20 100644 --- a/Server/src/main/java/core/game/node/entity/combat/special/SliceAndDiceSpecialHandler.java +++ b/Server/src/main/java/core/game/node/entity/combat/special/SliceAndDiceSpecialHandler.java @@ -68,7 +68,6 @@ public final class SliceAndDiceSpecialHandler extends MeleeSwingHandler implemen } else { hit = getHit(entity, victim, (int) (maximum * 1.5)); if (hit > 0) { - maximum *= 1.5; hits = new int[] {0, 0, 0, hit}; } else { hits = new int[] {0, RandomFunction.random(2)}; diff --git a/Server/src/main/java/core/game/node/entity/npc/bosses/KalphiteQueenNPC.java b/Server/src/main/java/core/game/node/entity/npc/bosses/KalphiteQueenNPC.java index 2e69bbd77..e94be4859 100644 --- a/Server/src/main/java/core/game/node/entity/npc/bosses/KalphiteQueenNPC.java +++ b/Server/src/main/java/core/game/node/entity/npc/bosses/KalphiteQueenNPC.java @@ -296,8 +296,8 @@ public final class KalphiteQueenNPC extends AbstractNPC { } @Override - public int calculateDefence(Entity entity, Entity attacker) { - return style.getSwingHandler().calculateDefence(entity, attacker); + public int calculateDefence(Entity victim, Entity attacker) { + return style.getSwingHandler().calculateDefence(victim, attacker); } @Override diff --git a/Server/src/main/java/core/game/node/entity/npc/bosses/TormentedDemonNPC.java b/Server/src/main/java/core/game/node/entity/npc/bosses/TormentedDemonNPC.java index 41142075a..df824b3e7 100644 --- a/Server/src/main/java/core/game/node/entity/npc/bosses/TormentedDemonNPC.java +++ b/Server/src/main/java/core/game/node/entity/npc/bosses/TormentedDemonNPC.java @@ -115,7 +115,7 @@ public class TormentedDemonNPC extends AbstractNPC { @Override public void checkImpact(BattleState state) { - if (fireShield && state.getAttacker().isPlayer() && state.getEstimatedHit() > 0 && state.getWeapon() != null && (state.getWeapon().getId() == 6746 || state.getWeapon().getId() == 6746 || state.getWeapon().getId() == 732)) { + if (fireShield && state.getAttacker().isPlayer() && state.getEstimatedHit() > 0 && state.getWeapon() != null && (state.getWeapon().getId() == 6746 || state.getWeapon().getId() == 732)) { shieldDelay = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(60); fireShield = false; setAttribute("shield-player", state.getAttacker()); @@ -315,8 +315,8 @@ public class TormentedDemonNPC extends AbstractNPC { } @Override - public int calculateDefence(Entity entity, Entity attacker) { - return style.getSwingHandler().calculateDefence(entity, attacker); + public int calculateDefence(Entity victim, Entity attacker) { + return style.getSwingHandler().calculateDefence(victim, attacker); } @Override diff --git a/Server/src/main/java/core/game/node/entity/npc/bosses/wilderness/KingBlackDragonNPC.java b/Server/src/main/java/core/game/node/entity/npc/bosses/wilderness/KingBlackDragonNPC.java index c594c54cf..b69cce4ef 100644 --- a/Server/src/main/java/core/game/node/entity/npc/bosses/wilderness/KingBlackDragonNPC.java +++ b/Server/src/main/java/core/game/node/entity/npc/bosses/wilderness/KingBlackDragonNPC.java @@ -143,11 +143,11 @@ public final class KingBlackDragonNPC extends AbstractNPC { } @Override - public int calculateDefence(Entity entity, Entity attacker) { + public int calculateDefence(Entity victim, Entity attacker) { if (style == CombatStyle.MELEE) { - return style.getSwingHandler().calculateDefence(entity, attacker); + return style.getSwingHandler().calculateDefence(victim, attacker); } - return CombatStyle.MAGIC.getSwingHandler().calculateDefence(entity, attacker); + return CombatStyle.MAGIC.getSwingHandler().calculateDefence(victim, attacker); } @Override diff --git a/Server/src/main/java/core/game/node/entity/npc/city/nardah/AliTheCarter.java b/Server/src/main/java/core/game/node/entity/npc/city/nardah/AliTheCarter.java index 07f6898f1..d0dca16ae 100644 --- a/Server/src/main/java/core/game/node/entity/npc/city/nardah/AliTheCarter.java +++ b/Server/src/main/java/core/game/node/entity/npc/city/nardah/AliTheCarter.java @@ -23,7 +23,7 @@ public class AliTheCarter extends DialoguePlugin { @Override public DialoguePlugin newInstance(Player player){return new AliTheCarter(player);} public boolean open(Object... args){ - NPC npc = (NPC)args[0]; + npc = (NPC)args[0]; player("Hello"); return true; } diff --git a/Server/src/main/java/core/game/node/entity/npc/city/pollnivneach/AliTheKebabSeller.java b/Server/src/main/java/core/game/node/entity/npc/city/pollnivneach/AliTheKebabSeller.java index 551bd1fb4..29de8fad9 100644 --- a/Server/src/main/java/core/game/node/entity/npc/city/pollnivneach/AliTheKebabSeller.java +++ b/Server/src/main/java/core/game/node/entity/npc/city/pollnivneach/AliTheKebabSeller.java @@ -20,7 +20,7 @@ public class AliTheKebabSeller extends DialoguePlugin { public DialoguePlugin newInstance(Player player){return new AliTheKebabSeller(player);} @Override public boolean open(Object... args){ - NPC npc = (NPC)args[0]; + npc = (NPC)args[0]; player("Hello"); return true; } diff --git a/Server/src/main/java/core/game/node/entity/npc/city/sophanem/SphinxDialogue.java b/Server/src/main/java/core/game/node/entity/npc/city/sophanem/SphinxDialogue.java index 75da6678b..3ae8d15cb 100644 --- a/Server/src/main/java/core/game/node/entity/npc/city/sophanem/SphinxDialogue.java +++ b/Server/src/main/java/core/game/node/entity/npc/city/sophanem/SphinxDialogue.java @@ -94,6 +94,7 @@ public final class SphinxDialogue extends DialoguePlugin { case 52: player.getFamiliarManager().getFamiliar().sendChat("Meow"); stage = 53; + break; case 53: player.getDialogueInterpreter().sendDialogue("The Sphinx and the cat have a chat."); stage = 54; diff --git a/Server/src/main/java/core/game/node/entity/npc/drop/NPCDropTables.java b/Server/src/main/java/core/game/node/entity/npc/drop/NPCDropTables.java index cf651066b..366f19ac5 100644 --- a/Server/src/main/java/core/game/node/entity/npc/drop/NPCDropTables.java +++ b/Server/src/main/java/core/game/node/entity/npc/drop/NPCDropTables.java @@ -221,7 +221,7 @@ public final class NPCDropTables { */ private boolean handleBoneCrusher(Player player, Item item) { Bones bone = Bones.forId(item.getId()); - if (bone == null || item == null) { + if (bone == null) { return false; } if (!player.getGlobalData().isEnableBoneCrusher()) { diff --git a/Server/src/main/java/core/game/node/entity/npc/drop/RareDropTable.java b/Server/src/main/java/core/game/node/entity/npc/drop/RareDropTable.java index d77313b69..fd2a17557 100644 --- a/Server/src/main/java/core/game/node/entity/npc/drop/RareDropTable.java +++ b/Server/src/main/java/core/game/node/entity/npc/drop/RareDropTable.java @@ -55,7 +55,7 @@ public final class RareDropTable { * Initializes the rare drop table. */ public static void init(){ - if(!new File(ServerConstants.RDT_DATA_PATH).exists()){ + if(ServerConstants.RDT_DATA_PATH != null && !new File(ServerConstants.RDT_DATA_PATH).exists()){ SystemLogger.logErr("Can't locate RDT file at " + ServerConstants.RDT_DATA_PATH); return; } diff --git a/Server/src/main/java/core/game/node/entity/npc/familiar/MinotaurFamiliarNPC.java b/Server/src/main/java/core/game/node/entity/npc/familiar/MinotaurFamiliarNPC.java index e6f6319c6..83b5222af 100644 --- a/Server/src/main/java/core/game/node/entity/npc/familiar/MinotaurFamiliarNPC.java +++ b/Server/src/main/java/core/game/node/entity/npc/familiar/MinotaurFamiliarNPC.java @@ -55,7 +55,7 @@ public final class MinotaurFamiliarNPC implements Plugin { familiar.sendFamiliarHit(target, RandomFunction.random(maxHit)); Projectile.magic(familiar, target, 1497, 80, 36, 70, 10).send(); familiar.visualize(Animation.create(8026), Graphics.create(1496)); - if (!(familiar instanceof BronzeMinotaurNPC && familiar instanceof RuneMinotaurNPC) && RandomFunction.random(10) < 6) { + if (!(familiar instanceof BronzeMinotaurNPC || familiar instanceof RuneMinotaurNPC) && RandomFunction.random(10) < 6) { final int ticks = 2 + (int) Math.floor(familiar.getLocation().getDistance(target.getLocation()) * 0.5); GameWorld.getPulser().submit(new Pulse(ticks) { @Override diff --git a/Server/src/main/java/core/game/node/entity/npc/familiar/SpiritTerrorbirdNPC.java b/Server/src/main/java/core/game/node/entity/npc/familiar/SpiritTerrorbirdNPC.java index b02ccdedc..7024a3e01 100644 --- a/Server/src/main/java/core/game/node/entity/npc/familiar/SpiritTerrorbirdNPC.java +++ b/Server/src/main/java/core/game/node/entity/npc/familiar/SpiritTerrorbirdNPC.java @@ -43,7 +43,7 @@ public class SpiritTerrorbirdNPC extends BurdenBeast { protected boolean specialMove(FamiliarSpecial special) { visualize(Animation.create(1009), Graphics.create(1521)); owner.getSkills().updateLevel(Skills.AGILITY, 2); - owner.getSettings().updateRunEnergy(-owner.getSkills().getStaticLevel(Skills.AGILITY) / 2); + owner.getSettings().updateRunEnergy(-owner.getSkills().getStaticLevel(Skills.AGILITY) / 2.0); return true; } diff --git a/Server/src/main/java/core/game/node/entity/npc/other/BorkNPC.java b/Server/src/main/java/core/game/node/entity/npc/other/BorkNPC.java index ecbcf43fb..c464ec4c0 100644 --- a/Server/src/main/java/core/game/node/entity/npc/other/BorkNPC.java +++ b/Server/src/main/java/core/game/node/entity/npc/other/BorkNPC.java @@ -229,9 +229,9 @@ public class BorkNPC extends AbstractNPC { unlock(); if (player != null) { attack(player); + player.getInterfaceManager().restoreTabs(); + PacketRepository.send(MinimapState.class, new MinimapStateContext(player, 0)); } - player.getInterfaceManager().restoreTabs(); - PacketRepository.send(MinimapState.class, new MinimapStateContext(player, 0)); for (NPC n : legions) { n.getProperties().getCombatPulse().attack(player); } diff --git a/Server/src/main/java/core/game/node/entity/npc/revenant/RevenantNPC.java b/Server/src/main/java/core/game/node/entity/npc/revenant/RevenantNPC.java index e090bb78a..2f03bcff0 100644 --- a/Server/src/main/java/core/game/node/entity/npc/revenant/RevenantNPC.java +++ b/Server/src/main/java/core/game/node/entity/npc/revenant/RevenantNPC.java @@ -104,7 +104,6 @@ public class RevenantNPC extends AbstractNPC { @Override public void finalizeDeath(Entity killer) { - Location itemLoc = getLocation(); super.finalizeDeath(killer); if (killer instanceof Player) { killer.asPlayer().getAudioManager().send(4063, true); diff --git a/Server/src/main/java/core/game/node/entity/player/Player.java b/Server/src/main/java/core/game/node/entity/player/Player.java index a39ff8e26..5949d4ef0 100644 --- a/Server/src/main/java/core/game/node/entity/player/Player.java +++ b/Server/src/main/java/core/game/node/entity/player/Player.java @@ -1,5 +1,6 @@ package core.game.node.entity.player; +import api.ContentAPI; import core.game.component.Component; import core.game.container.Container; import core.game.container.impl.BankContainer; @@ -70,6 +71,7 @@ import core.tools.RandomFunction; import core.tools.StringUtils; import kotlin.Unit; import kotlin.jvm.functions.Function1; +import org.rs09.consts.Items; import rs09.ServerConstants; import rs09.game.VarpManager; import rs09.game.content.ame.RandomEventManager; @@ -109,7 +111,7 @@ public class Player extends Entity { public Location startLocation = null; - private Graphics wardrobe_hold_graphics = new Graphics(1182,0,0); + private final Graphics wardrobe_hold_graphics = new Graphics(1182,0,0); public boolean newPlayer = getSkills().getTotalLevel() < 50; @@ -385,10 +387,10 @@ public class Player extends Entity { * @param force If we should force removal, a player engaged in combat will otherwise remain active until out of combat. */ public void clear(boolean force) { - if (!force && allowRemoval()) { + /*if (!force && allowRemoval()) { Repository.getDisconnectionQueue().add(this, true); return; - } + }*/ if (force) { Repository.getDisconnectionQueue().remove(getName()); } @@ -755,6 +757,14 @@ public class Player extends Entity { Arrays.fill(renderInfo.getAppearanceStamps(),0); } + /** + * Checks if the player is wearing void. + */ + public boolean isWearingVoid(boolean melee){ + int helm = melee ? Items.VOID_MELEE_HELM_11665 : Items.VOID_RANGER_HELM_11664; + return ContentAPI.inEquipment(this, helm, 1) && ContentAPI.inEquipment(this, Items.VOID_KNIGHT_ROBE_8840, 1) && ContentAPI.inEquipment(this, Items.VOID_KNIGHT_TOP_8839, 1); + } + /** * Updates the player's scene graph. * @param login If the player is logging in. diff --git a/Server/src/main/java/core/game/node/entity/player/info/login/LoginType.java b/Server/src/main/java/core/game/node/entity/player/info/login/LoginType.java index 63f17f8d2..c53f280b7 100644 --- a/Server/src/main/java/core/game/node/entity/player/info/login/LoginType.java +++ b/Server/src/main/java/core/game/node/entity/player/info/login/LoginType.java @@ -54,7 +54,7 @@ public enum LoginType { /** * @param type the type to set. */ - public void setType(int type) { + private void setType(int type) { this.type = type; } } diff --git a/Server/src/main/java/core/game/node/entity/player/info/login/PlayerParser.java b/Server/src/main/java/core/game/node/entity/player/info/login/PlayerParser.java index a59b46fbf..e8c0dad3d 100644 --- a/Server/src/main/java/core/game/node/entity/player/info/login/PlayerParser.java +++ b/Server/src/main/java/core/game/node/entity/player/info/login/PlayerParser.java @@ -32,6 +32,7 @@ public final class PlayerParser { } return true; } catch (Exception e){ + e.printStackTrace(); return false; } } @@ -58,7 +59,7 @@ public final class PlayerParser { while ((length = is.read(buffer)) > 0) { os.write(buffer, 0, length); } - } catch (Exception ignored){ + } catch (Exception e){ e.printStackTrace(); } finally { try { assert is != null; @@ -67,6 +68,7 @@ public final class PlayerParser { os.close(); } catch (Exception f){ SystemLogger.logWarn("Unable to close file copiers in PlayerParser.java line 216."); + f.printStackTrace(); } } } diff --git a/Server/src/main/java/core/game/node/entity/player/link/InterfaceManager.java b/Server/src/main/java/core/game/node/entity/player/link/InterfaceManager.java index 447c81b21..d56b34537 100644 --- a/Server/src/main/java/core/game/node/entity/player/link/InterfaceManager.java +++ b/Server/src/main/java/core/game/node/entity/player/link/InterfaceManager.java @@ -467,7 +467,7 @@ public final class InterfaceManager { close(new Component(Components.OPTIONS_261)); // Settings close(new Component(Components.EMOTES_464)); // Emotes close(new Component(Components.MUSIC_V3_187)); // Music - close(new Component(Components.LOGOUT_182)); // Logout + //close(new Component(Components.LOGOUT_182)); // Logout } /** diff --git a/Server/src/main/java/core/game/node/entity/player/link/prayer/PrayerType.java b/Server/src/main/java/core/game/node/entity/player/link/prayer/PrayerType.java index d4d523813..f21292e92 100644 --- a/Server/src/main/java/core/game/node/entity/player/link/prayer/PrayerType.java +++ b/Server/src/main/java/core/game/node/entity/player/link/prayer/PrayerType.java @@ -445,8 +445,4 @@ public enum PrayerType { return defenceReq; } - public void setDefenceReq(int defenceReq) { - this.defenceReq = defenceReq; - } - } diff --git a/Server/src/main/java/core/game/node/entity/player/link/request/assist/AssistSession.java b/Server/src/main/java/core/game/node/entity/player/link/request/assist/AssistSession.java index 1d225f7d4..e596895ad 100644 --- a/Server/src/main/java/core/game/node/entity/player/link/request/assist/AssistSession.java +++ b/Server/src/main/java/core/game/node/entity/player/link/request/assist/AssistSession.java @@ -406,7 +406,7 @@ public final class AssistSession extends Pulse implements RequestModule { if (getPlayer() != p) { int index = getSkillIndex(slot); if (index != -1) { - if (index != -1 && !isRestricted()) { + if (!isRestricted()) { int level = p.getSkills().getLevel(slot); int pLevel = player.getSkills().getLevel(slot); if (pLevel < level) { diff --git a/Server/src/main/java/core/game/node/entity/player/link/spawn/PKScoreBoard.java b/Server/src/main/java/core/game/node/entity/player/link/spawn/PKScoreBoard.java index 804eb5c71..99f8ed69f 100644 --- a/Server/src/main/java/core/game/node/entity/player/link/spawn/PKScoreBoard.java +++ b/Server/src/main/java/core/game/node/entity/player/link/spawn/PKScoreBoard.java @@ -1,6 +1,6 @@ package core.game.node.entity.player.link.spawn; -import core.cache.ServerStore; +import core.cache.AriosStore; import core.cache.StoreFile; import core.cache.misc.buffer.ByteBufferUtils; import core.game.component.Component; @@ -52,7 +52,7 @@ public final class PKScoreBoard { * Initializes the score boards data. */ public static void init() { - StoreFile file = ServerStore.get("pk_scores"); + StoreFile file = AriosStore.get("pk_scores"); if (file == null) { //Indicates no cache exists yet. return; } @@ -73,7 +73,7 @@ public final class PKScoreBoard { ByteBufferUtils.putString(names[i], buffer); } buffer.flip(); - ServerStore.setArchive("pk_scores", buffer); + AriosStore.setArchive("pk_scores", buffer); } /** @@ -114,7 +114,7 @@ public final class PKScoreBoard { int score = player.getSavedData().getSpawnData().getKills(); int myScore = 0; for (int i = 0; i < names.length; i++) { - if (names[i].equals(player.getName()) || names[i].equals(player.getName())) { + if (names[i].equals(player.getName())) { myScore = scores[i]; break; } @@ -152,13 +152,13 @@ public final class PKScoreBoard { if (scores[index] == score) { return; } - if (names[index].equals(player.getName()) || names[index].equals(player.getName())) { + if (names[index].equals(player.getName())) { scores[index] = score; return; } for (int i = SIZE - 2; i >= index; i--) { String name = names[i]; - if (name.equals(player.getName()) || name.equals(player.getName())) { + if (name.equals(player.getName())) { name = names[--i]; } scores[i + 1] = scores[i]; diff --git a/Server/src/main/java/core/game/node/entity/skill/agility/AgilityHandler.java b/Server/src/main/java/core/game/node/entity/skill/agility/AgilityHandler.java index b81f26dd6..4ccca3d9e 100644 --- a/Server/src/main/java/core/game/node/entity/skill/agility/AgilityHandler.java +++ b/Server/src/main/java/core/game/node/entity/skill/agility/AgilityHandler.java @@ -103,27 +103,28 @@ public final class AgilityHandler { public static void fail(final Player player, int delay, final Location dest, Animation anim, final int hit, final String message) { if (anim != null) { ContentAPI.animate(player, anim, true); - } - ContentAPI.submitWorldPulse(new Pulse(ContentAPI.animationDuration(anim), player) { - boolean dmg = false; - @Override - public boolean pulse() { - ContentAPI.teleport(player, dest, TeleportManager.TeleportType.INSTANT); - ContentAPI.animate(player, Animation.RESET, true); - if(!dmg) { - if (hit > 0) { - player.getImpactHandler().setDisabledTicks(0); - ContentAPI.impact(player, hit, HitsplatType.NORMAL); + ContentAPI.submitWorldPulse(new Pulse(ContentAPI.animationDuration(anim), player) { + boolean dmg = false; + + @Override + public boolean pulse() { + ContentAPI.teleport(player, dest, TeleportManager.TeleportType.INSTANT); + ContentAPI.animate(player, Animation.RESET, true); + if (!dmg) { + if (hit > 0) { + player.getImpactHandler().setDisabledTicks(0); + ContentAPI.impact(player, hit, HitsplatType.NORMAL); + } + if (message != null) { + ContentAPI.sendMessage(player, message); + } + dmg = true; } - if (message != null) { - ContentAPI.sendMessage(player, message); - } - dmg = true; + setDelay(0); + return player.getLocation().equals(dest); } - setDelay(0); - return player.getLocation().equals(dest); - } - }); + }); + } } /** diff --git a/Server/src/main/java/core/game/node/entity/skill/agility/brimhaven/BrimhavenArena.java b/Server/src/main/java/core/game/node/entity/skill/agility/brimhaven/BrimhavenArena.java index 0def82a92..be5b658c6 100644 --- a/Server/src/main/java/core/game/node/entity/skill/agility/brimhaven/BrimhavenArena.java +++ b/Server/src/main/java/core/game/node/entity/skill/agility/brimhaven/BrimhavenArena.java @@ -281,7 +281,8 @@ public final class BrimhavenArena extends MapZone implements Plugin { Location l = set.entrance[i]; for (int x = 1; x < set.exit[i].getX() - l.getX(); x++) { Scenery object = RegionManager.getObject(l.transform(x, 0, 0)); - SceneryBuilder.replace(object, object.transform(avail ? 3573 : 3576)); + if(object != null) + SceneryBuilder.replace(object, object.transform(avail ? 3573 : 3576)); } RegionManager.getObject(set.entrance[i]).setCharge(avail ? 1000 : 500); RegionManager.getObject(set.exit[i]).setCharge(avail ? 1000 : 500); diff --git a/Server/src/main/java/core/game/node/entity/skill/agility/pyramid/AgilityPyramidCourse.java b/Server/src/main/java/core/game/node/entity/skill/agility/pyramid/AgilityPyramidCourse.java index 308241cd6..81d56efef 100644 --- a/Server/src/main/java/core/game/node/entity/skill/agility/pyramid/AgilityPyramidCourse.java +++ b/Server/src/main/java/core/game/node/entity/skill/agility/pyramid/AgilityPyramidCourse.java @@ -239,8 +239,7 @@ public final class AgilityPyramidCourse extends AgilityCourse { Direction d = Direction.getLogicalDirection(player.getLocation(), getLedgeLocation(player, object)); final Direction dir = d; final int diff = object.getRotation() == 3 && dir == Direction.EAST ? 1 : object.getRotation() == 3 && dir == Direction.WEST ? 0 : d == Direction.EAST || (d == Direction.SOUTH && object.getRotation() != 0) || d == Direction.NORTH ? 0 : 1; - final boolean fail = player.getSkills().getLevel(Skills.AGILITY) >= 75 ? false : hasFailed(player) ; - player.getSkills().getLevel(Skills.AGILITY); + final boolean fail = player.getSkills().getLevel(Skills.AGILITY) < 75 && hasFailed(player); final Location end = player.getLocation().transform(dir.getStepX() * (fail ? 3 : 5), dir.getStepY() * (fail ? 3 : 5), 0); player.getPacketDispatch().sendMessage("You put your foot on the ledge and try to edge across..."); if (fail) { diff --git a/Server/src/main/java/core/game/node/entity/skill/agility/pyramid/MovingBlockNPC.java b/Server/src/main/java/core/game/node/entity/skill/agility/pyramid/MovingBlockNPC.java index 292b445ce..6c96397ef 100644 --- a/Server/src/main/java/core/game/node/entity/skill/agility/pyramid/MovingBlockNPC.java +++ b/Server/src/main/java/core/game/node/entity/skill/agility/pyramid/MovingBlockNPC.java @@ -134,7 +134,9 @@ public final class MovingBlockNPC extends AbstractNPC { } player.lock(4); player.setAttribute("block-move", GameWorld.getTicks() + 4); - AgilityHandler.failWalk(player, close ? 1 : 3, player.getLocation(), dest, AgilityPyramidCourse.transformLevel(dest), Animation.create(3066), 10, 8, null, getId() == 3124 ? Direction.WEST : Direction.SOUTH); + if(dest != null) { + AgilityHandler.failWalk(player, close ? 1 : 3, player.getLocation(), dest, AgilityPyramidCourse.transformLevel(dest), Animation.create(3066), 10, 8, null, getId() == 3124 ? Direction.WEST : Direction.SOUTH); + } return true; } }); diff --git a/Server/src/main/java/core/game/node/entity/skill/agility/shortcuts/WaterOrbGrapple.java b/Server/src/main/java/core/game/node/entity/skill/agility/shortcuts/WaterOrbGrapple.java index 4e69e31e9..70749edc6 100644 --- a/Server/src/main/java/core/game/node/entity/skill/agility/shortcuts/WaterOrbGrapple.java +++ b/Server/src/main/java/core/game/node/entity/skill/agility/shortcuts/WaterOrbGrapple.java @@ -59,8 +59,6 @@ public class WaterOrbGrapple extends OptionHandler { Location current = player.getLocation(); Scenery rock = RegionManager.getObject(Location.create(2841, 3426, 0)); Scenery tree = RegionManager.getObject(Location.create(2841, 3434, 0)); - System.out.println(rock); - System.out.println(tree); switch (option) { case "grapple": diff --git a/Server/src/main/java/core/game/node/entity/skill/construction/BuildHotspot.java b/Server/src/main/java/core/game/node/entity/skill/construction/BuildHotspot.java index 5c8577c43..b3cefa033 100644 --- a/Server/src/main/java/core/game/node/entity/skill/construction/BuildHotspot.java +++ b/Server/src/main/java/core/game/node/entity/skill/construction/BuildHotspot.java @@ -375,7 +375,7 @@ public enum BuildHotspot { /** * The linked hotspots */ - private static List linkedHotspots = new ArrayList(); + private static final List linkedHotspots = new ArrayList(); /** * Configures hotspots. diff --git a/Server/src/main/java/core/game/node/entity/skill/construction/HouseManager.java b/Server/src/main/java/core/game/node/entity/skill/construction/HouseManager.java index ed39f3893..5629301fa 100644 --- a/Server/src/main/java/core/game/node/entity/skill/construction/HouseManager.java +++ b/Server/src/main/java/core/game/node/entity/skill/construction/HouseManager.java @@ -377,15 +377,21 @@ public final class HouseManager { Region from = RegionManager.forId(style.getRegionId()); Region.load(from, true); RegionChunk defaultChunk = from.getPlanes()[style.getPlane()].getRegionChunk(1, 0); - ZoneBorders borders = DynamicRegion.reserveArea(8, 8); - region = new DynamicRegion(-1, borders.getSouthWestX() >> 6, borders.getSouthWestY() >> 6); - region.setBorders(borders); + RegionChunk defaultSkyChunk = from.getPlanes()[1].getRegionChunk(0,0); + ZoneBorders borders; + //DynamicRegion[] regions = DynamicRegion.create(borders); + region = DynamicRegion.create(style.getRegionId()); +/* region.setBorders(borders); region.setUpdateAllPlanes(true); - RegionManager.addRegion(region.getId(), region); + RegionManager.addRegion(region.getId(), region);*/ configureRoofs(); - for (int z = 0; z < 3; z++) { + for (int z = 0; z < 4; z++) { for (int x = 0; x < 8; x++) { for (int y = 0; y < 8; y++) { + if(z == 3){ + region.replaceChunk(z, x, y, defaultSkyChunk.copy(region.getPlanes()[z]), from); + continue; + } Room room = rooms[z][x][y]; if (room != null) { if (room.getProperties().isRoof() && buildingMode) { @@ -395,7 +401,7 @@ public final class HouseManager { region.replaceChunk(z, x, y, copy, from); room.loadDecorations(z, copy, this); } else { - region.replaceChunk(z, x, y, z != 0 ? null : defaultChunk.copy(region.getPlanes()[0]), from); + region.replaceChunk(z, x, y, z != 0 ? defaultSkyChunk.copy(region.getPlanes()[z]) : defaultChunk.copy(region.getPlanes()[0]), from); } } } @@ -488,6 +494,9 @@ public final class HouseManager { chunkY = 7 - chunkY; break; } + default: { + + } } for (Hotspot h : room.getHotspots()) { if ((h.getChunkX() == chunkX || h.getChunkX2() == chunkX) && (h.getChunkY() == chunkY || h.getChunkY2() == chunkY) && h.getHotspot().getObjectId(style) == object.getId()) { diff --git a/Server/src/main/java/core/game/node/entity/skill/cooking/CookableItems.java b/Server/src/main/java/core/game/node/entity/skill/cooking/CookableItems.java index 52c13bc97..18df2ccef 100644 --- a/Server/src/main/java/core/game/node/entity/skill/cooking/CookableItems.java +++ b/Server/src/main/java/core/game/node/entity/skill/cooking/CookableItems.java @@ -91,10 +91,10 @@ public enum CookableItems { RAW_OOMLIE(Items.RAW_OOMLIE_2337, 0, Items.BURNT_OOMLIE_2426, 50, 0, 999,0,0), // always burns OOMLIE_WRAP(Items.COOKED_OOMLIE_WRAP_2343, Items.WRAPPED_OOMLIE_2341, Items.BURNT_OOMLIE_WRAP_2345, 50, 110, 999,0,0); - public static HashMapcookingMap = new HashMap<>(); - public static HashMapintentionalBurnMap = new HashMap<>(); - public int raw,cooked,level,burnLevel,burnt; - public double experience; + public final static HashMapcookingMap = new HashMap<>(); + public final static HashMapintentionalBurnMap = new HashMap<>(); + public final int raw,cooked,level,burnLevel,burnt; + public final double experience; double low,high; CookableItems(int cooked, int raw, int burnt, int level, double experience, int burnLevel, double low, double high){ this.raw = raw; diff --git a/Server/src/main/java/core/game/node/entity/skill/cooking/recipe/stew/StewRecipe.java b/Server/src/main/java/core/game/node/entity/skill/cooking/recipe/stew/StewRecipe.java index e53e8da1d..17f6c4a08 100644 --- a/Server/src/main/java/core/game/node/entity/skill/cooking/recipe/stew/StewRecipe.java +++ b/Server/src/main/java/core/game/node/entity/skill/cooking/recipe/stew/StewRecipe.java @@ -47,13 +47,15 @@ public class StewRecipe extends Recipe { public void mix(Player player, NodeUsageEvent event) { Item first = event.getUsedItem(); Item second = event.getBaseItem(); - if (player.getInventory().remove(first) && player.getInventory().remove(second)) { - if (first.getId() == BOWL_OF_WATER.getId() || second.getId() == BOWL_OF_WATER.getId()) { - player.getInventory().add(first.getId() == POTATO.getId() ? INCOMPLETE_STEW : first.getId() == MEAT.getId() ? INCOMPLETE_STEW2 : second.getId() == POTATO.getId() ? INCOMPLETE_STEW : second.getId() == MEAT.getId() ? INCOMPLETE_STEW2 : null); - } else { - player.getInventory().add(UNCOOKED_STEW); + if(first != null && second != null) { + if (player.getInventory().remove(first) && player.getInventory().remove(second)) { + if (first.getId() == BOWL_OF_WATER.getId() || second.getId() == BOWL_OF_WATER.getId()) { + player.getInventory().add(first.getId() == POTATO.getId() ? INCOMPLETE_STEW : first.getId() == MEAT.getId() ? INCOMPLETE_STEW2 : second.getId() == POTATO.getId() ? INCOMPLETE_STEW : second.getId() == MEAT.getId() ? INCOMPLETE_STEW2 : null); + } else { + player.getInventory().add(UNCOOKED_STEW); + } + player.getPacketDispatch().sendMessage(getMixMessage(event)); } - player.getPacketDispatch().sendMessage(getMixMessage(event)); } } diff --git a/Server/src/main/java/core/game/node/entity/skill/crafting/gem/GemCutPulse.java b/Server/src/main/java/core/game/node/entity/skill/crafting/gem/GemCutPulse.java index c023e0c3c..206a09851 100644 --- a/Server/src/main/java/core/game/node/entity/skill/crafting/gem/GemCutPulse.java +++ b/Server/src/main/java/core/game/node/entity/skill/crafting/gem/GemCutPulse.java @@ -68,9 +68,6 @@ public final class GemCutPulse extends SkillPulse { @Override public boolean reward() { - if (++ticks % 1 != 0) { - return false; - } if (player.getInventory().remove(gem.getUncut())) { final Item item = gem.getGem(); player.getInventory().add(item); diff --git a/Server/src/main/java/core/game/node/entity/skill/fletching/Fletching.java b/Server/src/main/java/core/game/node/entity/skill/fletching/Fletching.java index 6b393bca0..55c26e67d 100644 --- a/Server/src/main/java/core/game/node/entity/skill/fletching/Fletching.java +++ b/Server/src/main/java/core/game/node/entity/skill/fletching/Fletching.java @@ -144,8 +144,8 @@ public class Fletching { public int unfinished,product,string,level; - public double experience; - public Animation animation; + public final double experience; + public final Animation animation; String(byte indicator, final int unfinished, final int product, final int level, final double experience, final Animation animation) { this.unfinished = unfinished; this.product = product; @@ -159,6 +159,8 @@ public class Fletching { case 2: this.string = org.rs09.consts.Items.CROSSBOW_STRING_9438; break; + default: + break; } } } diff --git a/Server/src/main/java/core/game/node/entity/skill/gather/SkillingResource.java b/Server/src/main/java/core/game/node/entity/skill/gather/SkillingResource.java index b6e7bb1c5..ed2aeb7c1 100644 --- a/Server/src/main/java/core/game/node/entity/skill/gather/SkillingResource.java +++ b/Server/src/main/java/core/game/node/entity/skill/gather/SkillingResource.java @@ -799,7 +799,7 @@ public enum SkillingResource { public int getRespawnDuration() { int minimum = respawnRate & 0xFFFF; int maximum = (respawnRate >> 16) & 0xFFFF; - double playerRatio = ServerConstants.MAX_PLAYERS / Repository.getPlayers().size(); + double playerRatio = (double) ServerConstants.MAX_PLAYERS / Repository.getPlayers().size(); return (int) (minimum + ((maximum - minimum) / playerRatio)); } diff --git a/Server/src/main/java/core/game/node/entity/skill/gather/mining/MiningNode.java b/Server/src/main/java/core/game/node/entity/skill/gather/mining/MiningNode.java index 00c726bfb..1c81dd7a5 100644 --- a/Server/src/main/java/core/game/node/entity/skill/gather/mining/MiningNode.java +++ b/Server/src/main/java/core/game/node/entity/skill/gather/mining/MiningNode.java @@ -636,7 +636,7 @@ public enum MiningNode{ public int getRespawnDuration() { int minimum = respawnRate & 0xFFFF; int maximum = (respawnRate >> 16) & 0xFFFF; - double playerRatio = ServerConstants.MAX_PLAYERS / Repository.getPlayers().size(); + double playerRatio = (double) ServerConstants.MAX_PLAYERS / Repository.getPlayers().size(); return (int) (minimum + ((maximum - minimum) / playerRatio)); } } diff --git a/Server/src/main/java/core/game/node/entity/skill/gather/woodcutting/WoodcuttingNode.java b/Server/src/main/java/core/game/node/entity/skill/gather/woodcutting/WoodcuttingNode.java index 39e72e675..beda21d8c 100644 --- a/Server/src/main/java/core/game/node/entity/skill/gather/woodcutting/WoodcuttingNode.java +++ b/Server/src/main/java/core/game/node/entity/skill/gather/woodcutting/WoodcuttingNode.java @@ -416,7 +416,7 @@ public enum WoodcuttingNode { public int getRespawnDuration() { int minimum = respawnRate & 0xFFFF; int maximum = (respawnRate >> 16) & 0xFFFF; - double playerRatio = ServerConstants.MAX_PLAYERS / Repository.getPlayers().size(); + double playerRatio = (double) ServerConstants.MAX_PLAYERS / Repository.getPlayers().size(); return (int) (minimum + ((maximum - minimum) / playerRatio)); } } diff --git a/Server/src/main/java/core/game/node/entity/skill/gather/woodcutting/WoodcuttingSkillPulse.java b/Server/src/main/java/core/game/node/entity/skill/gather/woodcutting/WoodcuttingSkillPulse.java index 429464291..7d1319102 100644 --- a/Server/src/main/java/core/game/node/entity/skill/gather/woodcutting/WoodcuttingSkillPulse.java +++ b/Server/src/main/java/core/game/node/entity/skill/gather/woodcutting/WoodcuttingSkillPulse.java @@ -284,7 +284,6 @@ public class WoodcuttingSkillPulse extends Pulse { if (!player.getAchievementDiaryManager().hasCompletedTask(DiaryType.SEERS_VILLAGE, 2, 1)) { player.setAttribute("/save:diary:seers:cut-yew", player.getAttribute("diary:seers:cut-yew", 0) + 1); } - System.out.println(player.getAttribute("diary:seers:cut-yew", 0)); if (player.getAttribute("diary:seers:cut-yew", 0) >= 5) { player.getAchievementDiaryManager().finishTask(player, DiaryType.SEERS_VILLAGE, 2, 1); } diff --git a/Server/src/main/java/core/game/node/entity/skill/hunter/bnet/BNetPulse.java b/Server/src/main/java/core/game/node/entity/skill/hunter/bnet/BNetPulse.java index 29b19c2fb..638531490 100644 --- a/Server/src/main/java/core/game/node/entity/skill/hunter/bnet/BNetPulse.java +++ b/Server/src/main/java/core/game/node/entity/skill/hunter/bnet/BNetPulse.java @@ -148,7 +148,7 @@ public final class BNetPulse extends SkillPulse { huntingLevel *= 0.5; } int currentLevel = RandomFunction.random(huntingLevel) + 1; - double ratio = currentLevel / (new Random().nextInt(level + 5) + 1); + double ratio = (double) currentLevel / (new Random().nextInt(level + 5) + 1); return Math.round(ratio * huntingLevel) >= level; } diff --git a/Server/src/main/java/core/game/node/entity/skill/hunter/bnet/ImplingNode.java b/Server/src/main/java/core/game/node/entity/skill/hunter/bnet/ImplingNode.java index 0a0799a5e..f0f595e7a 100644 --- a/Server/src/main/java/core/game/node/entity/skill/hunter/bnet/ImplingNode.java +++ b/Server/src/main/java/core/game/node/entity/skill/hunter/bnet/ImplingNode.java @@ -84,7 +84,7 @@ public final class ImplingNode extends BNetNode { strengthLevel /= 0.5; int level = getLevel(); int currentLevel = RandomFunction.random(strengthLevel) + 1; - double ratio = currentLevel / (new Random().nextInt(level + 5) + 1); + double ratio = (double) currentLevel / (new Random().nextInt(level + 5) + 1); return Math.round(ratio * strengthLevel) < level; } @@ -93,10 +93,8 @@ public final class ImplingNode extends BNetNode { if (!success) { return; } - switch (type) { - case 1: + if(type == 1){ player.sendMessage("You manage to catch the impling and squeeze it into a jar."); - break; } } diff --git a/Server/src/main/java/core/game/node/entity/skill/prayer/PrayerAltarPlugin.java b/Server/src/main/java/core/game/node/entity/skill/prayer/PrayerAltarPlugin.java index b74a00daa..a8a16b454 100644 --- a/Server/src/main/java/core/game/node/entity/skill/prayer/PrayerAltarPlugin.java +++ b/Server/src/main/java/core/game/node/entity/skill/prayer/PrayerAltarPlugin.java @@ -229,14 +229,6 @@ public class PrayerAltarPlugin extends OptionHandler { return id; } - /** - * Sets the baid. - * @param id the id to set. - */ - public void setId(int id) { - this.id = id; - } - /** * Gets the book. * @return the book @@ -245,14 +237,6 @@ public class PrayerAltarPlugin extends OptionHandler { return book; } - /** - * Sets the babook. - * @param book the book to set. - */ - public void setBook(int book) { - this.book = book; - } - /** * Gets the messages. * @return the messages @@ -260,15 +244,6 @@ public class PrayerAltarPlugin extends OptionHandler { public String[] getMessages() { return messages; } - - /** - * Sets the bamessages. - * @param messages the messages to set. - */ - public void setMessages(String[] messages) { - this.messages = messages; - } - } } diff --git a/Server/src/main/java/core/game/node/entity/skill/slayer/DustDevilNPC.java b/Server/src/main/java/core/game/node/entity/skill/slayer/DustDevilNPC.java index 14618f10d..f604131ef 100644 --- a/Server/src/main/java/core/game/node/entity/skill/slayer/DustDevilNPC.java +++ b/Server/src/main/java/core/game/node/entity/skill/slayer/DustDevilNPC.java @@ -36,7 +36,7 @@ public final class DustDevilNPC extends AbstractNPC { for (int i : SKILLS) { player.getSkills().updateLevel(i, -player.getSkills().getStaticLevel(i), 0); } - player.getSkills().decrementPrayerPoints(player.getSkills().getStaticLevel(Skills.PRAYER) / 2); + player.getSkills().decrementPrayerPoints((double) player.getSkills().getStaticLevel(Skills.PRAYER) / 2); state.setEstimatedHit(14); } } diff --git a/Server/src/main/java/core/game/node/entity/skill/smithing/SmithingType.java b/Server/src/main/java/core/game/node/entity/skill/smithing/SmithingType.java index 7f00a32ad..3b1d93c63 100644 --- a/Server/src/main/java/core/game/node/entity/skill/smithing/SmithingType.java +++ b/Server/src/main/java/core/game/node/entity/skill/smithing/SmithingType.java @@ -168,15 +168,15 @@ public enum SmithingType { */ TYPE_PICKAXE(2, 267, 268, new int[] { 273, 272, 271, 270 }, 1); - private int name; + private final int name; - private int[] button; + private final int[] button; - private int child; + private final int child; - private int required; + private final int required; - private int product_amount; + private final int product_amount; /** * Constructs a new {@code SmithingType.java} {@code Object}. @@ -229,13 +229,6 @@ public enum SmithingType { return product_amount; } - /** - * @param name the name to set. - */ - public void setName(int name) { - this.name = name; - } - public static int forButton(Player player, Bars bar, int button, int item) { int count = 0; if (bar == null) { diff --git a/Server/src/main/java/core/game/node/item/Item.java b/Server/src/main/java/core/game/node/item/Item.java index 39d771ad1..59bbcf8ea 100644 --- a/Server/src/main/java/core/game/node/item/Item.java +++ b/Server/src/main/java/core/game/node/item/Item.java @@ -100,7 +100,6 @@ public class Item extends Node{ */ public long getValue() { long value = 1; - value = OfferManager.getRecommendedPrice(getId(), false); if (definition.getValue() > value) { value = definition.getValue(); } diff --git a/Server/src/main/java/core/game/system/SystemTermination.java b/Server/src/main/java/core/game/system/SystemTermination.java index 012d2f99d..b37025ac9 100644 --- a/Server/src/main/java/core/game/system/SystemTermination.java +++ b/Server/src/main/java/core/game/system/SystemTermination.java @@ -4,7 +4,9 @@ import core.game.ge.GrandExchangeDatabase; import core.game.interaction.object.dmc.DMCHandler; import core.game.node.entity.player.Player; import core.game.node.entity.player.info.login.PlayerParser; +import rs09.Server; import rs09.ServerConstants; +import rs09.ServerStore; import rs09.game.ge.OfferManager; import rs09.game.system.SystemLogger; import rs09.game.world.repository.Repository; @@ -34,13 +36,15 @@ public final class SystemTermination { public void terminate() { SystemLogger.logInfo("[SystemTerminator] Initializing termination sequence - do not shutdown!"); try { + Server.setRunning(false); for(Player player : Repository.getPlayers()){ DMCHandler dmc = player.getAttribute("dmc",null); if(dmc != null){ dmc.clear(false); } } - save(ServerConstants.DATA_PATH); + if(ServerConstants.DATA_PATH != null) + save(ServerConstants.DATA_PATH); } catch (Throwable e) { e.printStackTrace(); } @@ -57,18 +61,14 @@ public final class SystemTermination { if (!file.isDirectory()) { file.mkdirs(); } - GrandExchangeDatabase.save(); - OfferManager.save(); - SystemLogger.flushLogs(); - SystemLogger.logInfo("[SystemTerminator] Saved Grand Exchange databases!"); - Repository.getDisconnectionQueue().clear(); + Server.getReactor().terminate(); for (Iterator it = Repository.getPlayers().iterator(); it.hasNext();) { try { Player p = it.next(); if (p != null && !p.isArtificial()) { // Should never be null. - p.removeAttribute("combat-time"); +/* p.removeAttribute("combat-time"); p.clear(); - PlayerParser.save(p); + PlayerParser.save(p);*/ p.getDetails().save(); p.getLogoutPlugins().forEach(playerPlugin -> { try { @@ -77,11 +77,28 @@ public final class SystemTermination { throwable.printStackTrace(); } }); + p.clear(); } - } catch (Throwable t) { - t.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); } } + long start = System.currentTimeMillis(); + while(!Repository.getDisconnectionQueue().isEmpty() && System.currentTimeMillis() - start < 5000L){ + Repository.getDisconnectionQueue().update(); + try { + Thread.sleep(100); + } catch (Exception ignored) {} + } + Repository.getDisconnectionQueue().update(); + GrandExchangeDatabase.save(); + OfferManager.save(); + SystemLogger.flushLogs(); + SystemLogger.logInfo("[SystemTerminator] Saved Grand Exchange databases!"); + Repository.getDisconnectionQueue().clear(); + SystemLogger.logInfo("[SystemTerminator] Saving Server Store..."); + ServerStore.save(); + SystemLogger.logInfo("[SystemTerminator] Server Store Saved!"); // ServerStore.dump(directory + "store/"); SystemLogger.logInfo("[SystemTerminator] Saved player accounts!"); } diff --git a/Server/src/main/java/core/game/system/communication/ClanEntry.java b/Server/src/main/java/core/game/system/communication/ClanEntry.java index 1e74baa80..55d2280cc 100644 --- a/Server/src/main/java/core/game/system/communication/ClanEntry.java +++ b/Server/src/main/java/core/game/system/communication/ClanEntry.java @@ -46,6 +46,7 @@ public class ClanEntry { @Override public boolean equals(Object o) { + if(o == null) return false; ClanEntry e = (ClanEntry) o; if (name != null && !name.equals(e.name)) { return false; diff --git a/Server/src/main/java/core/game/system/monitor/ExceptionLog.java b/Server/src/main/java/core/game/system/monitor/ExceptionLog.java deleted file mode 100644 index d5b742c39..000000000 --- a/Server/src/main/java/core/game/system/monitor/ExceptionLog.java +++ /dev/null @@ -1,98 +0,0 @@ -package core.game.system.monitor; - -import java.io.File; -import java.io.IOException; -import java.io.PrintStream; - -/** - * Handles exception logging. - * @author Emperor - */ -public final class ExceptionLog extends PrintStream { - - /** - * The logger. - */ - private final PrintStream logger; - - /** - * Constructs a new {@code ExceptionLog} {@code Object} - * @param file The output file directory. - * @throws IOException When an I/O exception occurs. - */ - public ExceptionLog(String file) throws IOException { - super(new File(file)); - this.logger = System.err; - } - - @Override - public void println(String message) { - logger.println(message); - } - - @Override - public PrintStream printf(String message, Object... objects) { - logger.printf(message, objects); - return super.printf(message, objects); - } - - @Override - public void println(boolean message) { - logger.println(message); - } - - @Override - public void println(int message) { - logger.println(message); - } - - @Override - public void println(double message) { - logger.println(message); - } - - @Override - public void println(char message) { - logger.println(message); - } - - @Override - public void println(long message) { - logger.println(message); - } - - @Override - public void println(Object message) { - logger.println(message); - } - - @Override - public void print(boolean message) { - logger.print(message); - } - - @Override - public void print(int message) { - logger.print(message); - } - - @Override - public void print(double message) { - logger.print(message); - } - - @Override - public void print(char message) { - logger.print(message); - } - - @Override - public void print(long message) { - logger.print(message); - } - - @Override - public void print(Object message) { - logger.print(message); - } -} \ No newline at end of file diff --git a/Server/src/main/java/core/game/system/monitor/MessageLog.java b/Server/src/main/java/core/game/system/monitor/MessageLog.java index f01ae34cf..bcf7772e7 100644 --- a/Server/src/main/java/core/game/system/monitor/MessageLog.java +++ b/Server/src/main/java/core/game/system/monitor/MessageLog.java @@ -21,7 +21,7 @@ public class MessageLog { /** * The date format used. */ - private static final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); + private final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); /** * The messages. diff --git a/Server/src/main/java/core/game/system/mysql/impl/PlayerLogSQLHandler.java b/Server/src/main/java/core/game/system/mysql/impl/PlayerLogSQLHandler.java index 4b6a77456..d0f2a53c9 100644 --- a/Server/src/main/java/core/game/system/mysql/impl/PlayerLogSQLHandler.java +++ b/Server/src/main/java/core/game/system/mysql/impl/PlayerLogSQLHandler.java @@ -75,12 +75,12 @@ public class PlayerLogSQLHandler extends SQLEntryHandler { } statement.setString(size + 1, log); } - statement.executeUpdate(); + //statement.executeUpdate(); } else { PreparedStatement statement = connection.prepareStatement("INSERT INTO " + table + " (username,public_chat,private_chat,clan_chat,address_log,command_log,trade_log,ge_log,duel_log,duplication_log) VALUES(?,?,?,?,?,?,?,?,?,?)"); statement.setString(1, value); for (int i = 0; i < MESSAGE_COLUMNS.length; i++) { - writeLog(statement, 2 + i, i); + //writeLog(statement, 2 + i, i); } String log = ""; MessageLog messageLog = entry.getDuplicationLog(); @@ -91,7 +91,7 @@ public class PlayerLogSQLHandler extends SQLEntryHandler { log += messageLog.getMessages().get(i) + "\n"; } statement.setString(10, log); - statement.executeUpdate(); + //statement.executeUpdate(); } entry.clear(); SQLManager.close(connection); diff --git a/Server/src/main/java/core/game/system/script/ScriptCompiler.java b/Server/src/main/java/core/game/system/script/ScriptCompiler.java index 2e5645f88..fddc305a2 100644 --- a/Server/src/main/java/core/game/system/script/ScriptCompiler.java +++ b/Server/src/main/java/core/game/system/script/ScriptCompiler.java @@ -14,6 +14,7 @@ import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; +import java.nio.file.Files; import java.util.*; /** @@ -105,7 +106,7 @@ public final class ScriptCompiler { */ public static ScriptContext parseRaw(File file) throws Throwable { loadInstructions(); - BufferedReader br = new BufferedReader(new FileReader(file)); + BufferedReader br = Files.newBufferedReader(file.toPath()); lineId = -1; String line; builder = null; diff --git a/Server/src/main/java/core/game/system/script/ScriptManager.java b/Server/src/main/java/core/game/system/script/ScriptManager.java index 51f03cd40..b86fdf0be 100644 --- a/Server/src/main/java/core/game/system/script/ScriptManager.java +++ b/Server/src/main/java/core/game/system/script/ScriptManager.java @@ -69,7 +69,8 @@ public final class ScriptManager { */ public static void load() { amount = 0; - load(new File(ServerConstants.SCRIPTS_PATH)); + if(ServerConstants.SCRIPTS_PATH != null) + load(new File(ServerConstants.SCRIPTS_PATH)); SystemLogger.logInfo("Parsed " + amount + " " + GameWorld.getSettings().getName() + " script" + (amount == 1 ? "" : "s") + "..."); } diff --git a/Server/src/main/java/core/game/system/security/EncryptionManager.java b/Server/src/main/java/core/game/system/security/EncryptionManager.java index fd8aa59b1..0b038fb3b 100644 --- a/Server/src/main/java/core/game/system/security/EncryptionManager.java +++ b/Server/src/main/java/core/game/system/security/EncryptionManager.java @@ -190,7 +190,7 @@ public class EncryptionManager { * @return the decoded value of x */ private static byte char64(char x) { - if ((int) x < 0 || (int) x > index_64.length) + if ((int) x > index_64.length) return -1; return index_64[(int) x]; } diff --git a/Server/src/main/java/core/game/world/map/Direction.java b/Server/src/main/java/core/game/world/map/Direction.java index 96cc6d0e5..5b34c2f50 100644 --- a/Server/src/main/java/core/game/world/map/Direction.java +++ b/Server/src/main/java/core/game/world/map/Direction.java @@ -254,19 +254,11 @@ public enum Direction { return true; } - /** - * Gets the traversal. - * @return The traversal. - */ - public int[] getTraversal() { - return traversal; - } - /** * Sets the traversal. * @param traversal The traversal to set. */ - public void setTraversal(int[] traversal) { + private void setTraversal(int[] traversal) { this.traversal = traversal; } } \ No newline at end of file diff --git a/Server/src/main/java/core/game/world/map/Region.java b/Server/src/main/java/core/game/world/map/Region.java index 5d894d57d..78b580d7c 100644 --- a/Server/src/main/java/core/game/world/map/Region.java +++ b/Server/src/main/java/core/game/world/map/Region.java @@ -507,14 +507,6 @@ public class Region { this.loaded = loaded; } - /** - * Gets the viewAmount. - * @return The viewAmount. - */ - public int getViewAmount() { - return viewAmount; - } - /** * Sets the viewAmount. * @param viewAmount The viewAmount to set. diff --git a/Server/src/main/java/core/game/world/map/RegionManager.kt b/Server/src/main/java/core/game/world/map/RegionManager.kt index 93d5e891b..50f77a212 100644 --- a/Server/src/main/java/core/game/world/map/RegionManager.kt +++ b/Server/src/main/java/core/game/world/map/RegionManager.kt @@ -33,17 +33,17 @@ object RegionManager { */ @JvmStatic fun forId(regionId: Int): Region { - LOCK.tryLock(10000, TimeUnit.MILLISECONDS) - var region = REGION_CACHE[regionId] - if (region == null) { - region = Region((regionId shr 8) and 0xFF, regionId and 0xFF) - if(region!!.regionId != regionId){ - SystemLogger.logErr("IDs do NOT match - ${region!!.regionId} supposed to be $regionId") + if(LOCK.tryLock() || LOCK.tryLock(10000, TimeUnit.MILLISECONDS)) { + var region = REGION_CACHE[regionId] + if (region == null) { + region = Region((regionId shr 8) and 0xFF, regionId and 0xFF) + REGION_CACHE[regionId] = region } - REGION_CACHE[regionId] = region + LOCK.unlock() + return REGION_CACHE[regionId]!! } - LOCK.unlock() - return REGION_CACHE[regionId]!! + SystemLogger.logErr("UNABLE TO OBTAIN LOCK WHEN GETTING REGION BY ID. RETURNING BLANK REGION.") + return Region(0,0) } /** @@ -51,15 +51,16 @@ object RegionManager { */ @JvmStatic fun pulse() { - LOCK.tryLock(10000,TimeUnit.MILLISECONDS) - for (r in REGION_CACHE.values) { - if (r != null && r.isActive) { - for (p in r.planes) { - p.pulse() + if(LOCK.tryLock() || LOCK.tryLock(10000,TimeUnit.MILLISECONDS)) { + for (r in REGION_CACHE.values) { + if (r.isActive) { + for (p in r.planes) { + p.pulse() + } } } + LOCK.unlock() } - LOCK.unlock() } /** @@ -354,7 +355,7 @@ object RegionManager { val region = forId(regionId) Region.load(region) val `object`: Scenery? = region.planes[z].getChunkObject(x, y, objectId) - return if (`object` != null && !`object`.isRenderable()) { + return if (`object` != null && !`object`.isRenderable) { null } else `object` } @@ -788,9 +789,10 @@ object RegionManager { @JvmStatic fun addRegion(id: Int, region: Region){ - LOCK.tryLock(10000, TimeUnit.MILLISECONDS) - REGION_CACHE[id] = region - LOCK.unlock() + if(lock.tryLock() || LOCK.tryLock(10000, TimeUnit.MILLISECONDS)) { + REGION_CACHE[id] = region + LOCK.unlock() + } } /** diff --git a/Server/src/main/java/core/game/world/map/build/LandscapeParser.java b/Server/src/main/java/core/game/world/map/build/LandscapeParser.java index 85ffd8ebc..95734f9cf 100644 --- a/Server/src/main/java/core/game/world/map/build/LandscapeParser.java +++ b/Server/src/main/java/core/game/world/map/build/LandscapeParser.java @@ -45,7 +45,9 @@ public final class LandscapeParser { int type = configuration >> 2; int z = location >> 12; r.setObjectCount(r.getObjectCount() + 1); - if (x >= 0 && y >= 0 && x < 64 && y < 64) { + if (x < 0 || y < 0 || x >= 64 || y >= 64) { + System.out.println("Object out of bounds: " + objectId + " - " + x + ", " + y + ", " + z); + } else { if ((mapscape[1][x][y] & 0x2) == 2) { z--; } @@ -53,8 +55,6 @@ public final class LandscapeParser { Scenery object = new Scenery(objectId, Location.create((r.getX() << 6) + x, (r.getY() << 6) + y, z), type, rotation); flagScenery(r.getPlanes()[z], x, y, object, true, storeObjects); } - } else { - System.out.println("Object out of bounds: " + objectId + " - " + x + ", " + y + ", " + z); } } } diff --git a/Server/src/main/java/core/game/world/map/path/Pathfinder.java b/Server/src/main/java/core/game/world/map/path/Pathfinder.java index 6c9cb36ba..28fe256ae 100644 --- a/Server/src/main/java/core/game/world/map/path/Pathfinder.java +++ b/Server/src/main/java/core/game/world/map/path/Pathfinder.java @@ -183,7 +183,7 @@ public abstract class Pathfinder { */ public static boolean canDecorationInteract(int curX, int curY, int size, int destX, int destY, int rotation, int type, int z, ClipMaskSupplier clipMaskSupplier) { if (size != 1) { - if (destX >= curX && destX <= (curX + size) - 1 && destY >= destY && destY <= (destY + size) - 1) { + if (destX >= curX && destX <= (curX + size) - 1 && destY <= (destY + size) - 1) { return true; } } else if (destX == curX && curY == destY) { @@ -307,7 +307,7 @@ public abstract class Pathfinder { */ public static boolean canDoorInteract(int curX, int curY, int size, int destX, int destY, int type, int rotation, int z, ClipMaskSupplier clipMaskSupplier) { if (size != 1) { - if (destX >= curX && destX <= size + curX - 1 && destY >= destY && destY <= destY + size - 1) { + if (destX >= curX && destX <= size + curX - 1 && destY <= destY + size - 1) { return true; } } else if (curX == destX && destY == curY) { diff --git a/Server/src/main/java/core/game/world/objectparser/ObjectParser.java b/Server/src/main/java/core/game/world/objectparser/ObjectParser.java index e00107bd9..ca6e0dc3a 100644 --- a/Server/src/main/java/core/game/world/objectparser/ObjectParser.java +++ b/Server/src/main/java/core/game/world/objectparser/ObjectParser.java @@ -22,6 +22,7 @@ import java.io.File; public class ObjectParser extends StartupPlugin { public void parseObjects(){ + if(ServerConstants.OBJECT_PARSER_PATH == null) return; File f = new File(ServerConstants.OBJECT_PARSER_PATH); if(!f.exists()){ System.out.println("[ObjectParser]: Can't find file " + ServerConstants.OBJECT_PARSER_PATH); diff --git a/Server/src/main/java/core/game/world/update/flag/player/ChatFlag.java b/Server/src/main/java/core/game/world/update/flag/player/ChatFlag.java index ca11afcee..cdefd314d 100644 --- a/Server/src/main/java/core/game/world/update/flag/player/ChatFlag.java +++ b/Server/src/main/java/core/game/world/update/flag/player/ChatFlag.java @@ -6,6 +6,8 @@ import core.game.world.update.flag.context.ChatMessage; import core.net.packet.IoBuffer; import core.tools.StringUtils; +import java.nio.charset.StandardCharsets; + /** * Handles the chat flag. * @author Emperor @@ -24,7 +26,7 @@ public class ChatFlag extends UpdateFlag { public void write(IoBuffer buffer) { byte[] chatStr = new byte[256]; chatStr[0] = (byte) context.getText().length(); - int offset = 1 + StringUtils.encryptPlayerChat(chatStr, 0, 1, context.getText().length(), context.getText().getBytes()); + int offset = 1 + StringUtils.encryptPlayerChat(chatStr, 0, 1, context.getText().length(), context.getText().getBytes(StandardCharsets.UTF_8)); buffer.putLEShort(context.getEffects()); // 0x8000 does something (you'd // need to send something // extra. diff --git a/Server/src/main/java/core/gui/tab/PlayerTab.java b/Server/src/main/java/core/gui/tab/PlayerTab.java index 9021eb0d8..165220f93 100644 --- a/Server/src/main/java/core/gui/tab/PlayerTab.java +++ b/Server/src/main/java/core/gui/tab/PlayerTab.java @@ -143,6 +143,7 @@ public class PlayerTab extends ConsoleTab { public void populatePlayerSearch() { playerNames.clear(); model.clear(); + if(ServerConstants.PLAYER_SAVE_PATH == null) return; File f = new File(ServerConstants.PLAYER_SAVE_PATH); if (f.listFiles() == null) { System.out.println("Player directory was null!"); diff --git a/Server/src/main/java/core/gui/tab/StatisticsTab.java b/Server/src/main/java/core/gui/tab/StatisticsTab.java index be5a5d8a5..67a065b5f 100644 --- a/Server/src/main/java/core/gui/tab/StatisticsTab.java +++ b/Server/src/main/java/core/gui/tab/StatisticsTab.java @@ -21,6 +21,9 @@ import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.StandardOpenOption; /** * Handles server info tab. @@ -314,7 +317,7 @@ public class StatisticsTab extends ConsoleTab { * @param file The file to log to. */ protected static void logQueues(File file) { - try (BufferedWriter bw = new BufferedWriter(new FileWriter(file, true))) { + try (BufferedWriter bw = Files.newBufferedWriter(file.toPath(), StandardCharsets.UTF_8, StandardOpenOption.APPEND)) { bw.append("/////////////////////////////////////////////////////////////////////////"); bw.newLine(); bw.append("/////////////////////////////////////////////////////////////////////////"); diff --git a/Server/src/main/java/core/gui/tab/UtilityTab.java b/Server/src/main/java/core/gui/tab/UtilityTab.java index 04fcb8f70..d049431c5 100644 --- a/Server/src/main/java/core/gui/tab/UtilityTab.java +++ b/Server/src/main/java/core/gui/tab/UtilityTab.java @@ -330,7 +330,6 @@ public final class UtilityTab extends ConsoleTab { public List itemScanner(Item item) { Map map = new HashMap<>(); for (Player p : players) { - p.getAnimator(); List containers = new ArrayList<>(20); containers.add(p.getInventory()); containers.add(p.getBank()); diff --git a/Server/src/main/java/core/net/IoEventHandler.java b/Server/src/main/java/core/net/IoEventHandler.java index bd8b48eb2..c5d7e7099 100644 --- a/Server/src/main/java/core/net/IoEventHandler.java +++ b/Server/src/main/java/core/net/IoEventHandler.java @@ -1,5 +1,7 @@ package core.net; +import rs09.game.system.SystemLogger; + import java.io.IOException; import java.nio.ByteBuffer; import java.nio.channels.*; @@ -58,8 +60,7 @@ public class IoEventHandler { ByteBuffer buffer = ByteBuffer.allocate(100_000); IoSession session = (IoSession) key.attachment(); if (channel.read(buffer) == -1) { - //just when a client closes their client, nothing to worry about. - throw new IOException("An existing connection was disconnected!"); + return; } buffer.flip(); if (session == null) { diff --git a/Server/src/main/java/core/net/IoSession.java b/Server/src/main/java/core/net/IoSession.java index 231b2c4c5..195cc0089 100644 --- a/Server/src/main/java/core/net/IoSession.java +++ b/Server/src/main/java/core/net/IoSession.java @@ -161,7 +161,7 @@ public class IoSession { try { writingLock.tryLock(1000L, TimeUnit.MILLISECONDS); } catch (Exception e){ - System.out.println(e); + e.printStackTrace(); writingLock.unlock(); } writingQueue.add(buffer); @@ -180,7 +180,7 @@ public class IoSession { try { writingLock.tryLock(1000L, TimeUnit.MILLISECONDS); } catch (Exception e){ - System.out.println(e); + e.printStackTrace(); writingLock.unlock(); return; } diff --git a/Server/src/main/java/core/net/amsc/MSPacketRepository.java b/Server/src/main/java/core/net/amsc/MSPacketRepository.java index 7d87f2452..0917a4281 100644 --- a/Server/src/main/java/core/net/amsc/MSPacketRepository.java +++ b/Server/src/main/java/core/net/amsc/MSPacketRepository.java @@ -599,8 +599,8 @@ public final class MSPacketRepository { Player player = Repository.getPlayerByName(key); if (player != null && player.isActive()) { player.getPacketDispatch().sendMessages((duration > 0L ? new String[]{"You have been muted.", "To prevent further mutes please read the rules."} : new String[]{"You have been unmuted."})); + player.getDetails().setMuteTime(duration); } - player.getDetails().setMuteTime(duration); break; case 1: player = Repository.getPlayerByName(key); diff --git a/Server/src/main/java/core/net/packet/IoBuffer.java b/Server/src/main/java/core/net/packet/IoBuffer.java index 31def3cc8..219d9c1a0 100644 --- a/Server/src/main/java/core/net/packet/IoBuffer.java +++ b/Server/src/main/java/core/net/packet/IoBuffer.java @@ -529,7 +529,7 @@ public class IoBuffer { */ public int getSmart() { int peek = buf.get(buf.position()); - if (peek <= Byte.MAX_VALUE) { + if (peek <= (0xFF & peek)) { return buf.get() & 0xFF; } return (buf.getShort() & 0xFFFF) - 32768; diff --git a/Server/src/main/java/core/net/packet/in/InteractionPacket.java b/Server/src/main/java/core/net/packet/in/InteractionPacket.java index d92d20cb3..f61e5f1ec 100644 --- a/Server/src/main/java/core/net/packet/in/InteractionPacket.java +++ b/Server/src/main/java/core/net/packet/in/InteractionPacket.java @@ -298,9 +298,6 @@ public final class InteractionPacket implements IncomingPacket { } final Option option = player.getInteraction().get(optionIndex); //Handling for "Pelt" option - if(option.getName().toLowerCase().equals("pelt")){ - - } if (option == null) { PacketRepository.send(ClearMinimapFlag.class, new PlayerContext(player)); return; diff --git a/Server/src/main/java/core/net/packet/in/InterfaceUseOnPacket.java b/Server/src/main/java/core/net/packet/in/InterfaceUseOnPacket.java index 03f9e3c2c..7e082c1a6 100644 --- a/Server/src/main/java/core/net/packet/in/InterfaceUseOnPacket.java +++ b/Server/src/main/java/core/net/packet/in/InterfaceUseOnPacket.java @@ -85,7 +85,8 @@ public class InterfaceUseOnPacket implements IncomingPacket { } break; case 195: // Interface On Player - payload = buffer.getShortA(); + //payload = buffer.getShortA(); + buffer.getShortA(); componentId = buffer.getLEShort(); interfaceId = buffer.getLEShort(); int targetIndex = buffer.getLEShortA(); @@ -175,7 +176,7 @@ public class InterfaceUseOnPacket implements IncomingPacket { case 239: // Interface On NPC componentId = buffer.getLEShort(); interfaceId = buffer.getLEShort(); - int unknown = buffer.getShortA(); + buffer.getShortA(); int index = buffer.getLEShortA(); if (index < 1 || index > ServerConstants.MAX_NPCS) { PacketRepository.send(ClearMinimapFlag.class, new PlayerContext(player)); @@ -228,7 +229,7 @@ public class InterfaceUseOnPacket implements IncomingPacket { interfaceId = buffer.getLEShort(); int itemSlot = buffer.getLEShortA(); itemId = buffer.getShortA(); - unknown = buffer.getShortA(); + buffer.getShortA(); if (itemSlot < 0 || itemSlot > 27) { break; } diff --git a/Server/src/main/java/core/tools/StringUtils.java b/Server/src/main/java/core/tools/StringUtils.java index 8637707b8..b0a941986 100644 --- a/Server/src/main/java/core/tools/StringUtils.java +++ b/Server/src/main/java/core/tools/StringUtils.java @@ -329,16 +329,16 @@ public final class StringUtils { try { i_27_ += i_25_; int i_29_ = 0; - int i_30_ = i_26_ << -2116795453; + int i_30_ = i_26_ << 3; for (; i_27_ > i_25_; i_25_++) { int i_31_ = 0xff & is_28_[i_25_]; int i_32_ = anIntArray233[i_31_]; int i_33_ = aByteArray235[i_31_]; - int i_34_ = i_30_ >> -1445887805; + int i_34_ = i_30_ >> 3; int i_35_ = i_30_ & 0x7; - i_29_ &= (-i_35_ >> 473515839); + i_29_ &= (-i_35_ >> 31); i_30_ += i_33_; - int i_36_ = ((-1 + (i_35_ - -i_33_)) >> -1430991229) + i_34_; + int i_36_ = ((-1 + (i_35_ - -i_33_)) >> 3) + i_34_; i_35_ += 24; is[i_34_] = (byte) (i_29_ = (i_29_ | (i_32_ >>> i_35_))); if ((i_36_ ^ 0xffffffff) < (i_34_ ^ 0xffffffff)) { @@ -362,7 +362,7 @@ public final class StringUtils { } } } - return -i_26_ + ((7 + i_30_) >> -662855293); + return -i_26_ + ((7 + i_30_) >> 3); } catch (RuntimeException runtimeexception) { } return 0; diff --git a/Server/src/main/java/core/tools/mysql/DatabaseManager.java b/Server/src/main/java/core/tools/mysql/DatabaseManager.java index 8da768606..d21ab3c6a 100644 --- a/Server/src/main/java/core/tools/mysql/DatabaseManager.java +++ b/Server/src/main/java/core/tools/mysql/DatabaseManager.java @@ -55,7 +55,7 @@ public class DatabaseManager { return statement.executeQuery(query); } catch (SQLException e) { - System.out.println(e); + e.printStackTrace(); } return null; @@ -75,7 +75,7 @@ public class DatabaseManager { return statement.executeUpdate(query); } catch (SQLException e) { - System.out.println(e); + e.printStackTrace(); } return -1; diff --git a/Server/src/main/java/rs09/game/ai/pvp/PVPAIPActions.java b/Server/src/main/java/rs09/game/ai/pvp/PVPAIPActions.java index a2ad48d4f..25b6f6830 100644 --- a/Server/src/main/java/rs09/game/ai/pvp/PVPAIPActions.java +++ b/Server/src/main/java/rs09/game/ai/pvp/PVPAIPActions.java @@ -75,7 +75,7 @@ public class PVPAIPActions { pvp_players.remove(bot); return true; } - if (!pvp_players.contains(target) || !Pathfinder.find(bot, target[0]).isSuccessful() || !canAttack(bot, target[0])) { + if (!pvp_players.contains(target[0]) || !Pathfinder.find(bot, target[0]).isSuccessful() || !canAttack(bot, target[0])) { target[0] = pvp_players.get(RandomFunction.getRandom(pvp_players.size() - 1)); } attackTarget(player, bot, target[0]); diff --git a/Server/src/main/java/rs09/game/ai/resource/task/ResourceTasks.java b/Server/src/main/java/rs09/game/ai/resource/task/ResourceTasks.java index 8e9a1120e..cd55e19bd 100644 --- a/Server/src/main/java/rs09/game/ai/resource/task/ResourceTasks.java +++ b/Server/src/main/java/rs09/game/ai/resource/task/ResourceTasks.java @@ -28,7 +28,7 @@ public enum ResourceTasks { } }); - private ResourceTask resourceTask; + private final ResourceTask resourceTask; ResourceTasks(ResourceTask resourceTask) { @@ -39,9 +39,6 @@ public enum ResourceTasks { return resourceTask; } - public void setResourceTask(ResourceTask resourceTask) { - this.resourceTask = resourceTask; - } private static String reqirementMessage() { return "You do not meet the requirements for this task."; diff --git a/Server/src/main/java/rs09/game/ai/wilderness/PvPBotsBuilder.java b/Server/src/main/java/rs09/game/ai/wilderness/PvPBotsBuilder.java index bd51bc9e7..fdaa7a5cb 100644 --- a/Server/src/main/java/rs09/game/ai/wilderness/PvPBotsBuilder.java +++ b/Server/src/main/java/rs09/game/ai/wilderness/PvPBotsBuilder.java @@ -537,14 +537,5 @@ public final class PvPBotsBuilder{ player.getSkills().updateCombatLevel(); player.getAppearance().sync(); } - - public void RandomItem() - { - Item test = null; - ArrayList tests = new ArrayList(); - for (int x = 0; x < 9999; x++) - test = new Item(x); - if (test.getDefinition().getEquipId() != 0) - tests.add(test); - } + } diff --git a/Server/src/main/kotlin/api/ContentAPI.kt b/Server/src/main/kotlin/api/ContentAPI.kt index c46e21ecc..1bbbb2b78 100644 --- a/Server/src/main/kotlin/api/ContentAPI.kt +++ b/Server/src/main/kotlin/api/ContentAPI.kt @@ -11,10 +11,10 @@ import core.game.node.`object`.SceneryBuilder import core.game.node.entity.Entity import core.game.node.entity.combat.ImpactHandler import core.game.node.entity.impl.Animator +import core.game.node.entity.impl.ForceMovement import core.game.node.entity.impl.Projectile import core.game.node.entity.npc.NPC import core.game.node.entity.player.Player -import core.game.node.entity.player.link.RunScript import core.game.node.entity.player.link.TeleportManager import core.game.node.entity.player.link.audio.Audio import core.game.node.entity.player.link.emote.Emotes @@ -26,13 +26,14 @@ import core.game.system.task.Pulse import core.game.world.map.Direction import core.game.world.map.Location import core.game.world.map.RegionManager +import core.game.world.map.RegionManager.getRegionChunk import core.game.world.map.path.Pathfinder import core.game.world.map.zone.MapZone import core.game.world.map.zone.ZoneBorders import core.game.world.map.zone.ZoneBuilder +import core.game.world.update.flag.chunk.AnimateObjectUpdateFlag import core.game.world.update.flag.context.Animation import core.game.world.update.flag.context.Graphics -import core.tools.RandomFunction import rs09.game.content.dialogue.DialogueFile import rs09.game.system.SystemLogger import rs09.game.world.GameWorld @@ -389,6 +390,16 @@ object ContentAPI { player.packetDispatch.sendSceneryAnimation(obj, getAnimation(animationId), global) } + /** + * Send an object animation independent of a player + */ + @JvmStatic + fun animateScenery(obj: Scenery, animationId: Int){ + val animation = Animation(animationId) + animation.setObject(obj) + getRegionChunk(obj.location).flag(AnimateObjectUpdateFlag(animation)) + } + /** * Produce a ground item owned by the player */ @@ -736,10 +747,14 @@ object ContentAPI { * Force an entity to walk to a given destination. * @param entity the entity to forcewalk * @param dest the Location object to walk to - * @param type the type of pathfinder to use. "smart" for the SMART pathfinder, anything else for DUMB. + * @param type the type of pathfinder to use. "smart" for the SMART pathfinder, "clip" for the noclip pathfinder, anything else for DUMB. */ @JvmStatic fun forceWalk(entity: Entity, dest: Location, type: String){ + if(type == "clip"){ + ForceMovement(entity, dest, 10, 10).run() + return + } val pathfinder = when(type){ "smart" -> Pathfinder.SMART else -> Pathfinder.DUMB diff --git a/Server/src/main/kotlin/rs09/Server.kt b/Server/src/main/kotlin/rs09/Server.kt index 14c79a264..13285503f 100644 --- a/Server/src/main/kotlin/rs09/Server.kt +++ b/Server/src/main/kotlin/rs09/Server.kt @@ -35,11 +35,13 @@ object Server { var lastHeartbeat = System.currentTimeMillis() + @JvmStatic var running = false /** * The NIO reactor. */ + @JvmStatic var reactor: NioReactor? = null /** @@ -67,12 +69,16 @@ object Server { } startTime = System.currentTimeMillis() val t = TimeStamp() + SystemLogger.logInfo("Initializing Server Store...") + ServerStore.init() + SystemLogger.logInfo("Initialized ${ServerStore.counter} store files.") GameWorld.prompt(true) SQLManager.init() Runtime.getRuntime().addShutdownHook(ServerConstants.SHUTDOWN_HOOK) SystemLogger.logInfo("Starting networking...") try { - NioReactor.configure(43594 + GameWorld.settings?.worldId!!).start() + reactor = NioReactor.configure(43594 + GameWorld.settings?.worldId!!) + reactor!!.start() } catch (e: BindException) { SystemLogger.logErr("Port " + (43594 + GameWorld.settings?.worldId!!) + " is already in use!") throw e @@ -88,7 +94,7 @@ object Server { while(scanner.hasNextLine()){ val command = scanner.nextLine() when(command){ - "stop" -> SystemManager.flag(SystemState.TERMINATED) + "stop" -> exitProcess(0) "players" -> System.out.println("Players online: " + (Repository.LOGGED_IN_PLAYERS.size)) "update" -> SystemManager.flag(SystemState.UPDATING) "help","commands" -> printCommands() @@ -100,8 +106,8 @@ object Server { GlobalScope.launch { delay(20000) while(running){ - if(System.currentTimeMillis() - lastHeartbeat > 1800){ - running = false + if(System.currentTimeMillis() - lastHeartbeat > 1800 && running){ + SystemLogger.logErr("Triggering reboot due to heartbeat timeout") exitProcess(0) } delay(625) diff --git a/Server/src/main/kotlin/rs09/ServerStore.kt b/Server/src/main/kotlin/rs09/ServerStore.kt new file mode 100644 index 000000000..195a03c98 --- /dev/null +++ b/Server/src/main/kotlin/rs09/ServerStore.kt @@ -0,0 +1,120 @@ +package rs09 + +import org.json.simple.JSONArray +import org.json.simple.JSONObject +import org.json.simple.parser.JSONParser +import rs09.game.system.SystemLogger +import java.io.File +import java.io.FileReader +import java.io.FileWriter +import javax.script.ScriptEngineManager + +object ServerStore { + val fileMap = HashMap() + var counter = 0 + + fun init(){ + val dir = File(ServerConstants.DATA_PATH + File.separator + "serverstore") + if(!dir.exists()){ + dir.mkdirs() + return + } + + var parser: JSONParser + var reader: FileReader + + dir.listFiles()?.forEach { storeFile -> + val key = storeFile.nameWithoutExtension + + reader = FileReader(storeFile) + parser = JSONParser() + + try { + val data = parser.parse(reader) as JSONObject + fileMap[key] = data + counter++ + } catch (e: Exception){ + SystemLogger.logErr("Failed parsing ${storeFile.name} - stack trace below.") + e.printStackTrace() + return@forEach + } + } + } + + @JvmStatic + fun save() { + val dir = File(ServerConstants.DATA_PATH + File.separator + "serverstore") + if(!dir.exists()){ + dir.mkdirs() + return + } + + val manager = ScriptEngineManager() + val scriptEngine = manager.getEngineByName("JavaScript") + + fileMap.forEach { (name, data) -> + val path = dir.absolutePath + File.separator + name + ".json" + + scriptEngine.put("jsonString", data.toJSONString()) + scriptEngine.eval("result = JSON.stringify(JSON.parse(jsonString), null, 2)") + val prettyPrintedJson = scriptEngine["result"] as String + + FileWriter(path).use { it.write(prettyPrintedJson); it.flush(); it.close() } + } + } + + fun getArchive(name: String): JSONObject { + if(fileMap[name] == null){ + fileMap[name] = JSONObject() + } + + return fileMap[name]!! + } + + fun setArchive(name: String, data: JSONObject){ + fileMap[name] = data + } + + fun clearDailyEntries() { + fileMap.keys.toTypedArray().forEach { + if(it.toLowerCase().contains("daily")) fileMap[it]?.clear() + } + } + + fun clearWeeklyEntries() { + fileMap.keys.toTypedArray().forEach { + if(it.toLowerCase().contains("weekly")) fileMap[it]?.clear() + } + } + + fun JSONObject.getInt(key: String): Int { + return when(val value = this[key]){ + is Long -> value.toInt() + is Double -> value.toInt() + is Float -> value.toInt() + is Int -> value + is Nothing -> 0 + else -> 0 + } + } + + fun JSONObject.getString(key: String): String { + return this[key] as? String ?: "nothing" + } + + fun JSONObject.getLong(key: String): Long { + return this[key] as? Long ?: 0L + } + + fun JSONObject.getBoolean(key: String): Boolean { + return this[key] as? Boolean ?: false + } + + fun List.toJSONArray(): JSONArray{ + val jArray = JSONArray() + for(i in this){ + jArray.add(i) + } + return jArray + } +} \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/game/ai/minigamebots/pestcontrol/CombatState.kt b/Server/src/main/kotlin/rs09/game/ai/minigamebots/pestcontrol/CombatState.kt index 8a1245973..0adf3c315 100644 --- a/Server/src/main/kotlin/rs09/game/ai/minigamebots/pestcontrol/CombatState.kt +++ b/Server/src/main/kotlin/rs09/game/ai/minigamebots/pestcontrol/CombatState.kt @@ -44,7 +44,7 @@ class CombatState(val bot: PestControlTestBot) { if (bot.justStartedGame) { bot.customState = "Walking randomly" bot.justStartedGame = false - bot.randomWalkAroundPoint(getMyPestControlSession1(bot)?.squire?.location, 15) + bot.randomWalkAroundPoint(getMyPestControlSession1(bot)?.squire?.location ?: bot.location, 15) bot.movetimer = Random.nextInt(7) + 6 return } diff --git a/Server/src/main/kotlin/rs09/game/ai/minigamebots/pestcontrol/CombatStateIntermediate.kt b/Server/src/main/kotlin/rs09/game/ai/minigamebots/pestcontrol/CombatStateIntermediate.kt index 471760b59..8a313ccee 100644 --- a/Server/src/main/kotlin/rs09/game/ai/minigamebots/pestcontrol/CombatStateIntermediate.kt +++ b/Server/src/main/kotlin/rs09/game/ai/minigamebots/pestcontrol/CombatStateIntermediate.kt @@ -43,7 +43,7 @@ class CombatStateIntermediate(val bot: PestControlTestBot2) { if (bot.justStartedGame) { bot.customState = "Walking randomly" bot.justStartedGame = false - bot.randomWalkAroundPoint(getMyPestControlSession2(bot)?.squire?.location, 15) + bot.randomWalkAroundPoint(getMyPestControlSession2(bot)?.squire?.location ?: bot.location, 15) bot.movetimer = Random.nextInt(7) + 6 return } diff --git a/Server/src/main/kotlin/rs09/game/ai/minigamebots/pestcontrol/PestControlIntermediateBot.kt b/Server/src/main/kotlin/rs09/game/ai/minigamebots/pestcontrol/PestControlIntermediateBot.kt index 32c401132..3f19a5335 100644 --- a/Server/src/main/kotlin/rs09/game/ai/minigamebots/pestcontrol/PestControlIntermediateBot.kt +++ b/Server/src/main/kotlin/rs09/game/ai/minigamebots/pestcontrol/PestControlIntermediateBot.kt @@ -98,7 +98,10 @@ class PestControlTestBot2(l: Location) : PvMBots(legitimizeLocation(l)) { combathandler.goToPortals() } else { movetimer = RandomFunction.random(2,10) - randomWalkAroundPoint(PestControlHelper.getMyPestControlSession2(this)?.squire?.location,5) + val location = PestControlHelper.getMyPestControlSession2(this)?.squire?.location ?: location + if(location != null) { + randomWalkAroundPoint(location, 5) + } combathandler.fightNPCs() } } @@ -108,7 +111,7 @@ class PestControlTestBot2(l: Location) : PvMBots(legitimizeLocation(l)) { justStartedGame = true openedGate = false time = 0 - if (!prayer.active.isEmpty()) { + if (prayer.active.isNotEmpty()) { prayer.reset() } if (PestControlHelper.outsideGangplankContainsLoc2(getLocation())){ @@ -168,7 +171,7 @@ class PestControlTestBot2(l: Location) : PvMBots(legitimizeLocation(l)) { } var switch = false - fun toPC() { + private fun toPC() { time = 0 if (!switch) { this.teleport(PestControlHelper.PestControlLanderIntermediate)//.also { println("I was stuck ${this.username}") } diff --git a/Server/src/main/kotlin/rs09/game/ai/minigamebots/pestcontrol/PestControlNoviceBot.kt b/Server/src/main/kotlin/rs09/game/ai/minigamebots/pestcontrol/PestControlNoviceBot.kt index 2369a302a..df865908f 100644 --- a/Server/src/main/kotlin/rs09/game/ai/minigamebots/pestcontrol/PestControlNoviceBot.kt +++ b/Server/src/main/kotlin/rs09/game/ai/minigamebots/pestcontrol/PestControlNoviceBot.kt @@ -97,7 +97,7 @@ class PestControlTestBot(l: Location) : PvMBots(legitimizeLocation(l)){ combathandler.goToPortals() } else { movetimer = RandomFunction.random(2,10) - randomWalkAroundPoint(PestControlHelper.getMyPestControlSession1(this)?.squire?.location,5) + randomWalkAroundPoint(PestControlHelper.getMyPestControlSession1(this)?.squire?.location ?: location,5) combathandler.fightNPCs() } } diff --git a/Server/src/main/kotlin/rs09/game/content/activity/pestcontrol/PestControlHelper.kt b/Server/src/main/kotlin/rs09/game/content/activity/pestcontrol/PestControlHelper.kt index 372c52037..098a0091f 100644 --- a/Server/src/main/kotlin/rs09/game/content/activity/pestcontrol/PestControlHelper.kt +++ b/Server/src/main/kotlin/rs09/game/content/activity/pestcontrol/PestControlHelper.kt @@ -36,7 +36,7 @@ object PestControlHelper { return p.getAttribute("pc_zeal") != null } - enum class BoatInfo(var boatBorder: ZoneBorders, var outsideBoatBorder: ZoneBorders, var ladderId: Int) { + enum class BoatInfo(val boatBorder: ZoneBorders, val outsideBoatBorder: ZoneBorders, val ladderId: Int) { NOVICE(ZoneBorders(2660, 2638, 2663, 2643), ZoneBorders(2658, 2635, 2656, 2646), 14315), INTERMEDIATE(ZoneBorders(2638, 2642, 2641, 2647), ZoneBorders(2645, 2639, 2643, 2652), 25631), VETERAN(ZoneBorders(2632, 2649, 2635, 2654), ZoneBorders(2638, 2652, 2638, 2655), 25632); diff --git a/Server/src/main/kotlin/rs09/game/content/ame/RandomEventManager.kt b/Server/src/main/kotlin/rs09/game/content/ame/RandomEventManager.kt index 0b7df0592..7ace936e6 100644 --- a/Server/src/main/kotlin/rs09/game/content/ame/RandomEventManager.kt +++ b/Server/src/main/kotlin/rs09/game/content/ame/RandomEventManager.kt @@ -17,10 +17,15 @@ class RandomEventManager(val player: Player) { fun fireEvent(){ if(player.zoneMonitor.isRestricted(ZoneRestriction.RANDOM_EVENTS)){ + nextSpawn = GameWorld.ticks + 3000 return } val ame = RandomEvents.values().random() event = ame.npc.create(player,ame.loot,ame.type) + if(event!!.spawnLocation == null){ + nextSpawn = GameWorld.ticks + 3000 + return + } event!!.init() nextSpawn = GameWorld.ticks + DELAY_TICKS SystemLogger.logRE("Fired ${event!!.name} for ${player.username}") diff --git a/Server/src/main/kotlin/rs09/game/content/ame/RandomEvents.kt b/Server/src/main/kotlin/rs09/game/content/ame/RandomEvents.kt index 06e004b5c..546addf50 100644 --- a/Server/src/main/kotlin/rs09/game/content/ame/RandomEvents.kt +++ b/Server/src/main/kotlin/rs09/game/content/ame/RandomEvents.kt @@ -31,6 +31,7 @@ enum class RandomEvents(val npc: RandomEventNPC, val loot: WeightBasedTable? = n SURPRISE_EXAM(MysteriousOldManNPC(),"sexam"); var type: String = "" + private set constructor(npc: RandomEventNPC, type: String) : this(npc,null){ this.type = type diff --git a/Server/src/main/kotlin/rs09/game/content/ame/events/drilldemon/DrillDemonUtils.kt b/Server/src/main/kotlin/rs09/game/content/ame/events/drilldemon/DrillDemonUtils.kt index 9807f75fc..bc44624fe 100644 --- a/Server/src/main/kotlin/rs09/game/content/ame/events/drilldemon/DrillDemonUtils.kt +++ b/Server/src/main/kotlin/rs09/game/content/ame/events/drilldemon/DrillDemonUtils.kt @@ -25,6 +25,9 @@ object DrillDemonUtils { fun teleport(player: Player){ player.setAttribute(DD_KEY_RETURN_LOC,player.location) player.properties.teleportLocation = Location.create(3163, 4819, 0) + player.interfaceManager.closeDefaultTabs() + player.packetDispatch.sendInterfaceConfig(548, 69, true) + player.packetDispatch.sendInterfaceConfig(746, 12, true) ContentAPI.registerLogoutListener(player, "drilldemon"){p -> ContentAPI.teleport(p, player.getAttribute(DD_KEY_RETURN_LOC, p.location)) @@ -82,6 +85,9 @@ object DrillDemonUtils { player.removeAttribute(DD_KEY_TASK) player.removeAttribute(DD_CORRECT_OFFSET) player.removeAttribute(DD_CORRECT_COUNTER) + player.interfaceManager.openDefaultTabs() + player.packetDispatch.sendInterfaceConfig(548, 69, false) + player.packetDispatch.sendInterfaceConfig(746, 12, false) } fun animationForTask(task: Int): Animation { diff --git a/Server/src/main/kotlin/rs09/game/content/global/worldevents/penguinhns/LarryHandler.kt b/Server/src/main/kotlin/rs09/game/content/global/worldevents/penguinhns/LarryHandler.kt index e31a48ca4..8a5c30ec1 100644 --- a/Server/src/main/kotlin/rs09/game/content/global/worldevents/penguinhns/LarryHandler.kt +++ b/Server/src/main/kotlin/rs09/game/content/global/worldevents/penguinhns/LarryHandler.kt @@ -2,10 +2,12 @@ package rs09.game.content.global.worldevents.penguinhns import core.game.component.Component import core.game.content.dialogue.DialoguePlugin +import core.game.content.dialogue.FacialExpression import core.game.node.entity.player.Player import core.game.node.item.Item import core.game.system.task.Pulse import rs09.game.world.GameWorld +import rs09.tools.END_DIALOGUE class LarryHandler(player: Player? = null) : DialoguePlugin(player){ override fun open(vararg args: Any?): Boolean { @@ -19,7 +21,7 @@ class LarryHandler(player: Player? = null) : DialoguePlugin(player){ override fun handle(interfaceId: Int, buttonId: Int): Boolean { class HintPulse : Pulse(){ override fun pulse(): Boolean { - val hint = PenguinManager.penguins.random().hint + val hint = Penguin.values()[PenguinManager.penguins.random()].hint player.sendMessage("Here, I know one is...") player.sendMessage(hint) return true @@ -36,7 +38,13 @@ class LarryHandler(player: Player? = null) : DialoguePlugin(player){ 1 -> npc("Sure!").also { player.inventory.add(Item(13732));stage = 1000 } //Hint - 10 -> npc("Yes, but I will have to write it down","for you so these penguins don't overhear.").also { GameWorld.submit(HintPulse()); stage = 1000 } + 10 -> npc("Yes, give me just one moment...").also { stage++ } + + 11 -> { + val hint = Penguin.values()[PenguinManager.penguins.random()].hint + npcl(FacialExpression.FRIENDLY, "One is $hint") + stage = END_DIALOGUE + } //Point turn-in 20 -> if(player.getAttribute("phns:points",0) > 0) npc("Sure thing, what would you like to be","rewarded with?").also { stage++ } else npc("Uh, you don't have any points","to turn in.").also{stage = 1000} diff --git a/Server/src/main/kotlin/rs09/game/content/global/worldevents/penguinhns/NotebookHandler.kt b/Server/src/main/kotlin/rs09/game/content/global/worldevents/penguinhns/NotebookHandler.kt index 5a7e97b08..40424ea68 100644 --- a/Server/src/main/kotlin/rs09/game/content/global/worldevents/penguinhns/NotebookHandler.kt +++ b/Server/src/main/kotlin/rs09/game/content/global/worldevents/penguinhns/NotebookHandler.kt @@ -9,8 +9,7 @@ import core.plugin.Plugin class NotebookHandler : OptionHandler(){ override fun handle(player: Player?, node: Node?, option: String?): Boolean { val total = player?.getAttribute("phns:points",0) - val weekly = player?.getAttribute("phns:weekly",0) - player?.dialogueInterpreter?.sendDialogue("Total points: $total","Penguins spied this week: $weekly") + player?.dialogueInterpreter?.sendDialogue("Total points: $total") return true } diff --git a/Server/src/main/kotlin/rs09/game/content/global/worldevents/penguinhns/PenguinHNSEvent.kt b/Server/src/main/kotlin/rs09/game/content/global/worldevents/penguinhns/PenguinHNSEvent.kt index 8af9c1c4c..e28aa1c3d 100644 --- a/Server/src/main/kotlin/rs09/game/content/global/worldevents/penguinhns/PenguinHNSEvent.kt +++ b/Server/src/main/kotlin/rs09/game/content/global/worldevents/penguinhns/PenguinHNSEvent.kt @@ -1,6 +1,8 @@ package rs09.game.content.global.worldevents.penguinhns import core.game.system.task.Pulse +import org.json.simple.JSONObject +import rs09.ServerStore import rs09.game.content.global.worldevents.PluginSet import rs09.game.content.global.worldevents.WorldEvent import rs09.game.content.global.worldevents.WorldEvents @@ -16,7 +18,7 @@ class PenguinHNSEvent : WorldEvent("penguin-hns"){ } override fun checkTrigger(): Boolean { - return GameWorld.ticks - lastTrigger >= tickDelay + return PenguinManager.penguins.isEmpty() } override fun initialize() { @@ -26,24 +28,21 @@ class PenguinHNSEvent : WorldEvent("penguin-hns"){ PenguinSpyingHandler() ) super.initialize() - GameWorld.Pulser.submit(PenguinRegeneration()) + fireEvent() log("Penguin HNS initialized.") } override fun fireEvent() { - log("Reshuffling Penguins...") + log("Loading penguins...") manager.rebuildVars() lastTrigger = GameWorld.ticks - log("Penguins Reshuffled.") + log("Penguins loaded.") } - class PenguinRegeneration : Pulse(25){ - override fun pulse(): Boolean { - val event = WorldEvents.get("penguin-hns") - event ?: return true - - if(event.checkTrigger()) event.fireEvent() - return false + companion object { + @JvmStatic + fun getStoreFile() : JSONObject { + return ServerStore.getArchive("weekly-penguinhns") } } diff --git a/Server/src/main/kotlin/rs09/game/content/global/worldevents/penguinhns/PenguinManager.kt b/Server/src/main/kotlin/rs09/game/content/global/worldevents/penguinhns/PenguinManager.kt index d82a6833c..7fdd5bf62 100644 --- a/Server/src/main/kotlin/rs09/game/content/global/worldevents/penguinhns/PenguinManager.kt +++ b/Server/src/main/kotlin/rs09/game/content/global/worldevents/penguinhns/PenguinManager.kt @@ -1,28 +1,66 @@ package rs09.game.content.global.worldevents.penguinhns import core.game.node.entity.npc.NPC +import core.game.node.entity.player.Player import rs09.game.system.SystemLogger import core.game.world.map.Location +import org.json.simple.JSONArray +import org.json.simple.JSONObject +import rs09.ServerStore.toJSONArray import java.util.* class PenguinManager{ companion object { - var penguins = ArrayList() + var penguins: MutableList = ArrayList() var npcs = ArrayList() val spawner = PenguinSpawner() - var tagMapping = HashMap>() + var tagMapping: MutableMap = HashMap() + + fun registerTag(player: Player, location: Location){ + val ordinal = Penguin.forLocation(location)?.ordinal ?: -1 + if(tagMapping[ordinal] == null){ + tagMapping[ordinal] = JSONArray() + } + tagMapping[ordinal]?.add(player.username.toLowerCase()) + updateStoreFile() + } + + fun hasTagged(player: Player, location: Location): Boolean{ + return tagMapping[Penguin.forLocation(location)?.ordinal]?.contains(player.username.toLowerCase()) ?: false + } + + private fun updateStoreFile(){ + val jsonTags = JSONArray() + tagMapping.forEach { (ordinal,taggers) -> + SystemLogger.logInfo("$ordinal - ${taggers.first()}") + val tag = JSONObject() + tag["ordinal"] = ordinal + tag["taggers"] = taggers + jsonTags.add(tag) + } + + PenguinHNSEvent.getStoreFile()["tag-mapping"] = jsonTags + } } fun rebuildVars() { - for(p in npcs){ - p.clear() - p.isActive = false - } - npcs.clear() - penguins = spawner.spawnPenguins(6) - tagMapping.clear() - for(p in penguins){ - tagMapping.put(p.loc, ArrayList()) + if(PenguinHNSEvent.getStoreFile().isEmpty()) { + penguins = spawner.spawnPenguins(10) + PenguinHNSEvent.getStoreFile()["spawned-penguins"] = penguins.toJSONArray() + for (p in penguins) { + tagMapping.put(p, JSONArray()) + } + } else { + val spawnedOrdinals = (PenguinHNSEvent.getStoreFile()["spawned-penguins"] as JSONArray).map { it.toString().toInt() } + spawner.spawnPenguins(spawnedOrdinals) + + val storedTags = (PenguinHNSEvent.getStoreFile()["tag-mapping"] as? JSONArray)?.map { jRaw -> + val jObj = jRaw as JSONObject + jObj["ordinal"].toString().toInt() to (jObj["taggers"] as JSONArray) + }?.toMap()?.toMutableMap() ?: HashMap() + + tagMapping = storedTags + penguins = spawnedOrdinals.toMutableList() } } diff --git a/Server/src/main/kotlin/rs09/game/content/global/worldevents/penguinhns/PenguinSpawner.kt b/Server/src/main/kotlin/rs09/game/content/global/worldevents/penguinhns/PenguinSpawner.kt index 17f9f9263..ebcfec2a1 100644 --- a/Server/src/main/kotlin/rs09/game/content/global/worldevents/penguinhns/PenguinSpawner.kt +++ b/Server/src/main/kotlin/rs09/game/content/global/worldevents/penguinhns/PenguinSpawner.kt @@ -2,54 +2,66 @@ package rs09.game.content.global.worldevents.penguinhns import core.game.node.entity.npc.NPC import core.game.world.map.Location +import org.rs09.consts.NPCs import rs09.game.content.global.worldevents.WorldEvents class PenguinSpawner { - val CACTUS = 8107 - val CRATE = 8108 - val BARREL = 8104 - val BUSH = 8105 - val ROCK = 8109 - val TOADSTOOL = 8110 - class Penguin(val id: Int, val hint: String, val loc: Location) - val penguins = arrayListOf( - Penguin(CACTUS,"...located in the northern desert.",Location.create(3310, 3157, 0)), - Penguin(BUSH,"...located between Fremennik and barbarians.",Location.create(2532, 3588, 0)), - Penguin(BUSH,"...located where banana smugglers dwell.",Location.create(2740, 3233, 0)), - Penguin(BUSH,"...located south of Ardougne.",Location.create(2456, 3092, 0)), - Penguin(BUSH,"...located deep in the jungle.",Location.create(2832, 3053, 0)), - Penguin(ROCK,"...located where the Imperial Guard train.",Location.create(2852, 3578, 0)), - Penguin(ROCK,"...located in the kingdom of Misthalin.",Location.create(3356, 3416, 0)), - Penguin(CRATE,"...located in the kingdom of Misthalin.",Location.create(3112, 3332, 0)), - Penguin(BUSH,"...located where eagles fly.",Location.create(2326, 3516, 0)), - Penguin(BARREL,"...located where no weapons may go.",Location.create(2806, 3383, 0)), - Penguin(ROCK,"...located near some ogres.",Location.create(2631, 2980, 0)), - Penguin(BUSH,"...located south of Ardougne.",Location.create(2513, 3154, 0)), - Penguin(BUSH,"...located near a big tree surrounded by short people.",Location.create(2387, 3451, 0)), - Penguin(BUSH,"...located in the kingdom of Asgarnia.",Location.create(2951, 3511, 0)), - Penguin(ROCK,"...located in the Kingdom of Asgarnia.",Location.create(3013, 3501, 0)), - Penguin(ROCK,"...located between Fremennik and barbarians.",Location.create(2532, 3630, 0)), - Penguin(CRATE,"...located in the Kingdom of Misthalin.",Location.create(3305, 3508, 0)), - Penguin(TOADSTOOL,"...located in the kingdom of Misthalin.",Location.create(3156, 3178, 0)), - Penguin(BUSH,"...located in the northern desert.",Location.create(3350, 3311, 0)), - Penguin(BUSH,"...located somewhere in the kingdom of Kandarin.",Location.create(2633, 3501, 0)), - Penguin(BUSH,"...located south of Ardougne.",Location.create(2440, 3206, 0)), - Penguin(CACTUS,"...located in the southern desert.",Location.create(3259, 3052, 0)), - Penguin(BUSH,"...located where wizards study.",Location.create(3112, 3149, 0)), - Penguin(TOADSTOOL,"...located in the fairy realm.",Location.create(2409, 4462, 0)) - ) - fun spawnPenguins(amount: Int): ArrayList { - var event = WorldEvents.get("penguin-hns") as PenguinHNSEvent + fun spawnPenguins(amount: Int): ArrayList { var counter = 0 - val list = penguins.toMutableList() - val penguinList = ArrayList() + val availableOrdinals = (0 until Penguin.values().size).toMutableList() + val spawnedOrdinals = ArrayList() while(counter < amount){ - val peng = list.random() - penguinList.add(peng).also { NPC(peng.id,peng.loc).also {PenguinManager.npcs.add(it);it.isNeverWalks = true; it.isWalks = false}.init() } - list.remove(peng) + val peng = Penguin.values()[availableOrdinals.random()] + availableOrdinals.remove(peng.ordinal) + spawnedOrdinals.add(peng.ordinal) + NPC(peng.id,peng.location) + .also {PenguinManager.npcs.add(it);it.isNeverWalks = true; it.isWalks = false}.init() counter++ } - return penguinList + return spawnedOrdinals } -} \ No newline at end of file + + fun spawnPenguins(ordinals: List){ + ordinals.forEach { + val peng = Penguin.values()[it] + NPC(peng.id,peng.location) + .also { PenguinManager.npcs.add(it); it.isNeverWalks = true; it.isWalks = false }.init() + } + } +} + +enum class Penguin(val id: Int, val hint: String, val location: Location){ + CACTUS_1(NPCs.CACTUS_8107,"located in the northern desert.", Location(3310, 3157, 0)), + CACTUS_2(NPCs.CACTUS_8107,"located in the southern desert.",Location.create(3259, 3052, 0)), + BUSH_1(NPCs.BUSH_8105,"located between Fremennik and barbarians.",Location.create(2532, 3588, 0)), + BUSH_2(NPCs.BUSH_8105,"located where banana smugglers dwell.",Location.create(2740, 3233, 0)), + BUSH_3(NPCs.BUSH_8105,"located south of Ardougne.",Location.create(2456, 3092, 0)), + BUSH_4(NPCs.BUSH_8105,"located deep in the jungle.",Location.create(2832, 3053, 0)), + BUSH_5(NPCs.BUSH_8105,"located where eagles fly.",Location.create(2326, 3516, 0)), + BUSH_6(NPCs.BUSH_8105,"located south of Ardougne.",Location.create(2513, 3154, 0)), + BUSH_7(NPCs.BUSH_8105,"located near a big tree surrounded by short people.",Location.create(2387, 3451, 0)), + BUSH_8(NPCs.BUSH_8105,"located in the kingdom of Asgarnia.",Location.create(2951, 3511, 0)), + BUSH_9(NPCs.BUSH_8105,"located in the northern desert.",Location.create(3350, 3311, 0)), + BUSH_10(NPCs.BUSH_8105,"located somewhere in the kingdom of Kandarin.",Location.create(2633, 3501, 0)), + BUSH_11(NPCs.BUSH_8105,"located south of Ardougne.",Location.create(2440, 3206, 0)), + BUSH_12(NPCs.BUSH_8105,"located where wizards study.",Location.create(3112, 3149, 0)), + ROCK_1(NPCs.ROCK_8109,"located where the Imperial Guard train.",Location.create(2852, 3578, 0)), + ROCK_2(NPCs.ROCK_8109,"located in the kingdom of Misthalin.",Location.create(3356, 3416, 0)), + ROCK_3(NPCs.ROCK_8109,"located near some ogres.",Location.create(2631, 2980, 0)), + ROCK_4(NPCs.ROCK_8109,"located in the Kingdom of Asgarnia.",Location.create(3013, 3501, 0)), + ROCK_5(NPCs.ROCK_8109,"located between Fremennik and barbarians.",Location.create(2532, 3630, 0)), + CRATE_1(NPCs.CRATE_8108,"located in the kingdom of Misthalin.",Location.create(3112, 3332, 0)), + CRATE_2(NPCs.CRATE_8108,"located in the Kingdom of Misthalin.",Location.create(3305, 3508, 0)), + BARREL_1(NPCs.CRATE_8108,"located where no weapons may go.",Location.create(2806, 3383, 0)), + TOADSTOOL_1(NPCs.TOADSTOOL_8110,"located in the kingdom of Misthalin.",Location.create(3156, 3178, 0)), + TOADSTOOL_2(NPCs.TOADSTOOL_8110,"located in the fairy realm.",Location.create(2409, 4462, 0)); + + companion object { + private val locationMap = values().map { it.location.toString() to it }.toMap() + + fun forLocation(location: Location): Penguin?{ + return locationMap[location.toString()] + } + } +} diff --git a/Server/src/main/kotlin/rs09/game/content/global/worldevents/penguinhns/PenguinSpyingHandler.kt b/Server/src/main/kotlin/rs09/game/content/global/worldevents/penguinhns/PenguinSpyingHandler.kt index 7c078daad..cf90e6852 100644 --- a/Server/src/main/kotlin/rs09/game/content/global/worldevents/penguinhns/PenguinSpyingHandler.kt +++ b/Server/src/main/kotlin/rs09/game/content/global/worldevents/penguinhns/PenguinSpyingHandler.kt @@ -18,16 +18,17 @@ class PenguinSpyingHandler : PluginInteraction(8107,8108,8104,8105,8109,8110){ var stage = 0 val curPoints = player.getAttribute("phns:points",0) val weeklyPoints = player.getAttribute("phns:weekly",0) - val WEEKLY_CAP = 10 val ANIMATION = Animation(10355) override fun pulse(): Boolean { when(stage++){ 0 -> player.lock().also { player.animator.animate(ANIMATION) } - 1 -> player.sendMessage("You manage to spy on the penguin.").also { player.setAttribute("/save:phns:points",curPoints + 1);player.setAttribute("/save:phns:weekly",weeklyPoints + 1);player.unlock();} - 2 -> if(weeklyPoints + 1 >= WEEKLY_CAP) player.setAttribute("/save:phns:date", ((System.currentTimeMillis() * 0.001) + 604800).toLong()) - 3 -> return true + 1 -> player.sendMessage("You manage to spy on the penguin.").also { + player.setAttribute("/save:phns:points",curPoints + 1) + player.unlock() + } + 2 -> return true } return false } @@ -41,19 +42,12 @@ class PenguinSpyingHandler : PluginInteraction(8107,8108,8104,8105,8109,8110){ } } if(option?.name?.toLowerCase()?.equals("spy-on")!!){ - val currentDate = System.currentTimeMillis() * 0.001 - val playerDate: Long = player?.getAttribute("phns:date",0L)!! - if(currentDate < playerDate){ - player.sendMessage("You have already earned your maximum number of points this week.").also { return true } - } else if(playerDate != 0L){ - player.removeAttribute("phns:date") - player.removeAttribute("phns:weekly") - } - if(PenguinManager.tagMapping[npc?.location]?.contains(player.username)!!){ + player ?: return false + if(PenguinManager.hasTagged(player, npc!!.location)){ player.sendMessage("You've already tagged this penguin.") } else { GameWorld.submit(movePulse()) - PenguinManager.tagMapping[npc?.location]?.add(player.username) + PenguinManager.registerTag(player, npc!!.location) } return true } diff --git a/Server/src/main/kotlin/rs09/game/content/global/worldevents/shootingstar/ShootingStar.kt b/Server/src/main/kotlin/rs09/game/content/global/worldevents/shootingstar/ShootingStar.kt index 5c4d89176..f250d441a 100644 --- a/Server/src/main/kotlin/rs09/game/content/global/worldevents/shootingstar/ShootingStar.kt +++ b/Server/src/main/kotlin/rs09/game/content/global/worldevents/shootingstar/ShootingStar.kt @@ -5,6 +5,10 @@ import core.game.node.`object`.SceneryBuilder import core.game.node.entity.npc.NPC import core.game.node.entity.player.Player import core.game.world.map.Location +import rs09.ServerStore.getBoolean +import rs09.ServerStore.getInt +import rs09.ServerStore.getString +import rs09.game.system.SystemLogger import rs09.game.world.repository.Repository /** @@ -51,6 +55,7 @@ class ShootingStar(var level: ShootingStarType = ShootingStarType.values().rando var ticks = 0 var isSpawned = false var spriteSpawned = false + var firstStar = true /** * Degrades a ShootingStar (or removes the starObject and spawns a Star Sprite if it's the last star) @@ -62,12 +67,16 @@ class ShootingStar(var level: ShootingStarType = ShootingStarType.values().rando starSprite.location = starObject.location starSprite.init() spriteSpawned = true + ShootingStarEvent.getStoreFile().clear() return } level = getNextType() maxDust = level.totalStardust dustLeft = level.totalStardust + ShootingStarEvent.getStoreFile()["level"] = level.ordinal + ShootingStarEvent.getStoreFile()["isDiscovered"] = isDiscovered + val newStar = Scenery(level.objectId, starObject.location) SceneryBuilder.replace(starObject, newStar) starObject = newStar @@ -93,13 +102,26 @@ class ShootingStar(var level: ShootingStarType = ShootingStarType.values().rando * Rebuilds some of the variables with new information. */ fun rebuildVars(){ - level = ShootingStarType.values().random() - location = crash_locations.entries.random().key + if(firstStar && ShootingStarEvent.getStoreFile().isNotEmpty()){ + level = ShootingStarType.values()[ShootingStarEvent.getStoreFile().getInt("level")] + location = ShootingStarEvent.getStoreFile().getString("location") + isDiscovered = ShootingStarEvent.getStoreFile().getBoolean("isDiscovered") + } else { + level = ShootingStarType.values().random() + location = crash_locations.entries.random().key + isDiscovered = false + } + maxDust = level.totalStardust dustLeft = level.totalStardust starObject = Scenery(level.objectId, crash_locations.get(location)) - isDiscovered = false + + ShootingStarEvent.getStoreFile()["level"] = level.ordinal + ShootingStarEvent.getStoreFile()["location"] = location + ShootingStarEvent.getStoreFile()["isDiscovered"] = false + ticks = 0 + firstStar = false } fun clearSprite() { diff --git a/Server/src/main/kotlin/rs09/game/content/global/worldevents/shootingstar/ShootingStarEvent.kt b/Server/src/main/kotlin/rs09/game/content/global/worldevents/shootingstar/ShootingStarEvent.kt index ff11e467c..bbfe2df56 100644 --- a/Server/src/main/kotlin/rs09/game/content/global/worldevents/shootingstar/ShootingStarEvent.kt +++ b/Server/src/main/kotlin/rs09/game/content/global/worldevents/shootingstar/ShootingStarEvent.kt @@ -4,6 +4,8 @@ import core.game.content.global.worldevents.shootingstar.ScoreboardHandler import core.game.content.global.worldevents.shootingstar.ShootingStarScoreboard import core.game.content.global.worldevents.shootingstar.StarChartPlugin import core.game.system.task.Pulse +import org.json.simple.JSONObject +import rs09.ServerStore import rs09.game.content.global.worldevents.PluginSet import rs09.game.content.global.worldevents.WorldEvent import rs09.game.content.global.worldevents.WorldEvents @@ -81,4 +83,10 @@ class ShootingStarEvent : WorldEvent("shooting-stars") { return false //always returns false because it needs to run forever. } } + + companion object { + fun getStoreFile() : JSONObject { + return ServerStore.getArchive("shooting-star") + } + } } \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/game/content/global/worldevents/shootingstar/StarSpriteDialogue.kt b/Server/src/main/kotlin/rs09/game/content/global/worldevents/shootingstar/StarSpriteDialogue.kt index dfb237cb2..becbf5aa8 100644 --- a/Server/src/main/kotlin/rs09/game/content/global/worldevents/shootingstar/StarSpriteDialogue.kt +++ b/Server/src/main/kotlin/rs09/game/content/global/worldevents/shootingstar/StarSpriteDialogue.kt @@ -8,7 +8,10 @@ import core.game.node.entity.npc.NPC import core.game.node.entity.player.Player import core.game.node.item.Item import core.tools.RandomFunction +import org.json.simple.JSONObject import org.rs09.consts.Items +import rs09.ServerStore +import rs09.ServerStore.getBoolean import rs09.game.node.entity.state.newsys.states.ShootingStarState import rs09.tools.END_DIALOGUE import rs09.tools.secondsToTicks @@ -61,15 +64,15 @@ class StarSpriteDialogue(player: Player? = null) : DialoguePlugin(player) { override fun open(vararg args: Any): Boolean { npc = args[0] as NPC - if (player.getSavedData().getGlobalData().getStarSpriteDelay() > System.currentTimeMillis() || !player.getInventory().contains(ShootingStarOptionHandler.STAR_DUST, 1)) { - npc("Hello, strange creature.") - stage = 0 - } else if (ContentAPI.inInventory(player, Items.ANCIENT_BLUEPRINT_14651) && !ContentAPI.getAttribute(player, "star-ring:bp-shown", false)) { + if (ContentAPI.inInventory(player, Items.ANCIENT_BLUEPRINT_14651) && !ContentAPI.getAttribute(player, "star-ring:bp-shown", false)) { npcl(FacialExpression.NEUTRAL, "I see you got ahold of a blueprint of those silly old rings we used to make.") stage = 1000 } else if (ContentAPI.inInventory(player, Items.ANCIENT_BLUEPRINT_14651) && ContentAPI.getAttribute(player, "star-ring:bp-shown", false)) { - playerl(FacialExpression.HALF_ASKING, "So about those rings...") - stage = 2000 + playerl(FacialExpression.HALF_ASKING, "So about those rings...") + stage = 2000 + } else if (getStoreFile().getBoolean(player.username.toLowerCase()) || !player.getInventory().contains(ShootingStarOptionHandler.STAR_DUST, 1)) { + npc("Hello, strange creature.") + stage = 0 } else { npc("Thank you for helping me out of here.") stage = 50 @@ -193,7 +196,9 @@ class StarSpriteDialogue(player: Player? = null) : DialoguePlugin(player) { player.getInventory().add(Item(GOLD_ORE, goldOre), player) player.getInventory().add(Item(COINS, coins), player) npc("I have rewarded you by making it so you can mine", "extra ore for the next 15 minutes. Also, have $cosmicRunes", "cosmic runes, $astralRunes astral runes, $goldOre gold ore and $coins", "coins.") - player.getSavedData().getGlobalData().setStarSpriteDelay(System.currentTimeMillis() + TimeUnit.DAYS.toMillis(1)) + + getStoreFile()[player.username.toLowerCase()] = true //flag daily as completed + player.registerState("shooting-star")?.init() if(wearingRing){ @@ -271,4 +276,8 @@ class StarSpriteDialogue(player: Player? = null) : DialoguePlugin(player) { } } + fun getStoreFile(): JSONObject{ + return ServerStore.getArchive("daily-shooting-star") + } + } \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/game/content/jobs/JobManager.kt b/Server/src/main/kotlin/rs09/game/content/jobs/JobManager.kt index b405d407c..d9703f8ad 100644 --- a/Server/src/main/kotlin/rs09/game/content/jobs/JobManager.kt +++ b/Server/src/main/kotlin/rs09/game/content/jobs/JobManager.kt @@ -6,6 +6,9 @@ import core.game.node.entity.npc.NPC import core.game.node.entity.player.Player import core.game.node.item.GroundItemManager import core.game.node.item.Item +import org.json.simple.JSONObject +import rs09.ServerStore +import rs09.ServerStore.getInt import rs09.game.system.SystemLogger import java.util.concurrent.TimeUnit @@ -52,11 +55,6 @@ object JobManager { val amt = player.getAttribute("jobs:original_amount",0) val type = player.getAttribute("jobs:type",0) val jobId = player.getAttribute("jobs:id",0) - val dailyDone = player.getAttribute("jobs:dailyAmt",0) - if(dailyDone == 3){ - player.dialogueInterpreter.sendDialogue("You can only complete 3 jobs per day.") - return - } if(type == 0){ val it = Item(GatheringJobs.values()[jobId].itemId) var amount = player.inventory.getAmount(it) @@ -88,7 +86,11 @@ object JobManager { player.removeAttribute("jobs:amount") player.removeAttribute("jobs:original_amount") player.removeAttribute("jobs:type") - player.incrementAttribute("/save:jobs:dailyAmt",1) - System.out.println("Complete amount: ${player.getAttribute("jobs:dailyAmt",0)}") + + getStoreFile()[player.username.toLowerCase()] = getStoreFile().getInt(player.username.toLowerCase()) + 1 + } + + fun getStoreFile(): JSONObject { + return ServerStore.getArchive("daily-jobs-tracking") } } \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/game/content/jobs/WorkForInteractionListener.kt b/Server/src/main/kotlin/rs09/game/content/jobs/WorkForInteractionListener.kt index 2f7ace650..bfacf46eb 100644 --- a/Server/src/main/kotlin/rs09/game/content/jobs/WorkForInteractionListener.kt +++ b/Server/src/main/kotlin/rs09/game/content/jobs/WorkForInteractionListener.kt @@ -2,12 +2,17 @@ package rs09.game.content.jobs import GatheringJobs import SlayingJob +import api.ContentAPI import core.game.node.entity.npc.NPC import core.game.node.entity.player.Player import core.game.node.entity.player.link.diary.DiaryType import core.game.node.item.Item +import org.json.simple.JSONObject import org.rs09.consts.Items +import rs09.ServerStore +import rs09.ServerStore.getInt import rs09.game.interaction.InteractionListener +import rs09.game.system.SystemLogger import java.util.concurrent.TimeUnit /** @@ -58,9 +63,9 @@ class WorkForInteractionListener : InteractionListener() { var amount = 0 var jobId = 0 - if(player.getAttribute("jobs:reset_time",Long.MAX_VALUE) < System.currentTimeMillis()){ - player.setAttribute("/save:jobs:dailyAmt",0) - player.setAttribute("/save:jobs:reset_time",System.currentTimeMillis() + TimeUnit.HOURS.toMillis(24)) + if(JobManager.getStoreFile().getInt(player.username.toLowerCase()) == 3){ + ContentAPI.sendNPCDialogue(player, node.id,"You've hit your limit for the day. Come back tomorrow!") + return@on true } if(player.getAttribute("jobs:id",-1) != -1){ diff --git a/Server/src/main/kotlin/rs09/game/ge/GrandExchange.kt b/Server/src/main/kotlin/rs09/game/ge/GrandExchange.kt index 6933fc243..b5e3a3ae5 100644 --- a/Server/src/main/kotlin/rs09/game/ge/GrandExchange.kt +++ b/Server/src/main/kotlin/rs09/game/ge/GrandExchange.kt @@ -32,6 +32,11 @@ object GrandExchange : CallBack { while(true) { SystemLogger.logGE("Updating offers...") OfferManager.update() + if(OfferManager.dumpDatabase){ + SystemLogger.logGE("Saving GE...") + OfferManager.save() + OfferManager.dumpDatabase = false + } Thread.sleep(60_000) //sleep for 60 seconds } }.start() diff --git a/Server/src/main/kotlin/rs09/game/ge/OfferManager.kt b/Server/src/main/kotlin/rs09/game/ge/OfferManager.kt index 9042c7a7a..2c779ee7c 100644 --- a/Server/src/main/kotlin/rs09/game/ge/OfferManager.kt +++ b/Server/src/main/kotlin/rs09/game/ge/OfferManager.kt @@ -89,7 +89,7 @@ object OfferManager { if(file.exists() && file.length() != 0L) { val parser = JSONParser() - val reader: FileReader? = FileReader(DB_PATH) + val reader: FileReader = FileReader(DB_PATH) val saveFile = parser.parse(reader) as JSONObject offsetUID = saveFile["offsetUID"].toString().toLong() @@ -98,10 +98,6 @@ object OfferManager { val offers = saveFile["offers"] as JSONArray for (offer in offers) { val o = offer as JSONObject - // Copy all the bot offers from the file - if (o["playerUID"].toString().toInt() == 0) { - addBotOffer(o["itemId"].toString().toInt(), o["amount"].toString().toInt() - o["completedAmount"].toString().toInt()) - } val no = GrandExchangeOffer() no.itemID = o["itemId"].toString().toInt() no.sell = o["sale"] as Boolean @@ -126,7 +122,7 @@ object OfferManager { if(File(BOT_DB_PATH).exists()) { try { - val botReader: FileReader? = FileReader(BOT_DB_PATH) + val botReader: FileReader = FileReader(BOT_DB_PATH) val botSave = JSONParser().parse(botReader) as JSONObject if (botSave.containsKey("offers")) { val offers = botSave["offers"] as JSONArray @@ -136,6 +132,7 @@ object OfferManager { } } } catch (e: IOException) { + GE_OFFER_LOCK.unlock() SystemLogger.logWarn("Unable to load bot offers. Perhaps it doesn't exist?") } } @@ -220,18 +217,18 @@ object OfferManager { return false } OFFER_MAPPING.remove(offer.uid) - OFFERS_BY_ITEMID[offer.itemID]!!.remove(offer) + OFFERS_BY_ITEMID[offer.itemID]?.remove(offer) GE_OFFER_LOCK.unlock() return true } - fun addEntry(offer: GrandExchangeOffer){ + @Synchronized fun addEntry(offer: GrandExchangeOffer){ GE_OFFER_LOCK.lock() OFFER_MAPPING[offer.uid] = offer if (!OFFERS_BY_ITEMID.containsKey(offer.itemID)) { OFFERS_BY_ITEMID[offer.itemID] = mutableListOf() } - OFFERS_BY_ITEMID[offer.itemID]!!.add(offer) + OFFERS_BY_ITEMID[offer.itemID]?.add(offer) GE_OFFER_LOCK.unlock() } @@ -267,7 +264,7 @@ object OfferManager { for(entry in OFFER_MAPPING){ val offer = entry.value - if (offer.offerState == OfferState.REMOVED || entry.value.playerUID == PlayerDetails.getDetails("2009scape").uid) { + if (offer.offerState == OfferState.REMOVED) { continue } val o = JSONObject() @@ -330,6 +327,7 @@ object OfferManager { } } catch (e: Exception) { e.printStackTrace() + GE_OFFER_LOCK.unlock() } GE_OFFER_LOCK.unlock() } @@ -386,7 +384,6 @@ object OfferManager { if (!offer.isActive) { return } - GE_OFFER_LOCK.lock() for (o in OFFERS_BY_ITEMID[offer.itemID]!!) { if (o.sell != offer.sell && o.isActive) { exchange(offer, o) @@ -396,7 +393,6 @@ object OfferManager { } } buyFromBots(offer) - GE_OFFER_LOCK.unlock() } private fun getBuylimitAmount(offer: GrandExchangeOffer): Int { diff --git a/Server/src/main/kotlin/rs09/game/interaction/item/StarRingListener.kt b/Server/src/main/kotlin/rs09/game/interaction/item/StarRingListener.kt index d59350e4f..6f56800e6 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/item/StarRingListener.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/item/StarRingListener.kt @@ -5,7 +5,10 @@ import core.game.node.entity.player.Player import core.game.node.entity.player.link.TeleportManager import core.game.node.entity.skill.Skills import core.game.world.map.Location +import org.json.simple.JSONObject import org.rs09.consts.Items +import rs09.ServerStore +import rs09.ServerStore.getBoolean import rs09.game.content.dialogue.DialogueFile import rs09.game.content.global.worldevents.WorldEvents import rs09.game.content.global.worldevents.shootingstar.ShootingStar @@ -23,7 +26,7 @@ class StarRingListener : InteractionListener(){ if(star == null) ContentAPI.sendDialogue(player, "There is currently no active star.").also { return@on true } - if(ContentAPI.getAttribute(player, "ring-next-tele", 0L) > System.currentTimeMillis()){ + if(getStoreFile().getBoolean(player.username.toLowerCase())){ ContentAPI.sendDialogue(player, "The ring is still recharging.") return@on true } @@ -79,7 +82,13 @@ class StarRingListener : InteractionListener(){ fun teleport(player: Player, star: ShootingStar){ ContentAPI.teleport(player, star.crash_locations[star.location]!!.transform(0, -1, 0), TeleportManager.TeleportType.MINIGAME) - ContentAPI.setAttribute(player, "/save:ring-next-tele", System.currentTimeMillis() + TimeUnit.DAYS.toMillis(1)) + getStoreFile()[player.username.toLowerCase()] = true + } + } + + companion object { + fun getStoreFile(): JSONObject { + return ServerStore.getArchive("daily-star-ring") } } } \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/game/interaction/item/withitem/HaySackOnSpear.kt b/Server/src/main/kotlin/rs09/game/interaction/item/withitem/HaySackOnSpear.kt new file mode 100644 index 000000000..331f80cd3 --- /dev/null +++ b/Server/src/main/kotlin/rs09/game/interaction/item/withitem/HaySackOnSpear.kt @@ -0,0 +1,22 @@ +package rs09.game.interaction.item.withitem + +import api.Container +import api.ContentAPI +import org.rs09.consts.Items +import rs09.game.interaction.InteractionListener + +class HaySackOnSpear : InteractionListener() { + val HAYSACK = Items.HAY_SACK_6057 + val SPEAR = Items.BRONZE_SPEAR_1237 + + override fun defineListeners() { + onUseWith(ITEM, HAYSACK, SPEAR){ player, used, _ -> + if(ContentAPI.removeItem(player, used.asItem(), Container.INVENTORY)){ + ContentAPI.addItem(player, Items.HAY_SACK_6058, 1) + ContentAPI.sendMessage(player, "You stab the hay sack with a bronze spear") + ContentAPI.removeItem(player, SPEAR, Container.INVENTORY) + } + return@onUseWith true + } + } +} \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/game/interaction/item/withitem/WatermelonOnSack.kt b/Server/src/main/kotlin/rs09/game/interaction/item/withitem/WatermelonOnSack.kt new file mode 100644 index 000000000..be5dca0d7 --- /dev/null +++ b/Server/src/main/kotlin/rs09/game/interaction/item/withitem/WatermelonOnSack.kt @@ -0,0 +1,27 @@ +package rs09.game.interaction.item.withitem + +import api.Container +import api.ContentAPI +import core.game.node.entity.skill.Skills +import org.rs09.consts.Items +import rs09.game.interaction.InteractionListener + +class WatermelonOnSack : InteractionListener() { + val SACK = Items.HAY_SACK_6058 + val WATERMELON = Items.WATERMELON_5982 + + override fun defineListeners() { + onUseWith(ITEM, SACK, WATERMELON){player, used, _ -> + if(ContentAPI.getStatLevel(player, Skills.FARMING) >= 23){ + ContentAPI.removeItem(player,SACK, Container.INVENTORY) + ContentAPI.removeItem(player,WATERMELON,Container.INVENTORY) + ContentAPI.addItem(player, Items.SCARECROW_6059) + ContentAPI.rewardXP(player, Skills.FARMING, 25.0) + ContentAPI.sendMessage(player, "You stab the watermelon on top of the spear, finishing your scarecrow") + }else{ + ContentAPI.sendMessage(player, "Your Farming level is not high enough to do this") + } + return@onUseWith true + } + } +} \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/game/node/entity/combat/CombatSwingHandler.kt b/Server/src/main/kotlin/rs09/game/node/entity/combat/CombatSwingHandler.kt index 146453e8d..451b37126 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/combat/CombatSwingHandler.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/combat/CombatSwingHandler.kt @@ -77,11 +77,11 @@ abstract class CombatSwingHandler(var type: CombatStyle?) { /** * Calculates the maximum defence of the entity. - * @param entity The entity. + * @param victim The entity. * @param attacker The entity to defend against. * @return The maximum defence value. */ - abstract fun calculateDefence(entity: Entity?, attacker: Entity?): Int + abstract fun calculateDefence(victim: Entity?, attacker: Entity?): Int /** * Gets the void set multiplier. @@ -188,18 +188,17 @@ abstract class CombatSwingHandler(var type: CombatStyle?) { } val attack = calculateAccuracy(entity) * accuracyMod * mod * getSetMultiplier(entity, Skills.ATTACK) val defence = calculateDefence(victim, entity) * defenceMod * getSetMultiplier(victim, Skills.DEFENCE) - val chance: Double - chance = if (attack < defence) { - (attack - 1) / (defence * 2) + val chance: Double = if (attack > defence) { + 1 - ((defence + 2) / ((2 * attack) + 1)) } else { - 1 - (defence + 1) / (attack * 2) + attack / ((2 * defence) + 1) } val ratio = chance * 100 val accuracy = floor(ratio) val block = floor(101 - ratio) val acc = Math.random() * accuracy val def = Math.random() * block - return acc > def + return (acc > def).also { if(entity?.username?.toLowerCase() == "test10") SystemLogger.logInfo("Should hit: $it") } } /** diff --git a/Server/src/main/kotlin/rs09/game/node/entity/combat/handlers/MagicSwingHandler.kt b/Server/src/main/kotlin/rs09/game/node/entity/combat/handlers/MagicSwingHandler.kt index 84455411b..7fcfe518a 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/combat/handlers/MagicSwingHandler.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/combat/handlers/MagicSwingHandler.kt @@ -192,7 +192,7 @@ open class MagicSwingHandler val level = entity!!.skills.getLevel(Skills.MAGIC, true) val bonus = entity.properties.bonuses[if (entity is Player) 14 else 13] val cumulativeStr = level.toDouble() - return 1 + ((14 + cumulativeStr + bonus / 8 + cumulativeStr * bonus * 0.016865) * baseDamage).toInt() / 10 + return 1 + ((14 + cumulativeStr + bonus.toDouble() / 8 + cumulativeStr * bonus * 0.016865) * baseDamage).toInt() / 10 } var levelMod = 1.0 val entityMod = entity!!.getLevelMod(entity, victim) @@ -202,14 +202,14 @@ open class MagicSwingHandler return (baseDamage * levelMod).toInt() + 1 } - override fun calculateDefence(entity: Entity?, attacker: Entity?): Int { - val level = entity!!.skills.getLevel(Skills.DEFENCE, true) + override fun calculateDefence(victim: Entity?, attacker: Entity?): Int { + val level = victim!!.skills.getLevel(Skills.DEFENCE, true) var prayer = 1.0 - if (entity is Player) { - prayer += entity.prayer.getSkillBonus(Skills.MAGIC) + if (victim is Player) { + prayer += victim.prayer.getSkillBonus(Skills.MAGIC) } - val effective = floor(level * prayer * 0.3) + entity.skills.getLevel(Skills.MAGIC, true) * 0.7 - val equipment = entity.properties.bonuses[WeaponInterface.BONUS_MAGIC + 5] + val effective = floor(level * prayer * 0.3) + victim.skills.getLevel(Skills.MAGIC, true) * 0.7 + val equipment = victim.properties.bonuses[WeaponInterface.BONUS_MAGIC + 5] return floor((effective + 8) * (equipment + 64) / 10).toInt() } diff --git a/Server/src/main/kotlin/rs09/game/node/entity/combat/handlers/MeleeSwingHandler.kt b/Server/src/main/kotlin/rs09/game/node/entity/combat/handlers/MeleeSwingHandler.kt index 6128d4b84..ace2c1905 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/combat/handlers/MeleeSwingHandler.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/combat/handlers/MeleeSwingHandler.kt @@ -1,6 +1,7 @@ package rs09.game.node.entity.combat.handlers -import core.game.container.Container +import api.ContentAPI +import api.EquipmentSlot import core.game.container.impl.EquipmentContainer import core.game.content.quest.tutorials.tutorialisland.TutorialSession import core.game.content.quest.tutorials.tutorialisland.TutorialStage @@ -18,7 +19,6 @@ import core.game.node.entity.state.EntityState import core.game.world.map.path.Pathfinder import core.tools.RandomFunction import rs09.game.node.entity.combat.CombatSwingHandler -import rs09.game.node.entity.skill.skillcapeperks.SkillcapePerks import kotlin.math.floor /** @@ -72,7 +72,7 @@ open class MeleeSwingHandler if (state.armourEffect === ArmourSet.VERAC || isAccurateImpact(entity, victim, CombatStyle.MELEE)) { val max = calculateHit(entity, victim, 1.0) state.maximumHit = max - hit = RandomFunction.random(max) + hit = RandomFunction.random(max + 1) } state.estimatedHit = hit if(victim != null) { @@ -137,46 +137,36 @@ open class MeleeSwingHandler } override fun calculateAccuracy(entity: Entity?): Int { - val baseLevel = entity!!.skills.getStaticLevel(Skills.ATTACK) - var weaponRequirement = baseLevel - if (entity is Player) { - val weapon = entity.equipment[3] - weaponRequirement = weapon?.definition?.getRequirement(Skills.ATTACK) ?: 1 + //formula taken from wiki: https://oldschool.runescape.wiki/w/Damage_per_second/Melee#Step_six:_Calculate_the_hit_chance Yes I know it's old school. It's the best resource we have for potentially authentic formulae. + entity ?: return 0 + var effectiveAttackLevel = entity.skills.getLevel(Skills.ATTACK).toDouble() + if(entity is Player) effectiveAttackLevel = floor(effectiveAttackLevel + (entity.prayer.getSkillBonus(Skills.ATTACK) * effectiveAttackLevel)) + if(entity.properties.attackStyle.style == WeaponInterface.STYLE_ACCURATE) effectiveAttackLevel += 3 + else if(entity.properties.attackStyle.style == WeaponInterface.STYLE_CONTROLLED) effectiveAttackLevel += 1 + effectiveAttackLevel += 8 + if(entity is Player && entity.isWearingVoid(true)) effectiveAttackLevel *= 1.1 + effectiveAttackLevel = floor(effectiveAttackLevel) + effectiveAttackLevel *= (entity.properties.bonuses[entity.properties.attackStyle.bonusType] + 64) + + val helmetName = (if(entity is Player) ContentAPI.getItemFromEquipment(entity, EquipmentSlot.HAT)?.name ?: "null" else "null").toLowerCase() + val amuletName = (if(entity is Player) ContentAPI.getItemFromEquipment(entity, EquipmentSlot.AMULET)?.name ?: "null" else "null").toLowerCase() + val victimName = entity.properties.combatPulse.getVictim()?.name ?: "none" + + if (entity is Player //Slayer helm/ black mask + && (helmetName.contains("black mask") || helmetName.contains("slayer helm")) + && entity.slayer.task?.ids?.contains((entity.properties.combatPulse.getVictim()?.id ?: 0)) == true + ) { + effectiveAttackLevel *= 1.2 } - var weaponBonus = 0.0 - if (baseLevel > weaponRequirement) { - weaponBonus = (baseLevel - weaponRequirement) * .3 + + else if (entity is Player //Salve amulet + && (amuletName.contains("salve")) + && checkUndead(victimName) + ) { + effectiveAttackLevel *= 1.2 } - val style = entity.properties.attackStyle - var level = entity.skills.getLevel(Skills.ATTACK) - if(entity is Player && SkillcapePerks.isActive(SkillcapePerks.PRECISION_STRIKES,entity.asPlayer())){ - level += 6 - } - var prayer = 1.0 - if (entity is Player) { - prayer += entity.prayer.getSkillBonus(Skills.ATTACK) - } - var additional = 1.0 // Black mask/slayer helmet/salve/... - if (entity.properties.combatPulse.getVictim() != null) { - if (!entity.properties.combatPulse.getVictim()!!.isPlayer && entity is Player) { - if (checkUndead(entity.getProperties().combatPulse.getVictim()!!.name) && entity.asPlayer().equipment[EquipmentContainer.SLOT_AMULET] != null) { - if (entity.asPlayer().equipment[EquipmentContainer.SLOT_AMULET].id == 10588) { - additional += 0.20 - } else if (entity.isPlayer() && entity.asPlayer().equipment[EquipmentContainer.SLOT_AMULET].id == 4081) { - additional += 0.15 - } - } - } - } - var styleBonus = 0 - if (style.style == WeaponInterface.STYLE_ACCURATE) { - styleBonus = 3 - } else if (style.style == WeaponInterface.STYLE_CONTROLLED) { - styleBonus = 1 - } - val effective = floor(level * prayer * additional + styleBonus + weaponBonus) - val bonus = entity.properties.bonuses[style.bonusType] - return floor((effective + 8) * (bonus + 64) / 10 * 1.10).toInt() + + return floor(effectiveAttackLevel).toInt() } override fun calculateHit(entity: Entity?, victim: Entity?, modifier: Double): Int { @@ -193,26 +183,34 @@ open class MeleeSwingHandler cumulativeStr += 1.0 } cumulativeStr *= getSetMultiplier(entity, Skills.STRENGTH) - val hit = (16 + cumulativeStr + bonus / 8 + cumulativeStr * bonus * 0.016865) * modifier - return (hit / 10).toInt() + 1 + /*val hit = (16 + cumulativeStr + bonus / 8 + cumulativeStr * bonus * 0.016865) * modifier + return (hit / 10).toInt() + 1*/ + return (1.3 + (cumulativeStr / 10) + (bonus / 80) + ((cumulativeStr * bonus) / 640)).toInt() } - override fun calculateDefence(entity: Entity?, attacker: Entity?): Int { - val style = entity!!.properties.attackStyle - var styleBonus = 0 - if (style.style == WeaponInterface.STYLE_DEFENSIVE || style.style == WeaponInterface.STYLE_LONG_RANGE) { - styleBonus = 3 - } else if (style.style == WeaponInterface.STYLE_CONTROLLED) { - styleBonus = 1 + override fun calculateDefence(victim: Entity?, attacker: Entity?): Int { + //authentic formula, taken from OSRS wiki: https://oldschool.runescape.wiki/w/Damage_per_second/Melee#Step_five:_Calculate_the_Defence_roll + victim ?: return 0 + attacker ?: return 0 + + when(victim){ + is Player -> { + var effectiveDefenceLevel = victim.skills.getLevel(Skills.DEFENCE).toDouble() + effectiveDefenceLevel = floor(effectiveDefenceLevel + (victim.prayer.getSkillBonus(Skills.DEFENCE) * effectiveDefenceLevel)) + if(victim.properties.attackStyle.style == WeaponInterface.STYLE_DEFENSIVE) effectiveDefenceLevel += 3 + else if(victim.properties.attackStyle.style == WeaponInterface.STYLE_CONTROLLED) effectiveDefenceLevel += 1 + effectiveDefenceLevel += 8 + effectiveDefenceLevel = floor(effectiveDefenceLevel) + return floor(effectiveDefenceLevel * (victim.properties.bonuses[attacker.properties.attackStyle.bonusType + 5] + 64)).toInt() + } + is NPC -> { + val defLevel = victim.skills.getLevel(Skills.DEFENCE) + val styleDefenceBonus = victim.properties.bonuses[attacker.properties.attackStyle.bonusType + 5] + 64 + return defLevel * styleDefenceBonus + } } - val level = entity.skills.getLevel(Skills.DEFENCE) - var prayer = 1.0 - if (entity is Player) { - prayer += entity.prayer.getSkillBonus(Skills.DEFENCE) - } - val effective = floor(level * prayer + styleBonus) - val equipment = entity.properties.bonuses[attacker!!.properties.attackStyle.bonusType + 5] - return floor((effective + 8) * (equipment + 64) / 10).toInt() + + return 0 } override fun getSetMultiplier(e: Entity?, skillId: Int): Double { @@ -220,19 +218,6 @@ open class MeleeSwingHandler // System.out.println("Fiist number -> " + 1.0 + ((e.getSkills().getMaximumLifepoints() - e.getSkills().getLifepoints()) * 0.01)); return 1.0 + (e!!.skills.maximumLifepoints - e.skills.lifepoints) * 0.01 } - if (e is Player) { - val c: Container = e.equipment - val itemId = c.getNew(EquipmentContainer.SLOT_HAT).id - if ((skillId == Skills.ATTACK || skillId == Skills.STRENGTH) && (itemId in 8901..8921 || itemId == 13263)) { - val victim = e.getProperties().combatPulse.getVictim() - if (victim is NPC && victim.task == e.slayer.task) { - return 1.15 - } - } - if (containsVoidSet(c) && c.getNew(EquipmentContainer.SLOT_HAT).id == 11665) { - return 1.1 - } - } return 1.0 } diff --git a/Server/src/main/kotlin/rs09/game/node/entity/combat/handlers/MultiSwingHandler.kt b/Server/src/main/kotlin/rs09/game/node/entity/combat/handlers/MultiSwingHandler.kt index ff7220475..55be23dd5 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/combat/handlers/MultiSwingHandler.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/combat/handlers/MultiSwingHandler.kt @@ -139,8 +139,8 @@ open class MultiSwingHandler(meleeDistance: Boolean, vararg attacks: SwitchAttac } else current.handler.calculateHit(entity, victim, modifier) } - override fun calculateDefence(entity: Entity?, attacker: Entity?): Int { - return current.handler.calculateDefence(entity, attacker) + override fun calculateDefence(victim: Entity?, attacker: Entity?): Int { + return current.handler.calculateDefence(victim, attacker) } override fun getSetMultiplier(e: Entity?, skillId: Int): Double { diff --git a/Server/src/main/kotlin/rs09/game/node/entity/combat/handlers/RangeSwingHandler.kt b/Server/src/main/kotlin/rs09/game/node/entity/combat/handlers/RangeSwingHandler.kt index 777833444..4654597d9 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/combat/handlers/RangeSwingHandler.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/combat/handlers/RangeSwingHandler.kt @@ -1,5 +1,7 @@ package rs09.game.node.entity.combat.handlers +import api.ContentAPI +import api.EquipmentSlot import core.game.container.Container import core.game.container.impl.EquipmentContainer import core.game.content.quest.tutorials.tutorialisland.TutorialSession @@ -79,9 +81,9 @@ open class RangeSwingHandler } var hit = 0 if (isAccurateImpact(entity, victim, CombatStyle.RANGE)) { - val max = calculateHit(entity, victim, 1.0) + val max = calculateHit(entity, victim, 1.0).also { if(entity?.name?.toLowerCase() == "test10") SystemLogger.logInfo("Damage: $it") } state.maximumHit = max - hit = RandomFunction.random(max) + hit = RandomFunction.random(max + 1) } state.estimatedHit = hit if (state.weapon.type == WeaponType.DOUBLE_SHOT) { @@ -239,32 +241,16 @@ open class RangeSwingHandler } override fun calculateAccuracy(entity: Entity?): Int { - val baseLevel = entity!!.skills.getStaticLevel(Skills.RANGE) - var weaponRequirement = baseLevel - if (entity is Player) { - val weapon = entity.equipment[3] - weaponRequirement = weapon?.definition?.getRequirement(Skills.RANGE) ?: 1 - } - var weaponBonus = 0.0 - if (baseLevel > weaponRequirement) { - weaponBonus = (baseLevel - weaponRequirement) * .3 - } - val level = entity.skills.getLevel(Skills.RANGE) - var prayer = 1.0 - if (entity is Player) { - prayer += entity.prayer.getSkillBonus(Skills.RANGE) - } - var additional = 1.0 // Slayer helmet/salve/... - if(entity is Player && rs09.game.node.entity.skill.skillcapeperks.SkillcapePerks.isActive(rs09.game.node.entity.skill.skillcapeperks.SkillcapePerks.ACCURATE_MARKSMAN,entity.asPlayer())){ - additional += 0.5 - } - var styleBonus = 0 - if (entity.properties.attackStyle.style == WeaponInterface.STYLE_RANGE_ACCURATE) { - styleBonus = 3 - } - val effective = floor(level * prayer * additional + styleBonus + weaponBonus) - val bonus = entity.properties.bonuses[WeaponInterface.BONUS_RANGE] - return floor((effective + 8) * (bonus + 64) / 10).toInt() + entity ?: return 0 + var effectiveRangedLevel = entity.skills.getLevel(Skills.RANGE).toDouble() + if(entity is Player) effectiveRangedLevel = floor(effectiveRangedLevel + (entity.prayer.getSkillBonus(Skills.RANGE) * effectiveRangedLevel)) + if(entity.properties.attackStyle.style == WeaponInterface.STYLE_RANGE_ACCURATE) effectiveRangedLevel += 3 + effectiveRangedLevel += 8 + if(entity is Player && entity.isWearingVoid(false)) effectiveRangedLevel *= 1.1 + effectiveRangedLevel = floor(effectiveRangedLevel) + effectiveRangedLevel *= (entity.properties.bonuses[entity.properties.attackStyle.bonusType] + 64) + + return floor(effectiveRangedLevel).toInt() } override fun calculateHit(entity: Entity?, victim: Entity?, modifier: Double): Int { @@ -277,29 +263,20 @@ open class RangeSwingHandler var cumulativeStr = floor(level * prayer) if (entity.properties.attackStyle.style == WeaponInterface.STYLE_RANGE_ACCURATE) { cumulativeStr += 3.0 - } else if (entity.properties.attackStyle.style == WeaponInterface.STYLE_LONG_RANGE) { - cumulativeStr += 1.0 } cumulativeStr *= getSetMultiplier(entity, Skills.RANGE) - return ((14 + cumulativeStr + bonus / 8 + cumulativeStr * bonus * 0.016865) * modifier).toInt() / 10 + 1 + cumulativeStr *= (bonus + 64) + return floor(1.5 + (ceil(cumulativeStr) / 640.0)).toInt() + //return ((14 + cumulativeStr + bonus / 8 + cumulativeStr * bonus * 0.016865) * modifier).toInt() / 10 + 1 } - override fun calculateDefence(entity: Entity?, attacker: Entity?): Int { - val style = entity!!.properties.attackStyle - var styleBonus = 0 - if (style.style == WeaponInterface.STYLE_DEFENSIVE || style.style == WeaponInterface.STYLE_LONG_RANGE) { - styleBonus = 3 - } else if (style.style == WeaponInterface.STYLE_CONTROLLED) { - styleBonus = 1 - } - val level = entity.skills.getLevel(Skills.DEFENCE) - var prayer = 1.0 - if (entity is Player) { - prayer += entity.prayer.getSkillBonus(Skills.DEFENCE) - } - val effective = floor(level * prayer + styleBonus) - val equipment = entity.properties.bonuses[WeaponInterface.BONUS_RANGE + 5] - return floor((effective + 8) * (equipment + 64) / 10).toInt() + override fun calculateDefence(victim: Entity?, attacker: Entity?): Int { + victim ?: return 0 + attacker ?: return 0 + + val defLevel = victim.skills.getLevel(Skills.DEFENCE) + val styleDefenceBonus = victim.properties.bonuses[attacker.properties.attackStyle.bonusType + 5] + 64 + return defLevel * styleDefenceBonus } override fun getSetMultiplier(e: Entity?, skillId: Int): Double { diff --git a/Server/src/main/kotlin/rs09/game/node/entity/combat/handlers/SalamanderSwingHandler.kt b/Server/src/main/kotlin/rs09/game/node/entity/combat/handlers/SalamanderSwingHandler.kt index fd8514c59..6c9a676f3 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/combat/handlers/SalamanderSwingHandler.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/combat/handlers/SalamanderSwingHandler.kt @@ -58,8 +58,8 @@ class SalamanderSwingHandler(private var style: CombatStyle) : CombatSwingHandle } } - override fun calculateDefence(entity: Entity?, attacker: Entity?): Int { - return style.swingHandler.calculateDefence(entity, attacker) + override fun calculateDefence(victim: Entity?, attacker: Entity?): Int { + return style.swingHandler.calculateDefence(victim, attacker) } override fun getSetMultiplier(e: Entity?, skillId: Int): Double { diff --git a/Server/src/main/kotlin/rs09/game/node/entity/npc/other/BlastFurnaceOre.kt b/Server/src/main/kotlin/rs09/game/node/entity/npc/other/BlastFurnaceOre.kt new file mode 100644 index 000000000..31de1e91b --- /dev/null +++ b/Server/src/main/kotlin/rs09/game/node/entity/npc/other/BlastFurnaceOre.kt @@ -0,0 +1,76 @@ +package rs09.game.node.entity.npc.other + +import api.ContentAPI +import core.game.node.entity.npc.AbstractNPC +import core.game.node.entity.player.Player +import core.game.world.map.Location +import core.game.world.map.path.Pathfinder +import core.plugin.Initializable +import org.rs09.consts.NPCs + +@Initializable +class BlastFurnaceOre : AbstractNPC { + //Arios constructor spaghetti + constructor() : super(NPCs.COAL_2562, null, true) {} + private constructor(id: Int, location: Location) : super(id, location) {} + + constructor(owner: Player, variant: BFOreVariant) : super( + when(variant){ + BFOreVariant.COPPER -> NPCs.COPPER_ORE_2555 + BFOreVariant.TIN -> NPCs.TIN_ORE_2554 + BFOreVariant.COAL -> NPCs.COAL_2562 + BFOreVariant.MITHRIL -> NPCs.MITHRIL_ORE_2557 + BFOreVariant.ADAMANT -> NPCs.ADAMANTITE_ORE_2558 + BFOreVariant.SILVER -> NPCs.SILVER_ORE_2560 + BFOreVariant.GOLD -> NPCs.GOLD_ORE_2561 + BFOreVariant.PERFECT_GOLD -> NPCs.PERFECT_GOLD_ORE_2563 + BFOreVariant.RUNITE -> NPCs.RUNITE_ORE_2559 + }, Location.create(1942, 4966, 0)) {this.owner = owner; isRespawn = false} + + var owner: Player? = null + var delay = 2 + var counter = 2 + + override fun construct(id: Int, location: Location, vararg objects: Any): AbstractNPC { + return BlastFurnaceOre(id, location) + } + + override fun getIds(): IntArray { + return intArrayOf( + NPCs.COPPER_ORE_2555, + NPCs.TIN_ORE_2554, + NPCs.COAL_2562, + NPCs.MITHRIL_ORE_2557, + NPCs.ADAMANTITE_ORE_2558, + NPCs.SILVER_ORE_2560, + NPCs.GOLD_ORE_2561, + NPCs.PERFECT_GOLD_ORE_2563, + NPCs.RUNITE_ORE_2559) + } + + override fun handleTickActions() { + delay-- + if(delay <= 0 && ContentAPI.getWorldTicks() % 2 == 0) { //run every other tick + if(counter > 0){ + properties.teleportLocation = location.transform(0, -1, 0) + counter-- + } else { + //increment ore count, update interface, whatever you need to do here. + clear() + } + } + } + +} + +enum class BFOreVariant { + COPPER, + TIN, + COAL, + MITHRIL, + ADAMANT, + SILVER, + GOLD, + PERFECT_GOLD, + RUNITE +} \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/CompostBin.kt b/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/CompostBin.kt index f7a430719..eaf15ab7b 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/CompostBin.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/CompostBin.kt @@ -71,9 +71,21 @@ class CompostBin(val player: Player, val bin: CompostBins) { Items.JANGERBERRIES_247, Items.WHITE_BERRIES_239, Items.POISON_IVY_BERRIES_6018, + Items.CLEAN_TOADFLAX_2998, + Items.CLEAN_AVANTOE_261, + Items.CLEAN_KWUARM_263, + Items.CLEAN_CADANTINE_265, + Items.CLEAN_DWARF_WEED_267, + Items.CLEAN_TORSTOL_269, + Items.CLEAN_LANTADYME_2481, + Items.CLEAN_SNAPDRAGON_3000, + Items.GRIMY_TOADFLAX_3049, + Items.GRIMY_KWUARM_213, + Items.GRIMY_AVANTOE_211, Items.GRIMY_TORSTOL_219, Items.GRIMY_DWARF_WEED_217, Items.GRIMY_LANTADYME_2485, + Items.GRIMY_SNAPDRAGON_3051, Items.GRIMY_CADANTINE_215 -> true else -> false } diff --git a/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/FarmingPatch.kt b/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/FarmingPatch.kt index 703659303..26087b8cc 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/FarmingPatch.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/FarmingPatch.kt @@ -64,7 +64,9 @@ enum class FarmingPatch(val varpIndex: Int, val varpOffset: Int, val type: Patch KARAMJA_SPIRIT_TREE(507,16,PatchType.SPIRIT_TREE), //Other - DRAYNOR_BELLADONNA(512, 16, PatchType.BELLADONNA); + DRAYNOR_BELLADONNA(512, 16, PatchType.BELLADONNA), + ALKHARID_CACTUS(512, 0, PatchType.CACTUS), + EVIL_TURNIP(1171, 7, PatchType.EVIL_TURNIP); companion object { @JvmField diff --git a/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/FruitAndBerryPicker.kt b/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/FruitAndBerryPicker.kt index 1df49e318..9b4ed0d52 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/FruitAndBerryPicker.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/FruitAndBerryPicker.kt @@ -25,6 +25,7 @@ class FruitAndBerryPicker : OptionHandler() { SceneryDefinition.setOptionHandler("pick-leaf",this) SceneryDefinition.setOptionHandler("pick-from",this) SceneryDefinition.setOptionHandler("pick-fruit",this) + SceneryDefinition.setOptionHandler("pick-spine",this) return this } diff --git a/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/HealthChecker.kt b/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/HealthChecker.kt index 59df17019..6c0c840b7 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/HealthChecker.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/HealthChecker.kt @@ -25,7 +25,7 @@ class HealthChecker : OptionHandler(){ val patch = fPatch.getPatchFor(player) val type = patch.patch.type - if(type != PatchType.BUSH && type != PatchType.FRUIT_TREE && type != PatchType.TREE){ + if(type != PatchType.BUSH && type != PatchType.FRUIT_TREE && type != PatchType.TREE && type != PatchType.CACTUS){ player.sendMessage("This shouldn't be happening. Please report this.") return true } @@ -38,6 +38,7 @@ class HealthChecker : OptionHandler(){ PatchType.TREE -> patch.setCurrentState(patch.getCurrentState() + 1) PatchType.FRUIT_TREE -> patch.setCurrentState(patch.getCurrentState() - 14) PatchType.BUSH -> patch.setCurrentState(patch.plantable!!.value + patch.plantable!!.stages + 4) + PatchType.CACTUS -> patch.setCurrentState(patch.plantable!!.value + patch.plantable!!.stages + 3) else -> SystemLogger.logErr("Unreachable patch type from when(type) switch in HealthChecker.kt line 36") } diff --git a/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/Patch.kt b/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/Patch.kt index 285c2571c..19aae22ab 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/Patch.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/Patch.kt @@ -15,7 +15,7 @@ class Patch(val player: Player, val patch: FarmingPatch, var plantable: Plantabl fun setNewHarvestAmount() { if(patch.type == PatchType.ALLOTMENT){ harvestAmt = RandomFunction.random(4,17) - } else if(patch.type == PatchType.FLOWER) { + } else if(patch.type == PatchType.FLOWER || patch.type == PatchType.EVIL_TURNIP) { harvestAmt = when (plantable) { Plantable.LIMPWURT_SEED, Plantable.WOAD_SEED -> 3 else -> 1 @@ -51,6 +51,7 @@ class Patch(val player: Player, val patch: FarmingPatch, var plantable: Plantabl when(patch.type){ PatchType.FRUIT_TREE -> player.varpManager.get(patch.varpIndex).setVarbit(patch.varpOffset,plantable!!.value + plantable!!.stages + 20) PatchType.BUSH -> player.varpManager.get(patch.varpIndex).setVarbit(patch.varpOffset,250 + (plantable!!.ordinal - Plantable.REDBERRY_SEED.ordinal)) + PatchType.CACTUS -> player.varpManager.get(patch.varpIndex).setVarbit(patch.varpOffset, 31) else -> SystemLogger.logWarn("Invalid setting of isCheckHealth for patch type: " + patch.type.name) } } else { @@ -62,7 +63,7 @@ class Patch(val player: Player, val patch: FarmingPatch, var plantable: Plantabl PatchType.BUSH -> { if(isDead) player.varpManager.get(patch.varpIndex).setVarbit(patch.varpOffset,getBushDeathValue()) else if(isDiseased && !isDead) player.varpManager.get(patch.varpIndex).setVarbit(patch.varpOffset,getBushDiseaseValue()) - else player.varpManager.get(patch.varpIndex).setVarbit(patch.varpOffset, plantable?.value ?: 0 + currentGrowthStage) + //else player.varpManager.get(patch.varpIndex).setVarbit(patch.varpOffset, (plantable?.value ?: 0) + currentGrowthStage) } PatchType.TREE -> { if(isDead) player.varpManager.get(patch.varpIndex).setVarbit(patch.varpOffset + 7,1) @@ -77,6 +78,10 @@ class Patch(val player: Player, val patch: FarmingPatch, var plantable: Plantabl else if(isDiseased && !isDead) player.varpManager.get(patch.varpIndex).setVarbit(patch.varpOffset, getBelladonnaDiseaseValue()) else player.varpManager.get(patch.varpIndex).setVarbit(patch.varpOffset, (plantable?.value ?: 0) + currentGrowthStage) } + PatchType.CACTUS -> { + if(isDead) player.varpManager.get(patch.varpIndex).setVarbit(patch.varpOffset, getCactusDeathValue()) + else if(isDiseased && !isDead) player.varpManager.get(patch.varpIndex).setVarbit(patch.varpOffset, getCactusDiseaseValue()) + } else -> {} } } @@ -88,6 +93,7 @@ class Patch(val player: Player, val patch: FarmingPatch, var plantable: Plantabl when(patch.type){ PatchType.BUSH,PatchType.FRUIT_TREE -> player.varpManager.get(patch.varpIndex).setVarbit(patch.varpOffset,(plantable?.value ?: 0) + currentGrowthStage) PatchType.TREE -> player.varpManager.get(patch.varpIndex).clearBitRange(patch.varpOffset + 6, patch.varpOffset + 7) + PatchType.CACTUS -> player.varpManager.get(patch.varpIndex).setVarbit(patch.varpOffset, (plantable?.value ?: 0) + currentGrowthStage) else -> {} } updateBit() @@ -100,9 +106,9 @@ class Patch(val player: Player, val patch: FarmingPatch, var plantable: Plantabl private fun getBushDiseaseValue(): Int{ if(plantable == Plantable.POISON_IVY_SEED){ - return (plantable?.value ?: 0) + currentGrowthStage + 13 + return (plantable?.value ?: 0) + currentGrowthStage + 12 } else { - return (plantable?.value ?: 0) + currentGrowthStage + 65 + return (plantable?.value ?: 0) + currentGrowthStage + 64 } } @@ -130,6 +136,14 @@ class Patch(val player: Player, val patch: FarmingPatch, var plantable: Plantabl return (plantable?.value ?: 0) + currentGrowthStage + 7 } + private fun getCactusDiseaseValue(): Int { + return (plantable?.value ?: 0) + currentGrowthStage + 10 + } + + private fun getCactusDeathValue(): Int { + return (plantable?.value ?: 0) + currentGrowthStage + 16 + } + private fun grow(){ if(isWeedy() && getCurrentState() > 0) { nextGrowth = System.currentTimeMillis() + 60000 @@ -149,20 +163,20 @@ class Patch(val player: Player, val patch: FarmingPatch, var plantable: Plantabl CompostType.SUPER -> 13 } - if(RandomFunction.random(128) <= (17 - diseaseMod) && !isWatered && !isGrown() && !protectionPaid && !isFlowerProtected()){ - //bush, tree, fruit tree can not disease on stage 1(0) of growth. - if(!((patch.type == PatchType.BUSH || patch.type == PatchType.TREE || patch.type == PatchType.FRUIT_TREE) && currentGrowthStage == 0)) { + if(RandomFunction.random(128) <= (17 - diseaseMod) && !isWatered && !isGrown() && !protectionPaid && !isFlowerProtected() && patch.type != PatchType.EVIL_TURNIP){ + //bush, tree, fruit tree and cactus can not disease on stage 1(0) of growth. + if(!((patch.type == PatchType.BUSH || patch.type == PatchType.TREE || patch.type == PatchType.FRUIT_TREE || patch.type == PatchType.CACTUS) && currentGrowthStage == 0)) { isDiseased = true return } } - if((patch.type == PatchType.FRUIT_TREE || patch.type == PatchType.TREE || patch.type == PatchType.BUSH) && plantable != null && plantable?.stages == currentGrowthStage + 1){ + if((patch.type == PatchType.FRUIT_TREE || patch.type == PatchType.TREE || patch.type == PatchType.BUSH || patch.type == PatchType.CACTUS) && plantable != null && plantable?.stages == currentGrowthStage + 1){ isCheckHealth = true } - if((patch.type == PatchType.FRUIT_TREE || patch.type == PatchType.BUSH) && plantable?.stages == currentGrowthStage){ - if((patch.type == PatchType.BUSH && getFruitOrBerryCount() < 4) || (patch.type == PatchType.FRUIT_TREE && getFruitOrBerryCount() < 6)){ + if((patch.type == PatchType.FRUIT_TREE || patch.type == PatchType.BUSH || patch.type == PatchType.CACTUS) && plantable?.stages == currentGrowthStage){ + if((patch.type == PatchType.BUSH && getFruitOrBerryCount() < 4) || (patch.type == PatchType.FRUIT_TREE && getFruitOrBerryCount() < 6) || (patch.type == PatchType.CACTUS && getFruitOrBerryCount() < 3)){ setCurrentState(getCurrentState() + 1) } } diff --git a/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/PatchType.kt b/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/PatchType.kt index bd66f56a8..7de600039 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/PatchType.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/PatchType.kt @@ -9,5 +9,7 @@ enum class PatchType(val stageGrowthTime: Int) { FLOWER(5), HERB(20), SPIRIT_TREE(293), - BELLADONNA(80) + BELLADONNA(80), + CACTUS(60), + EVIL_TURNIP(5) } \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/Plantable.kt b/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/Plantable.kt index 5de521b1f..8cf594791 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/Plantable.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/Plantable.kt @@ -76,7 +76,9 @@ enum class Plantable(val itemID: Int, val value: Int, val stages: Int, val plant TORSTOL_SEED(5304,103,4,199.5,224.5,0.0,85,PatchType.HERB,Items.GRIMY_TORSTOL_219), //Other - BELLADONNA_SEED(5281, 4, 4, 91.0, 128.0, 0.0, 63, PatchType.BELLADONNA, Items.CAVE_NIGHTSHADE_2398) + BELLADONNA_SEED(5281, 4, 4, 91.0, 128.0, 0.0, 63, PatchType.BELLADONNA, Items.CAVE_NIGHTSHADE_2398), + CACTUS_SEED(Items.CACTUS_SEED_5280, 8, 7, 66.5, 25.0, 374.0, 55, PatchType.CACTUS, Items.CACTUS_SPINE_6016), + EVIL_TURNIP_SEED(Items.EVIL_TURNIP_SEED_12148, 4, 1, 41.0, 46.0, 0.0, 42, PatchType.EVIL_TURNIP, Items.EVIL_TURNIP_12134) ; constructor(itemID: Int, value: Int, stages: Int, plantingXP: Double, harvestXP: Double, checkHealthXP: Double, requiredLevel: Int, applicablePatch: PatchType, harvestItem: Int, protectionFlower: Plantable) diff --git a/Server/src/main/kotlin/rs09/game/node/entity/skill/gather/mining/MiningSkillPulse.kt b/Server/src/main/kotlin/rs09/game/node/entity/skill/gather/mining/MiningSkillPulse.kt index e8427ea64..9e401b01c 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/skill/gather/mining/MiningSkillPulse.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/skill/gather/mining/MiningSkillPulse.kt @@ -184,7 +184,7 @@ class MiningSkillPulse(private val player: Player, private val node: Node) : Pul altered = true } if (RandomFunction.roll(chance)) { - val gem = RandomFunction.rollChanceTable(true, *GEM_REWARDS)[0] + val gem = GEM_REWARDS.random() player.packetDispatch.sendMessage("You find a " + gem.name + "!") if (!player.inventory.add(gem, player)) { player.packetDispatch.sendMessage("You do not have enough space in your inventory, so you drop the gem on the floor.") diff --git a/Server/src/main/kotlin/rs09/game/node/entity/skill/runecrafting/abyss/AbyssPlugin.kt b/Server/src/main/kotlin/rs09/game/node/entity/skill/runecrafting/abyss/AbyssPlugin.kt index d3342ea4a..df625a63a 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/skill/runecrafting/abyss/AbyssPlugin.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/skill/runecrafting/abyss/AbyssPlugin.kt @@ -26,9 +26,11 @@ import rs09.game.world.GameWorld */ class AbyssPlugin : InteractionListener() { - val OBSTACLE = AbbysalObstacle.values().filter { it != AbbysalObstacle.MINE && it != AbbysalObstacle.SQUEEZE }.map { it.option }.toTypedArray() + val OBSTACLE = AbbysalObstacle.values().filter { it != AbbysalObstacle.MINE && it != AbbysalObstacle.SQUEEZE && it != AbbysalObstacle.PASSAGE && it != AbbysalObstacle.CHOP }.map { it.option }.toTypedArray() val miningObstacle = 7158 val agilityObstacle = 7164 + val passage = 7154 + val chopObstacle = 7161 override fun defineListeners() { definePlugin(AbyssalNPC()) @@ -62,7 +64,16 @@ class AbyssPlugin : InteractionListener() { obstacle!!.handle(player, node as Scenery) return@on true } - + on(passage, SCENERY, "go-through",){ player, node -> + val obstacle = AbbysalObstacle.forObject(node as Scenery) + obstacle!!.handle(player, node as Scenery) + return@on true + } + on(chopObstacle, SCENERY, "chop"){ player, node -> + val obstacle = AbbysalObstacle.forObject(node as Scenery) + obstacle!!.handle(player, node as Scenery) + return@on true + } } @@ -75,7 +86,7 @@ class AbyssPlugin : InteractionListener() { /** * Represents the option. */ - var option: String, + val option: String, /** * Represents the corssing location. */ @@ -434,15 +445,6 @@ class AbyssPlugin : InteractionListener() { } else player.inventory.contains(tool.getId(), 1) } } - - /** - * Constructs a new `RunecraftingOptionPlugin` `Object`. - * @param locations the locations. - * @param objects the objects. - */ - init { - option = option - } } companion object { diff --git a/Server/src/main/kotlin/rs09/game/node/entity/skill/thieving/Pickpockets.kt b/Server/src/main/kotlin/rs09/game/node/entity/skill/thieving/Pickpockets.kt index f2c5b8647..8fe2b811c 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/skill/thieving/Pickpockets.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/skill/thieving/Pickpockets.kt @@ -93,37 +93,44 @@ enum class Pickpockets(val ids: IntArray, val requiredLevel: Int, val low: Doubl WeightedItem(Items.IRON_ORE_441,1,4,0.25) )), MASTER_FARMER(intArrayOf(2234, 2235, NPCs.MARTIN_THE_MASTER_GARDENER_3299), 38, 90.0, 240.0, 43.0, 3, 3, 5, WeightBasedTable.create( - WeightedItem(Items.POTATO_SEED_5318,1,4,100.0), - WeightedItem(Items.HAMMERSTONE_SEED_5307,1,9,100.0), - WeightedItem(Items.ASGARNIAN_SEED_5308,1,6,95.0), - WeightedItem(Items.JUTE_SEED_5306,1,9,93.0), - WeightedItem(Items.YANILLIAN_SEED_5309,1,6,86.0), - WeightedItem(Items.KRANDORIAN_SEED_5310,1,6,80.0), - WeightedItem(Items.WILDBLOOD_SEED_5311,1,3,76.0), - WeightedItem(Items.MARIGOLD_SEED_5096,1,1,93.0), - WeightedItem(Items.NASTURTIUM_SEED_5098,1,1,90.0), - WeightedItem(Items.ROSEMARY_SEED_5097,1,1,78.0), - WeightedItem(Items.WOAD_SEED_5099,1,1,75.0), - WeightedItem(Items.LIMPWURT_SEED_5100,1,1,70.0), + WeightedItem(Items.POTATO_SEED_5318,1,3,50.0), + WeightedItem(Items.ONION_SEED_5319,1,3,50.0), + WeightedItem(Items.CABBAGE_SEED_5324,1,3,50.0), + WeightedItem(Items.TOMATO_SEED_5322,1,2,50.0), + WeightedItem(Items.SWEETCORN_SEED_5320,1,2,50.0), + WeightedItem(Items.STRAWBERRY_SEED_5323,1,1,25.0), + WeightedItem(Items.WATERMELON_SEED_5321,1,1,8.0), + WeightedItem(Items.BARLEY_SEED_5305,1,4,50.0), + WeightedItem(Items.HAMMERSTONE_SEED_5307,1,3,50.0), + WeightedItem(Items.ASGARNIAN_SEED_5308,1,3,50.0), + WeightedItem(Items.JUTE_SEED_5306,1,3,50.0), + WeightedItem(Items.YANILLIAN_SEED_5309,1,2,25.0), + WeightedItem(Items.KRANDORIAN_SEED_5310,1,2,25.0), + WeightedItem(Items.WILDBLOOD_SEED_5311,1,1,8.0), + WeightedItem(Items.MARIGOLD_SEED_5096,1,1,50.0), + WeightedItem(Items.NASTURTIUM_SEED_5098,1,1,50.0), + WeightedItem(Items.ROSEMARY_SEED_5097,1,1,50.0), + WeightedItem(Items.WOAD_SEED_5099,1,1,50.0), + WeightedItem(Items.LIMPWURT_SEED_5100,1,1,25.0), WeightedItem(Items.REDBERRY_SEED_5101,1,1,50.0), WeightedItem(Items.CADAVABERRY_SEED_5102,1,1,50.0), - WeightedItem(Items.DWELLBERRY_SEED_5103,1,1,50.0), - WeightedItem(Items.JANGERBERRY_SEED_5104,1,1,50.0), - WeightedItem(Items.WHITEBERRY_SEED_5105,1,1,50.0), - WeightedItem(Items.GUAM_SEED_5291,1,1,30.0), - WeightedItem(Items.MARRENTILL_SEED_5292,1,1,30.0), - WeightedItem(Items.TARROMIN_SEED_5293,1,1,30.0), - WeightedItem(Items.HARRALANDER_SEED_5294,1,1,30.0), - WeightedItem(Items.RANARR_SEED_5295,1,1,10.0), - WeightedItem(Items.TOADFLAX_SEED_5296,1,1,10.0), - WeightedItem(Items.IRIT_SEED_5297,1,1,10.0), - WeightedItem(Items.AVANTOE_SEED_5298,1,1,5.0), - WeightedItem(Items.KWUARM_SEED_5299,1,1,5.0), - WeightedItem(Items.SNAPDRAGON_SEED_5300,1,1,3.0), - WeightedItem(Items.CADANTINE_SEED_5301,1,1,3.0), - WeightedItem(Items.LANTADYME_SEED_5302,1,1,3.0), - WeightedItem(Items.DWARF_WEED_SEED_5303,1,1,3.0), - WeightedItem(Items.TORSTOL_SEED_5304,1,1,3.0) + WeightedItem(Items.DWELLBERRY_SEED_5103,1,1,25.0), + WeightedItem(Items.JANGERBERRY_SEED_5104,1,1,25.0), + WeightedItem(Items.WHITEBERRY_SEED_5105,1,1,25.0), + WeightedItem(Items.GUAM_SEED_5291,1,1,50.0), + WeightedItem(Items.MARRENTILL_SEED_5292,1,1,50.0), + WeightedItem(Items.TARROMIN_SEED_5293,1,1,50.0), + WeightedItem(Items.HARRALANDER_SEED_5294,1,1,25.0), + WeightedItem(Items.RANARR_SEED_5295,1,1,8.0), + WeightedItem(Items.TOADFLAX_SEED_5296,1,1,8.0), + WeightedItem(Items.IRIT_SEED_5297,1,1,8.0), + WeightedItem(Items.AVANTOE_SEED_5298,1,1,8.0), + WeightedItem(Items.KWUARM_SEED_5299,1,1,8.0), + WeightedItem(Items.SNAPDRAGON_SEED_5300,1,1,5.0), + WeightedItem(Items.CADANTINE_SEED_5301,1,1,8.0), + WeightedItem(Items.LANTADYME_SEED_5302,1,1,5.0), + WeightedItem(Items.DWARF_WEED_SEED_5303,1,1,5.0), + WeightedItem(Items.TORSTOL_SEED_5304,1,1,5.0) )), GUARD(intArrayOf(9, 32, 206, 296, 297, 298, 299, 344, 345, 346, 368, 678, 812, 9, 32, 296, 297, 298, 299, 2699, 2700, 2701, 2702, 2703, 3228, 3229, 3230, 3231, 3232, 3233, 3241, 3407, 3408, 4307, 4308, 4309, 4310, 4311, 5919, 5920), 40, 50.0, 240.0, 46.5, 2,2,5, WeightBasedTable.create( WeightedItem(Items.COINS_995,30,30,1.0,true) diff --git a/Server/src/main/kotlin/rs09/game/system/SystemLogger.kt b/Server/src/main/kotlin/rs09/game/system/SystemLogger.kt index 61755329d..a51547784 100644 --- a/Server/src/main/kotlin/rs09/game/system/SystemLogger.kt +++ b/Server/src/main/kotlin/rs09/game/system/SystemLogger.kt @@ -29,8 +29,10 @@ object SystemLogger { @JvmStatic() fun flushLogs() { - tradeLogWriter?.flush() - tradeLogWriter?.close() + try { + tradeLogWriter?.flush() + tradeLogWriter?.close() + } catch(ignored: Exception) {} } fun getTime(): String{ @@ -76,10 +78,12 @@ object SystemLogger { @JvmStatic fun logTrade(message: String){ - if(message.isNotBlank()){ - if(tradeLogWriter == null) logWarn("Trade Logger is null!") - tradeLogWriter?.write("${getTime()}: $message") - tradeLogWriter?.newLine() - } + try { + if (message.isNotBlank()) { + if (tradeLogWriter == null) logWarn("Trade Logger is null!") + tradeLogWriter?.write("${getTime()}: $message") + tradeLogWriter?.newLine() + } + } catch(ignored: Exception){} } } \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/game/system/command/sets/SystemCommandSet.kt b/Server/src/main/kotlin/rs09/game/system/command/sets/SystemCommandSet.kt index e6f82a794..53a35f777 100644 --- a/Server/src/main/kotlin/rs09/game/system/command/sets/SystemCommandSet.kt +++ b/Server/src/main/kotlin/rs09/game/system/command/sets/SystemCommandSet.kt @@ -12,6 +12,7 @@ import core.plugin.Initializable import org.rs09.consts.Items import rs09.game.system.command.Command import rs09.game.world.repository.Repository +import kotlin.system.exitProcess @Initializable class SystemCommandSet : CommandSet(Command.Privilege.ADMIN) { @@ -233,5 +234,9 @@ class SystemCommandSet : CommandSet(Command.Privilege.ADMIN) { player.inventory.add(Item(Items.ROTTEN_POTATO_5733)) } + define("shutdown",Command.Privilege.ADMIN) { player, _ -> + exitProcess(0) + } + } } \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/game/world/GameWorld.kt b/Server/src/main/kotlin/rs09/game/world/GameWorld.kt index ba4d60c62..5005ce006 100644 --- a/Server/src/main/kotlin/rs09/game/world/GameWorld.kt +++ b/Server/src/main/kotlin/rs09/game/world/GameWorld.kt @@ -1,7 +1,7 @@ package rs09.game.world import core.cache.Cache -import core.cache.ServerStore +import core.cache.AriosStore import core.cache.def.impl.SceneryDefinition import core.game.ge.GrandExchangeDatabase import core.game.node.entity.npc.drop.RareDropTable @@ -25,6 +25,7 @@ import rs09.game.world.callback.CallbackHub import rs09.game.world.repository.Repository import rs09.plugin.PluginManager import rs09.worker.MajorUpdateWorker +import java.text.SimpleDateFormat import java.util.* import java.util.function.Consumer @@ -90,11 +91,9 @@ object GameWorld { } } - private fun checkDay(): Boolean { - val calendar = Calendar.getInstance(TimeZone.getTimeZone("America/Toronto")) - val day = calendar[Calendar.DAY_OF_WEEK] - val hour = calendar[Calendar.HOUR_OF_DAY] - return day == Calendar.SATURDAY && hour == 1 || day == Calendar.SUNDAY && hour == 1 || day == Calendar.TUESDAY && hour == 10 + fun checkDay(): Int { + val weeklySdf = SimpleDateFormat("u") + return weeklySdf.format(Date()).toInt() } /** @@ -131,7 +130,7 @@ object GameWorld { fun prompt(run: Boolean, directory: String?){ SystemLogger.logInfo("Prompting ${settings?.name} Game World...") Cache.init(ServerConstants.CACHE_PATH) - ServerStore.init(ServerConstants.STORE_PATH) + AriosStore.init(ServerConstants.STORE_PATH) databaseManager = DatabaseManager(ServerConstants.DATABASE) databaseManager!!.connect() GrandExchangeDatabase.init() diff --git a/Server/src/main/kotlin/rs09/game/world/repository/DisconnectionQueue.kt b/Server/src/main/kotlin/rs09/game/world/repository/DisconnectionQueue.kt index d29538d6d..864d2663e 100644 --- a/Server/src/main/kotlin/rs09/game/world/repository/DisconnectionQueue.kt +++ b/Server/src/main/kotlin/rs09/game/world/repository/DisconnectionQueue.kt @@ -37,6 +37,11 @@ class DisconnectionQueue { } } + + fun isEmpty(): Boolean{ + return queue.isEmpty() + } + /** * Finishes a disconnection. * @param entry The entry. @@ -48,6 +53,7 @@ class DisconnectionQueue { return false } if (entry.isClear) { + SystemLogger.logInfo("Clearing player...") player.clear() } Repository.playerNames.remove(player.name) @@ -56,8 +62,10 @@ class DisconnectionQueue { Repository.LOGGED_IN_PLAYERS.remove(player.details.username) SystemLogger.logInfo("Player cleared. Removed ${player.details.username}") try { - player.communication.clan.leave(player, false) + if(player.communication.clan != null) + player.communication.clan.leave(player, false) } catch (e: Exception) { + e.printStackTrace() } if (player.isArtificial) { return true @@ -189,8 +197,8 @@ class DisconnectionQueue { if (sql) { player.details.sqlManager.update(player) player.details.save() - SQLEntryHandler.write(HighscoreSQLHandler(player)) - SQLEntryHandler.write(PlayerLogSQLHandler(player.monitor, player.name)) + /*SQLEntryHandler.write(HighscoreSQLHandler(player)) + SQLEntryHandler.write(PlayerLogSQLHandler(player.monitor, player.name))*/ } return true } catch (t: Throwable) { diff --git a/Server/src/main/kotlin/rs09/plugin/PluginManager.kt b/Server/src/main/kotlin/rs09/plugin/PluginManager.kt index f579146e7..879cd45b7 100644 --- a/Server/src/main/kotlin/rs09/plugin/PluginManager.kt +++ b/Server/src/main/kotlin/rs09/plugin/PluginManager.kt @@ -18,7 +18,6 @@ import rs09.game.system.SystemLogger import rs09.game.system.command.Command import java.util.* import java.util.function.Consumer -import kotlin.reflect.jvm.internal.impl.load.kotlin.JvmType /** * Represents a class used to handle the loading of all plugins. @@ -62,7 +61,7 @@ object PluginManager { var result = ClassGraph().enableClassInfo().enableAnnotationInfo().scan() result.getClassesWithAnnotation("core.plugin.Initializable").forEach(Consumer { p: ClassInfo -> try { - definePlugin(p.loadClass().newInstance() as Plugin) + definePlugin(p.loadClass().newInstance() as Plugin) } catch (e: InstantiationException) { e.printStackTrace() } catch (e: IllegalAccessException) { diff --git a/Server/src/main/kotlin/rs09/worker/MajorUpdateWorker.kt b/Server/src/main/kotlin/rs09/worker/MajorUpdateWorker.kt index 56a18ee0d..88a91785f 100644 --- a/Server/src/main/kotlin/rs09/worker/MajorUpdateWorker.kt +++ b/Server/src/main/kotlin/rs09/worker/MajorUpdateWorker.kt @@ -10,14 +10,19 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.launch import rs09.Server import rs09.ServerConstants +import rs09.ServerStore +import rs09.game.system.SystemLogger import rs09.game.world.GameWorld import rs09.game.world.repository.Repository import rs09.game.world.update.UpdateSequence import rs09.net.packet.PacketWriteQueue import rs09.tools.stringtools.colorize +import java.lang.Long.max +import java.lang.Long.min import java.text.SimpleDateFormat import java.util.* import kotlin.collections.ArrayList +import kotlin.system.exitProcess /** * Handles the running of pulses and writing of masks, etc @@ -26,11 +31,12 @@ import kotlin.collections.ArrayList class MajorUpdateWorker { var started = false val sequence = UpdateSequence() - val sdf = SimpleDateFormat("HHmm") + val sdf = SimpleDateFormat("HHmmss") fun start() = GlobalScope.launch { started = true + delay(600L) while(true){ - delay(600L) + val start = System.currentTimeMillis() val rmlist = ArrayList() val list = ArrayList(GameWorld.Pulser.TASKS) @@ -59,22 +65,32 @@ class MajorUpdateWorker { Server.heartbeat() //Handle daily restart if enabled - if(ServerConstants.DAILY_RESTART && sdf.format(Date()).toInt() == 0){ - Repository.sendNews(colorize("%RSERVER GOING DOWN FOR DAILY RESTART IN 5 MINUTES!")) - ServerConstants.DAILY_RESTART = false - ContentAPI.submitWorldPulse(object : Pulse(100) { - var counter = 0 - override fun pulse(): Boolean { - counter++ - if(counter == 5){ - SystemManager.flag(SystemState.TERMINATED) - return true + if(sdf.format(Date()).toInt() == 0){ + + if(GameWorld.checkDay() == 7) {//sunday + ServerStore.clearWeeklyEntries() + } + + ServerStore.clearDailyEntries() + if(ServerConstants.DAILY_RESTART ) { + Repository.sendNews(colorize("%RSERVER GOING DOWN FOR DAILY RESTART IN 5 MINUTES!")) + ServerConstants.DAILY_RESTART = false + ContentAPI.submitWorldPulse(object : Pulse(100) { + var counter = 0 + override fun pulse(): Boolean { + counter++ + if (counter == 5) { + exitProcess(0) + } + Repository.sendNews(colorize("%RSERVER GOING DOWN FOR DAILY RESTART IN ${5 - counter} MINUTE${if (counter < 4) "S" else ""}!")) + return false } - Repository.sendNews(colorize("%RSERVER GOING DOWN FOR DAILY RESTART IN ${5 - counter} MINUTE${if(counter < 4) "S" else ""}!")) - return false - } - }) + }) + } } + + val end = System.currentTimeMillis() + delay(max(600 - (end - start), 0)) } } } \ No newline at end of file