Skip to content
This repository has been archived by the owner on Oct 15, 2023. It is now read-only.

Fixed clouds and sleeping #197

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions code/game/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
var/atom_say_verb = "says"
var/bubble_icon = "default" ///what icon the mob uses for speechbubbles
var/bubble_emote_icon = "emote" ///what icon the mob uses for emotebubbles
var/bubble_sleeping_icon = "sleeping" ///what icon the mob uses for sleepingbubbles
var/dont_save = FALSE // For atoms that are temporary by necessity - like lighting overlays

///Chemistry.
Expand Down
3 changes: 2 additions & 1 deletion code/modules/mob/living/carbon/carbon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@
if(H.w_uniform)
H.w_uniform.add_fingerprint(M)
AdjustSleeping(-5)
if(sleeping == 0)
if(sleeping == 0 || player_triggered_sleeping)
src.player_triggered_sleeping = 0
Comment on lines +216 to +217
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

в случаях, где 0 и 1 используются как булевые значения, то есть 0 - это FALSE, то есть ложность выражения и 1 - это TRUE, то есть истинность выражения, то необходимо их и использовать.
Вместо 0 - FALSE.
Вместо 1 - TRUE.
Так же, не обязательно писать полностью sleeping == 0, достаточно просто !sleeping - где ! - это оператор отрицания, то есть читаем ! - не, sleeping - спит - не спит. Всё что я написал - истинно только для булевых значений. Для других - есть свои тонкости - в бьенде для всех значений есть своё булевое соответствие.

Suggested change
if(sleeping == 0 || player_triggered_sleeping)
src.player_triggered_sleeping = 0
if(!sleeping || player_triggered_sleeping)
player_triggered_sleeping = FALSE

src - явно обращаться к src надо только тогда, когда существует локальная с таким же названием как и вызываемая у src. В противном случае просто вызывай переменную, без обращения к src

StopResting()
AdjustParalysis(-3)
AdjustStunned(-3)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/life.dm
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@
AdjustHallucinate(-2)

// Keep SSD people asleep
if(player_logged)
if(player_logged || player_triggered_sleeping)
Sleeping(2)

/mob/living/carbon/handle_sleeping()
Expand Down
1 change: 1 addition & 0 deletions code/modules/mob/living/status_procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
var/paralysis = 0
var/silent = 0
var/sleeping = 0
var/player_triggered_sleeping = 0
var/slowed = 0
var/slurring = 0
var/stunned = 0
Expand Down
6 changes: 6 additions & 0 deletions code/modules/mob/living/update_status.dm
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,15 @@

/mob/living/update_sleeping_effects(no_alert = FALSE)
if(sleeping)

GLOB.typing_indicator[bubble_sleeping_icon] = image('icons/mob/talk.dmi', null, "[bubble_sleeping_icon]", FLY_LAYER)
var/image/I = GLOB.typing_indicator[bubble_sleeping_icon]
I.appearance_flags = APPEARANCE_UI_IGNORE_ALPHA
overlays += GLOB.typing_indicator[bubble_sleeping_icon]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

мы не добавляем overlays вручную, только через add_overlays

Comment on lines +38 to +41
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
GLOB.typing_indicator[bubble_sleeping_icon] = image('icons/mob/talk.dmi', null, "[bubble_sleeping_icon]", FLY_LAYER)
var/image/I = GLOB.typing_indicator[bubble_sleeping_icon]
I.appearance_flags = APPEARANCE_UI_IGNORE_ALPHA
overlays += GLOB.typing_indicator[bubble_sleeping_icon]
var/image/bubble_sleeping_icon_to_display = GLOB.typing_indicator[bubble_sleeping_icon]
if (!bubble_sleeping_icon_to_display)
bubble_sleeping_icon_to_display = image('icons/mob/talk.dmi', null, "[bubble_sleeping_icon]", FLY_LAYER)
GLOB.typing_indicator[bubble_sleeping_icon] = bubble_sleeping_icon_to_display
FLY_LAYER)
bubble_sleeping_icon_to_display.appearance_flags = APPEARANCE_UI_IGNORE_ALPHA
add_overlays(bubble_sleeping_icon_to_display)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Не создаём каждый раз новую image для sleeping_icon в том случае, если она уже есть в глобальном списке
  2. Добавляем в глобальный список НОВУЮ sleeping_icon только в том случае, если её там нет
  3. Мы не добавляем overlays вручную, только через add_overlays, так как для работы над оверлеями есть целая сабсистема, которая по очереди их добавляет

if(!no_alert)
throw_alert("asleep", /obj/screen/alert/asleep)
else
overlays -= GLOB.typing_indicator[bubble_sleeping_icon]
clear_alert("asleep")
Comment on lines +45 to 46
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут аналогично с add_overlays, используется cut_overlays

cut_overlays(GLOB.typing_indicator[bubble_sleeping_icon])


// Querying status of the mob
Expand Down
9 changes: 3 additions & 6 deletions code/modules/mob/mob_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -412,12 +412,9 @@ GLOBAL_LIST_INIT(intents, list(INTENT_HELP,INTENT_DISARM,INTENT_GRAB,INTENT_HARM
set name = "Sleep"
set category = "IC"

if(sleeping)
to_chat(src, "<span class='notice'>Вы уже спите.</span>")
return
else
if(alert(src, "You sure you want to sleep for a while?", "Sleep", "Yes", "No") == "Yes")
SetSleeping(20) //Short nap
if(alert("Ты уверен[genderize_ru(src.gender,"","а")], что хочешь [player_triggered_sleeping ? "проснуться?" : "немного поспать? Используй 'sleep' снова ,чтобы проснуться."]", "Sleep", "Нет", "Да") == "Да")
player_triggered_sleeping = !player_triggered_sleeping


/mob/living/verb/lay_down()
set name = "Rest"
Expand Down
Binary file modified icons/mob/talk.dmi
Binary file not shown.