From d04302c99fed3767a9ae47265253b70e12e2df4d Mon Sep 17 00:00:00 2001 From: Zerken Date: Fri, 16 Jun 2023 06:28:40 +0000 Subject: [PATCH] Hunter sound improvements Implemented setup, dismantle, and catching sound for bird snares Implemented setup, dismantle, and catching sound for box traps Implemented setup, dismantle, and catching sound for net traps Implemented setup, dismantle, and catching sound for dead falls Implemented setup and dismantle sound for rabbit snares Implemented butterfly net swing sound Implemented falconry fly and catch sound Implemented noose sound when catching kebbits Implemented setup, dismantle, catching, teasing, jumping over, and npc jumping over pitfall sound to pitfalls Implemented appropriate player lock time to setting up net traps and deadfalls to avoid players from interrupting the action Implemented appropriate player lock time to dismantling bird snares, box traps, net traps, rabbit snares and deadfalls to avoid players from interrupting the action Implemented a new function to play sound at a location --- .../global/skill/hunter/TrapCreatePulse.java | 23 ++++++++++++++++++ .../skill/hunter/TrapDismantlePulse.java | 24 +++++++++++++++++++ .../global/skill/hunter/TrapSetting.java | 17 +++++++++++++ .../global/skill/hunter/bnet/BNetPulse.java | 2 ++ .../hunter/falconry/FalconryCatchPulse.java | 3 +++ .../skill/hunter/pitfall/HunterPitfall.kt | 9 +++++++ .../skill/hunter/tracking/HunterTracking.kt | 2 ++ .../player/link/audio/AudioManager.java | 12 ++++++++++ 8 files changed, 92 insertions(+) diff --git a/Server/src/main/content/global/skill/hunter/TrapCreatePulse.java b/Server/src/main/content/global/skill/hunter/TrapCreatePulse.java index 642525df5..c40e81919 100644 --- a/Server/src/main/content/global/skill/hunter/TrapCreatePulse.java +++ b/Server/src/main/content/global/skill/hunter/TrapCreatePulse.java @@ -11,6 +11,9 @@ import core.game.node.scenery.Scenery; import core.game.node.scenery.SceneryBuilder; import core.game.world.map.Location; import core.game.world.map.RegionManager; +import org.rs09.consts.Sounds; + +import static core.api.ContentAPIKt.*; /** * Handles the trap creating pulse. @@ -51,6 +54,26 @@ public final class TrapCreatePulse extends SkillPulse { this.trap = trap; this.startLocation = node instanceof GroundItem ? node.getLocation() : player.getLocation(); this.instance = HunterManager.getInstance(player); + if (checkRequirements()){ + switch(trap) { + case BIRD_SNARE: + player.getAudioManager().send(Sounds.HUNTING_SETNOOSE_2646, 10, 40); + break; + case BOX_TRAP: + player.getAudioManager().send(Sounds.HUNTING_LAYBOXTRAP_2636, 10, 20); + break; + case NET_TRAP: + lock(player, 3); + player.getAudioManager().send(Sounds.HUNTING_SET_TWITCHNET_2644); + break; + case RABBIT_SNARE: + player.getAudioManager().send(Sounds.HUNTING_SETSNARE_2647); + break; + case DEAD_FALL: + lock(player, 6); + player.getAudioManager().send(Sounds.HUNTING_SETDEADFALL_2645, 10, 130); + } + } } @Override diff --git a/Server/src/main/content/global/skill/hunter/TrapDismantlePulse.java b/Server/src/main/content/global/skill/hunter/TrapDismantlePulse.java index 8a468ca84..292ad1874 100644 --- a/Server/src/main/content/global/skill/hunter/TrapDismantlePulse.java +++ b/Server/src/main/content/global/skill/hunter/TrapDismantlePulse.java @@ -5,6 +5,9 @@ import core.game.node.entity.skill.SkillPulse; import core.game.node.entity.skill.Skills; import core.game.node.entity.player.Player; import core.game.node.scenery.Scenery; +import org.rs09.consts.Sounds; + +import static core.api.ContentAPIKt.*; /** * Handles the dismantling of a trap. @@ -39,6 +42,27 @@ public final class TrapDismantlePulse extends SkillPulse { this.trap = wrapper.getType(); this.wrapper = wrapper; this.instance = HunterManager.getInstance(player); + if (checkRequirements()){ + switch(trap) { + case BIRD_SNARE: + lock(player,5); + player.getAudioManager().send(Sounds.HUNTING_DISMANTLE_2632, 10, 50); + break; + case BOX_TRAP: + lock(player,4); + player.getAudioManager().send(Sounds.HUNTING_DISMANTLE_2632, 10, 50); + break; + case NET_TRAP: + lock(player, 5); + player.getAudioManager().send(Sounds.HUNTING_DISMANTLE_2632, 10, 20); + break; + case RABBIT_SNARE: + case DEAD_FALL: + lock(player, 4); + player.getAudioManager().send(Sounds.HUNTING_DISMANTLE_2632, 10, 80); + break; + } + } } @Override diff --git a/Server/src/main/content/global/skill/hunter/TrapSetting.java b/Server/src/main/content/global/skill/hunter/TrapSetting.java index f20daa17e..461c2c5c9 100644 --- a/Server/src/main/content/global/skill/hunter/TrapSetting.java +++ b/Server/src/main/content/global/skill/hunter/TrapSetting.java @@ -16,6 +16,7 @@ import core.game.world.GameWorld; import core.game.world.map.Location; import core.game.world.update.flag.context.Animation; import core.tools.RandomFunction; +import org.rs09.consts.Sounds; /** * A setting for a trap type. @@ -306,6 +307,22 @@ public class TrapSetting { wrapper.setTicks(GameWorld.getTicks() + 100); wrapper.setReward(node); wrapper.setObject(getFinalId(wrapper, node)); + switch(wrapper.getType()) { + case BIRD_SNARE: + player.getAudioManager().send(Sounds.HUNTING_NOOSE_2637, 10, 0, 10, wrapper.getObject().getLocation()); + player.getAudioManager().send(Sounds.HUNTING_BIRDCAUGHT_2625, 10, 20, 10, wrapper.getObject().getLocation()); + break; + case BOX_TRAP: + player.getAudioManager().send(Sounds.HUNTING_BOXTRAP_2627, 10, 0, 10, wrapper.getObject().getLocation()); + break; + case NET_TRAP: + player.getAudioManager().send(Sounds.HUNTING_TWITCHNET_2652, 10, 0, 10, wrapper.getObject().getLocation()); + player.getAudioManager().send(Sounds.SALAMANDER_HIT_739, 10, 20, 10, wrapper.getObject().getLocation()); + break; + case DEAD_FALL: + player.getAudioManager().send(Sounds.HUNTING_DEADFALL_2631, 10, 0, 10, wrapper.getObject().getLocation()); + break; + } return true; } npc.moveStep(); diff --git a/Server/src/main/content/global/skill/hunter/bnet/BNetPulse.java b/Server/src/main/content/global/skill/hunter/bnet/BNetPulse.java index f00add82d..7729bb00f 100644 --- a/Server/src/main/content/global/skill/hunter/bnet/BNetPulse.java +++ b/Server/src/main/content/global/skill/hunter/bnet/BNetPulse.java @@ -11,6 +11,7 @@ import core.game.world.GameWorld; import core.game.world.update.flag.context.Animation; import core.tools.RandomFunction; import core.tools.StringUtils; +import org.rs09.consts.Sounds; import java.util.Random; @@ -93,6 +94,7 @@ public final class BNetPulse extends SkillPulse { public void animate() { if (ticks < 1) { player.animate(ANIMATION); + player.getAudioManager().send(Sounds.HUNTING_BUTTERFLYNET_2623); } } diff --git a/Server/src/main/content/global/skill/hunter/falconry/FalconryCatchPulse.java b/Server/src/main/content/global/skill/hunter/falconry/FalconryCatchPulse.java index d49ee8653..99c64c7d5 100644 --- a/Server/src/main/content/global/skill/hunter/falconry/FalconryCatchPulse.java +++ b/Server/src/main/content/global/skill/hunter/falconry/FalconryCatchPulse.java @@ -13,6 +13,7 @@ import core.game.world.GameWorld; import core.game.world.map.Location; import core.game.world.repository.Repository; import core.tools.RandomFunction; +import org.rs09.consts.Sounds; /** * Represents the skill pulse used to catch a kebbit. @@ -123,6 +124,7 @@ public final class FalconryCatchPulse extends SkillPulse { falcon.setAttribute("falcon:catch", falconCatch); falcon.init(); HintIconManager.registerHintIcon(player, falcon); + player.getAudioManager().send(Sounds.HUNTING_FALCON_SWOOP_2634, 10, 0, 12, node.getLocation()); GameWorld.getPulser().submit(new Pulse(100, falcon) { @Override public boolean pulse() { @@ -155,6 +157,7 @@ public final class FalconryCatchPulse extends SkillPulse { projectile.setStartHeight(26); projectile.setEndHeight(1); projectile.send(); + player.getAudioManager().send(Sounds.HUNTING_FALCON_FLY_2633); } /** diff --git a/Server/src/main/content/global/skill/hunter/pitfall/HunterPitfall.kt b/Server/src/main/content/global/skill/hunter/pitfall/HunterPitfall.kt index 5797b5b23..c54cbd693 100644 --- a/Server/src/main/content/global/skill/hunter/pitfall/HunterPitfall.kt +++ b/Server/src/main/content/global/skill/hunter/pitfall/HunterPitfall.kt @@ -22,6 +22,7 @@ import org.rs09.consts.NPCs import core.game.interaction.InteractionListener import core.game.interaction.IntType import core.game.world.GameWorld +import org.rs09.consts.Sounds /*@Initializable class HunterPitfall : OptionHandler() { @@ -187,6 +188,7 @@ class PitfallListeners : InteractionListener { player.setAttribute("pitfall:timestamp:${pit.location.x}:${pit.location.y}", System.currentTimeMillis()) setPitState(player, pit.location, 1) + playAudio(player, getAudio(Sounds.HUNTING_PLACEBRANCHES_2639)) val collapsePulse = object : Pulse(201, player) { override fun pulse(): Boolean { val oldTime = player.getAttribute("pitfall:timestamp:${pit.location.x}:${pit.location.y}", System.currentTimeMillis()) @@ -208,6 +210,7 @@ class PitfallListeners : InteractionListener { if(dir != null) { val dst = src.transform(dir, 3) ForceMovement.run(player, src, dst, ForceMovement.WALK_ANIMATION, Animation(1603), dir, 16); + playAudio(player, getAudio(Sounds.HUNTING_JUMP_2635)) val pitfall_npc: Entity? = player.getAttribute("pitfall_npc", null) if(pitfall_npc != null && pitfall_npc.getLocation().getDistance(src) < 3.0) { val last_pit_loc: Location? = pitfall_npc.getAttribute("last_pit_loc", null) @@ -222,6 +225,8 @@ class PitfallListeners : InteractionListener { //pitfall_npc.setLocation(pit.getLocation()); //pitfall_npc.walkingQueue.addPath(pit.location.x, pit.location.y); teleport(pitfall_npc, pit.location) + player.audioManager.send(Sounds.HUNTING_PITFALL_COLLAPSE_2638, 10, 0, 10, pit.location) + player.audioManager.send(Sounds.PANTHER_DEATH_667, 10, 50, 10, pit.location) pitfall_npc.startDeath(null) player.removeAttribute("pitfall:timestamp:${pit.location.x}:${pit.location.y}") player.incrementAttribute("pitfall:count", -1) @@ -233,6 +238,7 @@ class PitfallListeners : InteractionListener { val npcdst = dst.transform(dir, if(dir == Direction.SOUTH || dir == Direction.WEST) 1 else 0) teleport(pitfall_npc, npcdst) pitfall_npc.animate(Animation(5232, Priority.HIGH)) + player.audioManager.send(Sounds.HUNTING_BIGCAT_JUMP_2619, 10, 0, 10, pit.location) pitfall_npc.attack(player) pitfall_npc.setAttribute("last_pit_loc", pit.location) } @@ -242,6 +248,7 @@ class PitfallListeners : InteractionListener { } on(SPIKED_PIT, IntType.SCENERY, "dismantle") { player, node -> val pit = node as Scenery; + playAudio(player, getAudio(Sounds.HUNTING_TAKEBRANCHES_2649)) player.removeAttribute("pitfall:timestamp:${pit.location.x}:${pit.location.y}") player.incrementAttribute("pitfall:count", -1) setPitState(player, pit.location, 0) @@ -274,6 +281,7 @@ class PitfallListeners : InteractionListener { return@on true } entity.attack(player) + playAudio(player, getAudio(Sounds.HUNTING_TEASE_FELINE_2651)) player.setAttribute("pitfall_npc", entity) return@on true } @@ -287,6 +295,7 @@ class PitfallListeners : InteractionListener { setPitState(player, pit.location, 0) player.getSkills().addExperience(Skills.HUNTER, xp, true); player.inventory.add(Item(Items.BIG_BONES_532)) + playAudio(player, getAudio(Sounds.HUNTING_TAKEBRANCHES_2649)) // TODO: what's the actual probability of tatty vs perfect fur? val chance = RandomFunction.getSkillSuccessChance(50.0, 100.0, player.skills.getLevel(Skills.HUNTER)) if(RandomFunction.random(0.0, 100.0) < chance) { diff --git a/Server/src/main/content/global/skill/hunter/tracking/HunterTracking.kt b/Server/src/main/content/global/skill/hunter/tracking/HunterTracking.kt index c5918aca4..429836909 100644 --- a/Server/src/main/content/global/skill/hunter/tracking/HunterTracking.kt +++ b/Server/src/main/content/global/skill/hunter/tracking/HunterTracking.kt @@ -16,6 +16,7 @@ import org.rs09.consts.Items import core.tools.SystemLogger import core.game.world.GameWorld import core.tools.Log +import org.rs09.consts.Sounds import java.util.* /** @@ -164,6 +165,7 @@ abstract class HunterTracking : OptionHandler(){ fun reward(player: Player, success: Boolean) { player.lock() player.animator.animate(if(success) KEBBIT_ANIM else MISS_ANIM) + playAudio(player, getAudio(Sounds.HUNTING_NOOSE_2637)) GameWorld.Pulser.submit(object : Pulse(KEBBIT_ANIM.duration){ override fun pulse(): Boolean { if(hasTrail(player) && success){ diff --git a/Server/src/main/core/game/node/entity/player/link/audio/AudioManager.java b/Server/src/main/core/game/node/entity/player/link/audio/AudioManager.java index b004afee4..82fb6d29b 100644 --- a/Server/src/main/core/game/node/entity/player/link/audio/AudioManager.java +++ b/Server/src/main/core/game/node/entity/player/link/audio/AudioManager.java @@ -65,6 +65,18 @@ public class AudioManager { send(new Audio(audioId, volume, delay), false); } + /** + * Sends an audio packet. + * @param audioId the audio id. + * @param volume the volume. + * @param delay the delay. + * @param radius the distance the sound can be heard. + * @param loc the location. + */ + public void send(int audioId, int volume, int delay, int radius, Location loc) { + send(new Audio(audioId, volume, delay, radius), false, loc); + } + /** * Sends an audio packet. * @param audio the audio.