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
This commit is contained in:
Zerken
2023-06-16 06:28:40 +00:00
committed by Ryan
parent 22776e7bb3
commit d04302c99f
8 changed files with 92 additions and 0 deletions
@@ -11,6 +11,9 @@ import core.game.node.scenery.Scenery;
import core.game.node.scenery.SceneryBuilder; import core.game.node.scenery.SceneryBuilder;
import core.game.world.map.Location; import core.game.world.map.Location;
import core.game.world.map.RegionManager; import core.game.world.map.RegionManager;
import org.rs09.consts.Sounds;
import static core.api.ContentAPIKt.*;
/** /**
* Handles the trap creating pulse. * Handles the trap creating pulse.
@@ -51,6 +54,26 @@ public final class TrapCreatePulse extends SkillPulse<Node> {
this.trap = trap; this.trap = trap;
this.startLocation = node instanceof GroundItem ? node.getLocation() : player.getLocation(); this.startLocation = node instanceof GroundItem ? node.getLocation() : player.getLocation();
this.instance = HunterManager.getInstance(player); 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 @Override
@@ -5,6 +5,9 @@ import core.game.node.entity.skill.SkillPulse;
import core.game.node.entity.skill.Skills; import core.game.node.entity.skill.Skills;
import core.game.node.entity.player.Player; import core.game.node.entity.player.Player;
import core.game.node.scenery.Scenery; import core.game.node.scenery.Scenery;
import org.rs09.consts.Sounds;
import static core.api.ContentAPIKt.*;
/** /**
* Handles the dismantling of a trap. * Handles the dismantling of a trap.
@@ -39,6 +42,27 @@ public final class TrapDismantlePulse extends SkillPulse<Scenery> {
this.trap = wrapper.getType(); this.trap = wrapper.getType();
this.wrapper = wrapper; this.wrapper = wrapper;
this.instance = HunterManager.getInstance(player); 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 @Override
@@ -16,6 +16,7 @@ import core.game.world.GameWorld;
import core.game.world.map.Location; import core.game.world.map.Location;
import core.game.world.update.flag.context.Animation; import core.game.world.update.flag.context.Animation;
import core.tools.RandomFunction; import core.tools.RandomFunction;
import org.rs09.consts.Sounds;
/** /**
* A setting for a trap type. * A setting for a trap type.
@@ -306,6 +307,22 @@ public class TrapSetting {
wrapper.setTicks(GameWorld.getTicks() + 100); wrapper.setTicks(GameWorld.getTicks() + 100);
wrapper.setReward(node); wrapper.setReward(node);
wrapper.setObject(getFinalId(wrapper, 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; return true;
} }
npc.moveStep(); npc.moveStep();
@@ -11,6 +11,7 @@ import core.game.world.GameWorld;
import core.game.world.update.flag.context.Animation; import core.game.world.update.flag.context.Animation;
import core.tools.RandomFunction; import core.tools.RandomFunction;
import core.tools.StringUtils; import core.tools.StringUtils;
import org.rs09.consts.Sounds;
import java.util.Random; import java.util.Random;
@@ -93,6 +94,7 @@ public final class BNetPulse extends SkillPulse<NPC> {
public void animate() { public void animate() {
if (ticks < 1) { if (ticks < 1) {
player.animate(ANIMATION); player.animate(ANIMATION);
player.getAudioManager().send(Sounds.HUNTING_BUTTERFLYNET_2623);
} }
} }
@@ -13,6 +13,7 @@ import core.game.world.GameWorld;
import core.game.world.map.Location; import core.game.world.map.Location;
import core.game.world.repository.Repository; import core.game.world.repository.Repository;
import core.tools.RandomFunction; import core.tools.RandomFunction;
import org.rs09.consts.Sounds;
/** /**
* Represents the skill pulse used to catch a kebbit. * Represents the skill pulse used to catch a kebbit.
@@ -123,6 +124,7 @@ public final class FalconryCatchPulse extends SkillPulse<NPC> {
falcon.setAttribute("falcon:catch", falconCatch); falcon.setAttribute("falcon:catch", falconCatch);
falcon.init(); falcon.init();
HintIconManager.registerHintIcon(player, falcon); HintIconManager.registerHintIcon(player, falcon);
player.getAudioManager().send(Sounds.HUNTING_FALCON_SWOOP_2634, 10, 0, 12, node.getLocation());
GameWorld.getPulser().submit(new Pulse(100, falcon) { GameWorld.getPulser().submit(new Pulse(100, falcon) {
@Override @Override
public boolean pulse() { public boolean pulse() {
@@ -155,6 +157,7 @@ public final class FalconryCatchPulse extends SkillPulse<NPC> {
projectile.setStartHeight(26); projectile.setStartHeight(26);
projectile.setEndHeight(1); projectile.setEndHeight(1);
projectile.send(); projectile.send();
player.getAudioManager().send(Sounds.HUNTING_FALCON_FLY_2633);
} }
/** /**
@@ -22,6 +22,7 @@ import org.rs09.consts.NPCs
import core.game.interaction.InteractionListener import core.game.interaction.InteractionListener
import core.game.interaction.IntType import core.game.interaction.IntType
import core.game.world.GameWorld import core.game.world.GameWorld
import org.rs09.consts.Sounds
/*@Initializable /*@Initializable
class HunterPitfall : OptionHandler() { class HunterPitfall : OptionHandler() {
@@ -187,6 +188,7 @@ class PitfallListeners : InteractionListener {
player.setAttribute("pitfall:timestamp:${pit.location.x}:${pit.location.y}", System.currentTimeMillis()) player.setAttribute("pitfall:timestamp:${pit.location.x}:${pit.location.y}", System.currentTimeMillis())
setPitState(player, pit.location, 1) setPitState(player, pit.location, 1)
playAudio(player, getAudio(Sounds.HUNTING_PLACEBRANCHES_2639))
val collapsePulse = object : Pulse(201, player) { val collapsePulse = object : Pulse(201, player) {
override fun pulse(): Boolean { override fun pulse(): Boolean {
val oldTime = player.getAttribute("pitfall:timestamp:${pit.location.x}:${pit.location.y}", System.currentTimeMillis()) val oldTime = player.getAttribute("pitfall:timestamp:${pit.location.x}:${pit.location.y}", System.currentTimeMillis())
@@ -208,6 +210,7 @@ class PitfallListeners : InteractionListener {
if(dir != null) { if(dir != null) {
val dst = src.transform(dir, 3) val dst = src.transform(dir, 3)
ForceMovement.run(player, src, dst, ForceMovement.WALK_ANIMATION, Animation(1603), dir, 16); 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) val pitfall_npc: Entity? = player.getAttribute("pitfall_npc", null)
if(pitfall_npc != null && pitfall_npc.getLocation().getDistance(src) < 3.0) { if(pitfall_npc != null && pitfall_npc.getLocation().getDistance(src) < 3.0) {
val last_pit_loc: Location? = pitfall_npc.getAttribute("last_pit_loc", null) 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.setLocation(pit.getLocation());
//pitfall_npc.walkingQueue.addPath(pit.location.x, pit.location.y); //pitfall_npc.walkingQueue.addPath(pit.location.x, pit.location.y);
teleport(pitfall_npc, pit.location) 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) pitfall_npc.startDeath(null)
player.removeAttribute("pitfall:timestamp:${pit.location.x}:${pit.location.y}") player.removeAttribute("pitfall:timestamp:${pit.location.x}:${pit.location.y}")
player.incrementAttribute("pitfall:count", -1) 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) val npcdst = dst.transform(dir, if(dir == Direction.SOUTH || dir == Direction.WEST) 1 else 0)
teleport(pitfall_npc, npcdst) teleport(pitfall_npc, npcdst)
pitfall_npc.animate(Animation(5232, Priority.HIGH)) 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.attack(player)
pitfall_npc.setAttribute("last_pit_loc", pit.location) pitfall_npc.setAttribute("last_pit_loc", pit.location)
} }
@@ -242,6 +248,7 @@ class PitfallListeners : InteractionListener {
} }
on(SPIKED_PIT, IntType.SCENERY, "dismantle") { player, node -> on(SPIKED_PIT, IntType.SCENERY, "dismantle") { player, node ->
val pit = node as Scenery; val pit = node as Scenery;
playAudio(player, getAudio(Sounds.HUNTING_TAKEBRANCHES_2649))
player.removeAttribute("pitfall:timestamp:${pit.location.x}:${pit.location.y}") player.removeAttribute("pitfall:timestamp:${pit.location.x}:${pit.location.y}")
player.incrementAttribute("pitfall:count", -1) player.incrementAttribute("pitfall:count", -1)
setPitState(player, pit.location, 0) setPitState(player, pit.location, 0)
@@ -274,6 +281,7 @@ class PitfallListeners : InteractionListener {
return@on true return@on true
} }
entity.attack(player) entity.attack(player)
playAudio(player, getAudio(Sounds.HUNTING_TEASE_FELINE_2651))
player.setAttribute("pitfall_npc", entity) player.setAttribute("pitfall_npc", entity)
return@on true return@on true
} }
@@ -287,6 +295,7 @@ class PitfallListeners : InteractionListener {
setPitState(player, pit.location, 0) setPitState(player, pit.location, 0)
player.getSkills().addExperience(Skills.HUNTER, xp, true); player.getSkills().addExperience(Skills.HUNTER, xp, true);
player.inventory.add(Item(Items.BIG_BONES_532)) 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? // TODO: what's the actual probability of tatty vs perfect fur?
val chance = RandomFunction.getSkillSuccessChance(50.0, 100.0, player.skills.getLevel(Skills.HUNTER)) val chance = RandomFunction.getSkillSuccessChance(50.0, 100.0, player.skills.getLevel(Skills.HUNTER))
if(RandomFunction.random(0.0, 100.0) < chance) { if(RandomFunction.random(0.0, 100.0) < chance) {
@@ -16,6 +16,7 @@ import org.rs09.consts.Items
import core.tools.SystemLogger import core.tools.SystemLogger
import core.game.world.GameWorld import core.game.world.GameWorld
import core.tools.Log import core.tools.Log
import org.rs09.consts.Sounds
import java.util.* import java.util.*
/** /**
@@ -164,6 +165,7 @@ abstract class HunterTracking : OptionHandler(){
fun reward(player: Player, success: Boolean) { fun reward(player: Player, success: Boolean) {
player.lock() player.lock()
player.animator.animate(if(success) KEBBIT_ANIM else MISS_ANIM) 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){ GameWorld.Pulser.submit(object : Pulse(KEBBIT_ANIM.duration){
override fun pulse(): Boolean { override fun pulse(): Boolean {
if(hasTrail(player) && success){ if(hasTrail(player) && success){
@@ -65,6 +65,18 @@ public class AudioManager {
send(new Audio(audioId, volume, delay), false); 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. * Sends an audio packet.
* @param audio the audio. * @param audio the audio.