Skip to content

Commit

Permalink
Bark->Blooper
Browse files Browse the repository at this point in the history
  • Loading branch information
RashCat committed Oct 11, 2023
1 parent fa0aa4b commit 130ffb9
Show file tree
Hide file tree
Showing 80 changed files with 280 additions and 280 deletions.
8 changes: 4 additions & 4 deletions code/__DEFINES/~ff_defines/DNA.dm
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#define SPECIES_NABBER "nabber"
#define SPECIES_TESHARI_ALT "teshari_alt"
// Blooper defines
#define DNA_BARK_SOUND_BLOCK 16
#define DNA_BARK_SPEED_BLOCK 17
#define DNA_BARK_PITCH_BLOCK 18
#define DNA_BARK_VARIANCE_BLOCK 19
#define DNA_BLOOPER_SOUND_BLOCK 16
#define DNA_BLOOPER_SPEED_BLOCK 17
#define DNA_BLOOPER_PITCH_BLOCK 18
#define DNA_BLOOPER_VARIANCE_BLOCK 19
// Blooper defines
4 changes: 2 additions & 2 deletions code/__DEFINES/~ff_defines/__HELPERS/global_lists.dm
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
GLOBAL_LIST_EMPTY(bark_list)
GLOBAL_LIST_EMPTY(bark_random_list)
GLOBAL_LIST_EMPTY(blooper_list)
GLOBAL_LIST_EMPTY(blooper_random_list)
2 changes: 1 addition & 1 deletion code/__DEFINES/~ff_defines/dcs/signals.dm
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define COMSIG_MOVABLE_QUEUE_BARK "movable_queue_bark" //from base of atom/movable/proc/send_speech(): (list/hearers, message, range, atom/movable/source, bubble_type, list/spans, datum/language/message_language, message_mode)
#define COMSIG_MOVABLE_QUEUE_BLOOPER "movable_queue_blooper" //from base of atom/movable/proc/send_speech(): (list/hearers, message, range, atom/movable/source, bubble_type, list/spans, datum/language/message_language, message_mode)
28 changes: 14 additions & 14 deletions code/__DEFINES/~ff_defines/say.dm
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
//Bark defines
#define BARK_DEFAULT_MINPITCH 0.4
#define BARK_DEFAULT_MAXPITCH 2
#define BARK_DEFAULT_MINVARY 0.1
#define BARK_DEFAULT_MAXVARY 0.8
#define BARK_DEFAULT_MINSPEED 2
#define BARK_DEFAULT_MAXSPEED 16
//BLOOPER defines
#define BLOOPER_DEFAULT_MINPITCH 0.4
#define BLOOPER_DEFAULT_MAXPITCH 2
#define BLOOPER_DEFAULT_MINVARY 0.1
#define BLOOPER_DEFAULT_MAXVARY 0.8
#define BLOOPER_DEFAULT_MINSPEED 2
#define BLOOPER_DEFAULT_MAXSPEED 16

#define BARK_SPEED_BASELINE 4 //Used to calculate delay between barks, any bark speeds below this feature higher bark density, any speeds above feature lower bark density. Keeps barking length consistent
#define BLOOPER_SPEED_BASELINE 4 //Used to calculate delay between BLOOPERs, any BLOOPER speeds below this feature higher BLOOPER density, any speeds above feature lower BLOOPER density. Keeps BLOOPERing length consistent

#define BARK_MAX_BARKS 24
#define BARK_MAX_TIME (1.5 SECONDS) // More or less the amount of time the above takes to process through with a bark speed of 2.
#define BLOOPER_MAX_BLOOPERS 24
#define BLOOPER_MAX_TIME (1.5 SECONDS) // More or less the amount of time the above takes to process through with a BLOOPER speed of 2.

#define BARK_PITCH_RAND(gend) ((gend == MALE ? rand(60, 120) : (gend == FEMALE ? rand(80, 140) : rand(60,140))) / 100) //Macro for determining random pitch based off gender
#define BARK_VARIANCE_RAND (rand(BARK_DEFAULT_MINVARY * 100, BARK_DEFAULT_MAXVARY * 100) / 100) //Macro for randomizing bark variance to reduce the amount of copy-pasta necessary for that
#define BLOOPER_PITCH_RAND(gend) ((gend == MALE ? rand(60, 120) : (gend == FEMALE ? rand(80, 140) : rand(60,140))) / 100) //Macro for determining random pitch based off gender
#define BLOOPER_VARIANCE_RAND (rand(BLOOPER_DEFAULT_MINVARY * 100, BLOOPER_DEFAULT_MAXVARY * 100) / 100) //Macro for randomizing BLOOPER variance to reduce the amount of copy-pasta necessary for that

#define BARK_DO_VARY(pitch, variance) (rand(((pitch * 100) - (variance*50)), ((pitch*100) + (variance*50))) / 100)
#define BLOOPER_DO_VARY(pitch, variance) (rand(((pitch * 100) - (variance*50)), ((pitch*100) + (variance*50))) / 100)

#define BARK_SOUND_FALLOFF_EXPONENT 0.5 //At lower ranges, we want the exponent to be below 1 so that whispers don't sound too awkward. At higher ranges, we want the exponent fairly high to make yelling less obnoxious
#define BLOOPER_SOUND_FALLOFF_EXPONENT 0.5 //At lower ranges, we want the exponent to be below 1 so that whispers don't sound too awkward. At higher ranges, we want the exponent fairly high to make yelling less obnoxious
8 changes: 4 additions & 4 deletions code/__HELPERS/global_lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@
//SKYRAT EDIT END

//THE FLUFFY FRONTIER EDIT ADDITION BEGIN - Blooper
for(var/sound_bark_path in subtypesof(/datum/bark))
var/datum/bark/B = new sound_bark_path()
GLOB.bark_list[B.id] = sound_bark_path
for(var/sound_blooper_path in subtypesof(/datum/blooper))
var/datum/blooper/B = new sound_blooper_path()
GLOB.blooper_list[B.id] = sound_blooper_path
if(B.allow_random)
GLOB.bark_random_list[B.id] = sound_bark_path
GLOB.blooper_random_list[B.id] = sound_blooper_path
//THE FLUFFY FRONTIER EDIT END

/// Inits GLOB.species_list. Not using GLOBAL_LIST_INIT b/c it depends on GLOB.string_lists
Expand Down
4 changes: 2 additions & 2 deletions code/game/atoms_movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -477,9 +477,9 @@
set_glide_size(var_value)
. = TRUE
// THE FLUFFY FRONTIER EDIT ADDITION BEGIN - BLOOPER
if(NAMEOF(src, vocal_bark)) // Sorry, Vishenka.
if(NAMEOF(src, blooper)) // Sorry, Vishenka.
if(isfile(var_value))
vocal_bark = sound(var_value) //bark() expects vocal_bark to already be a sound datum, for performance reasons. adminbus QoL!
blooper = sound(var_value) //bark() expects vocal_bark to already be a sound datum, for performance reasons. adminbus QoL!
. = TRUE
// THE FLUFFY FRONTIER EDIT ADDITION END

Expand Down
82 changes: 41 additions & 41 deletions tff_modular/modules/blooper/atoms_movable.dm
Original file line number Diff line number Diff line change
@@ -1,84 +1,84 @@
/atom/movable
// Text-to-bark sounds
// Text-to-blooper sounds
// Да. У нас все атом могут иметь звучение для say.
var/sound/vocal_bark
var/vocal_bark_id
var/vocal_pitch = 1
var/vocal_pitch_range = 0.2 //Actual pitch is (pitch - (vocal_pitch_range*0.5)) to (pitch + (vocal_pitch_range*0.5))
var/vocal_volume = 70
var/vocal_speed = 4 //Lower values are faster, higher values are slower
var/vocal_current_bark //When barks are queued, this gets passed to the bark proc. If vocal_current_bark doesn't match the args passed to the bark proc (if passed at all), then the bark simply doesn't play. Basic curtailing of spam~
var/sound/blooper
var/blooper_id
var/blooper_pitch = 1
var/blooper_pitch_range = 0.2 //Actual pitch is (pitch - (blooper_pitch_range*0.5)) to (pitch + (blooper_pitch_range*0.5))
var/blooper_volume = 70
var/blooper_speed = 4 //Lower values are faster, higher values are slower
var/blooper_current_blooper //When bloopers are queued, this gets passed to the blooper proc. If blooper_current_blooper doesn't match the args passed to the blooper proc (if passed at all), then the blooper simply doesn't play. Basic curtailing of spam~

/atom/movable/proc/set_bark(id)
/atom/movable/proc/set_blooper(id)
if(!id)
return FALSE
var/datum/bark/B = GLOB.bark_list[id]
var/datum/blooper/B = GLOB.blooper_list[id]
if(!B)
return FALSE
vocal_bark = sound(initial(B.soundpath))
vocal_bark_id = id
return vocal_bark
blooper = sound(initial(B.soundpath))
blooper_id = id
return blooper

/atom/movable/proc/bark(list/listeners, distance, volume, pitch, queue_time)
/atom/movable/proc/blooper(list/listeners, distance, volume, pitch, queue_time)
if(!GLOB.blooper_allowed)
return
if(queue_time && vocal_current_bark != queue_time)
if(queue_time && blooper_current_blooper != queue_time)
return
if(!vocal_bark)
if(!vocal_bark_id || !set_bark(vocal_bark_id)) //just-in-time bark generation
if(!blooper)
if(!blooper_id || !set_blooper(blooper_id)) //just-in-time blooper generation
return
volume = min(volume, 100)
var/turf/T = get_turf(src)
for(var/mob/M in listeners)
M.playsound_local(T, vol = volume, vary = TRUE, frequency = pitch, max_distance = distance, falloff_distance = 0, falloff_exponent = BARK_SOUND_FALLOFF_EXPONENT, sound_to_use = vocal_bark, distance_multiplier = 1)
M.playsound_local(T, vol = volume, vary = TRUE, frequency = pitch, max_distance = distance, falloff_distance = 0, falloff_exponent = BLOOPER_SOUND_FALLOFF_EXPONENT, sound_to_use = blooper, distance_multiplier = 1)

/atom/movable/send_speech(message, range = 7, obj/source = src, bubble_type, list/spans, datum/language/message_language, list/message_mods = list(), forced = FALSE, tts_message, list/tts_filter)
. = ..()
var/list/listeners = get_hearers_in_view(range, source)
if(SEND_SIGNAL(src, COMSIG_MOVABLE_QUEUE_BARK, listeners, args) || vocal_bark || vocal_bark_id)
if(SEND_SIGNAL(src, COMSIG_MOVABLE_QUEUE_BLOOPER, listeners, args) || blooper || blooper_id)
for(var/mob/M in listeners)
if(!M.client)
continue
if(!(M.client?.prefs.read_preference(/datum/preference/toggle/hear_sound_bark)))
if(!(M.client?.prefs.read_preference(/datum/preference/toggle/hear_sound_blooper)))
listeners -= M
var/barks = min(round((LAZYLEN(message) / vocal_speed)) + 1, BARK_MAX_BARKS)
var/bloopers = min(round((LAZYLEN(message) / blooper_speed)) + 1, BLOOPER_MAX_BLOOPERS)
var/total_delay
vocal_current_bark = world.time //this is juuuuust random enough to reliably be unique every time send_speech() is called, in most scenarios
for(var/i in 1 to barks)
if(total_delay > BARK_MAX_TIME)
blooper_current_blooper = world.time //this is juuuuust random enough to reliably be unique every time send_speech() is called, in most scenarios
for(var/i in 1 to bloopers)
if(total_delay > BLOOPER_MAX_TIME)
break
addtimer(CALLBACK(src, PROC_REF(bark), listeners, range, vocal_volume, BARK_DO_VARY(vocal_pitch, vocal_pitch_range), vocal_current_bark), total_delay)
total_delay += rand(DS2TICKS(vocal_speed / BARK_SPEED_BASELINE), DS2TICKS(vocal_speed / BARK_SPEED_BASELINE) + DS2TICKS(vocal_speed / BARK_SPEED_BASELINE)) TICKS
addtimer(CALLBACK(src, PROC_REF(blooper), listeners, range, blooper_volume, BLOOPER_DO_VARY(blooper_pitch, blooper_pitch_range), blooper_current_blooper), total_delay)
total_delay += rand(DS2TICKS(blooper_speed / BLOOPER_SPEED_BASELINE), DS2TICKS(blooper_speed / BLOOPER_SPEED_BASELINE) + DS2TICKS(blooper_speed / BLOOPER_SPEED_BASELINE)) TICKS

/randomize_human(mob/living/carbon/human/human)
. = ..()
human.set_bark(pick(GLOB.bark_random_list))
human.vocal_pitch = BARK_PITCH_RAND(human.gender)
human.vocal_pitch_range = BARK_VARIANCE_RAND
human.set_blooper(pick(GLOB.blooper_random_list))
human.blooper_pitch = BLOOPER_PITCH_RAND(human.gender)
human.blooper_pitch_range = BLOOPER_VARIANCE_RAND

/mob/living/send_speech(message_raw, message_range = 6, obj/source = src, bubble_type = bubble_icon, list/spans, datum/language/message_language = null, list/message_mods = list(), forced = null, tts_message, list/tts_filter)
. = ..()
if(client)
if(!(client?.prefs.read_preference(/datum/preference/toggle/send_sound_bark)))
if(!(client?.prefs.read_preference(/datum/preference/toggle/send_sound_blooper)))
return
vocal_volume = 55
blooper_volume = 55
if(message_mods[WHISPER_MODE])
vocal_volume = 25
blooper_volume = 25
message_range++
var/list/listening = get_hearers_in_view(message_range, source)
var/is_yell = (say_test(message_raw) == "2")
//Listening gets trimmed here if a vocal bark's present. If anyone ever makes this proc return listening, make sure to instead initialize a copy of listening in here to avoid wonkiness
if(SEND_SIGNAL(src, COMSIG_MOVABLE_QUEUE_BARK, listening, args) || vocal_bark || vocal_bark_id)
//Listening gets trimmed here if a blooper blooper's present. If anyone ever makes this proc return listening, make sure to instead initialize a copy of listening in here to avoid wonkiness
if(SEND_SIGNAL(src, COMSIG_MOVABLE_QUEUE_BLOOPER, listening, args) || blooper || blooper_id)
for(var/mob/M in listening)
if(!M.client)
continue
if(!(M.client?.prefs.read_preference(/datum/preference/toggle/hear_sound_bark)))
if(!(M.client?.prefs.read_preference(/datum/preference/toggle/hear_sound_blooper)))
listening -= M
var/barks = min(round((LAZYLEN(message_raw) / vocal_speed)) + 1, BARK_MAX_BARKS)
var/bloopers = min(round((LAZYLEN(message_raw) / blooper_speed)) + 1, BLOOPER_MAX_BLOOPERS)
var/total_delay
vocal_current_bark = world.time
for(var/i in 1 to barks)
if(total_delay > BARK_MAX_TIME)
blooper_current_blooper = world.time
for(var/i in 1 to bloopers)
if(total_delay > BLOOPER_MAX_TIME)
break
addtimer(CALLBACK(src, TYPE_PROC_REF(/atom/movable, bark), listening, message_range + 1, (vocal_volume * (is_yell ? 2 : 1)), BARK_DO_VARY(vocal_pitch, vocal_pitch_range), vocal_current_bark), total_delay) //На седьмом тайле функция равна нулю, поэтому мы обязаны ставить максимум на 1 тайл дальше.
total_delay += rand(DS2TICKS(vocal_speed / BARK_SPEED_BASELINE), DS2TICKS(vocal_speed / BARK_SPEED_BASELINE) + DS2TICKS((vocal_speed / BARK_SPEED_BASELINE) * (is_yell ? 0.5 : 1))) TICKS
addtimer(CALLBACK(src, TYPE_PROC_REF(/atom/movable, blooper), listening, message_range + 1, (blooper_volume * (is_yell ? 2 : 1)), BLOOPER_DO_VARY(blooper_pitch, blooper_pitch_range), blooper_current_blooper), total_delay) //На седьмом тайле функция равна нулю, поэтому мы обязаны ставить максимум на 1 тайл дальше.
total_delay += rand(DS2TICKS(blooper_speed / BLOOPER_SPEED_BASELINE), DS2TICKS(blooper_speed / BLOOPER_SPEED_BASELINE) + DS2TICKS((blooper_speed / BLOOPER_SPEED_BASELINE) * (is_yell ? 0.5 : 1))) TICKS
Loading

0 comments on commit 130ffb9

Please sign in to comment.