From 276db7f50fa2ccf901d83511cc2e7f382bc6ffb4 Mon Sep 17 00:00:00 2001 From: "polyxenitopalidou@gmail.com" Date: Thu, 12 Apr 2012 15:31:46 +0000 Subject: [PATCH] =?UTF-8?q?=E2=80=A2Fixed=20Issue=20440=20and=20made=20sle?= =?UTF-8?q?ep=20work=20as=20intended.=20http://code.google.com/p/tgstation?= =?UTF-8?q?13/issues/detail=3Fid=3D440?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ◘The problem: People being able to move while resting/lying ◘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. git-svn-id: http://tgstation13.googlecode.com/svn/trunk@3442 316c924e-a436-60f5-8080-3fe189b3f50e --- code/modules/chemical/Chemistry-Reagents.dm | 21 +++++++++---------- .../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 | 5 +++-- code/modules/mob/living/carbon/human/emote.dm | 4 +++- code/modules/mob/living/carbon/human/life.dm | 6 +++--- code/modules/mob/living/carbon/monkey/life.dm | 4 ++-- code/modules/mob/screen.dm | 6 +++++- html/changelog.html | 8 +++++++ 12 files changed, 39 insertions(+), 25 deletions(-) diff --git a/code/modules/chemical/Chemistry-Reagents.dm b/code/modules/chemical/Chemistry-Reagents.dm index 842362c5152..061ece24211 100644 --- a/code/modules/chemical/Chemistry-Reagents.dm +++ b/code/modules/chemical/Chemistry-Reagents.dm @@ -394,7 +394,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) @@ -2223,7 +2223,7 @@ datum ..() M.dizziness = max(0,M.dizziness-5) M:drowsyness = max(0,M:drowsyness-3) - 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(5) @@ -2242,7 +2242,7 @@ datum M.dizziness = max(0,M.dizziness-2) M:drowsyness = max(0,M:drowsyness-1) M:jitteriness = max(0,M:jitteriness-3) - M:sleeping = 0 + M:sleeping = max(0,M.sleeping-1) if(M:getToxLoss() && prob(20)) M:adjustToxLoss(-1) if (M.bodytemperature < 310) //310 is the normal bodytemp. 310.055 @@ -2261,7 +2261,7 @@ datum ..() M.dizziness = max(0,M.dizziness-5) M:drowsyness = max(0,M:drowsyness-3) - 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(5) @@ -2279,7 +2279,7 @@ datum ..() M.dizziness = max(0,M.dizziness-2) M:drowsyness = max(0,M:drowsyness-1) - 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 @@ -2313,7 +2313,7 @@ datum M.druggy = max(M.druggy, 30) M.dizziness +=5 M:drowsyness = 0 - 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 @@ -2329,7 +2329,7 @@ datum on_mob_life(var/mob/living/M as mob) M:drowsyness = max(0,M:drowsyness-7) - M:sleeping = 0 + M:sleeping = max(0,M.sleeping-1) if (M.bodytemperature > 310) M.bodytemperature = max(310, M.bodytemperature-5) M.make_jittery(5) @@ -2346,7 +2346,7 @@ datum on_mob_life(var/mob/living/M as mob) M:drowsyness = max(0,M:drowsyness-7) - M:sleeping = 0 + M:sleeping = max(0,M.sleeping-2) if (M.bodytemperature > 310) M.bodytemperature = max(310, M.bodytemperature-5) M.make_jittery(5) @@ -2614,7 +2614,7 @@ datum on_mob_life(var/mob/living/M as mob) M.dizziness = max(0,M.dizziness-5) M:drowsyness = max(0,M:drowsyness-3) - M:sleeping = 0 + M:sleeping = max(0,M.sleeping-2) if (M.bodytemperature > 310) M.bodytemperature = max(310, M.bodytemperature-5) ..() @@ -2630,7 +2630,7 @@ datum on_mob_life(var/mob/living/M as mob) M.dizziness = max(0,M.dizziness-5) M:drowsyness = max(0,M:drowsyness-3) - M:sleeping = 0//Copy-paste from Coffee, derp + M:sleeping = max(0,M.sleeping-2)//Copy-paste from Coffee, derp M.make_jittery(5) ..() return @@ -2703,7 +2703,6 @@ datum on_mob_life(var/mob/living/M as mob) M.dizziness = max(0,M.dizziness-5) M:drowsyness = max(0,M:drowsyness-3) - M:sleeping = 0 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 b7d224dec56..62035c47bdc 100644 --- a/code/modules/mob/living/carbon/alien/humanoid/humanoid.dm +++ b/code/modules/mob/living/carbon/alien/humanoid/humanoid.dm @@ -714,7 +714,7 @@ In all, this is a lot like the monkey code. /N switch(M.a_intent) if ("help") - 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 6760429a780..3e6f48dc1bd 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 e4a5e0a16ae..eb27d1ffe6f 100644 --- a/code/modules/mob/living/carbon/alien/larva/larva.dm +++ b/code/modules/mob/living/carbon/alien/larva/larva.dm @@ -468,7 +468,7 @@ switch(M.a_intent) if ("help") - 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 5f381f75e35..054208e2f08 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 ef7a98d2976..1169c8e6176 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 1bf229c96cb..657ca1c1b57 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -201,8 +201,9 @@ 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 = 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 b8b6f25bbf5..38bcdf6d4c6 100644 --- a/code/modules/mob/living/carbon/human/emote.dm +++ b/code/modules/mob/living/carbon/human/emote.dm @@ -141,7 +141,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 ab9e69eeaef..a74d814447a 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -330,7 +330,7 @@ return null update_canmove() - if(paralysis || stunned || weakened || buckled || (changeling && changeling.changeling_fakedeath)) + if(paralysis || stunned || weakened || resting || buckled || (changeling && changeling.changeling_fakedeath)) canmove = 0 else canmove = 1 @@ -416,7 +416,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, 2) + 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")) @@ -692,7 +692,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 97506dbfbee..d12c4e6b365 100644 --- a/code/modules/mob/living/carbon/monkey/life.dm +++ b/code/modules/mob/living/carbon/monkey/life.dm @@ -328,7 +328,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")) @@ -406,7 +406,7 @@ src.drowsyness-- src.eye_blurry = max(2, src.eye_blurry) if (prob(5)) - src.sleeping = 1 + src.sleeping += 1 Paralyse(5) confused = max(0, confused - 1) diff --git a/code/modules/mob/screen.dm b/code/modules/mob/screen.dm index 6058e70df91..08dc7eb9253 100644 --- a/code/modules/mob/screen.dm +++ b/code/modules/mob/screen.dm @@ -410,9 +410,13 @@ if("pull") usr.pulling = null if("sleep") - usr.sleeping = !( usr.sleeping ) + if(usr.sleeping) + return + else + usr.sleeping = 20 //Short nap if("rest") usr.resting = !( usr.resting ) + //kavala2 if("throw") if (!usr.stat && isturf(usr.loc) && !usr.restrained()) usr:toggle_throw_mode() diff --git a/html/changelog.html b/html/changelog.html index c560ed169ad..9aac8f2d490 100644 --- a/html/changelog.html +++ b/html/changelog.html @@ -93,6 +93,14 @@ Stuff which is in development and not yet visible to players or just code relate should be listed in the changelog upon commit tho. Thanks. --> +
+

Thursday, April 12th

+

Agouri updated:

+ +

Wednesday, April 11th

PolymorphBlue updated: