streamlining dreams

no calling by clientless mobs, this should save several thousand wasted calls.
turning the massive string list that would be defined each call into a global list.
the chance the same dream gets picked twice is negletable.
This commit is contained in:
Walter0o
2014-07-19 23:00:20 +02:00
parent c4abe1f5d5
commit 8ccce503a9

View File

@@ -1,6 +1,5 @@
mob/living/carbon/proc/dream()
dreaming = 1 var/list/dreams = list(
var/list/dreams = list(
"an ID card","a bottle","a familiar face","a crewmember","a toolbox","a security officer","the captain", "an ID card","a bottle","a familiar face","a crewmember","a toolbox","a security officer","the captain",
"voices from all around","deep space","a doctor","the engine","a traitor","an ally","darkness", "voices from all around","deep space","a doctor","the engine","a traitor","an ally","darkness",
"light","a scientist","a monkey","a catastrophe","a loved one","a gun","warmth","freezing","the sun", "light","a scientist","a monkey","a catastrophe","a loved one","a gun","warmth","freezing","the sun",
@@ -14,11 +13,13 @@ mob/living/carbon/proc/dream()
"a beach","the holodeck","a smokey room","a voice","the cold","a mouse","an operating table","the bar","the rain","a skrell", "a beach","the holodeck","a smokey room","a voice","the cold","a mouse","an operating table","the bar","the rain","a skrell",
"a unathi","a tajaran","the ai core","the mining station","the research station","a beaker of strange liquid", "a unathi","a tajaran","the ai core","the mining station","the research station","a beaker of strange liquid",
) )
mob/living/carbon/proc/dream()
dreaming = 1
spawn(0) spawn(0)
for(var/i = rand(1,4),i > 0, i--) for(var/i = rand(1,4),i > 0, i--)
var/dream_image = pick(dreams) src << "\blue <i>... [pick(dreams)] ...</i>"
dreams -= dream_image
src << "\blue <i>... [dream_image] ...</i>"
sleep(rand(40,70)) sleep(rand(40,70))
if(paralysis <= 0) if(paralysis <= 0)
dreaming = 0 dreaming = 0
@@ -27,6 +28,7 @@ mob/living/carbon/proc/dream()
return 1 return 1
mob/living/carbon/proc/handle_dreams() mob/living/carbon/proc/handle_dreams()
if(prob(5) && !dreaming) dream() if(client && !dreaming && prob(5))
dream()
mob/living/carbon/var/dreaming = 0 mob/living/carbon/var/dreaming = 0