From 838edacba5298e15b14a3b9d534c3e6a92a9a678 Mon Sep 17 00:00:00 2001 From: ceikry Date: Mon, 26 Jul 2021 19:36:36 -0500 Subject: [PATCH 1/3] Made the various signposts like cow and church sign authentic and persistent --- .../city/lumbridge/CowFieldSign.java | 9 +++- .../city/lumbridge/CowPenZone.java | 3 +- .../core/game/node/entity/player/Player.java | 2 + Server/src/main/kotlin/rs09/GlobalStats.kt | 45 +++++++++++++++++++ .../object/VarrockGuardSignpost.kt | 15 +++++-- .../interaction/region/LumbridgeListeners.kt | 23 ++++++++++ .../kotlin/rs09/worker/MajorUpdateWorker.kt | 14 +++--- 7 files changed, 100 insertions(+), 11 deletions(-) create mode 100644 Server/src/main/kotlin/rs09/GlobalStats.kt create mode 100644 Server/src/main/kotlin/rs09/game/interaction/region/LumbridgeListeners.kt diff --git a/Server/src/main/java/core/game/interaction/city/lumbridge/CowFieldSign.java b/Server/src/main/java/core/game/interaction/city/lumbridge/CowFieldSign.java index 377a1bece..38ee9713f 100644 --- a/Server/src/main/java/core/game/interaction/city/lumbridge/CowFieldSign.java +++ b/Server/src/main/java/core/game/interaction/city/lumbridge/CowFieldSign.java @@ -1,5 +1,6 @@ package core.game.interaction.city.lumbridge; +import api.ContentAPI; import core.cache.def.impl.SceneryDefinition; import core.game.content.dialogue.DialoguePlugin; import core.game.interaction.OptionHandler; @@ -7,6 +8,7 @@ import core.game.node.Node; import core.game.node.entity.player.Player; import core.plugin.Initializable; import core.plugin.Plugin; +import rs09.GlobalStats; /** * Cow field sign manager @@ -40,7 +42,12 @@ public class CowFieldSign extends OptionHandler { public DialoguePlugin newInstance(Player player){return new SignDialogue(player);} @Override public boolean open(Object... args){ - interpreter.sendPlainMessage(false,"Wandering adventurers have killed " + CowPenZone.CowDeaths + " cows in this field.", "Local farmers call it an epidemic."); + int dailyCowDeaths = GlobalStats.getDailyCowDeaths(); + if(dailyCowDeaths > 0) { + ContentAPI.sendDialogue(player, "Local cowherders have reported that " + dailyCowDeaths + " cows have been slain in this field today by passing adventurers. Farmers throughout the land fear this may be an epidemic."); + } else { + ContentAPI.sendDialogue(player, "The Lumbridge cow population has been thriving today, without a single cow death to worry about!" ); + } return true; } diff --git a/Server/src/main/java/core/game/interaction/city/lumbridge/CowPenZone.java b/Server/src/main/java/core/game/interaction/city/lumbridge/CowPenZone.java index d9577f8c7..6c14c1eea 100644 --- a/Server/src/main/java/core/game/interaction/city/lumbridge/CowPenZone.java +++ b/Server/src/main/java/core/game/interaction/city/lumbridge/CowPenZone.java @@ -8,6 +8,7 @@ import core.game.world.map.zone.ZoneBorders; import core.game.world.map.zone.ZoneBuilder; import core.plugin.Initializable; import core.plugin.Plugin; +import rs09.GlobalStats; /** * Zone for the lumbridge cow pen @@ -40,7 +41,7 @@ public class CowPenZone extends MapZone implements Plugin { @Override public boolean death(Entity e, Entity killer) { if (killer instanceof Player && e instanceof NPC) { - CowDeaths++; + GlobalStats.incrementDailyCowDeaths(); } return false; } 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 5949d4ef0..93249b33c 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 @@ -72,6 +72,7 @@ import core.tools.StringUtils; import kotlin.Unit; import kotlin.jvm.functions.Function1; import org.rs09.consts.Items; +import rs09.GlobalStats; import rs09.ServerConstants; import rs09.game.VarpManager; import rs09.game.content.ame.RandomEventManager; @@ -582,6 +583,7 @@ public class Player extends Entity { @Override public void finalizeDeath(Entity killer) { + GlobalStats.incrementDeathCount(); settings.setSpecialEnergy(100); settings.updateRunEnergy(settings.getRunEnergy() - 100); Player k = killer instanceof Player ? (Player) killer : this; diff --git a/Server/src/main/kotlin/rs09/GlobalStats.kt b/Server/src/main/kotlin/rs09/GlobalStats.kt new file mode 100644 index 000000000..8817ae3b3 --- /dev/null +++ b/Server/src/main/kotlin/rs09/GlobalStats.kt @@ -0,0 +1,45 @@ +package rs09 + +import org.json.simple.JSONObject +import rs09.ServerStore.getInt + +object GlobalStats { + + @JvmStatic + fun incrementDeathCount(){ + getDailyDeathArchive()["players"] = getDailyDeathArchive().getInt("players") + 1 + } + + @JvmStatic + fun incrementDailyCowDeaths(){ + getDailyDeathArchive()["lumbridge-cows"] = getDailyDeathArchive().getInt("lumbridge-cows") + 1 + } + + @JvmStatic + fun incrementGuardPickpockets(){ + getGuardPickpocketArchive()["count"] = getGuardPickpocketArchive().getInt("count") + 1 + } + + @JvmStatic + fun getDailyGuardPickpockets(): Int { + return getGuardPickpocketArchive().getInt("count") + } + + fun getDailyDeaths(): Int { + return getDailyDeathArchive().getInt("players") + } + + @JvmStatic + fun getDailyCowDeaths(): Int { + return getDailyDeathArchive().getInt("lumbridge-cows") + } + + private fun getDailyDeathArchive(): JSONObject { + return ServerStore.getArchive("daily-deaths-global") + } + + private fun getGuardPickpocketArchive(): JSONObject { + return ServerStore.getArchive("daily-guard-pickpockets") + } + +} \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/game/interaction/object/VarrockGuardSignpost.kt b/Server/src/main/kotlin/rs09/game/interaction/object/VarrockGuardSignpost.kt index 8d212864c..0c3cf23a4 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/object/VarrockGuardSignpost.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/object/VarrockGuardSignpost.kt @@ -6,15 +6,16 @@ import core.game.node.Node import core.game.node.entity.Entity import core.game.world.map.zone.MapZone import core.game.world.map.zone.ZoneBorders +import rs09.GlobalStats import rs09.game.interaction.InteractionListener +import rs09.game.system.SystemLogger class VarrockGuardSignpost : InteractionListener() { override fun defineListeners() { val zone = object : MapZone("Varrock Guards", true){ - var pickpocketCounter = 0 override fun interact(e: Entity?, target: Node?, option: Option?): Boolean { if(option != null && option.name.toLowerCase().contains("pickpocket") && target != null && target.name.toLowerCase().contains("guard")){ - pickpocketCounter++ + GlobalStats.incrementGuardPickpockets() } return false } @@ -25,8 +26,14 @@ class VarrockGuardSignpost : InteractionListener() { ContentAPI.registerMapZone(zone, ZoneBorders(3180,3420,3165,3435)) ContentAPI.registerMapZone(zone, ZoneBorders(3280,3422,3266,3435)) - on(31298, SCENERY, "read"){player, node -> - ContentAPI.sendDialogue(player, "Guards in the Varrock Palace are on full alert due to increasing levels of pickpocketing. So far today, ${zone.pickpocketCounter} guards have had their money pickpocketed in the palace or at the city gates.") + on(31298, SCENERY, "read"){player, _ -> + val pickpocketCount = GlobalStats.getDailyGuardPickpockets() + SystemLogger.logInfo("Is equal? ${pickpocketCount == 0}") + when(pickpocketCount){ + 0 -> ContentAPI.sendDialogue(player, "The Varrock Palace guards are pleased to announce that crime is at an all-time low, without a single guard in the palace or at the city gates being pickpocketed today.") + 1 -> ContentAPI.sendDialogue(player, "One of the Varrock Palace guards was pickpocketed today. He was close to tears at having lost his last few gold pieces." ) + else -> ContentAPI.sendDialogue(player, "Guards in the Varrock Palace are on full alert due to increasing levels of pickpocketing. So far today, $pickpocketCount guards have had their money pickpocketed in the palace or at the city gates.") + } return@on true } } diff --git a/Server/src/main/kotlin/rs09/game/interaction/region/LumbridgeListeners.kt b/Server/src/main/kotlin/rs09/game/interaction/region/LumbridgeListeners.kt new file mode 100644 index 000000000..b4511f0cb --- /dev/null +++ b/Server/src/main/kotlin/rs09/game/interaction/region/LumbridgeListeners.kt @@ -0,0 +1,23 @@ +package rs09.game.interaction.region + +import api.ContentAPI +import rs09.GlobalStats +import rs09.game.interaction.InteractionListener + +class LumbridgeListeners : InteractionListener() { + + val CHURCH_SIGN = 31299 + + override fun defineListeners() { + on(CHURCH_SIGN, SCENERY, "read"){player, _ -> + val deaths = GlobalStats.getDailyDeaths() + if(deaths > 0){ + ContentAPI.sendDialogue(player, "So far today $deaths unlucky adventurers have died on RuneScape and been sent to their respawn location. Be careful out there.") + } else { + ContentAPI.sendDialogue(player, "So far today not a single adventurer on RuneScape has met their end grisly or otherwise. Either the streets are getting safer or adventurers are getting warier.") + } + return@on true + } + } + +} \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/worker/MajorUpdateWorker.kt b/Server/src/main/kotlin/rs09/worker/MajorUpdateWorker.kt index 88a91785f..498c29d88 100644 --- a/Server/src/main/kotlin/rs09/worker/MajorUpdateWorker.kt +++ b/Server/src/main/kotlin/rs09/worker/MajorUpdateWorker.kt @@ -39,6 +39,7 @@ class MajorUpdateWorker { val start = System.currentTimeMillis() val rmlist = ArrayList() val list = ArrayList(GameWorld.Pulser.TASKS) + Server.heartbeat() //run our pulses for(pulse in list) { @@ -52,17 +53,20 @@ class MajorUpdateWorker { rmlist.clear() //perform our update sequence where we write masks, etc - sequence.start() - sequence.run() - sequence.end() - PacketWriteQueue.flush() + try { + sequence.start() + sequence.run() + sequence.end() + PacketWriteQueue.flush() + } catch (e: Exception){ + e.printStackTrace() + } //increment global ticks variable GameWorld.pulse() //disconnect all players waiting to be disconnected Repository.disconnectionQueue.update() //tick all manager plugins Managers.tick() - Server.heartbeat() //Handle daily restart if enabled if(sdf.format(Date()).toInt() == 0){ From b656da6d5d1a8070c8ab01a718ce1aeb3d0c6884 Mon Sep 17 00:00:00 2001 From: ceikry Date: Tue, 27 Jul 2021 08:24:05 -0500 Subject: [PATCH 2/3] Made weekly things like penguins reset on Monday --- Server/src/main/kotlin/rs09/worker/MajorUpdateWorker.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Server/src/main/kotlin/rs09/worker/MajorUpdateWorker.kt b/Server/src/main/kotlin/rs09/worker/MajorUpdateWorker.kt index 498c29d88..bedfce79a 100644 --- a/Server/src/main/kotlin/rs09/worker/MajorUpdateWorker.kt +++ b/Server/src/main/kotlin/rs09/worker/MajorUpdateWorker.kt @@ -71,7 +71,7 @@ class MajorUpdateWorker { //Handle daily restart if enabled if(sdf.format(Date()).toInt() == 0){ - if(GameWorld.checkDay() == 7) {//sunday + if(GameWorld.checkDay() == 1) {//monday ServerStore.clearWeeklyEntries() } From 8ee848b01c8be70d12f11a77302c0d753798d03e Mon Sep 17 00:00:00 2001 From: ceikry Date: Tue, 27 Jul 2021 18:36:32 -0500 Subject: [PATCH 3/3] Added tiadeche's karambwan shop --- Server/data/configs/shops.json | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Server/data/configs/shops.json b/Server/data/configs/shops.json index 930720c4d..202eb9638 100644 --- a/Server/data/configs/shops.json +++ b/Server/data/configs/shops.json @@ -2122,5 +2122,14 @@ "id": "239", "title": "Contraband yak produce.", "stock": "{10818,25}-{10816,50}-{10814,50}-{10820,10}" + }, + { + "npcs": "1163,1164", + "high_alch": "0", + "currency": "995", + "general_store": "false", + "id": "240", + "title": "Tiadeche's Karambwan Stall", + "stock": "{3142,10}-{3157,10}" } ] \ No newline at end of file