From c52e02936d13d0ed6a260c6584ea49fd5528030a Mon Sep 17 00:00:00 2001 From: Zerken Date: Thu, 24 Aug 2023 13:58:19 +0000 Subject: [PATCH] Audio refactor continued Implemented admin audio command ::audio audioId loops[optional] Implemented admin globalaudio command ::globalaudio audioId radius playername (plays from that players location) or can be used by coords ::globalaudio audioId radius x y z Refactored the following sounds: Tribal totem quest Cromperty teleport (fixed looping) Vinesweeper tool leprechaun teleport sound (Corrected this sound so it does not loop 10 times) Antifire and poision immunity 30 seconds remaining tick tock sounds and sound of the potions expiring (Fixed it so it plays the correct number of tick tocks) Sound when summoning a familiar (All familiars were using the summon unicorn sound. It is now defaulted to the normal summoning sound instead of the unicorn summon sound. All familiars on first summon have a their own sounds that will need to be implemented later) Door and gate sounds Bank interface sounds Unicorn stallion special move sound Agility pyramid rolling block sounds Prayer book sounds Lunar stat spy Hunter falconry Picking items in a field like potatoes Ectophial teleport and refill Summoning pouch creation and renewing points Runecrafting at altar sound Making finished and unfinished potions Cutting gems Entering giant mole area Praying at an altar Warriors guild animator sounds Chiseling limestone Spirit wolf special move sound Telegrab spell sound Glassblowing sound Strong of security opening reward chest creaking sound Butterfly net sound Desert rug travel rise and descend sound Enchanting bolts Woodcutting tree falling and chopping sound Hunter setting up dismantling traps and pitfall sounds Explorers ring run energy restore sound Farming: Raking, adding compost to patch, picking from fruit trees, seed dibb, using plant cure on patch, opening/closing/adding to/from compost bin Mage training arena alchemy spell sounds Breaking bones to peaches/bananas tab sound Casting silver sickle bloom Entrana magic door teleport Cabbage teleport Teleother cast sound Fairy ring teleport sound Lunar vengeance spells Running out of prayer sound Lunar (non teleport) spells Super heat and bones to bananas normal spell book sounds Equip/unequip item sound Revenant combat sounds Herb cleaning sound Emptying buckets/bowls/jugs of water Making cannonballs at a furnace Digging with a spade Peer the seer fremmenik trials challenge: heating items on the range Blessing a spirit shield at a POH altar ContentAPI function stun sound Picking up items off the ground Eating food sound Cooking and intentionally burning food Drinking a potion Warriors guild catapult Pulling wilderness teleport levers Offering bones on a POH altar Slashing spider webs in Varrock sewers Entering POH portal teleport sound GE exchanging item set sound Jumping wilderness ditch Dragon axe special Digging up a farming patch Lunar heal spells Chaos elemental projectile impact sounds Mounted glory teleport Lunar share and boost potion spell Dwarf multi cannon setup, rotate, and firing sounds NPC attacking sound Enchanted bolt effect combat sound --- .../main/content/data/tables/BirdNest.java | 5 +- .../iface/BoltEnchantingInterface.java | 5 +- .../global/handlers/iface/GlassInterface.java | 2 +- .../iface/ge/GrandExchangeInterface.java | 6 +- .../handlers/item/EmptyOptionPlugin.java | 4 +- .../handlers/item/ExplorersRingPlugin.kt | 2 +- .../handlers/item/SpadeDigOptionPlugin.java | 5 +- .../special/ClobberSpecialHandler.kt | 16 +- .../item/withobject/AmmoMouldOnFurnace.kt | 2 +- .../handlers/scenery/FieldPickingPlugin.java | 6 +- .../handlers/scenery/SlashWebPlugin.java | 6 +- .../skill/agility/pyramid/RollingBlock.java | 7 +- .../skill/construction/HouseManager.java | 4 +- .../decoration/chapel/BoneOfferPlugin.java | 3 +- .../decoration/chapel/ShieldBlessingPlugin.kt | 5 +- .../decoration/questhall/MountedGlory.kt | 9 +- .../questhall/MountedGloryPlugin.java | 6 +- .../skill/cooking/IntentionalBurnPulse.java | 5 +- .../skill/cooking/StandardCookingPulse.java | 5 +- .../skill/crafting/gem/GemCutPulse.java | 5 +- .../limestone/ChiselLimestonePulse.java | 5 +- .../global/skill/farming/CompostBin.kt | 9 +- .../global/skill/farming/CropHarvester.kt | 12 +- .../skill/farming/DigUpPatchDialogue.kt | 6 +- .../skill/farming/FruitAndBerryPicker.kt | 3 +- .../global/skill/farming/PatchRaker.kt | 4 +- .../skill/farming/UseWithPatchHandler.kt | 9 +- .../skill/gather/PickaxeRepairPlugin.kt | 4 +- .../gather/woodcutting/WoodcuttingListener.kt | 16 +- .../woodcutting/WoodcuttingSkillPulse.java | 11 +- .../skill/herblore/HerbCleanPlugin.java | 2 +- .../global/skill/herblore/HerblorePulse.java | 7 +- .../global/skill/hunter/TrapCreatePulse.java | 10 +- .../skill/hunter/TrapDismantlePulse.java | 8 +- .../global/skill/hunter/TrapSetting.java | 14 +- .../global/skill/hunter/bnet/BNetPulse.java | 4 +- .../hunter/falconry/FalconryCatchPulse.java | 6 +- .../skill/hunter/pitfall/HunterPitfall.kt | 6 +- .../global/skill/magic/SpellListener.kt | 3 +- .../global/skill/magic/SpellTablets.kt | 4 +- .../skill/magic/ancient/BloodSpells.java | 2 +- .../global/skill/magic/ancient/IceSpells.java | 2 +- .../skill/magic/ancient/MiasmicSpells.java | 2 +- .../skill/magic/ancient/ShadowSpells.java | 2 +- .../skill/magic/ancient/SmokeSpells.java | 2 +- .../global/skill/magic/lunar/HealSpell.java | 12 +- .../skill/magic/lunar/MagicImbueSpell.java | 5 +- .../skill/magic/lunar/StatBoostSpell.java | 8 +- .../skill/magic/lunar/StatRestoreSpell.java | 6 +- .../skill/magic/lunar/StatSpySpell.java | 7 +- .../skill/magic/lunar/VengeanceSpell.java | 6 +- .../skill/magic/modern/ModernListeners.kt | 4 +- .../skill/magic/modern/TeleblockSpell.java | 2 +- .../skill/prayer/BoneBuryingOptionPlugin.java | 10 +- .../skill/prayer/PrayerAltarPlugin.java | 4 +- .../skill/runecrafting/RuneCraftPulse.java | 7 +- .../smithing/smelting/SmeltingPulse.java | 2 +- .../skill/summoning/ObeliskOptionPlugin.java | 6 +- .../skill/summoning/SummoningCreator.java | 5 +- .../skill/summoning/familiar/Familiar.java | 8 +- .../summoning/familiar/SpiritWolfNPC.java | 5 +- .../familiar/UnicornStallionNPC.java | 5 +- .../main/content/minigame/mta/MTAListeners.kt | 6 +- .../minigame/mta/TelekineticGrabSpell.java | 5 +- .../minigame/vinesweeper/Vinesweeper.kt | 7 +- .../wguild/animator/AnimationRoom.java | 7 +- .../wguild/catapult/CatapultRoom.java | 5 +- .../falador/handlers/GiantMoleNPC.java | 5 +- .../desert/dialogue/RugMerchantDialogue.java | 4 +- .../thefremenniktrials/SeersHouseListeners.kt | 11 +- .../handlers/WildernessLeverPlugin.java | 5 +- .../quest/dwarfcannon/dmc/DMCHandler.java | 7 +- .../quest/tribaltotem/CrompertyDialogue.kt | 4 +- .../stronghold/StrongHoldSecurityPlugin.java | 12 +- .../quest/anma/AnimalMagnetismPlugin.java | 8 +- .../phas/handlers/EctoplasmFillPlugin.java | 7 +- .../morytania/quest/naturespirit/NSUtils.kt | 3 +- .../handlers/ChaosElementalNPC.java | 10 +- .../handlers/WildernessInterfacePlugin.java | 7 +- .../handlers/WildernessObeliskPlugin.java | 5 +- .../revenants/RevenantCombatHandler.java | 11 +- .../handlers/revenants/RevenantNPC.java | 10 +- Server/src/main/core/api/ContentAPI.kt | 14 +- .../src/main/core/game/consumable/Drink.java | 7 +- .../src/main/core/game/consumable/Food.java | 8 +- .../src/main/core/game/consumable/Potion.java | 6 +- Server/src/main/core/game/ge/GrandExchange.kt | 4 +- .../game/global/action/DoorActionHandler.java | 36 ++-- .../core/game/global/action/EquipHandler.kt | 6 +- .../core/game/global/action/PickupHandler.kt | 6 +- .../node/entity/combat/CombatSwingHandler.kt | 2 +- .../game/node/entity/combat/DeathTask.java | 2 +- .../entity/combat/equipment/BoltEffect.java | 4 +- .../node/entity/combat/spell/CombatSpell.java | 2 +- .../node/entity/combat/spell/MagicSpell.java | 2 +- .../main/core/game/node/entity/npc/NPC.java | 2 +- .../core/game/node/entity/player/Player.java | 25 +-- .../entity/player/link/BankPinManager.java | 13 +- .../entity/player/link/TeleportManager.java | 55 ++----- .../node/entity/player/link/audio/Audio.java | 155 ------------------ .../node/entity/player/link/audio/Audio.kt | 29 ++++ .../player/link/audio/AudioManager.java | 131 --------------- .../entity/player/link/prayer/Prayer.java | 10 +- .../entity/player/link/prayer/PrayerType.java | 6 +- .../link/request/assist/AssistSession.java | 4 +- .../core/game/node/entity/skill/Skills.java | 4 +- .../system/command/oldsys/VisualCommand.kt | 4 - ...{MusicCommandSet.kt => AudioCommandSet.kt} | 31 ++++ .../main/core/net/packet/out/AudioPacket.java | 12 +- 109 files changed, 463 insertions(+), 619 deletions(-) delete mode 100644 Server/src/main/core/game/node/entity/player/link/audio/Audio.java create mode 100644 Server/src/main/core/game/node/entity/player/link/audio/Audio.kt delete mode 100644 Server/src/main/core/game/node/entity/player/link/audio/AudioManager.java rename Server/src/main/core/game/system/command/sets/{MusicCommandSet.kt => AudioCommandSet.kt} (60%) diff --git a/Server/src/main/content/data/tables/BirdNest.java b/Server/src/main/content/data/tables/BirdNest.java index 929ca3adc..0552daa2e 100644 --- a/Server/src/main/content/data/tables/BirdNest.java +++ b/Server/src/main/content/data/tables/BirdNest.java @@ -8,6 +8,9 @@ import core.game.node.item.GroundItemManager; import core.game.node.item.Item; import core.tools.RandomFunction; import core.tools.StringUtils; +import org.rs09.consts.Sounds; + +import static core.api.ContentAPIKt.playAudio; /** * Represents a birds nest. @@ -93,7 +96,7 @@ public enum BirdNest { */ public static void drop(final Player player) { final BirdNest nest = getRandomNest(false); - player.getAudioManager().send(1997); + playAudio(player, Sounds.CUCKOO_1_1997); GroundItemManager.create(nest.getNest(), player); player.getPacketDispatch().sendMessage("A bird's nest falls out of the tree."); } diff --git a/Server/src/main/content/global/handlers/iface/BoltEnchantingInterface.java b/Server/src/main/content/global/handlers/iface/BoltEnchantingInterface.java index 77ea04dec..5d4a567ff 100644 --- a/Server/src/main/content/global/handlers/iface/BoltEnchantingInterface.java +++ b/Server/src/main/content/global/handlers/iface/BoltEnchantingInterface.java @@ -1,5 +1,6 @@ package content.global.handlers.iface; +import core.api.ContentAPIKt; import core.game.component.Component; import core.game.component.ComponentDefinition; import core.game.component.ComponentPlugin; @@ -15,6 +16,8 @@ import core.game.world.update.flag.context.Graphics; import core.plugin.Plugin; import org.rs09.consts.Sounds; +import static core.api.ContentAPIKt.playAudio; + /** * Represents the component plugin used to handle the bolt enchanting interface. * @author Emperor @@ -88,7 +91,7 @@ public final class BoltEnchantingInterface extends ComponentPlugin { } player.getSkills().addExperience(Skills.MAGIC, bolts.getExp(), true); player.getPacketDispatch().sendMessage("The magic of the runes coaxes out the true nature of the gem tips."); - player.getAudioManager().send(Sounds.ENCHANTED_TIPPING_2921); + playAudio(player, Sounds.ENCHANTED_TIPPING_2921); return true; } }); diff --git a/Server/src/main/content/global/handlers/iface/GlassInterface.java b/Server/src/main/content/global/handlers/iface/GlassInterface.java index dd515ce37..0dc72c9ad 100644 --- a/Server/src/main/content/global/handlers/iface/GlassInterface.java +++ b/Server/src/main/content/global/handlers/iface/GlassInterface.java @@ -106,7 +106,7 @@ public final class GlassInterface extends ComponentPlugin { return true; } player.animate(ANIMATION); - player.getAudioManager().send(Sounds.GLASSBLOWING_2724); + playAudio(player, Sounds.GLASSBLOWING_2724); player.getInventory().remove(MOLTEN_GLASS); player.getInventory().add(new Item(glass.getProduct(), 1)); player.getSkills().addExperience(Skills.CRAFTING, glass.getExperience(), true); diff --git a/Server/src/main/content/global/handlers/iface/ge/GrandExchangeInterface.java b/Server/src/main/content/global/handlers/iface/ge/GrandExchangeInterface.java index dd01103aa..853808349 100644 --- a/Server/src/main/content/global/handlers/iface/ge/GrandExchangeInterface.java +++ b/Server/src/main/content/global/handlers/iface/ge/GrandExchangeInterface.java @@ -8,7 +8,6 @@ import core.game.component.ComponentPlugin; import core.game.ge.GEGuidePrice; import core.game.ge.GEItemSet; import core.game.node.entity.player.Player; -import core.game.node.entity.player.link.audio.Audio; import core.game.node.item.Item; import core.game.system.task.Pulse; import core.net.packet.PacketRepository; @@ -19,6 +18,9 @@ import core.plugin.Plugin; import core.game.ge.GrandExchangeOffer; import core.game.ge.GrandExchangeRecords; import core.game.world.GameWorld; +import org.rs09.consts.Sounds; + +import static core.api.ContentAPIKt.playAudio; /** * Handles the Grand Exchange interface options. @@ -178,7 +180,7 @@ public class GrandExchangeInterface extends ComponentPlugin { player.getInventory().refresh(); player.getPacketDispatch().sendMessage("You successfully traded your item components for a set!"); } - player.getAudioManager().send(new Audio(4044, 1, 1)); + playAudio(player, Sounds.GE_TRADE_OK_4044); PacketRepository.send(ContainerPacket.class, new ContainerContext(player, -1, -2, player.getAttribute("container-key", 93), player.getInventory(), false)); break; case 155: diff --git a/Server/src/main/content/global/handlers/item/EmptyOptionPlugin.java b/Server/src/main/content/global/handlers/item/EmptyOptionPlugin.java index 7e5514ff5..ac51b226b 100644 --- a/Server/src/main/content/global/handlers/item/EmptyOptionPlugin.java +++ b/Server/src/main/content/global/handlers/item/EmptyOptionPlugin.java @@ -11,6 +11,8 @@ import org.rs09.consts.Sounds; import java.util.HashMap; +import static core.api.ContentAPIKt.playAudio; + /** * Handles items with "empty" options * @author ceik @@ -29,7 +31,7 @@ public final class EmptyOptionPlugin extends OptionHandler { } if(EmptyItem.emptyItemMap.get(node.getId()) != null){ player.getInventory().remove(node.asItem()); - player.getAudioManager().send(Sounds.LIQUID_2401, 1); + playAudio(player, Sounds.LIQUID_2401, 0 ,1); player.getInventory().add(EmptyItem.getEmpty(node.getId())); player.getPacketDispatch().sendMessage(EmptyItem.getEmptyMessage(node.getId())); } else { diff --git a/Server/src/main/content/global/handlers/item/ExplorersRingPlugin.kt b/Server/src/main/content/global/handlers/item/ExplorersRingPlugin.kt index f8dc9de65..01fd85be6 100644 --- a/Server/src/main/content/global/handlers/item/ExplorersRingPlugin.kt +++ b/Server/src/main/content/global/handlers/item/ExplorersRingPlugin.kt @@ -28,7 +28,7 @@ class ExplorersRingPlugin : InteractionListener { return@on true } player.settings.updateRunEnergy(-50.0) - player.audioManager.send(5035) + playAudio(player, 5035) getStoreFile()[player.username.toLowerCase() + ":run"] = charges + 1 diff --git a/Server/src/main/content/global/handlers/item/SpadeDigOptionPlugin.java b/Server/src/main/content/global/handlers/item/SpadeDigOptionPlugin.java index 88228fe35..70d478faa 100644 --- a/Server/src/main/content/global/handlers/item/SpadeDigOptionPlugin.java +++ b/Server/src/main/content/global/handlers/item/SpadeDigOptionPlugin.java @@ -7,6 +7,9 @@ import core.game.node.Node; import core.game.node.entity.player.Player; import core.plugin.Initializable; import core.plugin.Plugin; +import org.rs09.consts.Sounds; + +import static core.api.ContentAPIKt.playAudio; /** * Represents the plugin used to handle the dig option on a spade. @@ -24,7 +27,7 @@ public class SpadeDigOptionPlugin extends OptionHandler { @Override public boolean handle(final Player player, Node node, String option) { - player.getAudioManager().send(1470,1,1); + playAudio(player, Sounds.DIGSPADE_1470); if (!DigSpadeHandler.dig(player)) { player.sendMessage("You dig but find nothing."); } diff --git a/Server/src/main/content/global/handlers/item/equipment/special/ClobberSpecialHandler.kt b/Server/src/main/content/global/handlers/item/equipment/special/ClobberSpecialHandler.kt index 25ff591a5..31629189e 100644 --- a/Server/src/main/content/global/handlers/item/equipment/special/ClobberSpecialHandler.kt +++ b/Server/src/main/content/global/handlers/item/equipment/special/ClobberSpecialHandler.kt @@ -1,6 +1,7 @@ package content.global.handlers.item.equipment.special import core.ServerConstants +import core.api.playAudio import core.game.container.impl.EquipmentContainer import core.game.node.entity.Entity import core.game.node.entity.combat.BattleState @@ -18,6 +19,7 @@ import core.plugin.Initializable import core.plugin.Plugin import core.tools.RandomFunction import org.rs09.consts.Items +import org.rs09.consts.Sounds /** @@ -70,7 +72,7 @@ class ClobberSpecialHandler : MeleeSwingHandler(), Plugin { victim.skills.updateLevel(Skills.DEFENCE, -hit, 0) victim.skills.updateLevel(Skills.MAGIC, -hit, 0) - player.audioManager.send(AUTHENTIC_AUDIO) + playAudio(player, Sounds.CLOBBER_2531, 20) return 1 } @@ -84,7 +86,7 @@ class ClobberSpecialHandler : MeleeSwingHandler(), Plugin { player.sendChat("Chop chop!") player.skills.updateLevel(Skills.WOODCUTTING, 3, player.skills.getStaticLevel(Skills.WOODCUTTING) + 3) visualize(player, null, null) - player.audioManager.send(OSRS_AUDIO) + playAudio(player, Sounds.CLOBBER_2531, 20) return -1 } @@ -104,16 +106,6 @@ class ClobberSpecialHandler : MeleeSwingHandler(), Plugin { */ private val GRAPHIC = Graphics(479, 96) - /** - * The authentic sound. - */ - private val AUTHENTIC_AUDIO = Audio(2531) - - /** - * The OSRS sound. - */ - private val OSRS_AUDIO = Audio(2530) - /** * The item. */ diff --git a/Server/src/main/content/global/handlers/item/withobject/AmmoMouldOnFurnace.kt b/Server/src/main/content/global/handlers/item/withobject/AmmoMouldOnFurnace.kt index 3ac1f9c45..5b78dd96b 100644 --- a/Server/src/main/content/global/handlers/item/withobject/AmmoMouldOnFurnace.kt +++ b/Server/src/main/content/global/handlers/item/withobject/AmmoMouldOnFurnace.kt @@ -40,7 +40,7 @@ class AmmoMouldOnFurnace : InteractionListener { 0 -> { sendMessage(player,"You heat the steel bar into a liquid state.") animate(player, 3243) // 899 would be preferable but the arms spaz out - player.audioManager.send(Sounds.FURNACE_2725, 1) + playAudio(player, Sounds.FURNACE_2725) } 3 -> { sendMessage(player,"You pour the molten metal into your cannonball mould.") diff --git a/Server/src/main/content/global/handlers/scenery/FieldPickingPlugin.java b/Server/src/main/content/global/handlers/scenery/FieldPickingPlugin.java index 12fd3eec8..ec2d8bc96 100644 --- a/Server/src/main/content/global/handlers/scenery/FieldPickingPlugin.java +++ b/Server/src/main/content/global/handlers/scenery/FieldPickingPlugin.java @@ -18,6 +18,8 @@ import core.plugin.Initializable; import core.tools.RandomFunction; import org.rs09.consts.Sounds; +import static core.api.ContentAPIKt.playAudio; + /** * Handles the pick option of interactive scenery (non-farming cabbages, * potatoes, bananas, etc) @@ -65,7 +67,7 @@ public final class FieldPickingPlugin extends OptionHandler { player.lock(1); player.setAttribute("delay:picking", GameWorld.getTicks() + (plant == PickingPlant.FLAX ? 2 : 3)); player.animate(ANIMATION); - player.getAudioManager().send(Sounds.PICK_2581,10, 30); + playAudio(player, Sounds.PICK_2581, 30); if (plant.name().startsWith("NETTLES") && (player.getEquipment().get(EquipmentContainer.SLOT_HANDS) == null || player.getEquipment().get(EquipmentContainer.SLOT_HANDS) != null && !player.getEquipment().get(EquipmentContainer.SLOT_HANDS).getName().contains("glove"))) { player.getPacketDispatch().sendMessage("You have been stung by the nettles!"); player.getImpactHandler().manualHit(player, 2, HitsplatType.POISON); @@ -126,7 +128,7 @@ public final class FieldPickingPlugin extends OptionHandler { */ private void handleFlaxPick(final Player player, final Scenery object, final PickingPlant plant) { int charge = object.getCharge(); - player.getAudioManager().send(2581); + playAudio(player, Sounds.PICK_2581); player.getPacketDispatch().sendMessage("You pick some flax."); // Seers achievement diary diff --git a/Server/src/main/content/global/handlers/scenery/SlashWebPlugin.java b/Server/src/main/content/global/handlers/scenery/SlashWebPlugin.java index d9fefe4c5..70ea5105b 100644 --- a/Server/src/main/content/global/handlers/scenery/SlashWebPlugin.java +++ b/Server/src/main/content/global/handlers/scenery/SlashWebPlugin.java @@ -12,13 +12,15 @@ import core.game.node.entity.combat.equipment.WeaponInterface.AttackStyle; import core.game.node.entity.combat.equipment.WeaponInterface.WeaponInterfaces; import core.game.node.entity.player.Player; import core.game.node.entity.player.link.diary.DiaryType; -import core.game.node.entity.player.link.audio.Audio; import core.game.node.item.Item; import core.game.node.scenery.Scenery; import core.game.node.scenery.SceneryBuilder; import core.game.world.update.flag.context.Animation; import core.plugin.Plugin; import core.tools.RandomFunction; +import org.rs09.consts.Sounds; + +import static core.api.ContentAPIKt.playAudio; /** * Handles the slashing of a web object. @@ -74,7 +76,7 @@ public final class SlashWebPlugin extends OptionHandler { } final boolean success = RandomFunction.random(2) == 1; player.lock(2); - player.getAudioManager().send(new Audio(2548)); + playAudio(player, Sounds.STABSWORD_SLASH_2548); player.animate(weapon == KNIFE ? KNIFE_ANIMATION : ANIMATION); if (success) { player.getPacketDispatch().sendMessage("You slash the web apart."); diff --git a/Server/src/main/content/global/skill/agility/pyramid/RollingBlock.java b/Server/src/main/content/global/skill/agility/pyramid/RollingBlock.java index f5d31adab..7573889aa 100644 --- a/Server/src/main/content/global/skill/agility/pyramid/RollingBlock.java +++ b/Server/src/main/content/global/skill/agility/pyramid/RollingBlock.java @@ -12,6 +12,9 @@ import core.game.world.map.Direction; import core.game.world.map.Location; import core.game.world.map.RegionManager; import core.game.world.update.flag.context.Animation; +import org.rs09.consts.Sounds; + +import static core.api.ContentAPIKt.playAudio; /** * Represents the rolling block obstacle. @@ -29,8 +32,8 @@ public final class RollingBlock implements MovementHook { final boolean fail = backwards || AgilityHandler.hasFailed(player, 2, 0.3); player.lock(5); AgilityPyramidCourse.addConfig(player, stone, 1, false); - player.getAudioManager().send(1396); - player.getAudioManager().send(2469, 10 , 40); + playAudio(player, Sounds.PYRAMID_SCRAPE_1396); + playAudio(player, Sounds.LAND_FLAT_2469, 40); if(e.isPlayer()) { diff --git a/Server/src/main/content/global/skill/construction/HouseManager.java b/Server/src/main/content/global/skill/construction/HouseManager.java index 3a93bbf06..9e5e4f1ea 100644 --- a/Server/src/main/content/global/skill/construction/HouseManager.java +++ b/Server/src/main/content/global/skill/construction/HouseManager.java @@ -8,7 +8,6 @@ import core.api.regionspec.RegionSpecification; import core.api.regionspec.contracts.FillChunkContract; import core.game.dialogue.FacialExpression; import core.game.node.entity.player.Player; -import core.game.node.entity.player.link.audio.Audio; import core.game.node.entity.skill.Skills; import core.game.node.scenery.Scenery; import core.game.system.task.Pulse; @@ -25,6 +24,7 @@ import org.json.simple.JSONArray; import org.json.simple.JSONObject; import core.tools.SystemLogger; import core.game.world.GameWorld; +import org.rs09.consts.Sounds; import java.awt.*; import java.nio.ByteBuffer; @@ -224,7 +224,7 @@ public final class HouseManager { private void openLoadInterface(Player player) { player.getInterfaceManager().openComponent(399); - player.getAudioManager().send(new Audio(984)); + playAudio(player, Sounds.POH_TELEPORT_984); submitCloseLoadInterfacePulse(player); } diff --git a/Server/src/main/content/global/skill/construction/decoration/chapel/BoneOfferPlugin.java b/Server/src/main/content/global/skill/construction/decoration/chapel/BoneOfferPlugin.java index d241c0e1a..70a5eeb81 100644 --- a/Server/src/main/content/global/skill/construction/decoration/chapel/BoneOfferPlugin.java +++ b/Server/src/main/content/global/skill/construction/decoration/chapel/BoneOfferPlugin.java @@ -18,6 +18,7 @@ import core.game.world.update.flag.context.Animation; import core.game.world.update.flag.context.Graphics; import core.plugin.Initializable; import core.plugin.Plugin; +import org.rs09.consts.Sounds; /** * Handles the offering of bones on an altar. @@ -98,7 +99,7 @@ public class BoneOfferPlugin extends UseWithHandler { if (counter == 1 || counter % 5 == 0) { if (player.getInventory().remove(new Item(b.getItemId()))) { player.animate(ANIM); - player.getAudioManager().send(new Audio(958)); + playAudio(player, Sounds.POH_OFFER_BONES_958); player.getPacketDispatch().sendPositionedGraphics(GFX, gfxLoc); player.sendMessage(getMessage(isLit(left), isLit(right))); player.getSkills().addExperience(Skills.PRAYER, b.getExperience() * getMod(altar, isLit(left), isLit(right))); diff --git a/Server/src/main/content/global/skill/construction/decoration/chapel/ShieldBlessingPlugin.kt b/Server/src/main/content/global/skill/construction/decoration/chapel/ShieldBlessingPlugin.kt index 6e6f6a539..9a8e34c76 100644 --- a/Server/src/main/content/global/skill/construction/decoration/chapel/ShieldBlessingPlugin.kt +++ b/Server/src/main/content/global/skill/construction/decoration/chapel/ShieldBlessingPlugin.kt @@ -1,14 +1,15 @@ package content.global.skill.construction.decoration.chapel +import core.api.playAudio import core.game.interaction.NodeUsageEvent import core.game.interaction.UseWithHandler -import core.game.node.entity.player.link.audio.Audio import core.game.node.entity.skill.Skills import core.game.node.item.Item import core.game.world.update.flag.context.Animation import core.plugin.Initializable import core.plugin.Plugin import org.rs09.consts.Items +import org.rs09.consts.Sounds const val HOLY_ELIXER = 13754 const val SPIRIT_SHIELD = 13734 @@ -38,7 +39,7 @@ class ShieldBlessingPlugin : UseWithHandler(HOLY_ELIXER, SPIRIT_SHIELD) { } player.animator.animate(Animation(896)) - player.audioManager.send(Audio(958)) + playAudio(player, Sounds.POH_OFFER_BONES_958) if(player.inventory.remove(Item(HOLY_ELIXER)) && player.inventory.remove(Item(SPIRIT_SHIELD))) player.inventory.add(Item(Items.BLESSED_SPIRIT_SHIELD_13736)) diff --git a/Server/src/main/content/global/skill/construction/decoration/questhall/MountedGlory.kt b/Server/src/main/content/global/skill/construction/decoration/questhall/MountedGlory.kt index 2a2adec95..44c9750a9 100644 --- a/Server/src/main/content/global/skill/construction/decoration/questhall/MountedGlory.kt +++ b/Server/src/main/content/global/skill/construction/decoration/questhall/MountedGlory.kt @@ -1,14 +1,15 @@ package content.global.skill.construction.decoration.questhall +import core.api.playGlobalAudio import core.api.teleport +import core.game.interaction.IntType +import core.game.interaction.InteractionListener import core.game.node.entity.player.Player -import core.game.node.entity.player.link.audio.Audio import core.game.system.task.Pulse import core.game.world.map.Location import core.game.world.update.flag.context.Animation import core.game.world.update.flag.context.Graphics -import core.game.interaction.InteractionListener -import core.game.interaction.IntType +import org.rs09.consts.Sounds import java.util.concurrent.Executors import java.util.concurrent.TimeUnit @@ -53,7 +54,7 @@ class MountedGlory : InteractionListener { 1 -> { player.lock(5) player.visualize(Animation(714), Graphics(308, 100, 50)) - player.getAudioManager().send(Audio(200), true) + playGlobalAudio(player.location, Sounds.TELEPORT_ALL_200) } 4 -> player.animator.reset().also { teleport(player, TELEPORTS[int]) } } diff --git a/Server/src/main/content/global/skill/construction/decoration/questhall/MountedGloryPlugin.java b/Server/src/main/content/global/skill/construction/decoration/questhall/MountedGloryPlugin.java index 4323ce498..90d96eb80 100644 --- a/Server/src/main/content/global/skill/construction/decoration/questhall/MountedGloryPlugin.java +++ b/Server/src/main/content/global/skill/construction/decoration/questhall/MountedGloryPlugin.java @@ -7,7 +7,6 @@ import core.game.dialogue.DialogueInterpreter; import core.game.interaction.OptionHandler; import core.game.node.Node; import core.game.node.entity.player.Player; -import core.game.node.entity.player.link.audio.Audio; import core.game.system.task.Pulse; import core.game.world.GameWorld; import core.game.world.map.Location; @@ -15,6 +14,9 @@ import core.game.world.update.flag.context.Animation; import core.game.world.update.flag.context.Graphics; import core.plugin.Initializable; import core.plugin.Plugin; +import org.rs09.consts.Sounds; + +import static core.api.ContentAPIKt.playGlobalAudio; /** * Handles the POH Mounted Glory. @@ -79,7 +81,7 @@ public class MountedGloryPlugin extends OptionHandler { } player.lock(); player.visualize(ANIMATION, GRAPHICS); - player.getAudioManager().send(new Audio(200), true); + playGlobalAudio(player.getLocation(), Sounds.TELEPORT_ALL_200); player.getImpactHandler().setDisabledTicks(4); GameWorld.getPulser().submit(new Pulse(4, player) { @Override diff --git a/Server/src/main/content/global/skill/cooking/IntentionalBurnPulse.java b/Server/src/main/content/global/skill/cooking/IntentionalBurnPulse.java index 1cd0d4923..051f5a14c 100644 --- a/Server/src/main/content/global/skill/cooking/IntentionalBurnPulse.java +++ b/Server/src/main/content/global/skill/cooking/IntentionalBurnPulse.java @@ -3,6 +3,9 @@ package content.global.skill.cooking; import core.game.node.entity.player.Player; import core.game.node.item.Item; import core.game.node.scenery.Scenery; +import org.rs09.consts.Sounds; + +import static core.api.ContentAPIKt.playAudio; public class IntentionalBurnPulse extends StandardCookingPulse { int initial,product,amount; @@ -47,7 +50,7 @@ public class IntentionalBurnPulse extends StandardCookingPulse { if (player.getInventory().remove(initialItem)) { player.getInventory().add(productItem); player.getPacketDispatch().sendMessage(getMessage(initialItem, productItem, burned)); - player.getAudioManager().send(SOUND); + playAudio(player, Sounds.FRY_2577); return true; } return false; diff --git a/Server/src/main/content/global/skill/cooking/StandardCookingPulse.java b/Server/src/main/content/global/skill/cooking/StandardCookingPulse.java index 9142ae020..66654e428 100644 --- a/Server/src/main/content/global/skill/cooking/StandardCookingPulse.java +++ b/Server/src/main/content/global/skill/cooking/StandardCookingPulse.java @@ -13,6 +13,9 @@ import core.game.system.task.Pulse; import core.game.world.update.flag.context.Animation; import core.tools.RandomFunction; import org.rs09.consts.Items; +import org.rs09.consts.Sounds; + +import static core.api.ContentAPIKt.playAudio; public class StandardCookingPulse extends Pulse { //range animation @@ -170,7 +173,7 @@ public class StandardCookingPulse extends Pulse { player.getInventory().add(CookableItems.getBurnt(initial)); } player.getPacketDispatch().sendMessage(getMessage(initialItem, productItem, burned)); - player.getAudioManager().send(SOUND); + playAudio(player, Sounds.FRY_2577); return true; } return false; diff --git a/Server/src/main/content/global/skill/crafting/gem/GemCutPulse.java b/Server/src/main/content/global/skill/crafting/gem/GemCutPulse.java index 123687c50..f094fa838 100644 --- a/Server/src/main/content/global/skill/crafting/gem/GemCutPulse.java +++ b/Server/src/main/content/global/skill/crafting/gem/GemCutPulse.java @@ -4,6 +4,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.item.Item; +import org.rs09.consts.Sounds; + +import static core.api.ContentAPIKt.playAudio; /** * Represents the pulse used to cut a gem. @@ -61,7 +64,7 @@ public final class GemCutPulse extends SkillPulse { @Override public void animate() { if (ticks % 5 == 0 || ticks < 1) { - player.getAudioManager().send(2586); + playAudio(player, Sounds.CHISEL_2586); player.animate(gem.getAnimation()); } } diff --git a/Server/src/main/content/global/skill/crafting/limestone/ChiselLimestonePulse.java b/Server/src/main/content/global/skill/crafting/limestone/ChiselLimestonePulse.java index 62333f0d6..259850dfa 100644 --- a/Server/src/main/content/global/skill/crafting/limestone/ChiselLimestonePulse.java +++ b/Server/src/main/content/global/skill/crafting/limestone/ChiselLimestonePulse.java @@ -5,6 +5,9 @@ import core.game.node.entity.skill.Skills; import core.game.node.entity.player.Player; import core.game.node.item.Item; import core.game.world.update.flag.context.Animation; +import org.rs09.consts.Sounds; + +import static core.api.ContentAPIKt.playAudio; /** * @@ -48,7 +51,7 @@ public class ChiselLimestonePulse extends SkillPulse { @Override public void animate() { if (ticks % 5 == 0 || ticks < 1) { - player.getAudioManager().send(2586); + playAudio(player, Sounds.CHISEL_2586); player.animate(Animation.create(4470)); } } diff --git a/Server/src/main/content/global/skill/farming/CompostBin.kt b/Server/src/main/content/global/skill/farming/CompostBin.kt index ebaf9a732..b8581d5e3 100644 --- a/Server/src/main/content/global/skill/farming/CompostBin.kt +++ b/Server/src/main/content/global/skill/farming/CompostBin.kt @@ -9,6 +9,7 @@ import core.tools.RandomFunction import org.json.simple.JSONArray import org.json.simple.JSONObject import org.rs09.consts.Items +import org.rs09.consts.Sounds import java.util.concurrent.TimeUnit class CompostBin(val player: Player, val bin: CompostBins) { @@ -25,14 +26,14 @@ class CompostBin(val player: Player, val bin: CompostBins) { fun close() { isClosed = true - player.audioManager.send(2428) + playAudio(player, Sounds.COMPOST_CLOSE_2428) finishedTime = System.currentTimeMillis() + TimeUnit.MINUTES.toMillis(RandomFunction.random(35,50).toLong()) updateBit() } fun open(){ isClosed = false - player.audioManager.send(2429) + playAudio(player, Sounds.COMPOST_OPEN_2429) updateBit() } @@ -47,7 +48,7 @@ class CompostBin(val player: Player, val bin: CompostBins) { isSuperCompost = true isClosed = false } - player.audioManager.send(Audio (2443, 1, 1)) + playAudio(player, Sounds.FARMING_SCOOP_2443) updateBit() if(isSuperCompost) rewardXP(player, Skills.FARMING, 8.5) else rewardXP(player, Skills.FARMING, 4.5) @@ -116,7 +117,7 @@ class CompostBin(val player: Player, val bin: CompostBins) { } else item.amount for(i in 0 until amount) { - player.audioManager.send(2441) + playAudio(player, Sounds.FARMING_PUTIN_2441) addItem(item.id) } } diff --git a/Server/src/main/content/global/skill/farming/CropHarvester.kt b/Server/src/main/content/global/skill/farming/CropHarvester.kt index d69f50bf0..4e0366e24 100644 --- a/Server/src/main/content/global/skill/farming/CropHarvester.kt +++ b/Server/src/main/content/global/skill/farming/CropHarvester.kt @@ -6,7 +6,6 @@ import core.game.interaction.OptionHandler import core.game.node.Node import content.global.skill.summoning.familiar.GiantEntNPC import core.game.node.entity.player.Player -import core.game.node.entity.player.link.audio.Audio import core.game.node.entity.skill.Skills import core.game.node.item.Item import core.game.system.task.Pulse @@ -14,6 +13,7 @@ import core.game.world.update.flag.context.Animation import core.plugin.Initializable import core.plugin.Plugin import org.rs09.consts.Items +import org.rs09.consts.Sounds val livesBased = arrayOf(PatchType.HERB, PatchType.CACTUS, PatchType.BELLADONNA, PatchType.HOPS, PatchType.ALLOTMENT,PatchType.EVIL_TURNIP) @@ -65,17 +65,17 @@ class CropHarvester : OptionHandler() { else -> Animation(0) } val sound = when(requiredItem){ - Items.SPADE_952 -> Audio(1470, 1, 1) - Items.SECATEURS_5329 -> Audio(2437, 1, 1) - Items.MAGIC_SECATEURS_7409 -> Audio(2437, 1, 1) - else -> Audio(0) + Items.SPADE_952 -> Sounds.DIGSPADE_1470 + Items.SECATEURS_5329 -> Sounds.FARMING_PICK_2437 + Items.MAGIC_SECATEURS_7409 -> Sounds.FARMING_PICK_2437 + else -> 0 } if(!player.inventory.containsItem(Item(requiredItem))){ player.sendMessage("You lack the needed tool to harvest these crops.") return true } player.animator.animate(anim) - player.audioManager.send(sound) + playAudio(player, sound) delay = 2 player.inventory.add(reward) player.skills.addExperience(Skills.FARMING,plantable.harvestXP) diff --git a/Server/src/main/content/global/skill/farming/DigUpPatchDialogue.kt b/Server/src/main/content/global/skill/farming/DigUpPatchDialogue.kt index c320336b1..c1f2666ff 100644 --- a/Server/src/main/content/global/skill/farming/DigUpPatchDialogue.kt +++ b/Server/src/main/content/global/skill/farming/DigUpPatchDialogue.kt @@ -1,5 +1,6 @@ package content.global.skill.farming +import core.api.playAudio import core.game.dialogue.DialoguePlugin import core.game.node.entity.player.Player import core.game.node.entity.player.link.audio.Audio @@ -8,6 +9,7 @@ import core.game.node.item.Item import core.game.system.task.Pulse import core.game.world.update.flag.context.Animation import core.plugin.Initializable +import org.rs09.consts.Sounds @Initializable class DigUpPatchDialogue(player: Player? = null) : DialoguePlugin(player) { @@ -35,8 +37,8 @@ class DigUpPatchDialogue(player: Player? = null) : DialoguePlugin(player) { 1 -> { end() player.animator.animate(Animation(830)) - player.audioManager.send(Audio(1470, 1, 1)) - player.pulseManager.run(object : Pulse(){ + playAudio(player, Sounds.DIGSPADE_1470) + player.pulseManager.run(object : Pulse(){ override fun pulse(): Boolean { if(patch?.patch?.type == PatchType.TREE){ if(patch?.getCurrentState() == (patch?.plantable?.value ?: 0) + (patch?.plantable?.stages ?: 0) + 2 && patch?.isWeedy() != true){ diff --git a/Server/src/main/content/global/skill/farming/FruitAndBerryPicker.kt b/Server/src/main/content/global/skill/farming/FruitAndBerryPicker.kt index 10ae27787..5c420a348 100644 --- a/Server/src/main/content/global/skill/farming/FruitAndBerryPicker.kt +++ b/Server/src/main/content/global/skill/farming/FruitAndBerryPicker.kt @@ -12,6 +12,7 @@ import core.game.system.task.Pulse import core.game.world.update.flag.context.Animation import core.plugin.Initializable import core.plugin.Plugin +import org.rs09.consts.Sounds import java.util.concurrent.TimeUnit @Initializable @@ -68,7 +69,7 @@ class FruitAndBerryPicker : OptionHandler() { } player.animator.animate(animation) - player.audioManager.send(2437) + playAudio(player, Sounds.FARMING_PICK_2437) addItemOrDrop(player,reward.id,reward.amount) player.skills.addExperience(Skills.FARMING,plantable.harvestXP) patch.setCurrentState(patch.getCurrentState() - 1) diff --git a/Server/src/main/content/global/skill/farming/PatchRaker.kt b/Server/src/main/content/global/skill/farming/PatchRaker.kt index ee4641925..6569ac495 100644 --- a/Server/src/main/content/global/skill/farming/PatchRaker.kt +++ b/Server/src/main/content/global/skill/farming/PatchRaker.kt @@ -1,11 +1,13 @@ package content.global.skill.farming +import core.api.playAudio import core.game.node.entity.player.Player import core.game.node.entity.skill.Skills import core.game.node.item.Item import core.game.system.task.Pulse import core.game.world.update.flag.context.Animation import org.rs09.consts.Items +import org.rs09.consts.Sounds object PatchRaker { val RAKE_ANIM = Animation(2273) @@ -17,7 +19,7 @@ object PatchRaker { var patchStage = patch.getPatchFor(player).getCurrentState() if(patchStage <= 2){ player.animator.animate(RAKE_ANIM) - player.audioManager.send(2442) + playAudio(player, Sounds.FARMING_RAKING_2442) } if(delay < 5) { delay = 5 diff --git a/Server/src/main/content/global/skill/farming/UseWithPatchHandler.kt b/Server/src/main/content/global/skill/farming/UseWithPatchHandler.kt index 02e02fcb6..a263f9812 100644 --- a/Server/src/main/content/global/skill/farming/UseWithPatchHandler.kt +++ b/Server/src/main/content/global/skill/farming/UseWithPatchHandler.kt @@ -9,6 +9,7 @@ import core.game.world.update.flag.context.Animation import org.rs09.consts.Items import core.game.interaction.IntType import core.game.interaction.InteractionListener +import org.rs09.consts.Sounds class UseWithPatchHandler : InteractionListener { val RAKE = Items.RAKE_5341 @@ -99,7 +100,7 @@ class UseWithPatchHandler : InteractionListener { player.pulseManager.run(object: Pulse(){ override fun pulse(): Boolean { player.animator.animate(plantCureAnim) - player.audioManager.send(2438) + playAudio(player, Sounds.FARMING_PLANTCURE_2438) if(player.inventory.remove(usedItem)){ player.inventory.add(Item(Items.VIAL_229)) p.cureDisease() @@ -123,7 +124,7 @@ class UseWithPatchHandler : InteractionListener { return true } player.animator.animate(wateringCanAnim) - player.audioManager.send(2446) + playAudio(player, Sounds.FARMING_WATERING_2446) if(player.inventory.remove(usedItem)){ player.inventory.add(Item(usedItem.id.getNext())) p.water() @@ -138,7 +139,7 @@ class UseWithPatchHandler : InteractionListener { val p = patch.getPatchFor(player) if(p.compost == CompostType.NONE) { player.animator.animate(pourBucketAnim) - player.audioManager.send(2427) + playAudio(player, Sounds.FARMING_COMPOST_2427) player.pulseManager.run(object : Pulse(){ override fun pulse(): Boolean { if(player.inventory.remove(usedItem,false)){ @@ -207,7 +208,7 @@ class UseWithPatchHandler : InteractionListener { player.lock() if(player.inventory.remove(plantItem)) { player.animator.animate(Animation(2291)) - player.audioManager.send(2432) + playAudio(player, Sounds.FARMING_DIBBING_2432) player.pulseManager.run(object : Pulse(3) { override fun pulse(): Boolean { if(plantable == Plantable.JUTE_SEED && patch == FarmingPatch.MCGRUBOR_HOPS && !player.achievementDiaryManager.hasCompletedTask(DiaryType.SEERS_VILLAGE,0,7)){ diff --git a/Server/src/main/content/global/skill/gather/PickaxeRepairPlugin.kt b/Server/src/main/content/global/skill/gather/PickaxeRepairPlugin.kt index 8ac6c82c9..83e3db86a 100644 --- a/Server/src/main/content/global/skill/gather/PickaxeRepairPlugin.kt +++ b/Server/src/main/content/global/skill/gather/PickaxeRepairPlugin.kt @@ -1,10 +1,12 @@ package content.global.skill.gather +import core.api.playAudio import core.game.interaction.NodeUsageEvent import core.game.interaction.UseWithHandler import core.game.node.item.Item import core.plugin.Initializable import core.plugin.Plugin +import org.rs09.consts.Sounds /** * Repairs pickaxes after being broken @@ -35,7 +37,7 @@ class PickaxeRepairPlugin : UseWithHandler(480,482,484,486,488,490){ event.player.inventory.remove(used.asItem()) event.player.inventory.add(Item(product)) event.player.sendMessage("You carefully reattach the head to the handle.") - event.player.audioManager.send(10) + playAudio(event.player, Sounds.EYEGLO_COIN_10) return true } diff --git a/Server/src/main/content/global/skill/gather/woodcutting/WoodcuttingListener.kt b/Server/src/main/content/global/skill/gather/woodcutting/WoodcuttingListener.kt index 29dfe67aa..ffb060243 100644 --- a/Server/src/main/content/global/skill/gather/woodcutting/WoodcuttingListener.kt +++ b/Server/src/main/content/global/skill/gather/woodcutting/WoodcuttingListener.kt @@ -12,14 +12,13 @@ import core.api.* import core.cache.def.impl.ItemDefinition import core.game.container.impl.EquipmentContainer import core.game.event.ResourceProducedEvent +import core.game.interaction.Clocks import core.game.interaction.IntType import core.game.interaction.InteractionListener -import core.game.interaction.Clocks import core.game.node.Node -import core.game.node.entity.npc.NPC import core.game.node.entity.impl.Projectile +import core.game.node.entity.npc.NPC import core.game.node.entity.player.Player -import core.game.node.entity.player.link.audio.Audio import core.game.node.entity.player.link.diary.DiaryType import core.game.node.entity.skill.Skills import core.game.node.item.Item @@ -169,7 +168,7 @@ class WoodcuttingListener : InteractionListener { SceneryBuilder.replace(node, node.transform(0), resource.getRespawnDuration()) } node.setActive(false) - player.getAudioManager().send(TREE_FALLING_2734) + playAudio(player, TREE_FALLING_2734) return true } } @@ -196,11 +195,10 @@ class WoodcuttingListener : InteractionListener { .filter { p: Player -> p.username != player.username } .toList() val soundIndex = RandomFunction.random(0, woodcuttingSounds.size) - player.audioManager.send( - Audio(woodcuttingSounds[soundIndex]), - playersAroundMe, - player.location - ) + + for (p in playersAroundMe) { + playAudio(p, woodcuttingSounds[soundIndex]) + } } } diff --git a/Server/src/main/content/global/skill/gather/woodcutting/WoodcuttingSkillPulse.java b/Server/src/main/content/global/skill/gather/woodcutting/WoodcuttingSkillPulse.java index 43e220666..00c153744 100644 --- a/Server/src/main/content/global/skill/gather/woodcutting/WoodcuttingSkillPulse.java +++ b/Server/src/main/content/global/skill/gather/woodcutting/WoodcuttingSkillPulse.java @@ -29,6 +29,7 @@ import org.rs09.consts.Sounds; import java.util.List; import java.util.stream.Collectors; +import static core.api.ContentAPIKt.playAudio; import static core.game.system.command.sets.StatAttributeKeysKt.STATS_BASE; import static core.game.system.command.sets.StatAttributeKeysKt.STATS_LOGS; @@ -123,11 +124,9 @@ public class WoodcuttingSkillPulse extends Pulse { int soundIndex = RandomFunction.random(0, woodcuttingSounds.length); - player.getAudioManager().send( - new Audio(woodcuttingSounds[soundIndex]), - playersAroundMe, - player.getLocation() - ); + for (Player p : playersAroundMe) { + playAudio(p, woodcuttingSounds[soundIndex]); + } } } @@ -216,7 +215,7 @@ public class WoodcuttingSkillPulse extends Pulse { } node.setActive(false); - player.getAudioManager().send(Sounds.TREE_FALLING_2734); + playAudio(player, Sounds.TREE_FALLING_2734); return true; } } diff --git a/Server/src/main/content/global/skill/herblore/HerbCleanPlugin.java b/Server/src/main/content/global/skill/herblore/HerbCleanPlugin.java index 62d8c9ec3..3de0c24f0 100644 --- a/Server/src/main/content/global/skill/herblore/HerbCleanPlugin.java +++ b/Server/src/main/content/global/skill/herblore/HerbCleanPlugin.java @@ -41,7 +41,7 @@ public final class HerbCleanPlugin extends OptionHandler { if (removeItem(player, node.asItem(), Container.INVENTORY)){ player.getSkills().addExperience(Skills.HERBLORE, exp, true); addItem(player, herb.getProduct().getId(), 1, Container.INVENTORY); - player.getAudioManager().send(5153, 1); + playAudio(player, 5153); player.getPacketDispatch().sendMessage("You clean the dirt from the " + herb.getProduct().getName().toLowerCase().replace("clean", "").trim() + " leaf."); } player.lock(1); diff --git a/Server/src/main/content/global/skill/herblore/HerblorePulse.java b/Server/src/main/content/global/skill/herblore/HerblorePulse.java index 2e45fb35b..fbf1a8c73 100644 --- a/Server/src/main/content/global/skill/herblore/HerblorePulse.java +++ b/Server/src/main/content/global/skill/herblore/HerblorePulse.java @@ -9,6 +9,9 @@ import core.tools.StringUtils; import content.global.skill.skillcapeperks.*; import content.data.consumables.Consumables; import core.tools.RandomFunction; +import org.rs09.consts.Sounds; + +import static core.api.ContentAPIKt.playAudio; /** @@ -121,7 +124,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); + playAudio(player, Sounds.GRIND_2608); if (cycles++ == 3) { player.animate(ANIMATION); cycles = 0; @@ -146,7 +149,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); + playAudio(player, Sounds.GRIND_2608); player.animate(ANIMATION); } } diff --git a/Server/src/main/content/global/skill/hunter/TrapCreatePulse.java b/Server/src/main/content/global/skill/hunter/TrapCreatePulse.java index c40e81919..dddc84e4d 100644 --- a/Server/src/main/content/global/skill/hunter/TrapCreatePulse.java +++ b/Server/src/main/content/global/skill/hunter/TrapCreatePulse.java @@ -57,21 +57,21 @@ public final class TrapCreatePulse extends SkillPulse { if (checkRequirements()){ switch(trap) { case BIRD_SNARE: - player.getAudioManager().send(Sounds.HUNTING_SETNOOSE_2646, 10, 40); + playAudio(player, Sounds.HUNTING_SETNOOSE_2646, 40); break; case BOX_TRAP: - player.getAudioManager().send(Sounds.HUNTING_LAYBOXTRAP_2636, 10, 20); + playAudio(player, Sounds.HUNTING_LAYBOXTRAP_2636, 20); break; case NET_TRAP: lock(player, 3); - player.getAudioManager().send(Sounds.HUNTING_SET_TWITCHNET_2644); + playAudio(player, Sounds.HUNTING_SET_TWITCHNET_2644); break; case RABBIT_SNARE: - player.getAudioManager().send(Sounds.HUNTING_SETSNARE_2647); + playAudio(player, Sounds.HUNTING_SETSNARE_2647); break; case DEAD_FALL: lock(player, 6); - player.getAudioManager().send(Sounds.HUNTING_SETDEADFALL_2645, 10, 130); + playAudio(player, Sounds.HUNTING_SETDEADFALL_2645, 130); } } } diff --git a/Server/src/main/content/global/skill/hunter/TrapDismantlePulse.java b/Server/src/main/content/global/skill/hunter/TrapDismantlePulse.java index 292ad1874..0492f937b 100644 --- a/Server/src/main/content/global/skill/hunter/TrapDismantlePulse.java +++ b/Server/src/main/content/global/skill/hunter/TrapDismantlePulse.java @@ -46,20 +46,20 @@ public final class TrapDismantlePulse extends SkillPulse { switch(trap) { case BIRD_SNARE: lock(player,5); - player.getAudioManager().send(Sounds.HUNTING_DISMANTLE_2632, 10, 50); + playAudio(player, Sounds.HUNTING_DISMANTLE_2632, 50); break; case BOX_TRAP: lock(player,4); - player.getAudioManager().send(Sounds.HUNTING_DISMANTLE_2632, 10, 50); + playAudio(player, Sounds.HUNTING_DISMANTLE_2632, 50); break; case NET_TRAP: lock(player, 5); - player.getAudioManager().send(Sounds.HUNTING_DISMANTLE_2632, 10, 20); + playAudio(player, Sounds.HUNTING_DISMANTLE_2632, 20); break; case RABBIT_SNARE: case DEAD_FALL: lock(player, 4); - player.getAudioManager().send(Sounds.HUNTING_DISMANTLE_2632, 10, 80); + playAudio(player, Sounds.HUNTING_DISMANTLE_2632, 80); break; } } diff --git a/Server/src/main/content/global/skill/hunter/TrapSetting.java b/Server/src/main/content/global/skill/hunter/TrapSetting.java index 461c2c5c9..ec0f87ba3 100644 --- a/Server/src/main/content/global/skill/hunter/TrapSetting.java +++ b/Server/src/main/content/global/skill/hunter/TrapSetting.java @@ -18,6 +18,8 @@ import core.game.world.update.flag.context.Animation; import core.tools.RandomFunction; import org.rs09.consts.Sounds; +import static core.api.ContentAPIKt.playAudio; + /** * A setting for a trap type. * @author Vexia @@ -309,18 +311,18 @@ public class TrapSetting { 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()); + playAudio(player, Sounds.HUNTING_NOOSE_2637, 0, 1, wrapper.getObject().getLocation(), 10); + playAudio(player, Sounds.HUNTING_BIRDCAUGHT_2625, 20, 1, wrapper.getObject().getLocation(), 10); break; case BOX_TRAP: - player.getAudioManager().send(Sounds.HUNTING_BOXTRAP_2627, 10, 0, 10, wrapper.getObject().getLocation()); + playAudio(player, Sounds.HUNTING_BOXTRAP_2627, 0, 1, wrapper.getObject().getLocation(), 10); 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()); + playAudio(player, Sounds.HUNTING_TWITCHNET_2652, 0, 1, wrapper.getObject().getLocation(), 10); + playAudio(player, Sounds.SALAMANDER_HIT_739, 20, 1, wrapper.getObject().getLocation(), 10); break; case DEAD_FALL: - player.getAudioManager().send(Sounds.HUNTING_DEADFALL_2631, 10, 0, 10, wrapper.getObject().getLocation()); + playAudio(player, Sounds.HUNTING_DEADFALL_2631, 0, 1, wrapper.getObject().getLocation(), 10); break; } return true; 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 7729bb00f..38371c49f 100644 --- a/Server/src/main/content/global/skill/hunter/bnet/BNetPulse.java +++ b/Server/src/main/content/global/skill/hunter/bnet/BNetPulse.java @@ -15,6 +15,8 @@ import org.rs09.consts.Sounds; import java.util.Random; +import static core.api.ContentAPIKt.playAudio; + /** * Handles the butterfly net catch pulse. * @author Vexia @@ -94,7 +96,7 @@ public final class BNetPulse extends SkillPulse { public void animate() { if (ticks < 1) { player.animate(ANIMATION); - player.getAudioManager().send(Sounds.HUNTING_BUTTERFLYNET_2623); + playAudio(player, 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 99c64c7d5..b33667e41 100644 --- a/Server/src/main/content/global/skill/hunter/falconry/FalconryCatchPulse.java +++ b/Server/src/main/content/global/skill/hunter/falconry/FalconryCatchPulse.java @@ -15,6 +15,8 @@ import core.game.world.repository.Repository; import core.tools.RandomFunction; import org.rs09.consts.Sounds; +import static core.api.ContentAPIKt.playAudio; + /** * Represents the skill pulse used to catch a kebbit. * @author Vexia @@ -124,7 +126,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()); + playAudio(player, Sounds.HUNTING_FALCON_SWOOP_2634, 10, 1, node.getLocation(), 12); GameWorld.getPulser().submit(new Pulse(100, falcon) { @Override public boolean pulse() { @@ -157,7 +159,7 @@ public final class FalconryCatchPulse extends SkillPulse { projectile.setStartHeight(26); projectile.setEndHeight(1); projectile.send(); - player.getAudioManager().send(Sounds.HUNTING_FALCON_FLY_2633); + playAudio(player, 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 cfe50aef7..7915f639d 100644 --- a/Server/src/main/content/global/skill/hunter/pitfall/HunterPitfall.kt +++ b/Server/src/main/content/global/skill/hunter/pitfall/HunterPitfall.kt @@ -225,8 +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) + playAudio(player, Sounds.HUNTING_PITFALL_COLLAPSE_2638, 0, 1, pit.location, 10) + playAudio(player, Sounds.PANTHER_DEATH_667, 50, 1, pit.location, 10) pitfall_npc.startDeath(null) player.removeAttribute("pitfall:timestamp:${pit.location.x}:${pit.location.y}") player.incrementAttribute("pitfall:count", -1) @@ -238,7 +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) + playAudio(player, Sounds.HUNTING_BIGCAT_JUMP_2619, 0, 1, pit.location, 10) pitfall_npc.attack(player) pitfall_npc.setAttribute("last_pit_loc", pit.location) } diff --git a/Server/src/main/content/global/skill/magic/SpellListener.kt b/Server/src/main/content/global/skill/magic/SpellListener.kt index 01eae8785..61c5e31c2 100644 --- a/Server/src/main/content/global/skill/magic/SpellListener.kt +++ b/Server/src/main/content/global/skill/magic/SpellListener.kt @@ -1,5 +1,6 @@ package content.global.skill.magic +import core.api.playAudio import core.api.setAttribute import core.cache.def.impl.ItemDefinition import core.game.node.Node @@ -76,7 +77,7 @@ abstract class SpellListener(val bookName: String) : Listener { if(player.getAttribute("tablet-spell",false)) return player.visualize(anim,gfx) if(soundID != -1){ - player.audioManager.send(soundID) + playAudio(player, soundID) } } diff --git a/Server/src/main/content/global/skill/magic/SpellTablets.kt b/Server/src/main/content/global/skill/magic/SpellTablets.kt index f6b8f428e..62b550f63 100644 --- a/Server/src/main/content/global/skill/magic/SpellTablets.kt +++ b/Server/src/main/content/global/skill/magic/SpellTablets.kt @@ -1,12 +1,14 @@ package content.global.skill.magic import content.global.skill.magic.spellconsts.Modern +import core.api.playAudio import core.game.node.entity.player.Player import core.game.node.item.Item import core.game.world.update.flag.context.Animation import org.rs09.consts.Items import core.game.interaction.InteractionListener import core.game.interaction.IntType +import org.rs09.consts.Sounds class SpellTablets : InteractionListener { val B2P_TABLET = Items.BONES_TO_PEACHES_8015 @@ -30,7 +32,7 @@ class SpellTablets : InteractionListener { } fun breakTablet(player: Player){ - player.audioManager.send(979) + playAudio(player, Sounds.POH_TABLET_BREAK_979) player.animator.forceAnimation(Animation(4069)) player.lock(5) player.setAttribute("tablet-spell",true) diff --git a/Server/src/main/content/global/skill/magic/ancient/BloodSpells.java b/Server/src/main/content/global/skill/magic/ancient/BloodSpells.java index b3db5e3f8..2cd31111c 100644 --- a/Server/src/main/content/global/skill/magic/ancient/BloodSpells.java +++ b/Server/src/main/content/global/skill/magic/ancient/BloodSpells.java @@ -97,7 +97,7 @@ public final class BloodSpells extends CombatSpell { projectile.transform(entity, (Entity) target, false, 58, 10).send(); } entity.animate(animation); - playGlobalAudio(entity.getLocation(), audio.getId(), 20); + playGlobalAudio(entity.getLocation(), audio.id, 20); } @Override diff --git a/Server/src/main/content/global/skill/magic/ancient/IceSpells.java b/Server/src/main/content/global/skill/magic/ancient/IceSpells.java index 8641ac76a..e4f287574 100644 --- a/Server/src/main/content/global/skill/magic/ancient/IceSpells.java +++ b/Server/src/main/content/global/skill/magic/ancient/IceSpells.java @@ -102,7 +102,7 @@ public final class IceSpells extends CombatSpell { projectile.transform(entity, (Entity) target, false, 58, 10).send(); } entity.animate(animation); - playGlobalAudio(entity.getLocation(), audio.getId(), 20); + playGlobalAudio(entity.getLocation(), audio.id, 20); } diff --git a/Server/src/main/content/global/skill/magic/ancient/MiasmicSpells.java b/Server/src/main/content/global/skill/magic/ancient/MiasmicSpells.java index 6df4d946c..1faf6ed30 100644 --- a/Server/src/main/content/global/skill/magic/ancient/MiasmicSpells.java +++ b/Server/src/main/content/global/skill/magic/ancient/MiasmicSpells.java @@ -101,7 +101,7 @@ public final class MiasmicSpells extends CombatSpell { projectile.transform(entity, (Entity) target, false, 58, 10).send(); } entity.animate(animation); - playGlobalAudio(entity.getLocation(), audio.getId(), 20); + playGlobalAudio(entity.getLocation(), audio.id, 20); } @Override diff --git a/Server/src/main/content/global/skill/magic/ancient/ShadowSpells.java b/Server/src/main/content/global/skill/magic/ancient/ShadowSpells.java index 75ec82d48..22ca33fa3 100644 --- a/Server/src/main/content/global/skill/magic/ancient/ShadowSpells.java +++ b/Server/src/main/content/global/skill/magic/ancient/ShadowSpells.java @@ -99,7 +99,7 @@ public final class ShadowSpells extends CombatSpell { projectile.transform(entity, (Entity) target, false, 58, 10).send(); } entity.animate(animation); - playGlobalAudio(entity.getLocation(), audio.getId(), 20); + playGlobalAudio(entity.getLocation(), audio.id, 20); } @Override diff --git a/Server/src/main/content/global/skill/magic/ancient/SmokeSpells.java b/Server/src/main/content/global/skill/magic/ancient/SmokeSpells.java index 7c6a71965..23ddf938f 100644 --- a/Server/src/main/content/global/skill/magic/ancient/SmokeSpells.java +++ b/Server/src/main/content/global/skill/magic/ancient/SmokeSpells.java @@ -108,7 +108,7 @@ public final class SmokeSpells extends CombatSpell { projectile.transform(entity, (Entity) target, false, 58, 10).send(); } entity.animate(animation); - playGlobalAudio(entity.getLocation(), audio.getId(), 20); + playGlobalAudio(entity.getLocation(), audio.id, 20); } @Override diff --git a/Server/src/main/content/global/skill/magic/lunar/HealSpell.java b/Server/src/main/content/global/skill/magic/lunar/HealSpell.java index 8fb86e46b..f79c85728 100644 --- a/Server/src/main/content/global/skill/magic/lunar/HealSpell.java +++ b/Server/src/main/content/global/skill/magic/lunar/HealSpell.java @@ -9,17 +9,19 @@ import core.game.node.entity.Entity; import core.game.node.entity.combat.ImpactHandler.HitsplatType; import core.game.node.entity.combat.spell.SpellType; import core.game.node.entity.player.Player; -import core.game.node.entity.player.link.audio.Audio; import core.game.node.entity.player.link.SpellBookManager.SpellBook; import core.game.node.item.Item; import core.game.world.map.RegionManager; import core.game.world.update.flag.context.Animation; import core.game.world.update.flag.context.Graphics; import core.plugin.Plugin; +import org.rs09.consts.Sounds; import java.util.Iterator; import java.util.List; +import static core.api.ContentAPIKt.playGlobalAudio; + /** * Represents the healing spell. * @author 'Vexia @@ -105,8 +107,8 @@ public final class HealSpell extends MagicSpell { player.getImpactHandler().manualHit(player, transfer, null); o.getSkills().heal(transfer); player.animate(ANIMATION); - player.getAudioManager().send(new Audio(2895), true); - o.getAudioManager().send(new Audio(2892), true); + playGlobalAudio(player.getLocation(), Sounds.LUNAR_HEAL_OTHER_2895); + playGlobalAudio(o.getLocation(), Sounds.LUNAR_HEAL_OTHER_INDIVIDUAL_2892); o.graphics(GRAPHICS); } else { List players = RegionManager.getLocalPlayers(player, 1); @@ -130,9 +132,9 @@ public final class HealSpell extends MagicSpell { } player.getImpactHandler().manualHit(player, percentage, HitsplatType.NORMAL); player.animate(ANIMATION_G); - player.getAudioManager().send(new Audio(2894), true); + playGlobalAudio(player.getLocation(), Sounds.LUNAR_HEAL_GROUP_2894); for (Player p : players) { - p.getAudioManager().send(new Audio(2892), true); + playGlobalAudio(p.getLocation(), Sounds.LUNAR_HEAL_OTHER_INDIVIDUAL_2892); p.graphics(GRAPHICS_G); p.getSkills().heal(percentage); } diff --git a/Server/src/main/content/global/skill/magic/lunar/MagicImbueSpell.java b/Server/src/main/content/global/skill/magic/lunar/MagicImbueSpell.java index 80574cddc..79512f7c4 100644 --- a/Server/src/main/content/global/skill/magic/lunar/MagicImbueSpell.java +++ b/Server/src/main/content/global/skill/magic/lunar/MagicImbueSpell.java @@ -13,6 +13,9 @@ import core.game.world.GameWorld; import core.game.world.update.flag.context.Animation; import core.game.world.update.flag.context.Graphics; import core.plugin.Plugin; +import org.rs09.consts.Sounds; + +import static core.api.ContentAPIKt.playAudio; /** * The magic imbue spell. @@ -61,7 +64,7 @@ public class MagicImbueSpell extends MagicSpell { player.lock(ANIMATION.getDuration() + 1); player.graphics(GRAPHIC); player.animate(ANIMATION); - player.getAudioManager().send(2888, 1, 1); + playAudio(player, Sounds.LUNAR_EMBUE_RUNES_2888); player.getPacketDispatch().sendMessage("You are charged to combine runes!"); return true; } diff --git a/Server/src/main/content/global/skill/magic/lunar/StatBoostSpell.java b/Server/src/main/content/global/skill/magic/lunar/StatBoostSpell.java index c77e03745..61aeee5f7 100644 --- a/Server/src/main/content/global/skill/magic/lunar/StatBoostSpell.java +++ b/Server/src/main/content/global/skill/magic/lunar/StatBoostSpell.java @@ -8,7 +8,6 @@ import core.game.node.Node; import core.game.node.entity.Entity; import core.game.node.entity.combat.spell.SpellType; import core.game.node.entity.player.Player; -import core.game.node.entity.player.link.audio.Audio; import core.game.bots.AIPlayer; import core.game.node.entity.player.link.SpellBookManager.SpellBook; import core.game.node.item.Item; @@ -17,9 +16,12 @@ import core.game.world.update.flag.context.Animation; import core.game.world.update.flag.context.Graphics; import core.plugin.Initializable; import core.plugin.Plugin; +import org.rs09.consts.Sounds; import java.util.List; +import static core.api.ContentAPIKt.playGlobalAudio; + @Initializable public final class StatBoostSpell extends MagicSpell { @@ -70,7 +72,7 @@ public final class StatBoostSpell extends MagicSpell { continue; } o.graphics(GRAPHICS); - o.getAudioManager().send(new Audio (2902), true); + playGlobalAudio(o.getLocation(), Sounds.LUNAR_STRENGTH_SHARE2_2902); potion.getEffect().activate(o); size++; } @@ -80,7 +82,7 @@ public final class StatBoostSpell extends MagicSpell { } super.meetsRequirements(player, true, true); potion.getEffect().activate(player); - player.getAudioManager().send(new Audio (2901), true); + playGlobalAudio(player.getLocation(), Sounds.LUNAR_STRENGTH_SHARE_2901); player.animate(ANIMATION); player.graphics(GRAPHICS); player.getInventory().remove(item); diff --git a/Server/src/main/content/global/skill/magic/lunar/StatRestoreSpell.java b/Server/src/main/content/global/skill/magic/lunar/StatRestoreSpell.java index 89d87f362..1f984d2da 100644 --- a/Server/src/main/content/global/skill/magic/lunar/StatRestoreSpell.java +++ b/Server/src/main/content/global/skill/magic/lunar/StatRestoreSpell.java @@ -9,7 +9,6 @@ import core.game.node.Node; import core.game.node.entity.Entity; import core.game.node.entity.combat.spell.SpellType; import core.game.node.entity.player.Player; -import core.game.node.entity.player.link.audio.Audio; import core.game.bots.AIPlayer; import core.game.node.entity.player.link.SpellBookManager.SpellBook; import core.game.node.item.Item; @@ -17,9 +16,12 @@ import core.game.world.map.RegionManager; import core.game.world.update.flag.context.Animation; import core.game.world.update.flag.context.Graphics; import core.plugin.Plugin; +import org.rs09.consts.Sounds; import java.util.List; +import static core.api.ContentAPIKt.playGlobalAudio; + @Initializable public class StatRestoreSpell extends MagicSpell { @@ -87,7 +89,7 @@ public class StatRestoreSpell extends MagicSpell { } super.meetsRequirements(player, true, true); potion.getEffect().activate(player); - player.getAudioManager().send(new Audio (2899), true); + playGlobalAudio(player.getLocation(), Sounds.LUNAR_STAT_SHARE_2899); player.animate(ANIMATION); player.graphics(GRAPHICS); player.getInventory().remove(item); diff --git a/Server/src/main/content/global/skill/magic/lunar/StatSpySpell.java b/Server/src/main/content/global/skill/magic/lunar/StatSpySpell.java index 009b0fb5a..4519e870e 100644 --- a/Server/src/main/content/global/skill/magic/lunar/StatSpySpell.java +++ b/Server/src/main/content/global/skill/magic/lunar/StatSpySpell.java @@ -15,6 +15,9 @@ import core.game.node.item.Item; import core.game.world.update.flag.context.Animation; import core.game.world.update.flag.context.Graphics; import core.plugin.Plugin; +import org.rs09.consts.Sounds; + +import static core.api.ContentAPIKt.playAudio; /** * The stat spy spell. @@ -72,7 +75,7 @@ public final class StatSpySpell extends MagicSpell { final Player o = ((Player) target); player.animate(ANIMATION); player.face(o); - player.getAudioManager().send(3620); + playAudio(player, Sounds.LUNAR_STAT_SPY_3620); COMPONENT.setCloseEvent(new CloseEvent() { @Override public boolean close(Player player, Component c) { @@ -82,7 +85,7 @@ public final class StatSpySpell extends MagicSpell { }); player.graphics(EYE); o.graphics(GRAPHIC); - player.getAudioManager().send(3621); + playAudio(player, Sounds.LUNAR_STAT_SPY_IMPACT_3621); for (int[] element : SKILLS) { player.getPacketDispatch().sendString("" + o.getSkills().getLevel(element[0]) + "", 523, element[1]); player.getPacketDispatch().sendString("" + o.getSkills().getStaticLevel(element[0]) + "", 523, element[2]); diff --git a/Server/src/main/content/global/skill/magic/lunar/VengeanceSpell.java b/Server/src/main/content/global/skill/magic/lunar/VengeanceSpell.java index 5883be295..e06821811 100644 --- a/Server/src/main/content/global/skill/magic/lunar/VengeanceSpell.java +++ b/Server/src/main/content/global/skill/magic/lunar/VengeanceSpell.java @@ -13,6 +13,10 @@ import core.game.world.update.flag.context.Animation; import core.game.world.update.flag.context.Graphics; import core.plugin.Initializable; import core.plugin.Plugin; +import org.rs09.consts.Sounds; + +import static core.api.ContentAPIKt.playAudio; +import static core.api.ContentAPIKt.playGlobalAudio; /** * Handles the vengeance (other) spell. @@ -81,7 +85,7 @@ public final class VengeanceSpell extends MagicSpell { visualize(entity, p); entity.setAttribute("vengeance_delay", ticks + 50); p.setAttribute("vengeance", true); - p.getAudioManager().send(vengOther ? 2908 : 2907); + playGlobalAudio(p.getLocation(), vengOther ? Sounds.LUNAR_VENGENCE_OTHER_2908 : Sounds.LUNAR_VENGENCE_2907); return true; } diff --git a/Server/src/main/content/global/skill/magic/modern/ModernListeners.kt b/Server/src/main/content/global/skill/magic/modern/ModernListeners.kt index 4ed7ea661..4c35f4a12 100644 --- a/Server/src/main/content/global/skill/magic/modern/ModernListeners.kt +++ b/Server/src/main/content/global/skill/magic/modern/ModernListeners.kt @@ -187,7 +187,7 @@ class ModernListeners : SpellListener("modern"){ } } visualizeSpell(player,BONE_CONVERT_ANIM, BONE_CONVERT_GFX) - player.audioManager.send(Audio(114)) + playAudio(player, Sounds.BONES_TO_BANANAS_ALL_114) removeRunes(player) addXP(player,if(bananas) 25.0 else 65.0) setDelay(player,false) @@ -223,7 +223,7 @@ class ModernListeners : SpellListener("modern"){ player.lock(3) removeRunes(player) addXP(player,53.0) - player.audioManager.send(Sounds.SUPERHEAT_ALL_190) + playAudio(player, Sounds.SUPERHEAT_ALL_190) showMagicTab(player) player.pulseManager.run(SmeltingPulse(player, item, bar, 1, true)) setDelay(player,false) diff --git a/Server/src/main/content/global/skill/magic/modern/TeleblockSpell.java b/Server/src/main/content/global/skill/magic/modern/TeleblockSpell.java index 1c3fc3f1b..baac8b57d 100644 --- a/Server/src/main/content/global/skill/magic/modern/TeleblockSpell.java +++ b/Server/src/main/content/global/skill/magic/modern/TeleblockSpell.java @@ -78,7 +78,7 @@ public final class TeleblockSpell extends CombatSpell { projectile.transform(entity, (Entity) target, false, 58, 10).send(); } entity.animate(animation); - playGlobalAudio(entity.getLocation(), audio.getId(), 20); + playGlobalAudio(entity.getLocation(), audio.id, 20); } @Override diff --git a/Server/src/main/content/global/skill/prayer/BoneBuryingOptionPlugin.java b/Server/src/main/content/global/skill/prayer/BoneBuryingOptionPlugin.java index bf1491456..f11feebe3 100644 --- a/Server/src/main/content/global/skill/prayer/BoneBuryingOptionPlugin.java +++ b/Server/src/main/content/global/skill/prayer/BoneBuryingOptionPlugin.java @@ -7,12 +7,14 @@ import core.game.node.entity.skill.Skills; import core.game.interaction.OptionHandler; import core.game.node.Node; import core.game.node.entity.player.Player; -import core.game.node.entity.player.link.audio.Audio; import core.game.node.item.Item; import core.game.system.task.Pulse; import core.game.world.GameWorld; import core.game.world.update.flag.context.Animation; import core.plugin.Plugin; +import org.rs09.consts.Sounds; + +import static core.api.ContentAPIKt.playAudio; /** * Represents the bone bury option plugin. @@ -26,10 +28,6 @@ public final class BoneBuryingOptionPlugin extends OptionHandler { */ private static final Animation ANIMATION = new Animation(827); - /** - * Represents the sound to use. - */ - private static final Audio SOUND = new Audio(2738, 10, 1); @Override public boolean handle(final Player player, Node node, String option) { @@ -57,7 +55,7 @@ public final class BoneBuryingOptionPlugin extends OptionHandler { player.lock(2); player.animate(ANIMATION); player.getPacketDispatch().sendMessage("You dig a hole in the ground..."); - player.getAudioManager().send(SOUND); + playAudio(player, Sounds.BONES_DOWN_2738); final Bones bonee = bone; GameWorld.getPulser().submit(new Pulse(2, player) { @Override diff --git a/Server/src/main/content/global/skill/prayer/PrayerAltarPlugin.java b/Server/src/main/content/global/skill/prayer/PrayerAltarPlugin.java index 9c9a7539e..c9cb114d7 100644 --- a/Server/src/main/content/global/skill/prayer/PrayerAltarPlugin.java +++ b/Server/src/main/content/global/skill/prayer/PrayerAltarPlugin.java @@ -14,8 +14,10 @@ import core.game.node.entity.player.link.quest.Quest; import core.game.world.map.Location; import core.game.world.update.flag.context.Animation; import core.plugin.Plugin; +import org.rs09.consts.Sounds; import static core.api.ContentAPIKt.hasRequirement; +import static core.api.ContentAPIKt.playAudio; /** * Handles the praying at an alter. @@ -93,7 +95,7 @@ public class PrayerAltarPlugin extends OptionHandler { */ public void visualize(Player player) { player.lock(3); - player.getAudioManager().send(2674); + playAudio(player, Sounds.PRAYER_RECHARGE_2674); player.animate(Animation.create(645)); } diff --git a/Server/src/main/content/global/skill/runecrafting/RuneCraftPulse.java b/Server/src/main/content/global/skill/runecrafting/RuneCraftPulse.java index 311d023e5..fe97eb3a1 100644 --- a/Server/src/main/content/global/skill/runecrafting/RuneCraftPulse.java +++ b/Server/src/main/content/global/skill/runecrafting/RuneCraftPulse.java @@ -12,12 +12,13 @@ import core.game.world.update.flag.context.Animation; import core.game.world.update.flag.context.Graphics; import core.tools.RandomFunction; -import static core.api.ContentAPIKt.inEquipment; +import static core.api.ContentAPIKt.*; import static core.game.system.command.sets.StatAttributeKeysKt.STATS_BASE; import static core.game.system.command.sets.StatAttributeKeysKt.STATS_RC; -import static core.api.ContentAPIKt.hasRequirement; + import core.game.world.GameWorld; import org.rs09.consts.Items; +import org.rs09.consts.Sounds; import java.util.ArrayList; import java.util.Arrays; @@ -152,7 +153,7 @@ public final class RuneCraftPulse extends SkillPulse { public void animate() { player.animate(ANIMATION); player.graphics(GRAPHICS); - player.getAudioManager().send(2710); + playAudio(player, Sounds.BIND_RUNES_2710); } @Override diff --git a/Server/src/main/content/global/skill/smithing/smelting/SmeltingPulse.java b/Server/src/main/content/global/skill/smithing/smelting/SmeltingPulse.java index f483a72b7..06c55f1e1 100644 --- a/Server/src/main/content/global/skill/smithing/smelting/SmeltingPulse.java +++ b/Server/src/main/content/global/skill/smithing/smelting/SmeltingPulse.java @@ -111,7 +111,7 @@ public class SmeltingPulse extends SkillPulse { player.visualize(Animation.create(725), new Graphics(148, 96)); } else { player.animate(Animation.create(3243)); // Used to be 899 but that looked wonky and broken - player.getAudioManager().send(Sounds.FURNACE_2725, 1); + playAudio(player, Sounds.FURNACE_2725); } } } diff --git a/Server/src/main/content/global/skill/summoning/ObeliskOptionPlugin.java b/Server/src/main/content/global/skill/summoning/ObeliskOptionPlugin.java index bddff2eee..3ecea4dc9 100644 --- a/Server/src/main/content/global/skill/summoning/ObeliskOptionPlugin.java +++ b/Server/src/main/content/global/skill/summoning/ObeliskOptionPlugin.java @@ -10,6 +10,9 @@ import core.game.node.entity.player.Player; import core.game.world.update.flag.context.Animation; import core.game.world.update.flag.context.Graphics; import core.plugin.Plugin; +import org.rs09.consts.Sounds; + +import static core.api.ContentAPIKt.playAudio; /** * Represents the option used on the summoning obelisk. @@ -31,7 +34,7 @@ public final class ObeliskOptionPlugin extends OptionHandler { return true; } player.visualize(Animation.create(8502), Graphics.create(1308)); - player.getAudioManager().send(4214); + playAudio(player, Sounds.DREADFOWL_BOOST_4214); player.getSkills().setLevel(Skills.SUMMONING, player.getSkills().getStaticLevel(Skills.SUMMONING)); player.dispatch(new SummoningPointsRechargeEvent(node)); player.getPacketDispatch().sendMessage("You renew your summoning points."); @@ -39,7 +42,6 @@ public final class ObeliskOptionPlugin extends OptionHandler { } return false; } - @Override public Plugin newInstance(Object arg) throws Throwable { SceneryDefinition.setOptionHandler("infuse-pouch", this); diff --git a/Server/src/main/content/global/skill/summoning/SummoningCreator.java b/Server/src/main/content/global/skill/summoning/SummoningCreator.java index 68d3e974a..d7a2827c9 100644 --- a/Server/src/main/content/global/skill/summoning/SummoningCreator.java +++ b/Server/src/main/content/global/skill/summoning/SummoningCreator.java @@ -10,6 +10,9 @@ import core.game.node.scenery.Scenery; import core.game.world.map.Location; import core.game.world.map.RegionManager; import core.game.world.update.flag.context.Animation; +import org.rs09.consts.Sounds; + +import static core.api.ContentAPIKt.playAudio; /** * Represents a utility class of creating summoning nodes. @@ -157,7 +160,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 + playAudio(player, Sounds.CRAFT_POUCH_4164); // 4277 also sounds the same return false; } player.getPacketDispatch().sendSceneryAnimation(object, Animation.create(8510)); diff --git a/Server/src/main/content/global/skill/summoning/familiar/Familiar.java b/Server/src/main/content/global/skill/summoning/familiar/Familiar.java index 2e0f5be84..3166b4be6 100644 --- a/Server/src/main/content/global/skill/summoning/familiar/Familiar.java +++ b/Server/src/main/content/global/skill/summoning/familiar/Familiar.java @@ -30,6 +30,7 @@ import core.game.node.entity.combat.CombatSwingHandler; import core.tools.SystemLogger; import core.game.world.GameWorld; import content.global.skill.summoning.SummoningPouch; +import org.rs09.consts.Sounds; import java.util.ArrayList; import java.util.List; @@ -371,7 +372,7 @@ public abstract class Familiar extends NPC implements Plugin { if (specialMove(special)) { setAttribute("special-delay", GameWorld.getTicks() + 3); owner.getInventory().remove(new Item(scroll.getItemId())); - owner.getAudioManager().send(4161); + playAudio(owner, Sounds.SPELL_4161); visualizeSpecialMove(); updateSpecialPoints(specialCost); owner.getSkills().addExperience(Skills.SUMMONING, scroll.getExperience(), true); @@ -564,10 +565,11 @@ public abstract class Familiar extends NPC implements Plugin { getProperties().setTeleportLocation(destination); if (!(this instanceof Pet)) { if(firstCall) { - owner.getAudioManager().send(4366); + // TODO: Each familiar has its own initial summon sound that needs to be implemented at some point + playAudio(owner, Sounds.SUMMON_NPC_188); firstCall = false; } else { - owner.getAudioManager().send(188); + playAudio(owner, Sounds.SUMMON_NPC_188); } if (size() > 1) { graphics(LARGE_SUMMON_GRAPHIC); diff --git a/Server/src/main/content/global/skill/summoning/familiar/SpiritWolfNPC.java b/Server/src/main/content/global/skill/summoning/familiar/SpiritWolfNPC.java index bd12dba8d..9c528bde7 100644 --- a/Server/src/main/content/global/skill/summoning/familiar/SpiritWolfNPC.java +++ b/Server/src/main/content/global/skill/summoning/familiar/SpiritWolfNPC.java @@ -15,6 +15,9 @@ import core.game.world.map.path.Path; import core.game.world.map.path.Pathfinder; import core.game.world.update.flag.context.Animation; import core.game.world.update.flag.context.Graphics; +import org.rs09.consts.Sounds; + +import static core.api.ContentAPIKt.playAudio; /** * Handles the Spirit wolf familiar. @@ -105,7 +108,7 @@ public final class SpiritWolfNPC extends Familiar { return false; } visualizeSpecialMove(); - owner.getAudioManager().send(4265); + playAudio(owner, Sounds.WOLF_HOWL2_4265); faceTemporary(npc, owner, 2); super.visualize(Animation.create(8293), new Graphics(1334, 96)); Projectile.magic(this, npc, 1333, 40, 36, 50, 5).send(); diff --git a/Server/src/main/content/global/skill/summoning/familiar/UnicornStallionNPC.java b/Server/src/main/content/global/skill/summoning/familiar/UnicornStallionNPC.java index 3bc361957..fde55d548 100644 --- a/Server/src/main/content/global/skill/summoning/familiar/UnicornStallionNPC.java +++ b/Server/src/main/content/global/skill/summoning/familiar/UnicornStallionNPC.java @@ -11,6 +11,7 @@ import core.game.world.update.flag.context.Animation; import core.game.world.update.flag.context.Graphics; import core.plugin.Plugin; import core.plugin.ClassScanner; +import org.rs09.consts.Sounds; import static core.api.ContentAPIKt.*; @@ -45,7 +46,7 @@ public class UnicornStallionNPC extends Familiar { @Override protected boolean specialMove(FamiliarSpecial special) { Player player = (Player) special.getNode(); - player.getAudioManager().send(4372); + playAudio(player, Sounds.HEALING_AURA_4372); visualize(Animation.create(8267), Graphics.create(1356)); player.getSkills().heal((int) (player.getSkills().getMaximumLifepoints() * 0.15)); return true; @@ -77,7 +78,7 @@ public class UnicornStallionNPC extends Familiar { player.sendMessage("You are not poisoned."); return true; } - player.getAudioManager().send(4372); + playAudio(player, Sounds.HEALING_AURA_4372); familiar.visualize(Animation.create(8267), Graphics.create(1356)); curePoison(player); player.getSkills().updateLevel(Skills.SUMMONING, -2, 0); diff --git a/Server/src/main/content/minigame/mta/MTAListeners.kt b/Server/src/main/content/minigame/mta/MTAListeners.kt index 538f9d5bc..bc656348b 100644 --- a/Server/src/main/content/minigame/mta/MTAListeners.kt +++ b/Server/src/main/content/minigame/mta/MTAListeners.kt @@ -2,6 +2,7 @@ package content.minigame.mta import content.global.skill.magic.SpellListener import content.global.skill.magic.spellconsts.Modern +import core.api.playAudio import core.game.node.item.Item import core.game.world.map.Direction import core.game.world.update.flag.context.Animation @@ -10,6 +11,7 @@ import org.rs09.consts.Items import org.rs09.consts.NPCs import core.game.interaction.InteractionListener import core.game.interaction.IntType +import org.rs09.consts.Sounds class MTAListeners : InteractionListener { override fun defineListeners() { @@ -55,7 +57,7 @@ class MTASpellListeners : SpellListener("modern"){ p.lock(3) p.visualize(HIGH_ALCH_ANIM,HIGH_ALCH_GFX) if(p.inventory.remove(Item(item.id,1))){ - p.audioManager.send(97) + playAudio(p, Sounds.HIGH_ALCHEMY_97) if (coins.amount != 0) { p.inventory.add(coins) } @@ -90,7 +92,7 @@ class MTASpellListeners : SpellListener("modern"){ p.lock(3) p.visualize(LOW_ALCH_ANIM,LOW_ALCH_GFX) if(p.inventory.remove(Item(item.id,1))){ - p.audioManager.send(97) + playAudio(p, Sounds.HIGH_ALCHEMY_97) if (coins.amount != 0) { p.inventory.add(coins) } diff --git a/Server/src/main/content/minigame/mta/TelekineticGrabSpell.java b/Server/src/main/content/minigame/mta/TelekineticGrabSpell.java index 9cb25850c..e2d496492 100644 --- a/Server/src/main/content/minigame/mta/TelekineticGrabSpell.java +++ b/Server/src/main/content/minigame/mta/TelekineticGrabSpell.java @@ -22,6 +22,9 @@ import core.game.world.update.flag.context.Graphics; import core.plugin.Plugin; import core.game.global.action.PickupHandler; import core.game.world.GameWorld; +import org.rs09.consts.Sounds; + +import static core.api.ContentAPIKt.playAudio; /** * Represents the telekenitic grab spell. @@ -143,7 +146,7 @@ public final class TelekineticGrabSpell extends MagicSpell { player.getPacketDispatch().sendMessage("Too late!"); return true; } - player.getAudioManager().send(3008); + playAudio(player, Sounds.VULNERABILITY_IMPACT_3008); if (!teleZone) { player.getInventory().add(new Item(g.getId(), g.getAmount(), g.getCharge())); } else { diff --git a/Server/src/main/content/minigame/vinesweeper/Vinesweeper.kt b/Server/src/main/content/minigame/vinesweeper/Vinesweeper.kt index 2362a83ec..787e1fc5c 100644 --- a/Server/src/main/content/minigame/vinesweeper/Vinesweeper.kt +++ b/Server/src/main/content/minigame/vinesweeper/Vinesweeper.kt @@ -25,10 +25,6 @@ import core.game.world.update.flag.context.Animation import core.game.world.update.flag.context.Graphics import core.plugin.Initializable import core.tools.RandomFunction -import org.rs09.consts.Animations -import org.rs09.consts.Components -import org.rs09.consts.Items -import org.rs09.consts.NPCs import content.minigame.vinesweeper.Vinesweeper.Companion.FARMERS import content.minigame.vinesweeper.Vinesweeper.Companion.FARMER_CLEAR_RADIUS import content.minigame.vinesweeper.Vinesweeper.Companion.HOLES @@ -43,6 +39,7 @@ import core.game.interaction.IntType import core.game.interaction.InterfaceListener import core.game.world.GameWorld import core.game.world.GameWorld.ticks +import org.rs09.consts.* import org.rs09.consts.Graphics as Gfx import org.rs09.consts.Scenery as Sceneries @@ -505,7 +502,7 @@ class Vinesweeper : InteractionListener, InterfaceListener, MapArea { npc.faceTemporary(player, 1) npc.graphics(Graphics(108)) player.lock() - player.audioManager.send(125) + playAudio(player, Sounds.CURSE_ALL_125, 0, 1) Projectile.create(npc, player, 109).send() npc.sendChat("Avach nimporto!") GameWorld.Pulser.submit(object : Pulse(1, player) { diff --git a/Server/src/main/content/region/asgarnia/burthorpe/handlers/wguild/animator/AnimationRoom.java b/Server/src/main/content/region/asgarnia/burthorpe/handlers/wguild/animator/AnimationRoom.java index 2e56db3b3..746fd9368 100644 --- a/Server/src/main/content/region/asgarnia/burthorpe/handlers/wguild/animator/AnimationRoom.java +++ b/Server/src/main/content/region/asgarnia/burthorpe/handlers/wguild/animator/AnimationRoom.java @@ -18,6 +18,9 @@ import core.game.world.map.zone.ZoneBuilder; import core.game.world.update.flag.context.Animation; import core.plugin.Initializable; import core.plugin.Plugin; +import org.rs09.consts.Sounds; + +import static core.api.ContentAPIKt.playAudio; /** * Handles the animation @@ -132,7 +135,7 @@ public final class AnimationRoom extends MapZone implements Plugin { return true; } } - player.getAudioManager().send(1909); + playAudio(player, Sounds.WARGUILD_ANIMATE_1909); player.logoutListeners.put("animation-room", player1 -> { for(int item : set.getPieces()) player1.getInventory().add(new Item(item)); return Unit.INSTANCE; @@ -144,7 +147,7 @@ public final class AnimationRoom extends MapZone implements Plugin { } if (getDelay() == 4) { setDelay(1); - player.getAudioManager().send(1910); + playAudio(player, Sounds.WARGUILD_ANIMATOR_ACTIVATE_1910); ForceMovement.run(player, player.getLocation().transform(0, 1, 0)).setDirection(Direction.SOUTH); return false; } diff --git a/Server/src/main/content/region/asgarnia/burthorpe/handlers/wguild/catapult/CatapultRoom.java b/Server/src/main/content/region/asgarnia/burthorpe/handlers/wguild/catapult/CatapultRoom.java index 0c26480d5..a5ae501b3 100644 --- a/Server/src/main/content/region/asgarnia/burthorpe/handlers/wguild/catapult/CatapultRoom.java +++ b/Server/src/main/content/region/asgarnia/burthorpe/handlers/wguild/catapult/CatapultRoom.java @@ -33,7 +33,9 @@ import core.plugin.Plugin; import core.plugin.ClassScanner; import core.plugin.Initializable; import core.tools.RandomFunction; +import org.rs09.consts.Sounds; +import static core.api.ContentAPIKt.playAudio; import static core.api.ContentAPIKt.setVarp; /** @@ -148,9 +150,8 @@ public final class CatapultRoom extends MapZone implements Plugin { Scenery object = RegionManager.getObject(Location.create(2840, 3552, 1)); if(object != null) SceneryBuilder.replace(object, object.transform(attack.objectId), 4); - Audio sound = new Audio(1911); for (Player p : players) { - p.getAudioManager().send(sound); + playAudio(p, Sounds.WARGUILD_CATAPULT_ANVIL_1911); } return players.isEmpty(); } diff --git a/Server/src/main/content/region/asgarnia/falador/handlers/GiantMoleNPC.java b/Server/src/main/content/region/asgarnia/falador/handlers/GiantMoleNPC.java index 256270b58..83e1c1d9c 100644 --- a/Server/src/main/content/region/asgarnia/falador/handlers/GiantMoleNPC.java +++ b/Server/src/main/content/region/asgarnia/falador/handlers/GiantMoleNPC.java @@ -33,6 +33,9 @@ import core.net.packet.out.Interface; import core.plugin.Plugin; import core.plugin.Initializable; import core.tools.RandomFunction; +import org.rs09.consts.Sounds; + +import static core.api.ContentAPIKt.playAudio; /** * Handles the Giant Mole NPC. @@ -239,7 +242,7 @@ public final class GiantMoleNPC extends AbstractNPC { public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) { if (button == 17) { player.getProperties().setTeleportLocation(Location.create(1752, 5237, 0)); - player.getAudioManager().send(1384); + playAudio(player, Sounds.ROOF_COLLAPSE_1384); player.getPacketDispatch().sendMessage("You seem to have dropped down into a network of mole tunnels."); if (!player.getAchievementDiaryManager().getDiary(DiaryType.FALADOR).isComplete(0, 5)) { diff --git a/Server/src/main/content/region/desert/dialogue/RugMerchantDialogue.java b/Server/src/main/content/region/desert/dialogue/RugMerchantDialogue.java index 3f02ee3db..577cb1151 100644 --- a/Server/src/main/content/region/desert/dialogue/RugMerchantDialogue.java +++ b/Server/src/main/content/region/desert/dialogue/RugMerchantDialogue.java @@ -295,7 +295,7 @@ public final class RugMerchantDialogue extends DialoguePlugin { player.getInterfaceManager().removeTabs(0,1,2,3,4,5,6,7,8,9,10,11,12,13); player.getEquipment().replace(new Item(Items.MAGIC_CARPET_5614),EquipmentContainer.SLOT_WEAPON); player.getPacketDispatch().sendInterfaceConfig(548,69,true); - player.getAudioManager().send(Sounds.CARPET_RISE_1196); + playAudio(player, Sounds.CARPET_RISE_1196); playJingle(player, 132); registerLogoutListener(player, "magic-carpet", (pl) -> { @@ -342,7 +342,7 @@ public final class RugMerchantDialogue extends DialoguePlugin { player.unlock(); player.animate(new Animation(-1)); setVarp(player, 499, 0); - player.getAudioManager().send(Sounds.CARPET_DESCEND_1195); + playAudio(player, Sounds.CARPET_DESCEND_1195); clearLogoutListener(player, "magic-carpet"); diff --git a/Server/src/main/content/region/fremennik/rellekka/quest/thefremenniktrials/SeersHouseListeners.kt b/Server/src/main/content/region/fremennik/rellekka/quest/thefremenniktrials/SeersHouseListeners.kt index 4ed643b4b..37e7434e9 100644 --- a/Server/src/main/content/region/fremennik/rellekka/quest/thefremenniktrials/SeersHouseListeners.kt +++ b/Server/src/main/content/region/fremennik/rellekka/quest/thefremenniktrials/SeersHouseListeners.kt @@ -15,6 +15,7 @@ import core.game.global.action.DoorActionHandler import core.game.interaction.InteractionListener import core.game.interaction.IntType import org.rs09.consts.NPCs +import org.rs09.consts.Sounds class SeersHouseListeners : InteractionListener { @@ -269,7 +270,7 @@ class SeersHouseListeners : InteractionListener { onUseWith(IntType.SCENERY,REDHERRING,COOKINGRANGE) { player, used, with -> player.animate(Animation(883,Animator.Priority.HIGH)) - player.audioManager.send(Audio(2577, 1, 1)) + playAudio(player, Sounds.FRY_2577) removeItem(player,REDHERRING) addItem(player,REDGOOP) sendDialogue(player,"As you cook the herring on the stove, the colouring on it peels off separately as a red sticky goop...") @@ -894,7 +895,7 @@ class SeersHouseListeners : InteractionListener { onUseWith(IntType.SCENERY, FROZENBUCKET, COOKINGRANGE) { player, used, with -> player.animate(Animation(883,Animator.Priority.HIGH)) - player.audioManager.send(Audio(2577, 1, 1)) + playAudio(player, Sounds.FRY_2577) removeItem(player,FROZENBUCKET) addItem(player,EMPTYBUCKET) sendMessage(player,"You place the frozen bucket on the range. The ice turns to steam.") @@ -903,7 +904,7 @@ class SeersHouseListeners : InteractionListener { onUseWith(IntType.SCENERY, FROZENJUG, COOKINGRANGE) { player, used, with -> player.animate(Animation(883,Animator.Priority.HIGH)) - player.audioManager.send(Audio(2577, 1, 1)) + playAudio(player, Sounds.FRY_2577) removeItem(player,FROZENJUG) addItem(player,EMPTYJUG) sendMessage(player,"You place the frozen jug on the range. The ice turns to steam.") @@ -912,7 +913,7 @@ class SeersHouseListeners : InteractionListener { onUseWith(IntType.SCENERY, FROZENVASE, COOKINGRANGE) { player, used, with -> player.animate(Animation(883,Animator.Priority.HIGH)) - player.audioManager.send(Audio(2577, 1, 1)) + playAudio(player, Sounds.FRY_2577) removeItem(player,FROZENVASE) addItem(player,VASE) sendMessage(player,"You place the frozen vase on the range. The ice turns into steam.") @@ -921,7 +922,7 @@ class SeersHouseListeners : InteractionListener { onUseWith(IntType.SCENERY, FROZENKEY, COOKINGRANGE) { player, used, with -> player.animate(Animation(883,Animator.Priority.HIGH)) - player.audioManager.send(Audio(2577, 1, 1)) + playAudio(player, Sounds.FRY_2577) removeItem(player,FROZENKEY) addItem(player,SEERSKEY) sendMessage(player,"The heat of the range melts the ice around the key.") diff --git a/Server/src/main/content/region/kandarin/ardougne/handlers/WildernessLeverPlugin.java b/Server/src/main/content/region/kandarin/ardougne/handlers/WildernessLeverPlugin.java index cbacfc598..5b8c59117 100644 --- a/Server/src/main/content/region/kandarin/ardougne/handlers/WildernessLeverPlugin.java +++ b/Server/src/main/content/region/kandarin/ardougne/handlers/WildernessLeverPlugin.java @@ -17,6 +17,9 @@ import core.game.world.map.Location; import core.game.world.update.flag.context.Animation; import core.plugin.Plugin; import core.plugin.ClassScanner; +import org.rs09.consts.Sounds; + +import static core.api.ContentAPIKt.playAudio; /** * Handles wilderness levers. @@ -64,7 +67,7 @@ public final class WildernessLeverPlugin extends OptionHandler { private static void pullLever(final Player player, final LeverSets lever, final int index) { player.lock(2); player.animate(lever.getAnimation()); - player.getAudioManager().send(new Audio(2400)); + playAudio(player, Sounds.LEVER_2400); GameWorld.getPulser().submit(new Pulse(2, player) { @Override public boolean pulse() { diff --git a/Server/src/main/content/region/kandarin/quest/dwarfcannon/dmc/DMCHandler.java b/Server/src/main/content/region/kandarin/quest/dwarfcannon/dmc/DMCHandler.java index 292f30a9d..9b7d2363c 100644 --- a/Server/src/main/content/region/kandarin/quest/dwarfcannon/dmc/DMCHandler.java +++ b/Server/src/main/content/region/kandarin/quest/dwarfcannon/dmc/DMCHandler.java @@ -21,6 +21,7 @@ import core.tools.RandomFunction; import org.jetbrains.annotations.NotNull; import core.game.node.entity.combat.CombatSwingHandler; import core.game.world.GameWorld; +import org.rs09.consts.Sounds; import static core.api.ContentAPIKt.*; @@ -75,13 +76,13 @@ public final class DMCHandler implements LogoutListener { } player.getPacketDispatch().sendSceneryAnimation(cannon, Animation.create(direction.getAnimationId())); Location l = cannon.getLocation().transform(1, 1, 0); - player.getAudioManager().send(new Audio(2877), true, l); + playGlobalAudio(l, Sounds.MCANNON_TURN_2877); direction = DMCRevolution.values()[(direction.ordinal() + 1) % DMCRevolution.values().length]; for (NPC npc : RegionManager.getLocalNpcs(l, 10)) { if (direction.isInSight(npc.getLocation().getX() - l.getX(), npc.getLocation().getY() - l.getY()) && npc.isAttackable(player, CombatStyle.RANGE, false) && CombatSwingHandler.isProjectileClipped(npc, l, false)) { int speed = (int) (25 + (l.getDistance(npc.getLocation()) * 10)); Projectile.create(l, npc.getLocation(), 53, 40, 36, 20, speed, 0, 128).send(); - player.getAudioManager().send(new Audio(1667), true, l); + playGlobalAudio(l, Sounds.MCANNON_FIRE_1667); cannonballs--; int hit = 0; if (player.getSwingHandler(false).isAccurateImpact(player, npc, CombatStyle.RANGE, 1.2, 1.0)) { @@ -197,7 +198,7 @@ public final class DMCHandler implements LogoutListener { registerTimer (player, handler.timer); return true; } - player.getAudioManager().send(new Audio(2876), true); + playGlobalAudio(player.getLocation(), Sounds.MCANNON_SETUP_2876); if(count != 0) { SceneryBuilder.remove(object); SceneryBuilder.add(object = object.transform(object.getId() + 1)); diff --git a/Server/src/main/content/region/karamja/quest/tribaltotem/CrompertyDialogue.kt b/Server/src/main/content/region/karamja/quest/tribaltotem/CrompertyDialogue.kt index d1ce9ee2f..f088c3aad 100644 --- a/Server/src/main/content/region/karamja/quest/tribaltotem/CrompertyDialogue.kt +++ b/Server/src/main/content/region/karamja/quest/tribaltotem/CrompertyDialogue.kt @@ -10,7 +10,9 @@ import core.game.world.update.flag.context.Graphics import core.plugin.Initializable import org.rs09.consts.NPCs import content.global.travel.EssenceTeleport +import core.api.playAudio import core.game.world.GameWorld +import org.rs09.consts.Sounds @Initializable class CrompertyDialogue(player: Player? = null) : core.game.dialogue.DialoguePlugin(player) { @@ -102,7 +104,7 @@ class CrompertyDialogue(player: Player? = null) : core.game.dialogue.DialoguePlu npc.faceTemporary(player, 1) npc.graphics(Graphics(108)) player.lock() - player.audioManager.send(125) + playAudio(player, Sounds.CURSE_ALL_125, 0, 1) Projectile.create(npc, player, 109).send() npc.sendChat("Dipsolum sententa sententi!") GameWorld.Pulser.submit(object : Pulse(1) { diff --git a/Server/src/main/content/region/misthalin/barbvillage/stronghold/StrongHoldSecurityPlugin.java b/Server/src/main/content/region/misthalin/barbvillage/stronghold/StrongHoldSecurityPlugin.java index d70e0e150..c6de2b356 100644 --- a/Server/src/main/content/region/misthalin/barbvillage/stronghold/StrongHoldSecurityPlugin.java +++ b/Server/src/main/content/region/misthalin/barbvillage/stronghold/StrongHoldSecurityPlugin.java @@ -32,6 +32,8 @@ import core.plugin.Initializable; import core.tools.RandomFunction; import org.rs09.consts.Sounds; +import static core.api.ContentAPIKt.playAudio; + /** * Handles the strong hold of security. * @author Vexia @@ -131,7 +133,7 @@ public final class StrongHoldSecurityPlugin extends MapZone implements Plugin animate(entity: Entity, anim: T, forced: Boolean = false) { /** * Plays audio for the player * @param player the player to play the defined audio for - * @param audio the audio id to play + * @param id the audio id to play * @param delay the delay in client cycles (50 cycles = 1 second) * @param loops the number of times to loop audio (for some audio ids it is used to define how many times to loop the audio) * @param location the location where the audio will play from (The sound will fade with distance) * @param radius the distance the audio can be heard from the defined location (default = 8 tiles if undefined) */ @JvmOverloads -fun playAudio(player: Player, audio: Int, delay: Int = 0, loops: Int = 1, location: Location? = null, radius: Int = 8) { - PacketRepository.send(AudioPacket::class.java, DefaultContext(player, Audio(audio, loops, delay, radius), location)) +fun playAudio(player: Player, id: Int, delay: Int = 0, loops: Int = 1, location: Location? = null, radius: Int = Audio.defaultAudioRadius) { + PacketRepository.send(AudioPacket::class.java, DefaultContext(player, Audio(id, delay, loops, radius), location)) } /** * Plays audio for players near a defined location * @param location the location where the audio will play from (The sound will fade with distance) - * @param audio the audio id to play + * @param id the audio id to play * @param delay the delay in client cycles (50 cycles = 1 second) * @param loops the number of times to loop audio (for some audio ids it is used to define how many times to loop the audio) * @param radius the distance the audio can be heard from the defined location (default = 8 tiles if undefined) */ @JvmOverloads -fun playGlobalAudio(location: Location, audio: Int, delay: Int = 0, loops: Int = 1, radius: Int = 8) { +fun playGlobalAudio(location: Location, id: Int, delay: Int = 0, loops: Int = 1, radius: Int = Audio.defaultAudioRadius) { val nearbyPlayers = RegionManager.getLocalPlayers(location, radius) for (player in nearbyPlayers) { - PacketRepository.send(AudioPacket::class.java, DefaultContext(player, Audio(audio, loops, delay, radius), location)) + PacketRepository.send(AudioPacket::class.java, DefaultContext(player, Audio(id, delay, loops, radius), location)) } } @@ -2803,7 +2803,7 @@ fun stun(entity: Entity, ticks: Int) { entity.clocks[Clocks.STUN] = getWorldTicks() + ticks entity.graphics(Graphics(80, 96)) if (entity is Player) { - entity.audioManager.send(Audio(2727, 1, 0)) + playAudio(entity.asPlayer(), Sounds.STUNNED_2727) entity.animate(Animation(424, Animator.Priority.VERY_HIGH)) sendMessage(entity, "You have been stunned!") } diff --git a/Server/src/main/core/game/consumable/Drink.java b/Server/src/main/core/game/consumable/Drink.java index ee9b6c165..e5b8611ab 100644 --- a/Server/src/main/core/game/consumable/Drink.java +++ b/Server/src/main/core/game/consumable/Drink.java @@ -1,13 +1,12 @@ package core.game.consumable; import core.game.node.entity.player.Player; -import core.game.node.entity.player.link.audio.Audio; import core.game.node.item.Item; import core.game.world.update.flag.context.Animation; -public class Drink extends Consumable { +import static core.api.ContentAPIKt.playAudio; - public static final Audio SOUND = new Audio(4580, 1, 1); +public class Drink extends Consumable { public Drink(int[] ids, ConsumableEffect effect, String... messages) { super(ids, effect, messages); @@ -26,7 +25,7 @@ public class Drink extends Consumable { @Override protected void executeConsumptionActions(Player player) { player.animate(animation); - player.getAudioManager().send(SOUND); + playAudio(player, 4580); } @Override diff --git a/Server/src/main/core/game/consumable/Food.java b/Server/src/main/core/game/consumable/Food.java index a8f31e1e3..d5b55bb82 100644 --- a/Server/src/main/core/game/consumable/Food.java +++ b/Server/src/main/core/game/consumable/Food.java @@ -1,14 +1,14 @@ package core.game.consumable; import core.game.node.entity.player.Player; -import core.game.node.entity.player.link.audio.Audio; import core.game.node.item.Item; import core.game.world.update.flag.context.Animation; +import org.rs09.consts.Sounds; + +import static core.api.ContentAPIKt.playAudio; public class Food extends Consumable { - public static final Audio SOUND = new Audio(2393, 1, 1); - public Food(final int[] ids, final ConsumableEffect effect, final String... messages) { super(ids, effect, messages); animation = new Animation(829); @@ -30,6 +30,6 @@ public class Food extends Consumable { } private void playEatingSound(Player player) { - player.getAudioManager().send(SOUND); + playAudio(player, Sounds.EAT_2393); } } diff --git a/Server/src/main/core/game/consumable/Potion.java b/Server/src/main/core/game/consumable/Potion.java index e715c6f69..d7614266c 100644 --- a/Server/src/main/core/game/consumable/Potion.java +++ b/Server/src/main/core/game/consumable/Potion.java @@ -1,10 +1,12 @@ package core.game.consumable; import content.data.consumables.Consumables; -import content.region.kandarin.barcrawl.BarcrawlManager; import core.game.node.entity.player.Player; import core.game.node.entity.player.link.audio.Audio; import core.game.node.item.Item; +import org.rs09.consts.Sounds; + +import static core.api.ContentAPIKt.playAudio; public class Potion extends Drink { @@ -40,7 +42,7 @@ public class Potion extends Drink { @Override protected void executeConsumptionActions(Player player) { player.animate(animation); - player.getAudioManager().send(SOUND); + playAudio(player, Sounds.LIQUID_2401); } @Override diff --git a/Server/src/main/core/game/ge/GrandExchange.kt b/Server/src/main/core/game/ge/GrandExchange.kt index 4e8745731..5b763bf71 100644 --- a/Server/src/main/core/game/ge/GrandExchange.kt +++ b/Server/src/main/core/game/ge/GrandExchange.kt @@ -5,7 +5,6 @@ import core.api.* import core.cache.def.impl.ItemDefinition import core.game.node.entity.player.Player import core.game.node.entity.player.info.PlayerDetails -import core.game.node.entity.player.link.audio.Audio import core.game.system.command.Privilege import core.game.system.config.ItemConfigParser import core.game.system.task.Pulse @@ -14,6 +13,7 @@ import core.game.world.repository.Repository import core.tools.Log import core.tools.SystemLogger import core.tools.colorize +import org.rs09.consts.Sounds import java.lang.Integer.max import java.util.concurrent.LinkedBlockingDeque @@ -279,7 +279,7 @@ class GrandExchange : StartupListener, Commands { buyer.completedAmount += amount if(seller.amountLeft < 1 && seller.player != null) - seller.player!!.audioManager.send(Audio(4042,1,1)) + playAudio(seller.player!!, Sounds.GE_COLLECT_COINS_4042) seller.addWithdrawItem(995, amount * if(sellerBias) buyer.offeredValue else seller.offeredValue) buyer.addWithdrawItem(seller.itemID, amount) diff --git a/Server/src/main/core/game/global/action/DoorActionHandler.java b/Server/src/main/core/game/global/action/DoorActionHandler.java index 2766685e5..98a886839 100644 --- a/Server/src/main/core/game/global/action/DoorActionHandler.java +++ b/Server/src/main/core/game/global/action/DoorActionHandler.java @@ -2,7 +2,6 @@ package core.game.global.action; import core.game.node.entity.Entity; import core.game.node.entity.player.Player; -import core.game.node.entity.player.link.audio.Audio; import core.game.node.entity.player.link.diary.DiaryType; import core.game.node.scenery.Constructed; import core.game.node.scenery.Scenery; @@ -18,6 +17,7 @@ import core.game.world.GameWorld; import org.rs09.consts.Sounds; import static core.api.ContentAPIKt.hasRequirement; +import static core.api.ContentAPIKt.playAudio; import java.awt.*; @@ -45,11 +45,11 @@ public final class DoorActionHandler { if (object instanceof Constructed && (o = ((Constructed) object).getReplaced()) != null) { DoorConfigLoader.Door d = DoorConfigLoader.Companion.forId(object.getId()); if (d != null && d.isMetal()) { - player.getAudioManager().send(Sounds.IRON_DOOR_CLOSE_70); + playAudio(player, Sounds.IRON_DOOR_CLOSE_70); } else if (d != null && d.isFence()){ - player.getAudioManager().send(Sounds.GATE_CLOSE_66); + playAudio(player, Sounds.GATE_CLOSE_66); } else { - player.getAudioManager().send(60); + playAudio(player, 60); } SceneryBuilder.replace(object, o); if (second instanceof Constructed && (o = ((Constructed) second).getReplaced()) != null) { @@ -61,20 +61,20 @@ public final class DoorActionHandler { if (object.getDefinition().hasAction("close")) { if (second != null) { player.getPacketDispatch().sendMessage("The doors appear to be stuck."); - player.getAudioManager().send(Sounds.DOOR_CREAK_61); + playAudio(player, Sounds.DOOR_CREAK_61); return; } DoorConfigLoader.Door d = DoorConfigLoader.Companion.forId(object.getId()); if (d != null && d.isMetal()) { - player.getAudioManager().send(Sounds.IRON_DOOR_OPEN_71); + playAudio(player, Sounds.IRON_DOOR_OPEN_71); } else if (d != null && d.isFence()){ - player.getAudioManager().send(Sounds.GATE_OPEN_67); + playAudio(player, Sounds.GATE_OPEN_67); } else { - player.getAudioManager().send(Sounds.DOOR_OPEN_62); + playAudio(player, Sounds.DOOR_OPEN_62); } if (d == null) { player.getPacketDispatch().sendMessage("The door appears to be stuck."); - player.getAudioManager().send(Sounds.DOOR_CREAK_61); + playAudio(player, Sounds.DOOR_CREAK_61); return; } int firstDir = (object.getRotation() + 3) % 4; @@ -93,11 +93,11 @@ public final class DoorActionHandler { return; } if (d.isMetal()) { - player.getAudioManager().send(Sounds.IRON_DOOR_OPEN_71); + playAudio(player, Sounds.IRON_DOOR_OPEN_71); } else if (d.isFence()){ - player.getAudioManager().send(Sounds.GATE_OPEN_67); + playAudio(player, Sounds.GATE_OPEN_67); } else { - player.getAudioManager().send(Sounds.DOOR_OPEN_62); + playAudio(player, Sounds.DOOR_OPEN_62); } if (second != null) { DoorConfigLoader.Door s = DoorConfigLoader.Companion.forId(second.getId()); @@ -124,14 +124,14 @@ public final class DoorActionHandler { if (entity instanceof Player) { DoorConfigLoader.Door d = DoorConfigLoader.Companion.forId(object.getId()); if (d != null && d.isMetal()) { - ((Player) entity).getAudioManager().send(Sounds.IRON_DOOR_OPEN_71, 10); - ((Player) entity).getAudioManager().send(Sounds.IRON_DOOR_CLOSE_70, 10, 60); + playAudio(entity.asPlayer(), Sounds.IRON_DOOR_OPEN_71); + playAudio(entity.asPlayer(), Sounds.IRON_DOOR_CLOSE_70, 60); } else if (d != null && d.isFence()){ - ((Player) entity).getAudioManager().send(Sounds.GATE_OPEN_67, 10); - ((Player) entity).getAudioManager().send(Sounds.GATE_CLOSE_66, 10, 60); + playAudio(entity.asPlayer(), Sounds.GATE_OPEN_67); + playAudio(entity.asPlayer(), Sounds.GATE_CLOSE_66, 60); } else { - ((Player) entity).getAudioManager().send(Sounds.DOOR_OPEN_62,10); - ((Player) entity).getAudioManager().send(60,10,60); + playAudio(entity.asPlayer(), Sounds.DOOR_OPEN_62); + playAudio(entity.asPlayer(), 60, 60); } entity.asPlayer().logoutListeners.put("autowalk", player -> { player.setLocation(loc); diff --git a/Server/src/main/core/game/global/action/EquipHandler.kt b/Server/src/main/core/game/global/action/EquipHandler.kt index ea8414b35..bab80e779 100644 --- a/Server/src/main/core/game/global/action/EquipHandler.kt +++ b/Server/src/main/core/game/global/action/EquipHandler.kt @@ -5,6 +5,7 @@ import core.game.event.ItemUnequipEvent import core.game.container.impl.EquipmentContainer import content.global.handlers.item.equipment.brawling_gloves.BrawlingGlovesManager import content.global.skill.slayer.SlayerEquipmentFlags +import core.api.playAudio import core.game.node.Node import core.game.node.entity.combat.equipment.WeaponInterface import core.game.node.entity.player.Player @@ -14,6 +15,7 @@ import core.game.interaction.InteractionListener import core.game.interaction.IntType import core.game.interaction.InteractionListeners import core.game.system.config.ItemConfigParser +import org.rs09.consts.Sounds /** * Represents the equipment equipping handler plugin. @@ -65,7 +67,7 @@ class EquipHandler : InteractionListener { player.dialogueInterpreter.close() /* TODO: Send different equip sound based on what is being equip.*/ - player.audioManager.send(item.definition.getConfiguration(ItemConfigParser.EQUIP_AUDIO, 2244)) + playAudio(player, item.definition.getConfiguration(ItemConfigParser.EQUIP_AUDIO, 2244)) if (player.properties.autocastSpell != null) { val itemEquipmentSlot = item.definition.getConfiguration(ItemConfigParser.EQUIP_SLOT, -1) @@ -125,7 +127,7 @@ class EquipHandler : InteractionListener { } if (player.equipment.remove(item)) { /* TODO: Send different unequip sound based on what is being unequipped.*/ - player.audioManager.send(Audio(2238, 10, 1)) + playAudio(player, Sounds.EQUIP_FUN_2238) player.dialogueInterpreter.close() player.inventory.add(item) diff --git a/Server/src/main/core/game/global/action/PickupHandler.kt b/Server/src/main/core/game/global/action/PickupHandler.kt index 10d7205fd..ec42b1858 100644 --- a/Server/src/main/core/game/global/action/PickupHandler.kt +++ b/Server/src/main/core/game/global/action/PickupHandler.kt @@ -4,8 +4,8 @@ import core.game.event.PickUpEvent import core.api.getItemName import content.data.GodType import core.game.node.entity.player.Player -import core.game.node.entity.player.link.audio.Audio import content.global.skill.runecrafting.RunePouch +import core.api.playAudio import core.game.node.entity.player.info.LogType import core.game.node.item.GroundItem import core.game.node.item.GroundItemManager @@ -13,9 +13,9 @@ import core.game.node.item.Item import core.game.world.map.RegionManager import core.game.world.update.flag.context.Animation import core.game.node.entity.player.info.PlayerMonitor -import core.tools.SystemLogger import core.game.system.config.GroundSpawnLoader import core.game.world.GameWorld +import org.rs09.consts.Sounds /** * A class used to handle the picking up of ground items. @@ -66,7 +66,7 @@ object PickupHandler { } */ - player.audioManager.send(Audio(2582, 10, 1)) + playAudio(player, Sounds.PICK2_2582) player.dispatch(PickUpEvent(item.id)) } return true diff --git a/Server/src/main/core/game/node/entity/combat/CombatSwingHandler.kt b/Server/src/main/core/game/node/entity/combat/CombatSwingHandler.kt index 525bfbd99..066bc64ba 100644 --- a/Server/src/main/core/game/node/entity/combat/CombatSwingHandler.kt +++ b/Server/src/main/core/game/node/entity/combat/CombatSwingHandler.kt @@ -367,7 +367,7 @@ abstract class CombatSwingHandler(var type: CombatStyle?) { } else if (entity is NPC && victim is Player) { val npc = entity.asNpc() val audio = npc.getAudio(0) - audio?.send(victim.asPlayer(), true, entity.location) + if (audio != null) playGlobalAudio(entity.location, audio.id) } } diff --git a/Server/src/main/core/game/node/entity/combat/DeathTask.java b/Server/src/main/core/game/node/entity/combat/DeathTask.java index 01318c4da..1454950af 100644 --- a/Server/src/main/core/game/node/entity/combat/DeathTask.java +++ b/Server/src/main/core/game/node/entity/combat/DeathTask.java @@ -53,7 +53,7 @@ public final class DeathTask extends NodeTask { Player p = killer.asPlayer(); Audio audio = e.asNpc().getAudio(2); if (audio != null) { - playGlobalAudio(e.getLocation(), audio.getId()); + playGlobalAudio(e.getLocation(), audio.id); } } } diff --git a/Server/src/main/core/game/node/entity/combat/equipment/BoltEffect.java b/Server/src/main/core/game/node/entity/combat/equipment/BoltEffect.java index 207add03e..eabede5ff 100644 --- a/Server/src/main/core/game/node/entity/combat/equipment/BoltEffect.java +++ b/Server/src/main/core/game/node/entity/combat/equipment/BoltEffect.java @@ -229,10 +229,10 @@ public enum BoltEffect { if (sound != null) { Entity attacker = state.getAttacker(); if (attacker instanceof Player) { - sound.send(attacker.asPlayer(), true); + playGlobalAudio(attacker.getLocation(), sound.id); } if (victim instanceof Player) { - sound.send(victim.asPlayer(), true); + playGlobalAudio(victim.getLocation(), sound.id); } } if (graphics != null) { diff --git a/Server/src/main/core/game/node/entity/combat/spell/CombatSpell.java b/Server/src/main/core/game/node/entity/combat/spell/CombatSpell.java index b277c3ead..3601d6849 100644 --- a/Server/src/main/core/game/node/entity/combat/spell/CombatSpell.java +++ b/Server/src/main/core/game/node/entity/combat/spell/CombatSpell.java @@ -173,7 +173,7 @@ public abstract class CombatSpell extends MagicSpell { entity.animate(animation); } } - playGlobalAudio(entity.getLocation(), audio.getId(), 20); + playGlobalAudio(entity.getLocation(), audio.id, 20); } @Override diff --git a/Server/src/main/core/game/node/entity/combat/spell/MagicSpell.java b/Server/src/main/core/game/node/entity/combat/spell/MagicSpell.java index 3b829cbd7..12059a76c 100644 --- a/Server/src/main/core/game/node/entity/combat/spell/MagicSpell.java +++ b/Server/src/main/core/game/node/entity/combat/spell/MagicSpell.java @@ -160,7 +160,7 @@ public abstract class MagicSpell implements Plugin { public void visualize(Entity entity, Node target) { entity.graphics(graphic); entity.animate(animation); - playGlobalAudio(entity.getLocation(), audio.getId(), 20); + playGlobalAudio(entity.getLocation(), audio.id, 20); } /** diff --git a/Server/src/main/core/game/node/entity/npc/NPC.java b/Server/src/main/core/game/node/entity/npc/NPC.java index 31771fa1e..ba1fdf3e3 100644 --- a/Server/src/main/core/game/node/entity/npc/NPC.java +++ b/Server/src/main/core/game/node/entity/npc/NPC.java @@ -628,7 +628,7 @@ public class NPC extends Entity { int[] audios = getDefinition().getConfiguration(NPCConfigParser.COMBAT_AUDIO, null); if (audios != null) { Audio audio = new Audio(audios[index]); - if (audio != null && audio.getId() != 0) { + if (audio != null && audio.id != 0) { return audio; } } diff --git a/Server/src/main/core/game/node/entity/player/Player.java b/Server/src/main/core/game/node/entity/player/Player.java index f65720d82..b64dbc6df 100644 --- a/Server/src/main/core/game/node/entity/player/Player.java +++ b/Server/src/main/core/game/node/entity/player/Player.java @@ -24,7 +24,6 @@ import core.game.node.entity.player.info.login.LoginConfiguration; import core.game.node.entity.player.info.login.PlayerParser; import core.game.node.entity.player.link.*; import core.game.node.entity.player.link.appearance.Appearance; -import core.game.node.entity.player.link.audio.AudioManager; import core.game.node.entity.player.link.diary.AchievementDiaryManager; import core.game.node.entity.player.link.emote.EmoteManager; import core.game.node.entity.player.link.music.MusicPlayer; @@ -60,6 +59,7 @@ import core.tools.*; import kotlin.Unit; import kotlin.jvm.functions.Function1; import org.rs09.consts.Items; +import org.rs09.consts.Sounds; import proto.management.ClanLeaveNotification; import proto.management.PlayerStatusUpdate; import core.GlobalStats; @@ -90,8 +90,6 @@ import static core.api.ContentAPIKt.*; import static core.game.system.command.sets.StatAttributeKeysKt.STATS_BASE; import static core.game.system.command.sets.StatAttributeKeysKt.STATS_DEATHS; import static core.tools.GlobalsKt.colorize; -import static core.game.world.map.zone.impl.WildernessZone.WILDERNESS_PROT_ATTR; -import static core.game.world.map.zone.impl.WildernessZone.WILDERNESS_HIGHER_NEXTFEE; /** * Represents a player entity. @@ -267,11 +265,6 @@ public class Player extends Entity { */ private final HouseManager houseManager = new HouseManager(); - /** - * The audio manager. - */ - private final AudioManager audioManager = new AudioManager(this); - /** * The bank pin manager. */ @@ -448,12 +441,12 @@ public class Player extends Entity { int time = getAttribute("fire:immune",0) - GameWorld.getTicks(); if(time == TickUtilsKt.secondsToTicks(30)){ sendMessage(colorize("%RYou have 30 seconds remaining on your antifire potion.")); - getAudioManager().send(3120); + playAudio(this, Sounds.CLOCK_TICK_1_3120, 0, 3); } if(time == 0){ sendMessage(colorize("%RYour antifire potion has expired.")); removeAttribute("fire:immune"); - getAudioManager().send(2607); + playAudio(this, Sounds.DRAGON_POTION_FINISHED_2607); } } if(getAttribute("poison:immunity",0) > 0){ @@ -461,12 +454,12 @@ public class Player extends Entity { debug(time + ""); if(time == TickUtilsKt.secondsToTicks(30)){ sendMessage(colorize("%RYou have 30 seconds remaining on your antipoison potion.")); - getAudioManager().send(3120); + playAudio(this, Sounds.CLOCK_TICK_1_3120, 0, 3); } if(time == 0){ sendMessage(colorize("%RYour antipoison potion has expired.")); removeAttribute("poison:immunity"); - getAudioManager().send(2607); + playAudio(this, Sounds.DRAGON_POTION_FINISHED_2607); } } if(getAttribute("infinite-special", false)) { @@ -1293,14 +1286,6 @@ public class Player extends Entity { return houseManager; } - /** - * Gets the audioManager. - * @return the audioManager - */ - public AudioManager getAudioManager() { - return audioManager; - } - /** * Gets the bankPinManager. * @return the bankPinManager diff --git a/Server/src/main/core/game/node/entity/player/link/BankPinManager.java b/Server/src/main/core/game/node/entity/player/link/BankPinManager.java index bf8190b62..96f8e15f7 100644 --- a/Server/src/main/core/game/node/entity/player/link/BankPinManager.java +++ b/Server/src/main/core/game/node/entity/player/link/BankPinManager.java @@ -14,6 +14,7 @@ import core.net.packet.out.RepositionChild; import core.net.packet.out.StringPacket; import core.tools.RandomFunction; import org.json.simple.JSONObject; +import org.rs09.consts.Sounds; import java.util.ArrayList; import java.util.Arrays; @@ -148,7 +149,7 @@ public class BankPinManager { player.getInterfaceManager().close(); tempPin = null; sendMessages(messages); - player.getAudioManager().send(1040); + playAudio(player, Sounds.PIN_PENDING_1040); player.getInterfaceManager().open(new Component(14)); } @@ -268,7 +269,7 @@ public class BankPinManager { for (int i = 60; i < 66; i++) { player.getPacketDispatch().sendInterfaceConfig(14, i, show); } - player.getAudioManager().send(1040); + playAudio(player, Sounds.PIN_PENDING_1040); player.getPacketDispatch().sendInterfaceConfig(14, 89, !show); player.getPacketDispatch().sendInterfaceConfig(14, 91, !show); player.getPacketDispatch().sendInterfaceConfig(14, 87, !show); @@ -341,13 +342,13 @@ public class BankPinManager { public void handlePinStage(int stage) { if (stage == 4) { if (!hasPin() || changeState == 2) { - player.getAudioManager().send(1040); + playAudio(player, Sounds.PIN_PENDING_1040); player.getPacketDispatch().sendString("Now please enter that number again!", 13, 28); shuffleDigits(); return; } else { if (!tempPin.equals(pin)) { - player.getAudioManager().send(1042); + playAudio(player, Sounds.PIN_CANCEL_1042); player.getInterfaceManager().close(); player.sendMessage("The PIN you entered is incorrect."); if (setTries(getTries() + 1) >= 2) { @@ -394,7 +395,7 @@ public class BankPinManager { } shuffleDigits(); if (stage != 0) { - player.getAudioManager().send(1041); + playAudio(player, Sounds.PIN_BEEP_1041); } } @@ -475,7 +476,7 @@ public class BankPinManager { pendingDelay = -1; pin = null; unlocked = false; - player.getAudioManager().send(1042); + playAudio(player, Sounds.PIN_CANCEL_1042); openSettings(messages); } diff --git a/Server/src/main/core/game/node/entity/player/link/TeleportManager.java b/Server/src/main/core/game/node/entity/player/link/TeleportManager.java index a58d6d4e5..d6382f529 100644 --- a/Server/src/main/core/game/node/entity/player/link/TeleportManager.java +++ b/Server/src/main/core/game/node/entity/player/link/TeleportManager.java @@ -13,7 +13,7 @@ import core.game.world.update.flag.context.Animation; import core.game.world.update.flag.context.Graphics; import org.rs09.consts.Sounds; -import static core.api.ContentAPIKt.hasTimerActive; +import static core.api.ContentAPIKt.*; /** * Handles the entity teleport. @@ -203,18 +203,14 @@ public class TeleportManager { @Override public boolean pulse() { if (delay == 0) { - if (entity instanceof Player) { - entity.asPlayer().getAudioManager().send(new Audio(200), true); - } + playGlobalAudio(entity.getLocation(), Sounds.TELEPORT_ALL_200); entity.getAnimator().forceAnimation(new Animation(getSettings().getStartEmote())); entity.graphics(new Graphics(getSettings().getStartGfx())); } else if (delay == 3) { entity.getProperties().setTeleportLocation(Location.create(location)); fireRandom(entity, location); } else if (delay == 4) { - if (entity instanceof Player) { - entity.asPlayer().getAudioManager().send(new Audio(201), true); - } + playGlobalAudio(entity.getLocation(), Sounds. TELEPORT_REVERSE_201); entity.getAnimator().forceAnimation(new Animation(getSettings().getEndEmote(), Priority.HIGH)); entity.graphics(new Graphics(getSettings().getEndGfx())); return true; @@ -241,10 +237,7 @@ public class TeleportManager { @Override public boolean pulse() { if (delay == 0) { - if (entity instanceof Player) { - entity.asPlayer().getAudioManager().send(new Audio(Sounds.BLOCK_TELEPORT_197), true); - } - + playGlobalAudio(entity.getLocation(), Sounds.BLOCK_TELEPORT_197, 0, 7); entity.getAnimator().forceAnimation(new Animation(getSettings().getStartEmote())); entity.graphics(new Graphics(getSettings().getStartGfx())); } else if (delay == 4) { @@ -311,9 +304,7 @@ public class TeleportManager { @Override public boolean pulse() { if (delay == 0) { - if (entity instanceof Player) { - entity.asPlayer().getAudioManager().send(979); - } + playGlobalAudio(entity.getLocation(), Sounds.POH_TABLET_BREAK_979); entity.getAnimator().forceAnimation(new Animation(4069)); } else if (delay == 2) { entity.getAnimator().forceAnimation(new Animation(getSettings().getStartEmote(), Priority.HIGH)); @@ -354,7 +345,7 @@ public class TeleportManager { player.getProperties().setTeleportLocation(location); return true; default: - entity.asPlayer().getAudioManager().send(getAudio(count)); + playGlobalAudio(entity.getLocation(), getAudio(count)); player.getPacketDispatch().sendGraphic(HOME_GRAPHICS[count]); player.getPacketDispatch().sendAnimation(HOME_ANIMATIONS[count]); break; @@ -424,9 +415,7 @@ public class TeleportManager { @Override public boolean pulse() { if (delay == 0) { - if (entity instanceof Player) { - entity.asPlayer().getAudioManager().send(199); - } + playGlobalAudio(entity.getLocation(), Sounds.TELE_OTHER_CAST_199); entity.getAnimator().forceAnimation(new Animation(getSettings().getStartEmote())); entity.graphics(new Graphics(getSettings().getStartGfx())); } else if (delay == 3) { @@ -455,7 +444,7 @@ public class TeleportManager { case 2: entity.animate(Animation.create(3265)); if(entity instanceof Player) { - ((Player) entity).getAudioManager().send(1098, 1); + playAudio(entity.asPlayer(), Sounds.FT_FAIRY_TELEPORT_1098); } break; case 4: @@ -503,18 +492,14 @@ public class TeleportManager { @Override public boolean pulse() { if (delay == 0) { - if (entity instanceof Player) { - entity.asPlayer().getAudioManager().send(200); - } + playGlobalAudio(entity.getLocation(), Sounds.TELEPORT_ALL_200); entity.getAnimator().forceAnimation(new Animation(getSettings().getStartEmote())); entity.graphics(new Graphics(getSettings().getStartGfx())); } else if (delay == 3) { entity.getProperties().setTeleportLocation(Location.create(location)); fireRandom(entity, location); } else if (delay == 4) { - if (entity instanceof Player) { - entity.asPlayer().getAudioManager().send(201); - } + playGlobalAudio(entity.getLocation(), Sounds.TELEPORT_REVERSE_201); entity.getAnimator().forceAnimation(new Animation(getSettings().getEndEmote(), Priority.HIGH)); entity.graphics(new Graphics(getSettings().getEndGfx())); return true; @@ -541,18 +526,14 @@ public class TeleportManager { @Override public boolean pulse() { if (delay == 0) { - if (entity instanceof Player) { - entity.asPlayer().getAudioManager().send(200); - } + playGlobalAudio(entity.getLocation(), Sounds.TELEPORT_ALL_200); entity.getAnimator().forceAnimation(new Animation(getSettings().getStartEmote())); entity.graphics(new Graphics(getSettings().getStartGfx())); } else if (delay == 3) { entity.getProperties().setTeleportLocation(Location.create(location)); fireRandom(entity, location); } else if (delay == 4) { - if (entity instanceof Player) { - entity.asPlayer().getAudioManager().send(201); - } + playGlobalAudio(entity.getLocation(), Sounds.TELEPORT_REVERSE_201); entity.getAnimator().forceAnimation(new Animation(getSettings().getEndEmote(), Priority.HIGH)); entity.graphics(new Graphics(getSettings().getEndGfx())); return true; @@ -580,7 +561,7 @@ public class TeleportManager { public boolean pulse() { if (delay == 0) { if (entity instanceof Player) { - entity.asPlayer().getAudioManager().send(5036); + playAudio(entity.asPlayer(), 5036); } entity.getAnimator().forceAnimation(new Animation(getSettings().getStartEmote())); entity.graphics(new Graphics(getSettings().getStartGfx())); @@ -588,7 +569,7 @@ public class TeleportManager { entity.getProperties().setTeleportLocation(Location.create(location)); fireRandom(entity, location); if (entity instanceof Player) { - entity.asPlayer().getAudioManager().send(5034); + playAudio(entity.asPlayer(), 5034); } entity.getAnimator().forceAnimation(new Animation(getSettings().getEndEmote(), Priority.HIGH)); entity.graphics(new Graphics(getSettings().getEndGfx())); @@ -616,18 +597,14 @@ public class TeleportManager { @Override public boolean pulse() { if (delay == 0) { - if (entity instanceof Player) { - entity.asPlayer().getAudioManager().send(200); - } + playGlobalAudio(entity.getLocation(), Sounds.TELEPORT_ALL_200); entity.getAnimator().forceAnimation(new Animation(getSettings().getStartEmote())); entity.graphics(new Graphics(getSettings().getStartGfx())); } else if (delay == 3) { entity.getProperties().setTeleportLocation(Location.create(location)); fireRandom(entity, location); } else if (delay == 4) { - if (entity instanceof Player) { - entity.asPlayer().getAudioManager().send(201); - } + playGlobalAudio(entity.getLocation(), Sounds.TELEPORT_REVERSE_201); entity.getAnimator().forceAnimation(new Animation(getSettings().getEndEmote(), Priority.HIGH)); entity.graphics(new Graphics(getSettings().getEndGfx())); return true; diff --git a/Server/src/main/core/game/node/entity/player/link/audio/Audio.java b/Server/src/main/core/game/node/entity/player/link/audio/Audio.java deleted file mode 100644 index 7206b01f5..000000000 --- a/Server/src/main/core/game/node/entity/player/link/audio/Audio.java +++ /dev/null @@ -1,155 +0,0 @@ -package core.game.node.entity.player.link.audio; - -import core.game.node.entity.player.Player; -import core.game.world.map.Location; - -import java.util.List; - -/** - * An audio piece to play. - * @author Vexia - */ -public class Audio { - - /** - * The default volume. - */ - public static final int VOLUME = 10; - - /** - * The default delay. - */ - public static final int DELAY = 0; - - /** - * The default radius in tiles of positional audio in [0,16). - */ - public static final int RADIUS = 8; - - /** - * The id of the audio piece. - */ - private final int id; - - /** - * The volume. - */ - private final int volume; - - /** - * The delay. - */ - private final int delay; - - /** - * The radius. - */ - private final int radius; - - /** - * Constructs a new {@Code Audio} {@Code Object} - * @param id the id. - * @param volume the volume. - * @param delay the delay. - * @param radius the radius. - */ - public Audio(int id, int volume, int delay, int radius) { - this.id = id; - this.volume = volume; - this.delay = delay; - this.radius = radius; - } - - /** - * Constructs a new {@Code Audio} {@Code Object} - * @param id the id. - * @param volume the volume. - * @param delay the delay. - */ - public Audio(int id, int volume, int delay) { - this(id, volume, delay, RADIUS); - } - - /** - * Constructs a new {@Code Audio} {@Code Object} - * @param id the id. - * @param volume the volume. - */ - public Audio(int id, int volume) { - this(id, volume, DELAY); - } - - /** - * Constructs a new {@Code Audio} {@Code Object} - * @param id the id. - */ - public Audio(int id) { - this(id, VOLUME, 0); - } - - /** - * Sends an audio through the manager. - * @param player the player. - * @param global the global. - */ - public void send(Player player, boolean global) { - send(player, global, null); - } - - public void send(Player player, boolean global, Location loc) { - player.getAudioManager().send(this, global, loc); - } - - /** - * Sends this audio. - * @param player the player. - */ - public void send(Player player) { - send(player, false); - } - - /** - * Sends the sound to a list of players. - * @param players the players. - */ - public void send(List players) { - for (Player p : players) { - if (p == null) { - continue; - } - send(p, false); - } - } - - /** - * Gets the id. - * @return the id - */ - public int getId() { - return id; - } - - /** - * Gets the volume. - * @return the volume - */ - public int getVolume() { - return volume; - } - - /** - * Gets the delay. - * @return the delay - */ - public int getDelay() { - return delay; - } - - /** - * Gets the radius. - * @return the radius - */ - public int getRadius() { - return radius; - } -} diff --git a/Server/src/main/core/game/node/entity/player/link/audio/Audio.kt b/Server/src/main/core/game/node/entity/player/link/audio/Audio.kt new file mode 100644 index 000000000..a1e155769 --- /dev/null +++ b/Server/src/main/core/game/node/entity/player/link/audio/Audio.kt @@ -0,0 +1,29 @@ +package core.game.node.entity.player.link.audio + +/** + * An audio object to play. + * @author Zerken + */ +class Audio + @JvmOverloads + constructor( + @JvmField + val id: Int, + @JvmField + val delay: Int = 0, + @JvmField + val loops: Int = 1, + @JvmField + val radius: Int = defaultAudioRadius + ) { + companion object { + /** + * ----Audio Radius Constants---- + * Values which represent the tile distance/radius from which certain groups of audio can be heard from + * Certain sounds can be heard from a further distance than others + * This is a common place where audio distances can be adjusted if needed + */ + // TODO: Add specific groups of audios to have the correct radius (some sounds should be heard from a farther radius than others) + const val defaultAudioRadius = 8 + } + } \ No newline at end of file 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 deleted file mode 100644 index e3166579f..000000000 --- a/Server/src/main/core/game/node/entity/player/link/audio/AudioManager.java +++ /dev/null @@ -1,131 +0,0 @@ -package core.game.node.entity.player.link.audio; - -import core.game.node.entity.player.Player; -import core.game.world.map.Location; -import core.game.world.map.RegionManager; -import core.net.packet.PacketRepository; -import core.net.packet.context.DefaultContext; -import core.net.packet.out.AudioPacket; - -import java.util.List; - -/** - * Manages audio for a player. - * @author Vexia - */ -public class AudioManager { - - /** - * The player instance. - */ - private final Player player; - - /** - * Constructs a new {@Code AudioManager} {@Code Object} - * @param player the player. - */ - public AudioManager(Player player) { - this.player = player; - } - - /** - * Sends an audio packet. - * @param audioId the audio id. - */ - public void send(int audioId) { - send(audioId, false); - } - - /** - * Sends an audio. - * @param audioId the audio id. - * @param global the global. - */ - public void send(int audioId, boolean global) { - send(new Audio(audioId), global); - } - - /** - * Sends an audio packet. - * @param audioId the audio id. - * @param volume the volume. - */ - public void send(int audioId, int volume) { - send(new Audio(audioId, volume), false); - } - - /** - * Sends an audio packet. - * @param audioId the audio id. - * @param volume the volume. - * @param delay the delay. - */ - public void send(int audioId, int volume, int delay) { - 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. - */ - public void send(Audio audio) { - send(audio, false); - } - - public void send(Audio audio, boolean global) { - send(audio, global, null); - } - - /** - * Sends an audio packet. - * @param audio the audio. - * @param global if the audio can be heard globally by other players. - * @param loc the location where the audio will play from. If location = null the players location is used. - */ - public void send(Audio audio, boolean global, Location loc) { - if (global) { - List players = RegionManager.getLocalPlayers(loc != null ? loc : player.getLocation(), audio.getRadius()); - for (Player p : players) { - if (p == null) { - continue; - } - PacketRepository.send(AudioPacket.class, new DefaultContext(p, audio, loc)); - } - } else PacketRepository.send(AudioPacket.class, new DefaultContext(player, audio, loc)); - } - - /** - * Sends an audio packet for a bunch of players. - * @param audio the audio. - * @param players the players. - */ - public void send(Audio audio, List players, Location loc) { - for (Player p : players) { - if (p == null) { - continue; - } - p.getAudioManager().send(audio, false, loc); - } - } - - /** - * Gets the player. - * @return the player - */ - public Player getPlayer() { - return player; - } - -} diff --git a/Server/src/main/core/game/node/entity/player/link/prayer/Prayer.java b/Server/src/main/core/game/node/entity/player/link/prayer/Prayer.java index 22336a0ce..8301e666e 100644 --- a/Server/src/main/core/game/node/entity/player/link/prayer/Prayer.java +++ b/Server/src/main/core/game/node/entity/player/link/prayer/Prayer.java @@ -15,12 +15,12 @@ import core.game.world.map.RegionManager; import core.game.world.update.flag.context.Graphics; import core.tools.RandomFunction; import core.game.world.GameWorld; +import org.rs09.consts.Sounds; import java.util.ArrayList; import java.util.List; -import static core.api.ContentAPIKt.setVarp; -import static core.api.ContentAPIKt.setVarbit; +import static core.api.ContentAPIKt.*; /** * Represents a managing class of a players prayers. @@ -82,7 +82,7 @@ public final class Prayer { * Starts the redemption effect. */ public void startRedemption() { - player.getAudioManager().send(2681); + playAudio(player, Sounds.REDEMPTION_HEAL_2681); player.graphics(Graphics.create(436)); player.getSkills().heal((int) (player.getSkills().getStaticLevel(Skills.PRAYER) * 0.25)); player.getSkills().setPrayerPoints(0.0); @@ -102,7 +102,7 @@ public final class Prayer { } } } - player.getAudioManager().send(159); + playAudio(player, Sounds.FIREBREATH_159); player.graphics(Graphics.create(437)); int maximum = (int) (player.getSkills().getStaticLevel(Skills.PRAYER) * 0.25) - 1; if (killer != player && killer.getLocation().withinDistance(player.getLocation(), 1)) { @@ -131,7 +131,7 @@ public final class Prayer { if(prayerActiveTicks > 0 && prayerActiveTicks % 2 == 0){ if(getPlayer().getSkills().getPrayerPoints() == 0){ - getPlayer().getAudioManager().send(2672); + playAudio(getPlayer(), Sounds.PRAYER_DRAIN_2672); reset(); return; } diff --git a/Server/src/main/core/game/node/entity/player/link/prayer/PrayerType.java b/Server/src/main/core/game/node/entity/player/link/prayer/PrayerType.java index 445a2449d..e8fba525e 100644 --- a/Server/src/main/core/game/node/entity/player/link/prayer/PrayerType.java +++ b/Server/src/main/core/game/node/entity/player/link/prayer/PrayerType.java @@ -222,7 +222,7 @@ public enum PrayerType { */ public boolean permitted(final Player player) { if (player.getSkills().getStaticLevel(Skills.PRAYER) < getLevel() || player.getSkills().getStaticLevel(Skills.DEFENCE) < defenceReq) { - player.getAudioManager().send(2673); + playAudio(player, Sounds.PRAYER_OFF_2673); player.getDialogueInterpreter().sendDialogue("You need a Prayer level of " + getLevel() + (player.getSkills().getStaticLevel(Skills.DEFENCE) < defenceReq ? (" and a Defence level of " + defenceReq) : "") + " to use " + StringUtils.formatDisplayName(name().toLowerCase().replace("_", " ")) + "."); return false; } @@ -240,7 +240,7 @@ public enum PrayerType { flag(player, this); player.getPrayer().getActive().add(this); iconify(player, getIcon(player, this)); - player.getAudioManager().send(getSound()); + playAudio(player, sound.id); if (this == PrayerType.PIETY && new ZoneBorders(2732, 3467, 2739, 3471, 0).insideBorder(player)) { @@ -249,7 +249,7 @@ public enum PrayerType { player.dispatch (new PrayerActivatedEvent(this)); } else { player.getPrayer().getActive().remove(this); - player.getAudioManager().send(Sounds.CANCEL_PRAYER_2663); + playAudio(player, Sounds.CANCEL_PRAYER_2663); findNextIcon(player); player.dispatch (new PrayerDeactivatedEvent(this)); } diff --git a/Server/src/main/core/game/node/entity/player/link/request/assist/AssistSession.java b/Server/src/main/core/game/node/entity/player/link/request/assist/AssistSession.java index b35cb1013..bf82b6548 100644 --- a/Server/src/main/core/game/node/entity/player/link/request/assist/AssistSession.java +++ b/Server/src/main/core/game/node/entity/player/link/request/assist/AssistSession.java @@ -154,8 +154,8 @@ public final class AssistSession extends Pulse implements RequestModule { player.animate(ANIMATION); player.graphics(GRAPHIC); partener.animate(ANIMATION); - partener.getAudioManager().send(4010); - player.getAudioManager().send(4010); + playAudio(partener, 4010); + playAudio(player, 4010); toggleIcon(player, false); toggleIcon(partener, false); GameWorld.getPulser().submit(this); diff --git a/Server/src/main/core/game/node/entity/skill/Skills.java b/Server/src/main/core/game/node/entity/skill/Skills.java index bb0cc7d27..88d56aac9 100644 --- a/Server/src/main/core/game/node/entity/skill/Skills.java +++ b/Server/src/main/core/game/node/entity/skill/Skills.java @@ -22,11 +22,13 @@ import core.game.world.GameWorld; import core.game.world.repository.Repository; import core.plugin.CorePluginTypes.XPGainPlugins; import org.rs09.consts.Items; +import org.rs09.consts.Sounds; import java.nio.ByteBuffer; import java.util.ArrayList; import static core.api.ContentAPIKt.getWorldTicks; +import static core.api.ContentAPIKt.playAudio; import static java.lang.Math.floor; import static java.lang.Math.max; @@ -362,7 +364,7 @@ public final class Skills { setLevel(i, staticLevel); } if (entity instanceof Player) { - entity.asPlayer().getAudioManager().send(2674); + playAudio(entity.asPlayer(), Sounds.PRAYER_RECHARGE_2674); } rechargePrayerPoints(); } diff --git a/Server/src/main/core/game/system/command/oldsys/VisualCommand.kt b/Server/src/main/core/game/system/command/oldsys/VisualCommand.kt index 458ac38e1..adaf066ad 100644 --- a/Server/src/main/core/game/system/command/oldsys/VisualCommand.kt +++ b/Server/src/main/core/game/system/command/oldsys/VisualCommand.kt @@ -416,10 +416,6 @@ class VisualCommand : CommandPlugin() { player!!.impactHandler.manualHit(player, toInteger(args!![1]!!), HitsplatType.NORMAL) return true } - "sound" -> { - player!!.audioManager.send(Audio(args!![1]!!.toInt(), 10, 1)) - return true - } "noclip" -> { player!!.setAttribute("no_clip", !player.getAttribute("no_clip", false)) return true diff --git a/Server/src/main/core/game/system/command/sets/MusicCommandSet.kt b/Server/src/main/core/game/system/command/sets/AudioCommandSet.kt similarity index 60% rename from Server/src/main/core/game/system/command/sets/MusicCommandSet.kt rename to Server/src/main/core/game/system/command/sets/AudioCommandSet.kt index def057ecb..ac8ee0324 100644 --- a/Server/src/main/core/game/system/command/sets/MusicCommandSet.kt +++ b/Server/src/main/core/game/system/command/sets/AudioCommandSet.kt @@ -1,7 +1,11 @@ package core.game.system.command.sets +import core.api.playAudio +import core.api.playGlobalAudio import core.game.node.entity.player.link.music.MusicEntry import core.game.system.command.Privilege +import core.game.world.map.Location +import core.game.world.repository.Repository import core.net.packet.PacketRepository import core.net.packet.context.MusicContext import core.net.packet.out.MusicPacket @@ -64,5 +68,32 @@ class MusicCommandSet : CommandSet(Privilege.STANDARD){ player.musicPlayer.unlock(me.id) } } + /** + * Command that lets you play an audio id + */ + define("audio", Privilege.ADMIN, "::audio id loops[optional]", "Plays audio by id") { player, args -> + if (args.size < 2 || args.size > 3) + reject(player, "Usage: ::audio id loops[optional]") + val id = args[1].toInt() + val loops = if (args.size > 2) args[2].toInt() else 1 + playAudio(player, id, 0, loops) + } + /** + * Command that lets you play an audio id globally by playername or coords + */ + define("globalaudio", Privilege.ADMIN, "::globalaudio id radius[max 15] location[player name or x y z]", "Play global audio by id, radius, and location") { player, args -> + if (args.size < 3) + reject(player, "Usage: ::globalaudio id radius[max 15] location[player name or x y z]") + val loc = when (args.size) { + 6 -> Location(args[3].toInt(),args[4].toInt(),args[5].toInt()) + 4 -> Repository.getPlayerByName(args[3])?.location + else -> null + } + if (loc == null) + reject(player, "Invalid player name / location") + val id = args[1].toInt() + val radius = if (args[2].toInt() > 15) 15 else args[2].toInt() + if (loc != null) playGlobalAudio(loc, id, 0, 1, radius) + } } } diff --git a/Server/src/main/core/net/packet/out/AudioPacket.java b/Server/src/main/core/net/packet/out/AudioPacket.java index e2520910a..beb04da91 100644 --- a/Server/src/main/core/net/packet/out/AudioPacket.java +++ b/Server/src/main/core/net/packet/out/AudioPacket.java @@ -15,15 +15,15 @@ public class AudioPacket implements OutgoingPacket { public static IoBuffer write(IoBuffer buffer, Audio audio, Location loc) { if(loc == null) { buffer.put((byte) 172); - buffer.putShort(audio.getId()); - buffer.put((byte) audio.getVolume()); - buffer.putShort(audio.getDelay()); + buffer.putShort(audio.id); + buffer.put((byte) audio.loops); + buffer.putShort(audio.delay); } else { buffer.put((byte) 97); buffer.put((byte) (loc.getChunkOffsetX() << 4 | loc.getChunkOffsetY())); - buffer.putShort(audio.getId()); - buffer.put((byte) (audio.getRadius() << 4 | audio.getVolume() & 7)); - buffer.put((byte) audio.getDelay()); + buffer.putShort(audio.id); + buffer.put((byte) (audio.radius << 4 | audio.loops & 7)); + buffer.put((byte) audio.delay); } return buffer; }