From a91fc0e7ca0d4bfa0b278d4ef430945ed889a68b Mon Sep 17 00:00:00 2001 From: Avi Weinstock Date: Thu, 14 Oct 2021 16:51:23 -0400 Subject: [PATCH] Add sound effects for chivalry, piety, potionmaking, and pouchmaking. --- .../java/org/runite/client/CS2Script.java | 5 +++- .../java/org/runite/client/DumpingTools.java | 24 +++++++++++++++++-- .../rs09/client/console/DeveloperConsole.kt | 10 ++++++++ .../entity/player/link/prayer/Prayer.java | 4 ++++ .../entity/player/link/prayer/PrayerType.java | 4 ++-- .../entity/skill/herblore/HerblorePulse.java | 2 ++ .../skill/summoning/SummoningCreator.java | 1 + .../system/command/sets/MiscCommandSet.kt | 7 ++++++ 8 files changed, 52 insertions(+), 5 deletions(-) diff --git a/Client/src/main/java/org/runite/client/CS2Script.java b/Client/src/main/java/org/runite/client/CS2Script.java index 5544b1896..db95bc72b 100644 --- a/Client/src/main/java/org/runite/client/CS2Script.java +++ b/Client/src/main/java/org/runite/client/CS2Script.java @@ -204,6 +204,7 @@ public final class CS2Script extends Linkable { Object[] aobj = script.arguments; int j = ((Integer) aobj[0]).intValue(); AssembledMethod currentMethod = ItemDefinition.getMethodByID(j); + // System.out.printf("Method id: %d\n", j); if (null == currentMethod) return; ItemDefinition.scriptHeapCounter = 0; @@ -270,7 +271,7 @@ public final class CS2Script extends Linkable { if (maxIterations < j2) throw new RuntimeException("Script exceeded max iterations"); int opcode = instructions[++programCounter]; - //System.out.println("Instruction: " + programCounter + ". opcode is: " + opcode); + // System.out.println("Instruction: " + programCounter + ". opcode is: " + opcode); if (opcode < 100) { if (opcode == CS2AsmOpcodes.PUSH_INT.getOp()) { ItemDefinition.intsStack[iStackCounter++] = instructionOperands[programCounter]; @@ -333,6 +334,7 @@ public final class CS2Script extends Linkable { if (opcode == 25) { int j3 = instructionOperands[programCounter]; ItemDefinition.intsStack[iStackCounter++] = NPCDefinition.method1484(j3); + // System.out.printf("varp lookup: %s %s\n", j3, ItemDefinition.intsStack[iStackCounter-1]); continue; } if (opcode == 27) { @@ -964,6 +966,7 @@ public final class CS2Script extends Linkable { if (opcode == 3306) { //Another Skill update listener (spams 10? Possible TOTAL hp) int j9 = ItemDefinition.intsStack[--iStackCounter]; ItemDefinition.intsStack[iStackCounter++] = Class3_Sub20.anIntArray2480[j9]; + //System.out.printf("3306 -> %s: %s\n", j9, ItemDefinition.intsStack[iStackCounter - 1]); continue; } if (3307 == opcode) { //Hover tooltip for Skill Interface, total xp for selected skill diff --git a/Client/src/main/java/org/runite/client/DumpingTools.java b/Client/src/main/java/org/runite/client/DumpingTools.java index 1ccd5a89f..ca9d9ad0a 100644 --- a/Client/src/main/java/org/runite/client/DumpingTools.java +++ b/Client/src/main/java/org/runite/client/DumpingTools.java @@ -28,13 +28,33 @@ public class DumpingTools { //DumpToRuneStarCompatible("binaryScripts"); // Requires making the folder first. Probably the most useful one. } + public static String FriendlyOpcodeName(int i, int opcode, int arg) { + switch(opcode) { + case 0: return String.format("push_int %d (%08x)", arg, arg); + case 6: return String.format("jmp +%d (%04d)", arg, i + 1 + arg); + case 7: return String.format("bne +%d (%04d)", arg, i + 1 + arg); + case 8: return String.format("be +%d (%04d)", arg, i + 1 + arg); + case 9: return String.format("bgt +%d (%04d)", arg, i + 1 + arg); + case 10: return String.format("blt +%d (%04d)", arg, i + 1 + arg); + case 21: return String.format("ret %d", arg); + case 25: return String.format("fetch_varbit %d", arg); + case 33: return String.format("push_arg %d", arg); + case 3305: return String.format("getcurrentlevel %d", arg); + case 3306: return String.format("getstaticlevel %d", arg); + case 3200: return String.format("playsfx %d", arg); + default: return String.format("unknown (%d: %d)", opcode, arg); + } + } + public static void DumpOpcodesToTextFile(String outputFile, int methodID) { try { AssembledMethod a = ItemDefinition.getMethodByID(methodID); FileWriter myWriter = new FileWriter(outputFile); myWriter.write("Opcodes for Method" + methodID + ":\n"); - for (int opcode : a.assemblyInstructions) { - myWriter.write(opcode + "\n"); + for (int i = 0; i < a.assemblyInstructions.length; i++) { + int opcode = a.assemblyInstructions[i]; + int arg = a.instructionOperands[i]; + myWriter.write(String.format("%04d: %s\n", i, FriendlyOpcodeName(i, opcode, arg))); } myWriter.close(); } catch (IOException e) { diff --git a/Client/src/main/kotlin/org/rs09/client/console/DeveloperConsole.kt b/Client/src/main/kotlin/org/rs09/client/console/DeveloperConsole.kt index 2b02b342f..14d2234b5 100644 --- a/Client/src/main/kotlin/org/rs09/client/console/DeveloperConsole.kt +++ b/Client/src/main/kotlin/org/rs09/client/console/DeveloperConsole.kt @@ -242,6 +242,16 @@ object DeveloperConsole { println("Error. Displays error message on login, account creation. Use: errormsg #") } } + "dumpscript" -> { + if (argSize == 2) { + val i = clientCommand[1].toIntOrNull() + if(i != null) { + DumpingTools.DumpOpcodesToTextFile("script_${i}.cs2", i) + } + } else { + println("Error. Dumps a cs2 script. Use: dumpscript #") + } + } "playsound" -> { if (argSize == 4) { val soundID = if (clientCommand[1].toIntOrNull() == null) 0 else clientCommand[1].toInt() diff --git a/Server/src/main/java/core/game/node/entity/player/link/prayer/Prayer.java b/Server/src/main/java/core/game/node/entity/player/link/prayer/Prayer.java index 019ad27a1..b2718b75d 100644 --- a/Server/src/main/java/core/game/node/entity/player/link/prayer/Prayer.java +++ b/Server/src/main/java/core/game/node/entity/player/link/prayer/Prayer.java @@ -43,6 +43,10 @@ public final class Prayer { */ public Prayer(Player player) { this.player = player; + + // 1050 is checked client-side for making piety/chivalry disallowed sfx, likely due to the minigame requirement. + // Set it here unconditionally until the minigame is implemented. + player.varpManager.get(1050).setVarbit(1, 8); } /** 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 f015f945f..b49a8bef5 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 @@ -61,8 +61,8 @@ public enum PrayerType { RETRIBUTION(46, 12, 98, 47, PrayerCategory.LIGHT_BROWN, PrayerCategory.MAGENTA, new Audio(10000)), REDEMPTION(49, 6, 99, 49, PrayerCategory.LIGHT_BROWN, PrayerCategory.MAGENTA, new Audio(2678)), SMITE(52, 2, 100, 51, PrayerCategory.LIGHT_BROWN, PrayerCategory.MAGENTA, new Audio(2685)), - CHIVALRY(60, 2, 1052, 55, PrayerCategory.PINK, 1000,65, new SkillBonus(Skills.DEFENCE, 0.2), new SkillBonus(Skills.STRENGTH, 0.18), new SkillBonus(Skills.ATTACK, 0.15)), - PIETY(70, 2, 1053, 57, PrayerCategory.PINK, 1000, 70 , new SkillBonus(Skills.DEFENCE, 0.25), new SkillBonus(Skills.STRENGTH, 0.23), new SkillBonus(Skills.ATTACK, 0.2)); + CHIVALRY(60, 2, 1052, 55, PrayerCategory.PINK, 3826, 65, new SkillBonus(Skills.DEFENCE, 0.2), new SkillBonus(Skills.STRENGTH, 0.18), new SkillBonus(Skills.ATTACK, 0.15)), + PIETY(70, 2, 1053, 57, PrayerCategory.PINK, 3825, 70, new SkillBonus(Skills.DEFENCE, 0.25), new SkillBonus(Skills.STRENGTH, 0.23), new SkillBonus(Skills.ATTACK, 0.2)); /** * Represents the a cache of objects related to prayers in order to decide diff --git a/Server/src/main/java/core/game/node/entity/skill/herblore/HerblorePulse.java b/Server/src/main/java/core/game/node/entity/skill/herblore/HerblorePulse.java index bf6639c8e..de9805852 100644 --- a/Server/src/main/java/core/game/node/entity/skill/herblore/HerblorePulse.java +++ b/Server/src/main/java/core/game/node/entity/skill/herblore/HerblorePulse.java @@ -117,6 +117,7 @@ public final class HerblorePulse extends SkillPulse { final Item item = potion.getProduct(); player.getInventory().add(item); player.getPacketDispatch().sendMessage("You put the" + StringUtils.formatDisplayName(potion.getIngredient().getName().toLowerCase().replace("clean", "")) + " leaf into the vial of water."); + player.getAudioManager().send(2608); if (cycles++ == 3) { player.animate(ANIMATION); cycles = 0; @@ -133,6 +134,7 @@ public final class HerblorePulse extends SkillPulse { player.getInventory().add(item); player.getSkills().addExperience(Skills.HERBLORE, potion.getExperience(), true); player.getPacketDispatch().sendMessage("You mix the " + potion.getIngredient().getName().toLowerCase() + " into your potion."); + player.getAudioManager().send(2608); player.animate(ANIMATION); } } diff --git a/Server/src/main/java/core/game/node/entity/skill/summoning/SummoningCreator.java b/Server/src/main/java/core/game/node/entity/skill/summoning/SummoningCreator.java index b8f8982af..effcd02ca 100644 --- a/Server/src/main/java/core/game/node/entity/skill/summoning/SummoningCreator.java +++ b/Server/src/main/java/core/game/node/entity/skill/summoning/SummoningCreator.java @@ -157,6 +157,7 @@ public final class SummoningCreator { if (getDelay() == 1) { setDelay(4); player.getPacketDispatch().sendSceneryAnimation(object, Animation.create(8509)); + player.getAudioManager().send(4164); // 4277 also sounds the same return false; } player.getPacketDispatch().sendSceneryAnimation(object, Animation.create(8510)); diff --git a/Server/src/main/kotlin/rs09/game/system/command/sets/MiscCommandSet.kt b/Server/src/main/kotlin/rs09/game/system/command/sets/MiscCommandSet.kt index 9512ea54c..c7b1ea3d4 100644 --- a/Server/src/main/kotlin/rs09/game/system/command/sets/MiscCommandSet.kt +++ b/Server/src/main/kotlin/rs09/game/system/command/sets/MiscCommandSet.kt @@ -312,6 +312,13 @@ class MiscCommandSet : CommandSet(Command.Privilege.ADMIN){ notify(player, "${VarbitDefinition.forObjectID(SceneryDefinition.forId(objectID).varbitID).configId}") } + define("define_varbit"){ player, args -> + if(args.size < 2) { + reject(player, "Syntax: ::define_varbit varbitId") + } + val varbitID = args[1].toInt() + notify(player, "${varbitID}: ${VarbitDefinition.forId(varbitID, 0)}") + } define("togglexp",Command.Privilege.STANDARD){ player, args -> val enabled = player.varpManager.get(2501).getVarbit(0)?.value == 1 player.varpManager.get(2501).setVarbit(0,if(enabled) 0 else 1).send(player)