Skip to content

Commit

Permalink
[MIRROR] Changes dreaming variable on carbons to a trait [MDB IGNOR…
Browse files Browse the repository at this point in the history
…E] (#860)

* Changes `dreaming` variable on carbons to a trait (#79940)

---------

Co-authored-by: SkyratBot <[email protected]>
Co-authored-by: san7890 <[email protected]>
  • Loading branch information
3 people authored Nov 28, 2023
1 parent fe7fa9e commit 1d0200e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
3 changes: 2 additions & 1 deletion code/__DEFINES/traits/declarations.dm
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,8 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
/// Trait given to angelic constructs to let them purge cult runes
#define TRAIT_ANGELIC "angelic"


/// Trait given to a dreaming carbon when they are currently doing dreaming stuff
#define TRAIT_DREAMING "currently_dreaming"

///generic atom traits
/// Trait from [/datum/element/rust]. Its rusty and should be applying a special overlay to denote this.
Expand Down
1 change: 1 addition & 0 deletions code/_globalvars/traits/_traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ GLOBAL_LIST_INIT(traits_by_type, list(
"TRAIT_DISSECTED" = TRAIT_DISSECTED,
"TRAIT_DONT_WRITE_MEMORY" = TRAIT_DONT_WRITE_MEMORY,
"TRAIT_DOUBLE_TAP" = TRAIT_DOUBLE_TAP,
"TRAIT_DREAMING" = TRAIT_DREAMING,
"TRAIT_DRINKS_BLOOD" = TRAIT_DRINKS_BLOOD,
"TRAIT_DUMB" = TRAIT_DUMB,
"TRAIT_DWARF" = TRAIT_DWARF,
Expand Down
12 changes: 8 additions & 4 deletions code/modules/flufftext/Dreaming.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#define DREAMING_SOURCE "dreaming_source"

/**
* Begins the dreaming process on a sleeping carbon.
*
Expand All @@ -6,7 +8,7 @@
*/

/mob/living/carbon/proc/handle_dreams()
if(prob(10) && !dreaming)
if(!HAS_TRAIT(src, TRAIT_DREAMING) && prob(10))
dream()

/**
Expand All @@ -22,7 +24,7 @@

var/datum/dream/chosen_dream = pick_weight(GLOB.dreams)

dreaming = TRUE
ADD_TRAIT(src, TRAIT_DREAMING, DREAMING_SOURCE)
dream_sequence(chosen_dream.GenerateDream(src), chosen_dream)

/**
Expand All @@ -38,7 +40,7 @@

/mob/living/carbon/proc/dream_sequence(list/dream_fragments, datum/dream/current_dream)
if(stat != UNCONSCIOUS || HAS_TRAIT(src, TRAIT_CRITICAL_CONDITION))
dreaming = FALSE
REMOVE_TRAIT(src, TRAIT_DREAMING, DREAMING_SOURCE)
current_dream.OnDreamEnd(src)
return
var/next_message = dream_fragments[1]
Expand All @@ -56,7 +58,7 @@
AdjustSleeping(next_wait)
addtimer(CALLBACK(src, PROC_REF(dream_sequence), dream_fragments, current_dream), next_wait)
else
dreaming = FALSE
REMOVE_TRAIT(src, TRAIT_DREAMING, DREAMING_SOURCE)
current_dream.OnDreamEnd(src)

//-------------------------
Expand Down Expand Up @@ -180,3 +182,5 @@ GLOBAL_LIST_INIT(dreams, populate_dream_list())

/datum/dream/hear_something/proc/StopSound(mob/living/carbon/dreamer)
SEND_SOUND(dreamer, sound(channel=reserved_sound_channel))

#undef DREAMING_SOURCE
2 changes: 0 additions & 2 deletions code/modules/mob/living/carbon/carbon_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
var/list/obj/item/organ/organs = list()
///Same as [above][/mob/living/carbon/var/organs], but stores "slot ID" - "organ" pairs for easy access.
var/list/organs_slot = list()
///How many dream images we have left to send
var/dreaming = 0

///Whether or not the mob is handcuffed
var/obj/item/handcuffed = null
Expand Down

0 comments on commit 1d0200e

Please sign in to comment.