More sounds + audio refactoring
Modified default audio radius default parameter to be safer, 8 tiles instead of 15 Improved location/direction based sounds Fixed the way sounds are handled for magic spells (All modern and ancient combat spells. All lunar teleport spells.) Magic spells now correctly fade in volume the further away you are from a target/player casting or being hit by a spell. The sound starts to fade after a few tiles until it cant be heard anymore Refactored lunar teleport sounds to use playGlobalAudio Humidfy now can be heard globally by other players Fixed Lunar fertile soil spell graphics and animation to be authentic Weapon attack sounds now start to fade after a few tiles until it cant be heard anymore NPC attack sound now fades with distance NPC hurt sound now fades with distance NPC death sound now fades with distance Fixed combat punching sound when no weapon is equipped so it can be heard globally Fixed a issue where you would hear a punching sound when casting any combat spell Fixed male player hurt sounds when in combat Implemented female player hurt sounds when in combat Failing agility obstacles will now play the correct hurt sound based on gender Fixed low wall agility pyramid sound Fixed taking damage from dying of thirst in the desert to use correct sounds Fixed the sound of drinking from a waterskin in the desert Implemented sound when attaching godsword blades to a hilt Fixed rune essence mine teleport sound so it no longer loops 10 times and plays authentically Implemented undead tree attack sound at Draynor manor Implemented all ectofunctus bone grinder sounds and the sound when offering to the ectofunctus Implemented mort myre ghast attack and player hurt sounds Fixed thieving pickpocket fail sounds Implemented falador guards combat sounds Implemented varrock guards combat sounds Implemented draynor market guard combat sounds Implemented cyclops combat sounds (warriors guild cyclops) Implemented animated armor combat sounds (all warriors guild animated armors) Implemented white wolf/big wolf/wolf combat sounds (wolves on white wolf mountain)
This commit is contained in:
@@ -76,6 +76,9 @@ import core.net.packet.out.MusicPacket
|
||||
import core.game.system.timer.*
|
||||
import core.game.system.timer.impl.*
|
||||
import core.game.node.entity.combat.CombatSwingHandler
|
||||
import core.net.packet.context.DefaultContext
|
||||
import core.net.packet.out.AudioPacket
|
||||
import org.rs09.consts.Sounds
|
||||
import java.util.regex.*
|
||||
import java.io.*
|
||||
import kotlin.math.*
|
||||
@@ -576,6 +579,7 @@ fun playJingle(player: Player, jingleId: Int) {
|
||||
*/
|
||||
fun impact(entity: Entity, amount: Int, type: ImpactHandler.HitsplatType = ImpactHandler.HitsplatType.NORMAL) {
|
||||
entity.impactHandler.manualHit(entity, amount, type)
|
||||
if (entity is Player) playHurtAudio(entity)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -822,18 +826,56 @@ fun playAudio(player: Player, audio: Audio, global: Boolean = false) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Plays the given Audio for the given Entity
|
||||
* @param player the player to play the audio for
|
||||
* @param audio the audio to play
|
||||
* @param volume the volume
|
||||
* @param delay the delay
|
||||
* @param global if other nearby entities should be able to hear it
|
||||
* @param location the location where the audio will play
|
||||
* @param radius the distance the audio can be heard from the given location
|
||||
* Plays audio for the player
|
||||
* @param player the player to play the defined audio for
|
||||
* @param audio the audio id to play
|
||||
* @param volume the volume for the audio (for some audio ids it is used to define how many times to play/loop the audio)
|
||||
* @param delay the delay in client cycles (50 cycles = 1 second)
|
||||
* @param global if other nearby players should be able to hear the audio
|
||||
* @param location the location where the audio will play from (if a location is defined 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, volume: Int = 10, delay: Int = 0, global: Boolean = false, location: Location? = null, radius: Int = 15) {
|
||||
player.audioManager.send(audio, volume, delay, global, location, radius)
|
||||
fun playAudio(player: Player, audio: Int, volume: Int = 10, delay: Int = 0, global: Boolean = false, location: Location? = null, radius: Int = 8) {
|
||||
if (global) {
|
||||
val nearbyPlayers = RegionManager.getLocalPlayers(location ?: player.location, radius)
|
||||
for ( player in nearbyPlayers ) {
|
||||
PacketRepository.send(AudioPacket::class.java, DefaultContext(player, Audio(audio, volume, delay, radius), location))
|
||||
}
|
||||
} else {
|
||||
PacketRepository.send(AudioPacket::class.java, DefaultContext(player, Audio(audio, volume, delay, 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 volume the volume for the audio (for some audio ids it is used to define how many times to play/loop the audio)
|
||||
* @param delay the delay in client cycles (50 cycles = 1 second)
|
||||
* @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, volume: Int = 10, delay: Int = 0, radius: Int = 8) {
|
||||
val nearbyPlayers = RegionManager.getLocalPlayers(location, radius)
|
||||
for (player in nearbyPlayers) {
|
||||
PacketRepository.send(AudioPacket::class.java, DefaultContext(player, Audio(audio, volume, delay, radius), location))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Plays a random hurt audio for the player based on gender
|
||||
* @param player the player to play hurt audio for
|
||||
* @param delay the delay in client cycles (50 cycles = 1 second)
|
||||
*/
|
||||
fun playHurtAudio(player: Player, delay: Int = 0) {
|
||||
val maleHurtAudio = intArrayOf(Sounds.HUMAN_HIT4_516, Sounds.HUMAN_HIT5_517, Sounds.HUMAN_HIT_518, Sounds.HUMAN_HIT_6_522)
|
||||
val femaleHurtAudio = intArrayOf(Sounds.FEMALE_HIT_506, Sounds.FEMALE_HIT_507, Sounds.FEMALE_HIT2_508, Sounds.FEMALE_HIT_2_510)
|
||||
if (player.isMale) {
|
||||
playAudio(player, maleHurtAudio.random(), 10, delay)
|
||||
} else {
|
||||
playAudio(player, femaleHurtAudio.random(), 10, delay)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user