[TF2] Soundscape Fixer (1.3.0 06/01/2015)
I got bored of waiting and made this recently. It seems to be working well on the server I admin so I am releasing it to everyone.
Description
A plugin to get most soundscapes working while valve sort out the ongoing issues.
It plays the appropriate soundscape to players based on their position, taking into account the radius and visibility of nearby soundscapes.
Features
- Bring the life back to custom maps!
- Full support for playlooping/playrandom env_soundscape, env_soundscape_proxy and env_soundscape_triggerable entities
- Respects volume and pitch values defined in the map's script file
- /scvolume and /scpitch commands for changing the volume and pitch of soundscapes
- One line per map configuration*
- *90% of the time - see unsupported things
- Small API for more complex maps that dynamically enable/disable soundscapes (e.g clocktown)
Unsupported things
- playsoundscape sounds are ignored
- dsp, soundlevel are ignored
- Positional soundscapes will play from the player
- No crossfading between soundscapes
- Dynamic enabling/disabling of soundscapes is not detected. Custom code is needed to hook the entities that are enabling/disabling soundscapes on a per map basis.
Installation
- Copy soundscapes.smx to plugins
- Copy soundscapes-clocktown.smx to plugins if you have clocktown on your map rotation
- Copy soundscapes_config.txt to configs and update for your map rotation (see below)
- Copy soundscapes.inc to scripting/includes if you want to make a plugin that uses the natives
- Load a new map
- Enjoy the music
Configuration
In order to work, soundscape fixer just needs to know where each maps soundscape script lives. It will default to scripts/soundscapes_[map name].txt if no script is specified, which should work for most maps.
If this does not work, you can find the name of the file by opening the .bsp file with Pakrat and checking the scripts folder, or by asking the map creator.
The config file is expected to be located at "configs/soundscapes_config.txt" and take the following form:
Code:
"Soundscapes"
{
"map name" "script location"
"map name2" "script location2"
... etc
}
An example file is attached which contains the locations of the scripts of several maps.
Tested Maps
The plugin should work fully in the following maps:
- trade_clocktown_b2a
- trade_hyrule_oot3d_alpha_6
- trade_franticfactory_v3p
- rusty_bucket_bay
- dm_mariokart3_v1
- dm_mariokart2_b3
- trade_windfallisland_final
Commands
sm_volume - changes volume of soundscapes that are played (0 - 1)
sm_scvolume - alias of sm_volume
sm_scpitch - changes pitch of soundscapes that are played (1 - 255. 100 is "normal" pitch. 0 resets pitch to script specified values)
API
As far as i am aware there are no outputs for when soundscapes are enabled or disabled, meaning there is nothing for this plugin to hook to determine whether a soundscape should be played.
To work around this, the plugin includes a few natives that allow soundscapes to be enabled and disabled using their name or entity id. This can fix maps with dynamic soundscapes by hooking the outputs of entities that are enabling/disabling soundscapes and calling the appropriate native to tell the plugin about the soundscapes new state.
Their documentation can be found in the inc file.
For enabling/disabling soundscapes on map load, there is also a OnSoundscapesLoaded() forward, which is called after the maps soundscapes have been found.
An example plugin that fixes the dynamic day soundscapes in clocktown (trade_clocktown_b2a) is attached.
Problems?
Feel free to ask if you have any problems. This is my first released plugin, and I would like to support it for as long soundscapes are broken.
Changelog
v 1.3.0 - 06/01/2014
- Added clientpreferences support for /scpitch and /scvolume
- Changed raytrace to filter out prop_dynamic entities
- Fixes soundscapes being blocked in certain situations, such as in the clocktown clocktower if you spawn behind the pole in the center of the room.
v 1.2.4 - 26/12/2014
- Changed /scpitch to accept values between 1-255 (same as the "pitch" keyvalue).
- All soundscapes will play with the specified pitch, ignoring any script specified values
- 100 is "normal" pitch
- /scpitch 0 will reset the pitch to the script specified value
- Fixed incorrect soundscapes playing when reloading the plugin without a map change
- Clocktown will still need a reload due to the dynamic nature of the day soundscapes, and it being difficult to work out what "day" it is when a plugin is late loaded.
v 1.2.3 - 24/12/2014
- Feature request: Added /scpitch command to control pitch of played soundscape. Didn't use /pitch to avoid possible collisions.
- Added /scvolume command to be consistent with /scpitch
v 1.2.2 - 14/12/2014
- Removed /closest debug command
v 1.2.1 - 14/12/2014
- Plugin now attempts to load scripts/soundscapes_[map name].txt by default if no script is specified in the config
- Fixed error spam when a client disconnects while within range of a playrandom soundscape
- Fixed soundscapes not updating when spectating another player
- Changed raytrace to not collide with other players
- Should fix soundscapes not updating when entering crowded areas
- Changed sounds to play on SNDCHAN_STATIC from SNDCHAN_AUTO
- Hopefully this will fix sounds overlapping for some people. I've been unable to reproduce this myself so not sure.
v 1.2.0 - 12/12/2014
- Added support for playrandom sounds
- Added support for multiple sounds per soundscape
- Fixed soundscapes not playing before the first round starts after a map change
- Fixed some situations where soundscape entities were not disabled and continued playing
- Updated the clocktown plugin to wait for the daystart sound to finish before playing day soundscapes
v 1.1.5 - 10/12/2014
- Initial forum release
- Added /volume command
- Replaced hardcoded soundscapes with script file parsing
- Added support for playlooping sounds with volume and pitch
v 1.0 - 8/12/2014