Codespeak language and manual

🆑 coiax
add: Syndicate agents can purchase a "codespeak manual", that teaches
them a language that sounds like a series of codewords. You can also hit
other people with the manual to teach them. One use per manual.
add: Nuclear operatives have access to a deluxe manual that is more
expensive but has unlimited uses.
/🆑

- DNM until we have language icons
- Syndicate codespeak only displays the language icon if you KNOW the
language, so you cannot tell the difference between someone just
shouting random codewords on the radio, and someone actually using the
language.
- Modifies generate_code_phrase to optionally return a list of words,
rather than a preformatted string.
- Codespeak manuals turn into random books after being used.
This commit is contained in:
Jack Edge
2017-05-14 15:55:52 +01:00
parent ff5272fd81
commit bf8bffcbe0
5 changed files with 123 additions and 28 deletions
+69
View File
@@ -0,0 +1,69 @@
/datum/language/common/codespeak
name = "Codespeak"
desc = "Syndicate operatives can use a series of codewords to convey complex information, while sounding like random concepts and drinks to anyone listening in."
key = "t"
default_priority = 0
/datum/language/common/codespeak/scramble(input)
var/lookup = check_cache(input)
if(lookup)
return lookup
. = ""
var/list/words = list()
while(length(.) < length(input))
words += generate_code_phrase(return_list=TRUE)
. = jointext(words, ", ")
add_to_cache(input, .)
/obj/item/weapon/codespeak_manual
name = "codespeak manual"
desc = "The book's cover reads: \"Codespeak(tm) - Secure your communication with metaphors so elaborate, they seem randomly generated!\""
icon = 'icons/obj/library.dmi'
icon_state = "book2"
var/charges = 1
/obj/item/weapon/codespeak_manual/attack_self(mob/living/user)
if(!isliving(user))
return
if(user.has_language(/datum/language/common/codespeak))
to_chat(user, "<span class='boldannounce'>You start skimming through [src], but you already know Codespeak.</span>")
return
to_chat(user, "<span class='boldannounce'>You start skimming through [src], and suddenly your mind is filled with codewords and responses.</span>")
user.grant_language(/datum/language/common/codespeak)
use_charge()
/obj/item/weapon/codespeak_manual/attack(mob/living/M, mob/living/user)
if(!istype(M) || !istype(user))
return
playsound(loc, "punch", 25, 1, -1)
if(M.stat == DEAD)
M.visible_message("<span class='danger'>[user] smacks [M]'s lifeless corpse with [src].</span>", "<span class='userdanger'>[user] smacks your lifeless corpse with [src].</span>", "<span class='italics'>You hear smacking.</span>")
else if(M.has_language(/datum/language/common/codespeak))
M.visible_message("<span class='danger'>[user] beats [M] over the head with [src]!</span>", "<span class='userdanger'>[user] beats you over the head with [src]!</span>", "<span class='italics'>You hear smacking.</span>")
else
M.visible_message("<span class='notice'>[user] teaches [M] by beating them over the head with [src]!</span>", "<span class='boldnotice'>As [user] hits you with [src], codewords and responses flow through your mind.</span>", "<span class='italics'>You hear smacking.</span>")
M.grant_language(/datum/language/common/codespeak)
/obj/item/weapon/codespeak_manual/proc/use_charge()
charges--
if(!charges)
say("Automatic data erasure in progress!")
visible_message("<span class='warning'>The cover and contents of [src] start shifting and changing!</span>")
var/obj/item/weapon/book/random/newbook = new(get_turf(src))
qdel(src)
if(ismob(loc))
var/mob/M = loc
if(M.is_holding(src))
M.put_in_active_hand(newbook)
/obj/item/weapon/codespeak_manual/unlimited
name = "deluxe codespeak manual"
charges = INFINITY
+15 -7
View File
@@ -56,16 +56,27 @@
return "[trim(full_name)]"
/datum/language/proc/check_cache(input)
var/lookup = scramble_cache[input]
if(lookup)
scramble_cache -= input
scramble_cache[input] = lookup
. = lookup
/datum/language/proc/add_to_cache(input, scrambled_text)
// Add it to cache, cutting old entries if the list is too long
scramble_cache[input] = scrambled_text
if(scramble_cache.len > SCRAMBLE_CACHE_LEN)
scramble_cache.Cut(1, scramble_cache.len-SCRAMBLE_CACHE_LEN-1)
/datum/language/proc/scramble(input)
if(!syllables || !syllables.len)
return stars(input)
// If the input is cached already, move it to the end of the cache and return it
var/lookup = scramble_cache[input]
var/lookup = check_cache(input)
if(lookup)
scramble_cache -= input
scramble_cache[input] = lookup
return lookup
var/input_size = length(input)
@@ -93,10 +104,7 @@
if(input_ending in list("!","?","."))
scrambled_text += input_ending
// Add it to cache, cutting old entries if the list is too long
scramble_cache[input] = scrambled_text
if(scramble_cache.len > SCRAMBLE_CACHE_LEN)
scramble_cache.Cut(1, scramble_cache.len-SCRAMBLE_CACHE_LEN-1)
add_to_cache(input, scrambled_text)
return scrambled_text