From 4fccc3506766cee088a9cd9d5fde45e4180db19e Mon Sep 17 00:00:00 2001 From: Ren Erthilo Date: Thu, 3 May 2012 00:40:47 +0100 Subject: [PATCH] =?UTF-8?q?TG:=20=E2=97=98The=20problem:=20People=20being?= =?UTF-8?q?=20able=20to=20move=20while=20resting/lying?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ◘What caused it: When a user decided to press "rest", a single variable, resting, was switched from 0 to 1. Through life.dm procs, when the handle_regular_status() proc saw the mob resting && his weakness being 0 or less, it would just give him 2 seconds of being-weak, through Weaken(2). Later on, the proc called update_canmove() to see if the guy had the ability to move due to weakness but also due to reagents/drugs/sleep etc. At every tick, this proc also reduced mob.weakness by 1. The chain that led to the problem was: ○User decides to rest ○resting is set to 1, handle_regular_status_updates() runs ○Proc sees that the user's resting var == 1. Does mob.weakness = 2 ○Proc handles weakness. mob.weakness -= 1. It is now 1. ○update_canmove() is blind to resting, though sees that there's weakness. Sets canmove to 0 ○Proc runs again the following second ○Proc sees user is resting. ○mob.weakness <= 0 fails, since it's 1 from the last run. Weakness stays at 1. ○Proc handles weakness, mob.weakness-=1. It is now 0. ○update_canmove() now sees that there's no weakness, and sets canmove to 1, even though the user is still resting & lying ○For a second, the user is able to roll around on his lying butt ○Proc runs again, giving Weaken(2) and disables movement again, and the circle repeats. ◘How it got fixed: Made update_canmove() not blind to resting. I don't like this solution, as resting still equals weakening and there's wasted processing, albeit miniscule. I will try to work on something better. ◘Sleep can now go over 1 again, some dumb shit did not realise this and led to sleep being weak as hell. You can now put people to permanent sleep through anaesthetic gasses and toxins. Deciding to sleep will put you out for 20. Deciding to faint will put you out for 10. Revision: r3442 Author: polyxenitopalidou --- code/modules/chemical/Chemistry-Reagents.dm | 20 +++++++++---------- .../living/carbon/alien/humanoid/humanoid.dm | 2 +- .../mob/living/carbon/alien/humanoid/life.dm | 2 +- .../mob/living/carbon/alien/larva/larva.dm | 2 +- .../mob/living/carbon/alien/larva/life.dm | 2 +- code/modules/mob/living/carbon/brain/life.dm | 2 +- code/modules/mob/living/carbon/carbon.dm | 6 +++--- code/modules/mob/living/carbon/human/emote.dm | 4 +++- code/modules/mob/living/carbon/human/life.dm | 4 ++-- code/modules/mob/living/carbon/monkey/life.dm | 2 +- code/modules/mob/say.dm | 4 +++- code/modules/mob/screen.dm | 8 ++++---- 12 files changed, 31 insertions(+), 27 deletions(-) diff --git a/code/modules/chemical/Chemistry-Reagents.dm b/code/modules/chemical/Chemistry-Reagents.dm index dbe506380c2..6a9bb90d841 100644 --- a/code/modules/chemical/Chemistry-Reagents.dm +++ b/code/modules/chemical/Chemistry-Reagents.dm @@ -436,7 +436,7 @@ datum if(15 to 25) M:drowsyness = max(M:drowsyness, 20) if(25 to INFINITY) - M.sleeping = 1 + M.sleeping += 1 M.adjustOxyLoss(-M.getOxyLoss()) M.SetWeakened(0) M.SetStunned(0) @@ -2446,7 +2446,7 @@ datum M:drowsyness = max(0,M:drowsyness-3) M:slurring = max(0, M:slurring-3) if(!M:sleeping_willingly) - M:sleeping = 0 + M:sleeping = max(0,M.sleeping - 2) if (M.bodytemperature < 310)//310 is the normal bodytemp. 310.055 M.bodytemperature = min(310, M.bodytemperature+5) M.make_jittery(1) @@ -2488,7 +2488,7 @@ datum M:drowsyness = max(0,M:drowsyness-3) M:slurring = max(0, M:slurring-3) if(!M:sleeping_willingly) - M:sleeping = 0 + M:sleeping = max(0,M.sleeping-2) if (M.bodytemperature > 310)//310 is the normal bodytemp. 310.055 M.bodytemperature = min(310, M.bodytemperature-5) M.make_jittery(1) @@ -2507,7 +2507,7 @@ datum M.dizziness = max(0,M.dizziness-2) M:drowsyness = max(0,M:drowsyness-1) if(!M:sleeping_willingly) - M:sleeping = 0 + M.sleeping = max(0,M.sleeping-2) if(M:getToxLoss() && prob(20)) M:adjustToxLoss(-1) if (M.bodytemperature > 310)//310 is the normal bodytemp. 310.055 @@ -2542,7 +2542,7 @@ datum M.dizziness +=5 M:drowsyness = 0 if(!M:sleeping_willingly) - M:sleeping = 0 + M:sleeping = max(0,M.sleeping-2) if (M.bodytemperature > 310)//310 is the normal bodytemp. 310.055 M.bodytemperature = max(310, M.bodytemperature-5) M:nutrition += 1 @@ -2559,7 +2559,7 @@ datum on_mob_life(var/mob/living/M as mob) M:drowsyness = max(0,M:drowsyness-7) if(!M:sleeping_willingly) - M:sleeping = 0 + M:sleeping = max(0,M.sleeping-1) if (M.bodytemperature > 310) M.bodytemperature = max(310, M.bodytemperature-5) M.make_jittery(1) @@ -2779,7 +2779,7 @@ datum on_mob_life(var/mob/living/M as mob) M:drowsyness = max(0,M:drowsyness-7) if(!M:sleeping_willingly) - M:sleeping = 0 + M:sleeping = max(0,M.sleeping-2) if (M.bodytemperature > 310) M.bodytemperature = max(310, M.bodytemperature-5) M.make_jittery(1) @@ -3095,7 +3095,7 @@ datum M.dizziness = max(0,M.dizziness-5) M:drowsyness = max(0,M:drowsyness-3) if(!M:sleeping_willingly) - M:sleeping = 0 + M:sleeping = max(0,M.sleeping-2) if (M.bodytemperature > 310) M.bodytemperature = max(310, M.bodytemperature-5) ..() @@ -3112,7 +3112,7 @@ datum M.dizziness = max(0,M.dizziness-5) M:drowsyness = max(0,M:drowsyness-3) if(!M:sleeping_willingly) - M:sleeping = 0 + M:sleeping = max(0,M.sleeping-2) M.make_jittery(1) ..() return @@ -3128,7 +3128,7 @@ datum M.dizziness = max(0,M.dizziness-5) M:drowsyness = max(0,M:drowsyness-3) if(!M:sleeping_willingly) - M:sleeping = 0 + M:sleeping = max(0,M.sleeping - 2) if (M.bodytemperature > 310) M.bodytemperature = max(310, M.bodytemperature-5) ..() diff --git a/code/modules/mob/living/carbon/alien/humanoid/humanoid.dm b/code/modules/mob/living/carbon/alien/humanoid/humanoid.dm index d7588011af1..e44e5937a06 100644 --- a/code/modules/mob/living/carbon/alien/humanoid/humanoid.dm +++ b/code/modules/mob/living/carbon/alien/humanoid/humanoid.dm @@ -741,7 +741,7 @@ In all, this is a lot like the monkey code. /N if ("help") if(!sleeping_willingly) - sleeping = 0 + sleeping = max(0,sleeping-5) resting = 0 AdjustParalysis(-3) AdjustStunned(-3) diff --git a/code/modules/mob/living/carbon/alien/humanoid/life.dm b/code/modules/mob/living/carbon/alien/humanoid/life.dm index 1388a1314c1..6356a385efe 100644 --- a/code/modules/mob/living/carbon/alien/humanoid/life.dm +++ b/code/modules/mob/living/carbon/alien/humanoid/life.dm @@ -380,7 +380,7 @@ src.drowsyness-- src.eye_blurry = max(2, src.eye_blurry) if (prob(5)) - src.sleeping = 1 + src.sleeping += 1 src.Paralyse(5) confused = max(0, confused - 1) diff --git a/code/modules/mob/living/carbon/alien/larva/larva.dm b/code/modules/mob/living/carbon/alien/larva/larva.dm index 252dc6349e7..3388ae322c6 100644 --- a/code/modules/mob/living/carbon/alien/larva/larva.dm +++ b/code/modules/mob/living/carbon/alien/larva/larva.dm @@ -490,7 +490,7 @@ if ("help") if(!sleeping_willingly) - sleeping = 0 + sleeping = max(0,sleeping-5) resting = 0 AdjustParalysis(-3) AdjustStunned(-3) diff --git a/code/modules/mob/living/carbon/alien/larva/life.dm b/code/modules/mob/living/carbon/alien/larva/life.dm index b975d969cbe..334676870a8 100644 --- a/code/modules/mob/living/carbon/alien/larva/life.dm +++ b/code/modules/mob/living/carbon/alien/larva/life.dm @@ -303,7 +303,7 @@ drowsyness-- eye_blurry = max(2, eye_blurry) if (prob(5)) - sleeping = 1 + sleeping += 1 Paralyse(5) confused = max(0, confused - 1) diff --git a/code/modules/mob/living/carbon/brain/life.dm b/code/modules/mob/living/carbon/brain/life.dm index 4106a1b0144..ac1fe5e7276 100644 --- a/code/modules/mob/living/carbon/brain/life.dm +++ b/code/modules/mob/living/carbon/brain/life.dm @@ -141,7 +141,7 @@ drowsyness-- eye_blurry = max(2, eye_blurry) if (prob(5)) - sleeping = 1 + sleeping += 1 Paralyse(5) confused = max(0, confused - 1) diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index cb42ba9b436..12af315a253 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -228,10 +228,10 @@ if (istype(src,/mob/living/carbon/human) && src:w_uniform) var/mob/living/carbon/human/H = src H.w_uniform.add_fingerprint(M) - src.sleeping = max(0,src.sleeping-5) if(!src.sleeping_willingly) - src.sleeping = 0 - src.resting = 0 + src.sleeping = max(0,src.sleeping-5) + if(src.sleeping == 0) + src.resting = 0 AdjustParalysis(-3) AdjustStunned(-3) AdjustWeakened(-3) diff --git a/code/modules/mob/living/carbon/human/emote.dm b/code/modules/mob/living/carbon/human/emote.dm index 0eae0dd45d8..fc6980a7891 100644 --- a/code/modules/mob/living/carbon/human/emote.dm +++ b/code/modules/mob/living/carbon/human/emote.dm @@ -164,7 +164,9 @@ if ("faint") message = "[src] faints." - src.sleeping = 1 + if(src.sleeping) + return //Can't faint while asleep + src.sleeping += 10 //Short-short nap m_type = 1 if ("cough") diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index 317e9824c8e..4d4b9e923c0 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -545,7 +545,7 @@ if(SA_pp > SA_para_min) // Enough to make us paralysed for a bit Paralyse(3) // 3 gives them one second to wake up and run away a bit! if(SA_pp > SA_sleep_min) // Enough to make us sleep as well - sleeping = max(sleeping, 4) + sleeping = max(src.sleeping+2, 10) else if(SA_pp > 0.01) // There is sleeping gas in their lungs, but only a little, so give them a bit of a warning if(prob(20) && isbreathing) spawn(0) emote(pick("giggle", "laugh")) @@ -819,7 +819,7 @@ drowsyness-- eye_blurry = max(2, eye_blurry) if (prob(5)) - sleeping = 1 + sleeping += 1 Paralyse(5) confused = max(0, confused - 1) diff --git a/code/modules/mob/living/carbon/monkey/life.dm b/code/modules/mob/living/carbon/monkey/life.dm index ab616822cee..64bad12d893 100644 --- a/code/modules/mob/living/carbon/monkey/life.dm +++ b/code/modules/mob/living/carbon/monkey/life.dm @@ -333,7 +333,7 @@ if(SA_pp > SA_para_min) // Enough to make us paralysed for a bit Paralyse(3) // 3 gives them one second to wake up and run away a bit! if(SA_pp > SA_sleep_min) // Enough to make us sleep as well - src.sleeping = max(src.sleeping, 2) + src.sleeping = max(src.sleeping+2, 10) else if(SA_pp > 0.01) // There is sleeping gas in their lungs, but only a little, so give them a bit of a warning if(prob(20)) spawn(0) emote(pick("giggle", "laugh")) diff --git a/code/modules/mob/say.dm b/code/modules/mob/say.dm index f036910eef8..f8e9fb94320 100644 --- a/code/modules/mob/say.dm +++ b/code/modules/mob/say.dm @@ -52,6 +52,8 @@ return 0 /mob/proc/say_quote(var/text) + if(!text) + return "says, \"...\""; //not the best solution, but it will stop a large number of runtimes. The cause is somewhere in the Tcomms code var/ending = copytext(text, length(text)) if (src.disease_symptoms & DISEASE_HOARSE) return "rasps, \"[text]\""; @@ -63,7 +65,7 @@ return "gibbers, \"[text]\""; if (ending == "?") return "asks, \"[text]\""; - else if (ending == "!") + if (ending == "!") return "exclaims, \"[text]\""; return "says, \"[text]\""; diff --git a/code/modules/mob/screen.dm b/code/modules/mob/screen.dm index 07343b0c6c8..4cc9c33b0a5 100644 --- a/code/modules/mob/screen.dm +++ b/code/modules/mob/screen.dm @@ -439,13 +439,13 @@ usr.pulling = null if("sleep") if(usr.sleeping && usr.sleeping_willingly) - usr.sleeping = 0 - usr.sleeping_willingly = 0 + return else if(!usr.sleeping) - usr.sleeping = 1 + usr.sleeping = 20 //Short nap usr.sleeping_willingly = 1 if("rest") - usr.resting = !usr.resting + usr.resting = !( usr.resting ) + //kavala2 if("throw") if (!usr.stat && isturf(usr.loc) && !usr.restrained()) usr:toggle_throw_mode()