vocal barks - Fully customizable noises for talking!

This commit is contained in:
deathride58
2022-06-09 03:59:17 -04:00
parent 2cf0fbea9a
commit 2a720ce054
16 changed files with 320 additions and 16 deletions
+79 -3
View File
@@ -140,6 +140,13 @@ GLOBAL_LIST_EMPTY(preferences_datums)
var/modified_limbs = list() //prosthetic/amputated limbs
var/chosen_limb_id //body sprite selected to load for the users limbs, null means default, is sanitized when loaded
// Vocal bark prefs
var/bark_id = "mutedc3"
var/bark_speed = 4
var/bark_pitch = 1
var/bark_variance = 0.2
COOLDOWN_DECLARE(bark_previewing)
/// Security record note section
var/security_records
/// Medical record note section
@@ -795,11 +802,21 @@ GLOBAL_LIST_EMPTY(preferences_datums)
dat += "<table><tr><td width='340px' height='300px' valign='top'>"
dat += "<h2>Speech preferences</h2>"
dat += "<b>Custom Speech Verb:</b><BR>"
dat += "</b><a style='display:block;width:100px' href='?_src_=prefs;preference=speech_verb;task=input'>[custom_speech_verb]</a><BR>"
dat += "<a style='display:block;width:100px' href='?_src_=prefs;preference=speech_verb;task=input'>[custom_speech_verb]</a><BR>"
dat += "<b>Custom Tongue:</b><BR>"
dat += "</b><a style='display:block;width:100px' href='?_src_=prefs;preference=tongue;task=input'>[custom_tongue]</a><BR>"
dat += "<a style='display:block;width:100px' href='?_src_=prefs;preference=tongue;task=input'>[custom_tongue]</a><BR>"
dat += "<b>Additional Language</b><BR>"
dat += "</b><a style='display:block;width:100px' href='?_src_=prefs;preference=language;task=input'>[additional_language]</a><BR>"
dat += "<a style='display:block;width:100px' href='?_src_=prefs;preference=language;task=input'>[additional_language]</a><BR>"
dat += "</td>"
dat += "<td width='340px' height='300px' valign='top'>"
dat += "<h2>Vocal Bark preferences</h2>"
var/datum/bark/B = GLOB.bark_list[bark_id]
dat += "<b>Vocal Bark Sound:</b><BR>"
dat += "<a style='display:block;width:200px' href='?_src_=prefs;preference=barksound;task=input'>[B ? initial(B.name) : "INVALID"]</a><BR>"
dat += "<b>Vocal Bark Speed:</b> <a href='?_src_=prefs;preference=barkspeed;task=input'>[bark_speed]</a><BR>"
dat += "<b>Vocal Bark Pitch:</b> <a href='?_src_=prefs;preference=barkpitch;task=input'>[bark_pitch]</a><BR>"
dat += "<b>Vocal Bark Variance:</b> <a href='?_src_=prefs;preference=barkvary;task=input'>[bark_variance]</a><BR>"
dat += "<BR><a href='?_src_=prefs;preference=barkpreview'>Preview Bark</a><BR>"
dat += "</td>"
dat += "</tr></table>"
@@ -2555,6 +2572,43 @@ GLOBAL_LIST_EMPTY(preferences_datums)
if(selected_language)
additional_language = selected_language
if("barksound")
var/list/woof_woof = list()
for(var/path in GLOB.bark_list)
var/datum/bark/B = GLOB.bark_list[path]
if(initial(B.ignore))
continue
if(initial(B.ckeys_allowed))
var/list/allowed = initial(B.ckeys_allowed)
if(!allowed.Find(user.client.ckey))
continue
woof_woof[initial(B.name)] = initial(B.id)
var/new_bork = input(user, "Choose your desired vocal bark", "Character Preference") as null|anything in woof_woof
if(new_bork)
bark_id = woof_woof[new_bork]
var/datum/bark/B = GLOB.bark_list[bark_id] //Now we need sanitization to take into account bark-specific min/max values
bark_speed = round(clamp(bark_speed, initial(B.minspeed), initial(B.maxspeed)), 1)
bark_pitch = clamp(bark_pitch, initial(B.minpitch), initial(B.maxpitch))
bark_variance = clamp(bark_variance, initial(B.minvariance), initial(B.maxvariance))
if("barkspeed")
var/datum/bark/B = GLOB.bark_list[bark_id]
var/borkset = input(user, "Choose your desired bark speed (Higher is slower, lower is faster). Min: [initial(B.minspeed)]. Max: [initial(B.maxspeed)]", "Character Preference") as null|num
if(borkset)
bark_speed = round(clamp(borkset, initial(B.minspeed), initial(B.maxspeed)), 1)
if("barkpitch")
var/datum/bark/B = GLOB.bark_list[bark_id]
var/borkset = input(user, "Choose your desired baseline bark pitch. Min: [initial(B.minpitch)]. Max: [initial(B.maxpitch)]", "Character Preference") as null|num
if(borkset)
bark_pitch = clamp(borkset, initial(B.minpitch), initial(B.maxpitch))
if("barkvary")
var/datum/bark/B = GLOB.bark_list[bark_id]
var/borkset = input(user, "Choose your desired baseline bark pitch. Min: [initial(B.minvariance)]. Max: [initial(B.maxvariance)]", "Character Preference") as null|num
if(borkset)
bark_variance = clamp(borkset, initial(B.minvariance), initial(B.maxvariance))
if("bodysprite")
var/selected_body_sprite = input(user, "Choose your desired body sprite", "Character Preference") as null|anything in pref_species.allowed_limb_ids
if(selected_body_sprite)
@@ -3015,6 +3069,23 @@ GLOBAL_LIST_EMPTY(preferences_datums)
if("hud_toggle_flash")
hud_toggle_flash = !hud_toggle_flash
if("barkpreview")
if(SSticker.current_state == GAME_STATE_STARTUP) //Timers don't tick at all during game startup, so let's just give an error message
to_chat(user, "<span class='warning'>Bark previews can't play during initialization!</span>")
return
if(!COOLDOWN_FINISHED(src, bark_previewing))
return
if(!parent || !parent.mob)
return
COOLDOWN_START(src, bark_previewing, (5 SECONDS))
var/atom/movable/barkbox = new(get_turf(parent.mob))
barkbox.set_bark(bark_id)
var/total_delay
for(var/i in 1 to (round((32 / bark_speed)) + 1))
addtimer(CALLBACK(barkbox, /atom/movable/proc/bark, list(parent.mob), 7, 70, rand((bark_pitch * 100), (bark_pitch*100) + (bark_variance*100)) / 100), total_delay)
total_delay += rand(DS2TICKS(bark_speed/4), DS2TICKS(bark_speed/4) + DS2TICKS(bark_speed/4)) TICKS
QDEL_IN(barkbox, total_delay)
if("save")
save_preferences()
save_character()
@@ -3236,6 +3307,11 @@ GLOBAL_LIST_EMPTY(preferences_datums)
character.additional_language = language_entry
character.grant_language(language_entry, TRUE, TRUE)
character.set_bark(bark_id)
character.vocal_speed = bark_speed
character.vocal_pitch = bark_pitch
character.vocal_pitch_range = bark_variance
//limb stuff, only done when initially spawning in
if(initial_spawn)
//delete any existing prosthetic limbs to make sure no remnant prosthetics are left over - But DO NOT delete those that are species-related