From 0238936bc0e712279e0beab7478df5ffd248dd8b Mon Sep 17 00:00:00 2001 From: Avi Weinstock Date: Mon, 21 Feb 2022 04:19:30 +0000 Subject: [PATCH] Runecrafting improvements: --- .../skill/runecrafting/RuneCraftPulse.java | 25 ++++++++++++++++--- .../interaction/inter/NPCContactInterface.kt | 16 ++++++++---- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/Server/src/main/java/core/game/node/entity/skill/runecrafting/RuneCraftPulse.java b/Server/src/main/java/core/game/node/entity/skill/runecrafting/RuneCraftPulse.java index 6485dc3ac..3329a700b 100644 --- a/Server/src/main/java/core/game/node/entity/skill/runecrafting/RuneCraftPulse.java +++ b/Server/src/main/java/core/game/node/entity/skill/runecrafting/RuneCraftPulse.java @@ -174,7 +174,12 @@ public final class RuneCraftPulse extends SkillPulse { final Item item = new Item(getEssence().getId(), getEssenceAmount()); int amount = player.getInventory().getAmount(item); if (!altar.isOurania()) { - Item i = new Item(rune.getRune().getId(), amount * getMultiplier()); + int total = 0; + for(int j = 0; j < amount; j++) { + // since getMultiplier is stochastic, roll `amount` independent copies + total += getMultiplier(); + } + Item i = new Item(rune.getRune().getId(), total); if (player.getInventory().remove(item) && player.getInventory().hasSpaceFor(i)) { player.getInventory().add(i); @@ -309,16 +314,28 @@ public final class RuneCraftPulse extends SkillPulse { if (altar.isOurania()) { return 1; } + int rcLevel = player.getSkills().getLevel(Skills.RUNECRAFTING); + int[] multipleLevels = rune.getMultiple(); int i = 0; - for (int level : rune.getMultiple()) { - if (player.getSkills().getLevel(Skills.RUNECRAFTING) >= level) { + for (int level : multipleLevels) { + if (rcLevel >= level) { i++; } } + if(multipleLevels.length > i) { + int a = Math.max(multipleLevels[i-1], rune.getLevel()); + int b = multipleLevels[i]; + double chance = ((double)rcLevel - (double)a) / ((double)b - (double)a); + player.debug(String.format("%d %d %d, %f", a, b, rcLevel, chance)); + if(RandomFunction.random(0.0, 1.0) < chance) { + i += 1; + } + } + if (player.getAchievementDiaryManager().getDiary(DiaryType.LUMBRIDGE).isComplete(1) && new ArrayList<>(Arrays.asList(Rune.AIR, Rune.WATER, Rune.FIRE, Rune.EARTH)).contains(rune) - && RandomFunction.getRandom(10) == 0) { //approximately 10% chance //TODO fix RandomFunction to be more random, should be uniformly distributed but isn't + && RandomFunction.getRandom(10) == 0) { //approximately 10% chance i += 1; } diff --git a/Server/src/main/kotlin/rs09/game/interaction/inter/NPCContactInterface.kt b/Server/src/main/kotlin/rs09/game/interaction/inter/NPCContactInterface.kt index 0f3ded10f..f7c1d8ef5 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/inter/NPCContactInterface.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/inter/NPCContactInterface.kt @@ -1,12 +1,14 @@ package rs09.game.interaction.inter import core.game.node.entity.npc.NPC +import core.game.world.map.Location import core.tools.RandomFunction +import org.rs09.consts.NPCs import rs09.game.content.dialogue.DialogueFile import rs09.game.interaction.InterfaceListener class NPCContactInterface : InterfaceListener() { - val NPCs = arrayOf(org.rs09.consts.NPCs.HONEST_JIMMY_4362, org.rs09.consts.NPCs.BERT_3108, org.rs09.consts.NPCs.ADVISOR_GHRIM_1375, org.rs09.consts.NPCs.TURAEL_8273, org.rs09.consts.NPCs.LANTHUS_1526, org.rs09.consts.NPCs.SUMONA_7780, org.rs09.consts.NPCs.MAZCHNA_8274, org.rs09.consts.NPCs.DURADEL_8275, org.rs09.consts.NPCs.VANNAKA_1597, org.rs09.consts.NPCs.MURPHY_463, org.rs09.consts.NPCs.CHAELDAR_1598, org.rs09.consts.NPCs.CYRISUS_432, org.rs09.consts.NPCs.LARRY_5424) + val contactNPCs = arrayOf(NPCs.HONEST_JIMMY_4362, NPCs.BERT_3108, NPCs.ADVISOR_GHRIM_1375, NPCs.TURAEL_8273, NPCs.LANTHUS_1526, NPCs.SUMONA_7780, NPCs.MAZCHNA_8274, NPCs.DURADEL_8275, NPCs.VANNAKA_1597, NPCs.DARK_MAGE_2262, NPCs.CHAELDAR_1598, NPCs.CYRISUS_432, NPCs.LARRY_5424) val DialogueFiles = arrayOf( /*TODO("Honest Jimmy"), TODO("Bert"), @@ -49,6 +51,10 @@ class NPCContactInterface : InterfaceListener() { player.packetDispatch.sendInterfaceConfig(429,27,true) player.packetDispatch.sendInterfaceConfig(429,42,true) + // Replace Murphy's icon with the Abyss's Dark Mage + player.packetDispatch.sendNpcOnInterface(NPCs.DARK_MAGE_2262, 429, 30) + player.packetDispatch.sendString("Dark mage", 429, 47) + return@onOpen true } @@ -69,17 +75,17 @@ class NPCContactInterface : InterfaceListener() { 34,49 -> 12 else -> -1 } - if(index == -1) index = RandomFunction.random(NPCs.size) + if(index == -1) index = RandomFunction.random(contactNPCs.size) val dialogueFile = DialogueFiles.getOrNull(index) player.getAttribute<() -> Unit>("contact-caller")?.invoke() player.interfaceManager.close() if(dialogueFile != null){ - player.dialogueInterpreter.open(dialogueFile, NPC(NPCs[index])) + player.dialogueInterpreter.open(dialogueFile, NPC(contactNPCs[index])) } else { - player.dialogueInterpreter.open(NPCs[index]) + player.dialogueInterpreter.open(contactNPCs[index], NPC(contactNPCs[index], Location(0, 0))) } return@on true } } -} \ No newline at end of file +}