From 38140d8665879063e7c177feb9c37612d9dfdf82 Mon Sep 17 00:00:00 2001 From: Dark98 Date: Sun, 5 Dec 2021 23:47:49 +0000 Subject: [PATCH] Add XP Rate Multiplier For Non-Bot Worlds --- 2006Scape Server/ServerConfig.Sample.json | 1 + .../src/main/java/com/rs2/ConfigLoader.java | 2 + .../src/main/java/com/rs2/GameConstants.java | 4 +- .../rs2/game/dialogues/DialogueHandler.java | 28 ++++++++++-- .../rs2/game/dialogues/DialogueOptions.java | 44 +++++++++++++++++-- .../java/com/rs2/game/players/Player.java | 2 +- .../com/rs2/net/packets/impl/Commands.java | 12 +++++ 7 files changed, 83 insertions(+), 10 deletions(-) diff --git a/2006Scape Server/ServerConfig.Sample.json b/2006Scape Server/ServerConfig.Sample.json index 019ddbb7..a57fada0 100644 --- a/2006Scape Server/ServerConfig.Sample.json +++ b/2006Scape Server/ServerConfig.Sample.json @@ -4,6 +4,7 @@ "server_debug": false, "file_server": true, "world_id": 1, + "bot_world": true, "members_only": false, "tutorial_island_enabled": false, "party_room_enabled": true, diff --git a/2006Scape Server/src/main/java/com/rs2/ConfigLoader.java b/2006Scape Server/src/main/java/com/rs2/ConfigLoader.java index c3248f90..2fb49d6b 100644 --- a/2006Scape Server/src/main/java/com/rs2/ConfigLoader.java +++ b/2006Scape Server/src/main/java/com/rs2/ConfigLoader.java @@ -25,6 +25,8 @@ public class ConfigLoader { GameConstants.FILE_SERVER = obj.getBoolean("file_server"); if(obj.has("world_id")) GameConstants.WORLD = obj.getInt("world_id"); + if(obj.has("bot_world")) + GameConstants.BOT_WORLD = obj.getBoolean("bot_world"); if(obj.has("members_only")) GameConstants.MEMBERS_ONLY = obj.getBoolean("members_only"); if(obj.has("tutorial_island_enabled")) diff --git a/2006Scape Server/src/main/java/com/rs2/GameConstants.java b/2006Scape Server/src/main/java/com/rs2/GameConstants.java index 5a6cc37d..17bafc04 100644 --- a/2006Scape Server/src/main/java/com/rs2/GameConstants.java +++ b/2006Scape Server/src/main/java/com/rs2/GameConstants.java @@ -32,8 +32,8 @@ public class GameConstants { RESPAWN_X = 3222, RESPAWN_Y = 3218; public static boolean FILE_SERVER = true, SERVER_DEBUG = false, MEMBERS_ONLY = false, TUTORIAL_ISLAND = false, PARTY_ROOM_DISABLED = false, CLUES_ENABLED = true, ITEM_REQUIREMENTS = true, - ADMIN_CAN_TRADE = false, ADMIN_DROP_ITEMS = false, ADMIN_CAN_SELL_ITEMS = false; - public static double XP_RATE = 1 * Player.xpRate; + ADMIN_CAN_TRADE = false, ADMIN_DROP_ITEMS = false, ADMIN_CAN_SELL_ITEMS = false, BOT_WORLD = true; + public static double XP_RATE = Player.xpRate; /** diff --git a/2006Scape Server/src/main/java/com/rs2/game/dialogues/DialogueHandler.java b/2006Scape Server/src/main/java/com/rs2/game/dialogues/DialogueHandler.java index b30e76a7..aaa91a96 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/dialogues/DialogueHandler.java +++ b/2006Scape Server/src/main/java/com/rs2/game/dialogues/DialogueHandler.java @@ -6137,10 +6137,14 @@ public class DialogueHandler { break; case 3116: - player.getPacketSender().showInterface(3559); - player.canChangeAppearance = true; - player.closeTutorialInterface = true; - player.nextChat = 0; + if(!GameConstants.BOT_WORLD) { + player.getDialogueHandler().sendDialogues(10001, -1); + } else { + player.getPacketSender().showInterface(3559); + player.canChangeAppearance = true; + player.closeTutorialInterface = true; + player.nextChat = 0; + } break; case 3117: @@ -7594,6 +7598,22 @@ public class DialogueHandler { ); player.dialogueAction = 10000; break; + case 10001: + sendNpcChat(2244, ChatEmotes.HAPPY_JOYFUL, "Please Select The XP Rate You'd Like.", "This Can Be Increased But Not Decreased Later On."); + player.nextChat = 10002; + break; + case 10002: + sendOption("x1", "x2", "x5", "x10"); + player.dialogueAction = 10002; + break; + case 10003: + sendNpcChat(2244, ChatEmotes.HAPPY_JOYFUL, "Are You Sure x" + player.getXPRate() + " Is The XP Rate You'd Like?"); + player.nextChat = 10004; + break; + case 10004: + sendOption("Yes", "No"); + player.dialogueAction = 10004; + break; } } public void chatboxText(String text, String text1, String text2, diff --git a/2006Scape Server/src/main/java/com/rs2/game/dialogues/DialogueOptions.java b/2006Scape Server/src/main/java/com/rs2/game/dialogues/DialogueOptions.java index 4200552e..4ebb930d 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/dialogues/DialogueOptions.java +++ b/2006Scape Server/src/main/java/com/rs2/game/dialogues/DialogueOptions.java @@ -618,11 +618,30 @@ public class DialogueOptions { player.getDialogueHandler().sendDialogues(3586, player.npcType); return; } - else if (player.dialogueAction == 7559) - { + else if (player.dialogueAction == 7559) { player.getDialogueHandler().sendDialogues(3864, player.npcType); return; - } + } else if (player.dialogueAction == 10004) { + if(!player.closeTutorialInterface) { + player.getPacketSender().sendMessage("Your XP Rate Is Now Set To x" + player.getXPRate() + " You Can Increase Your Rate In The Future By Using"); + player.getPacketSender().sendMessage("::xprate"); + player.getPacketSender().showInterface(3559); + player.canChangeAppearance = true; + player.closeTutorialInterface = true; + player.nextChat = 0; + player.dialogueAction = 0; + } else if (player.getXPRate() != 10) { + player.getPacketSender().sendMessage("Your XP Rate Is Now Set To x" + player.getXPRate() + " You Can Increase Your Rate In The Future By Using"); + player.getPacketSender().sendMessage("::xprate"); + player.dialogueAction = 0; + player.getPacketSender().closeAllWindows(); + } else { + player.getPacketSender().sendMessage("Your XP Rate Is Now Set To x" + player.getXPRate()); + player.dialogueAction = 0; + player.getPacketSender().closeAllWindows(); + } + return; + } player.dialogueAction = 0; player.getPacketSender().closeAllWindows(); break; @@ -848,6 +867,9 @@ public class DialogueOptions { { player.getDialogueHandler().sendDialogues(3865, player.npcType); return; + } else if (player.dialogueAction == 10004) { + player.getDialogueHandler().sendDialogues(10002, 2244); + return; } player.dialogueAction = 0; player.getPacketSender().closeAllWindows(); @@ -922,6 +944,10 @@ public class DialogueOptions { if (player.dialogueAction == 701) { player.getDialogueHandler().sendDialogues(3561, player.npcType); } + if (player.dialogueAction == 10002) { + player.setXPRate(1); + player.getDialogueHandler().sendDialogues(10003, player.npcType); + } break; case 9179: @@ -991,6 +1017,10 @@ public class DialogueOptions { if (player.dialogueAction == 701) { player.getDialogueHandler().sendDialogues(3562, player.npcType); } + if (player.dialogueAction == 10002) { + player.setXPRate(2); + player.getDialogueHandler().sendDialogues(10003, player.npcType); + } break; case 9180: @@ -1063,6 +1093,10 @@ public class DialogueOptions { if (player.dialogueAction == 701) { player.getDialogueHandler().sendDialogues(3563, player.npcType); } + if (player.dialogueAction == 10002) { + player.setXPRate(5); + player.getDialogueHandler().sendDialogues(10003, player.npcType); + } break; case 9181: @@ -1120,6 +1154,10 @@ public class DialogueOptions { if (player.dialogueAction == 701) { player.getDialogueHandler().sendDialogues(3564, player.npcType); } + if (player.dialogueAction == 10002) { + player.setXPRate(10); + player.getDialogueHandler().sendDialogues(10003, player.npcType); + } break; } } diff --git a/2006Scape Server/src/main/java/com/rs2/game/players/Player.java b/2006Scape Server/src/main/java/com/rs2/game/players/Player.java index 3afa00bd..ef31bdca 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/players/Player.java +++ b/2006Scape Server/src/main/java/com/rs2/game/players/Player.java @@ -98,7 +98,7 @@ public abstract class Player { public byte buffer[] = null; public String lastConnectedFrom; - public static int xpRate; + public static int xpRate = 1; private Compost compost = new Compost(this); private Allotments allotment = new Allotments(this); private Flowers flower = new Flowers(this); diff --git a/2006Scape Server/src/main/java/com/rs2/net/packets/impl/Commands.java b/2006Scape Server/src/main/java/com/rs2/net/packets/impl/Commands.java index 365a973a..f0090705 100644 --- a/2006Scape Server/src/main/java/com/rs2/net/packets/impl/Commands.java +++ b/2006Scape Server/src/main/java/com/rs2/net/packets/impl/Commands.java @@ -45,6 +45,18 @@ public class Commands implements PacketType { public static void playerCommands(Player player, String playerCommand, String[] arguments) { switch (playerCommand.toLowerCase()) { + case "xprate": + case "XPRate": + if(player.getXPRate() == 0 || player.playerRights == 3) { + player.getDialogueHandler().sendDialogues(10001, 2244); + return; + } else if (player.getXPRate() == 10) { + player.getPacketSender().sendMessage("You Already Have The Highest XP Rate"); + return; + } else { + player.getDialogueHandler().sendDialogues(10001, 2244); + } + break; case "toggleyell": case "tglyell": case "hideyell":