Adds Repeating Ambience and Ambience Chance Preferences!

Adds a Random Ambience Frequency and Ambience Chance Setting under Global, underneath Client FPS. Images here:

![](https://i.imgur.com/381HPGH.png)
![](https://i.imgur.com/tWuff1W.png)
![](https://i.imgur.com/smEtoQ9.png)

Self-explanatory. Random-Ambience-Frequency controls how long before it checks if it can play ambience to you again. Setting it to 0 disables the random re-play of ambience.

Ambience Chance affects the % chance to play ambience to your client. It defaults to 35%, but can be set from 0 to 100 to disable it or always play every time you move into an area or have the Random Ambience check called.
This commit is contained in:
Rykka
2020-08-13 01:40:23 -04:00
parent e4b5b8ea2d
commit 9690f85ec3
4 changed files with 39 additions and 13 deletions

View File

@@ -46,7 +46,7 @@
//Check if we're on fire
handle_fire()
if(client) // Handle re-running ambience to mobs if they've remained in an area, AND have an active client assigned to them.
if(client && !(client.prefs.ambience_freq == 0)) // Handle re-running ambience to mobs if they've remained in an area, AND have an active client assigned to them, and do not have repeating ambience disabled.
handle_ambience()
//stuff in the stomach
@@ -92,10 +92,11 @@
/mob/living/proc/handle_stomach()
return
/mob/living/proc/handle_ambience() // If you're in an ambient area and have not moved out of it for x time, we're going to play ambience again to you, to help break up the silence.
if(world.time >= (lastareachange + 30 SECONDS)) // Every 30 seconds, we're going to run a 35% chance to play ambience.
/mob/living/proc/handle_ambience() // If you're in an ambient area and have not moved out of it for x time as configured per-client, and do not have it disabled, we're going to play ambience again to you, to help break up the silence.
if(world.time >= (lastareachange + client.prefs.ambience_freq MINUTES)) // Every 5 minutes (by default, set per-client), we're going to run a 35% chance (by default, also set per-client) to play ambience.
var/area/A = get_area(src)
if(A)
lastareachange = world.time // This will refresh the last area change to prevent this call happening LITERALLY every life tick.
A.play_ambience(src, initial = FALSE)
/mob/living/proc/update_pulling()