From 133eb9e9d0fef284e80da43ddafdb30c1dddfdfa Mon Sep 17 00:00:00 2001 From: Cael_Aislinn Date: Thu, 27 Dec 2012 01:31:32 +1000 Subject: [PATCH] removed talking crystals, added code to allow all item/weapons talkative Signed-off-by: Cael_Aislinn --- code/modules/mob/living/say.dm | 7 +- .../research/xenoarchaeology/crystal.dm | 213 ------------------ .../research/xenoarchaeology/talking_item.dm | 108 +++++++++ 3 files changed, 112 insertions(+), 216 deletions(-) delete mode 100644 code/modules/research/xenoarchaeology/crystal.dm create mode 100644 code/modules/research/xenoarchaeology/talking_item.dm diff --git a/code/modules/mob/living/say.dm b/code/modules/mob/living/say.dm index f56c672da84..09de584c845 100644 --- a/code/modules/mob/living/say.dm +++ b/code/modules/mob/living/say.dm @@ -425,9 +425,10 @@ var/list/department_radio_keys = list( del(B) */ - //talking crystals - for(var/obj/item/weapon/talkingcrystal/O in view(3,src)) - O.catchMessage(message,src) + //talking items + for(var/obj/item/weapon/O in view(3,src)) + if(O.listening_to_players) + O.catchMessage(message, src) log_say("[name]/[key] : [message]") diff --git a/code/modules/research/xenoarchaeology/crystal.dm b/code/modules/research/xenoarchaeology/crystal.dm deleted file mode 100644 index ec2aaff7761..00000000000 --- a/code/modules/research/xenoarchaeology/crystal.dm +++ /dev/null @@ -1,213 +0,0 @@ - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// crystals - -/obj/item/weapon/crystal - name = "Crystal" - icon = 'mining.dmi' - icon_state = "crystal" - -//needs to be solid to have collision, but shouldn't block movement -/*/obj/item/weapon/crystal/bullet_act(var/obj/item/projectile/P) - if(istype(P,/obj/item/projectile/beam/emitter)) - switch(rand(0,3)) - if(0) - var/obj/item/projectile/beam/emitter/A = new /obj/item/projectile/beam/emitter( src.loc ) - A.dir = 1 - A.yo = 20 - A.xo = 0 - if(0) - var/obj/item/projectile/beam/emitter/A = new /obj/item/projectile/beam/emitter( src.loc ) - A.dir = 2 - A.yo = -20 - A.xo = 0 - if(0) - var/obj/item/projectile/beam/emitter/A = new /obj/item/projectile/beam/emitter( src.loc ) - A.dir = 4 - A.yo = 0 - A.xo = 20 - if(0) - var/obj/item/projectile/beam/emitter/A = new /obj/item/projectile/beam/emitter( src.loc ) - A.dir = 8 - A.yo = 0 - A.xo = -20 - else - ..()*/ - -/obj/item/weapon/talkingcrystal - name = "Crystal" - icon = 'mining.dmi' - icon_state = "crystal2" - var/list/list/words = list() - var/lastsaid - -/obj/item/weapon/talkingcrystal/New() - spawn(100) - process() - -//needs to be solid to have collision, but shouldn't block movement -/*/obj/item/weapon/talkingcrystal/bullet_act(var/obj/item/projectile/P) - if(istype(P,/obj/item/projectile/beam)) - switch(rand(0,3)) - if(0) - var/obj/item/projectile/beam/A = new /obj/item/projectile/beam( src.loc ) - A.dir = pick(alldirs) - A.yo = 20 - A.xo = 0 - if(0) - var/obj/item/projectile/beam/A = new /obj/item/projectile/beam( src.loc ) - A.dir = pick(alldirs) - A.yo = -20 - A.xo = 0 - if(0) - var/obj/item/projectile/beam/A = new /obj/item/projectile/beam( src.loc ) - A.dir = pick(alldirs) - A.yo = 0 - A.xo = 20 - if(0) - var/obj/item/projectile/beam/A = new /obj/item/projectile/beam( src.loc ) - A.dir = pick(alldirs) - A.yo = 0 - A.xo = -20 - var/word = pick("pain","hurt","masochism","sadist","rage","repressed","ouch","evil","void","kill","destroy") - SaySomething(word) - else - ..()*/ - -/obj/item/weapon/talkingcrystal/proc/catchMessage(var/msg, var/mob/source) - var/list/seperate = list() - if(findtext(msg,"((")) - return - else if(findtext(msg,"))")) - return - else if(findtext(msg," ")==0) - return - else - /*var/l = lentext(msg) - if(findtext(msg," ",l,l+1)==0) - msg+=" "*/ - seperate = stringsplit(msg, " ") - - var/addressing_crystal = 0 - if("crystal" in seperate || "gem" in seperate) - addressing_crystal = 1 - - for(var/Xa = 1,Xa 20 + rand(10,20)) - words.Remove(words[1]) - if(!words["[lowertext(seperate[Xa])]"]) - words["[lowertext(seperate[Xa])]"] = list() - var/list/w = words["[lowertext(seperate[Xa])]"] - if(w) - w.Add("[lowertext(seperate[next])]") - //world << "Adding [lowertext(seperate[next])] to [lowertext(seperate[Xa])]" - - for(var/mob/O in viewers(src)) - O.show_message("\blue The crystal hums for bit then stops...", 1) - if(!rand(0, 5 - addressing_crystal * 3)) - spawn(2) SaySomething(pick(seperate)) - -/obj/item/weapon/talkingcrystal/proc/debug() - //set src in view() - for(var/v in words) - world << "[uppertext(v)]" - var/list/d = words["[v]"] - for(var/X in d) - world << "[X]" - -/obj/item/weapon/talkingcrystal/proc/SaySomething(var/word = null) - - var/msg - var/limit = rand(max(5,words.len/2))+3 - var/text - if(!word) - text = "[pick(words)]" - else - text = pick(stringsplit(word, " ")) - if(lentext(text)==1) - text=uppertext(text) - else - var/cap = copytext(text,1,2) - cap = uppertext(cap) - cap += copytext(text,2,lentext(text)+1) - text=cap - var/q = 0 - msg+=text - if(msg=="What" | msg == "Who" | msg == "How" | msg == "Why" | msg == "Are") - q=1 - - text=lowertext(text) - for(var/ya,ya <= limit,ya++) - - if(words.Find("[text]")) - var/list/w = words["[text]"] - text=pick(w) - else - text = "[pick(words)]" - msg+=" [text]" - if(q) - msg+="?" - else - if(rand(0,10)) - msg+="." - else - msg+="!" - - var/list/listening = viewers(src) - for(var/mob/M in world) - if (!M.client) - continue //skip monkeys and leavers - if (istype(M, /mob/new_player)) - continue - if(M.stat == 2 && M.client.ghost_ears) - listening|=M - - for(var/mob/M in listening) - M << "The crystal reverberates, \blue\"[msg]\"" - lastsaid = world.timeofday + rand(300,800) - -/obj/item/weapon/talkingcrystal/process() - if(prob(25) && world.timeofday >= lastsaid && words.len >= 1) - SaySomething() - spawn(100) - process() - - - - -//sentient crystals -/mob/sentient_crystal - name = "Crystal" - icon = 'mining.dmi' - icon_state = "crystal2" - var/list/list/words = list() - var/lastsaid - -/mob/sentient_crystal/proc/catchMessage(var/msg, var/mob/source) - var/list/seperate = list() - if(findtext(msg,"((")) - return - else if(findtext(msg,"))")) - return - else - /*var/l = lentext(msg) - if(findtext(msg," ",l,l+1)==0) - msg+=" "*/ - seperate = stringsplit(msg, " ") - - for(var/Xa = 1,Xa 20 + rand(10,20)) - words.Remove(words[1]) - if(!words["[lowertext(seperate[Xa])]"]) - words["[lowertext(seperate[Xa])]"] = list() - var/list/w = words["[lowertext(seperate[Xa])]"] - if(w) - w.Add("[lowertext(seperate[next])]") - //world << "Adding [lowertext(seperate[next])] to [lowertext(seperate[Xa])]" - - for(var/mob/O in viewers(src)) - O.show_message("\blue The crystal hums for bit then stops...", 1) - -/mob/sentient_crystal/Life() \ No newline at end of file diff --git a/code/modules/research/xenoarchaeology/talking_item.dm b/code/modules/research/xenoarchaeology/talking_item.dm new file mode 100644 index 00000000000..75532f98c89 --- /dev/null +++ b/code/modules/research/xenoarchaeology/talking_item.dm @@ -0,0 +1,108 @@ + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Formerly talking crystals - these procs are now modular so that you can make any /obj/item/weapon 'parrot' player speech back to them +// This could be extended to atoms, but it's bad enough as is +// I genuinely tried to Add and Remove them from var and proc lists, but just couldn't get it working + +/obj/item/weapon + var/list/heard_words = list() + var/lastsaid + var/listening_to_players = 0 + var/speaking_to_players = 0 + +/obj/item/weapon/proc/process_talking(var/word = null) + if(prob(25) && world.timeofday >= lastsaid && heard_words.len >= 1) + SaySomething(word) + spawn(100) + process_talking() + +/obj/item/weapon/proc/catchMessage(var/msg, var/mob/source) + if(speaking_to_players) + var/list/seperate = list() + if(findtext(msg,"((")) + return + else if(findtext(msg,"))")) + return + else if(findtext(msg," ")==0) + return + else + /*var/l = lentext(msg) + if(findtext(msg," ",l,l+1)==0) + msg+=" "*/ + seperate = stringsplit(msg, " ") + + for(var/Xa = 1,Xa 20 + rand(10,20)) + heard_words.Remove(heard_words[1]) + if(!heard_words["[lowertext(seperate[Xa])]"]) + heard_words["[lowertext(seperate[Xa])]"] = list() + var/list/w = heard_words["[lowertext(seperate[Xa])]"] + if(w) + w.Add("[lowertext(seperate[next])]") + //world << "Adding [lowertext(seperate[next])] to [lowertext(seperate[Xa])]" + + if(!rand(0, 5)) + spawn(2) SaySomething(pick(seperate)) + if(prob(30)) + for(var/mob/O in viewers(src)) + O.show_message("\blue [src] hums for bit then stops...", 1) + +/*/obj/item/weapon/talkingcrystal/proc/debug() + //set src in view() + for(var/v in heard_words) + world << "[uppertext(v)]" + var/list/d = heard_words["[v]"] + for(var/X in d) + world << "[X]"*/ + +/obj/item/weapon/proc/SaySomething(var/word = null) + + var/msg + var/limit = rand(max(5,heard_words.len/2))+3 + var/text + if(!word) + text = "[pick(heard_words)]" + else + text = pick(stringsplit(word, " ")) + if(lentext(text)==1) + text=uppertext(text) + else + var/cap = copytext(text,1,2) + cap = uppertext(cap) + cap += copytext(text,2,lentext(text)+1) + text=cap + var/q = 0 + msg+=text + if(msg=="What" | msg == "Who" | msg == "How" | msg == "Why" | msg == "Are") + q=1 + + text=lowertext(text) + for(var/ya,ya <= limit,ya++) + + if(heard_words.Find("[text]")) + var/list/w = heard_words["[text]"] + text=pick(w) + else + text = "[pick(heard_words)]" + msg+=" [text]" + if(q) + msg+="?" + else + if(rand(0,10)) + msg+="." + else + msg+="!" + + var/list/listening = viewers(src) + for(var/mob/M in world) + if (!M.client) + continue //skip monkeys and leavers + if (istype(M, /mob/new_player)) + continue + if(M.stat == 2 && M.client.ghost_ears) + listening|=M + + for(var/mob/M in listening) + M << "[src] reverberates, \blue\"[msg]\"" + lastsaid = world.timeofday + rand(300,800)