From aa70b6cffbccb2139f4d5f2d2960c908401a3a02 Mon Sep 17 00:00:00 2001 From: Alberyk Date: Sun, 14 Apr 2019 13:45:45 -0300 Subject: [PATCH] Changes how clumsy checks are handled (#6299) This pr adds the is_clumsy check, that checks if the mob has the mutation or if they are drunk enough. This fixes a bug where mobs would still have the clumsy mutation due to drinking. --- code/game/objects/items/devices/flash.dm | 2 +- code/game/objects/items/devices/flashlight.dm | 4 ++-- code/game/objects/items/devices/scanners.dm | 4 ++-- .../game/objects/items/weapons/grenades/grenade.dm | 2 +- code/game/objects/items/weapons/handcuffs.dm | 2 +- .../game/objects/items/weapons/material/kitchen.dm | 6 +++--- code/game/objects/items/weapons/material/knives.dm | 2 +- code/game/objects/items/weapons/melee/energy.dm | 2 +- code/game/objects/items/weapons/shields.dm | 2 +- code/game/objects/items/weapons/stunbaton.dm | 2 +- code/game/objects/items/weapons/swords_axes_etc.dm | 4 ++-- code/game/objects/items/weapons/tools.dm | 2 +- code/game/objects/items/weapons/trays.dm | 2 +- code/game/objects/items/weapons/weaponry.dm | 2 +- code/modules/assembly/mousetrap.dm | 4 ++-- code/modules/mob/living/carbon/carbon.dm | 1 + code/modules/mob/living/carbon/human/human.dm | 14 +++++++++++++- .../mob/living/carbon/human/intoxication.dm | 4 +--- code/modules/mob/living/living.dm | 2 +- code/modules/mob/living/silicon/robot/analyzer.dm | 2 +- code/modules/mob/mob.dm | 7 +++++++ code/modules/paperwork/paper.dm | 2 +- code/modules/projectiles/gun.dm | 2 +- .../modules/reagents/reagent_containers/inhaler.dm | 2 +- .../reagent_containers/inhaler_advanced.dm | 2 +- .../reagents/reagent_containers/syringes.dm | 2 +- code/modules/virus2/items_devices.dm | 2 +- html/changelogs/alberyk-drinking.yml | 6 ++++++ 28 files changed, 57 insertions(+), 33 deletions(-) create mode 100644 html/changelogs/alberyk-drinking.yml diff --git a/code/game/objects/items/devices/flash.dm b/code/game/objects/items/devices/flash.dm index a9247f91802..37854d80906 100644 --- a/code/game/objects/items/devices/flash.dm +++ b/code/game/objects/items/devices/flash.dm @@ -15,7 +15,7 @@ var/last_used = 0 //last world.time it was used. /obj/item/device/flash/proc/clown_check(var/mob/user) - if(user && (CLUMSY in user.mutations) && prob(50)) + if(user && (user.is_clumsy()) && prob(50)) to_chat(user, "\The [src] slips out of your hand.") user.drop_from_inventory(src) return 0 diff --git a/code/game/objects/items/devices/flashlight.dm b/code/game/objects/items/devices/flashlight.dm index 8de8bba0c01..f97ba4e5b50 100644 --- a/code/game/objects/items/devices/flashlight.dm +++ b/code/game/objects/items/devices/flashlight.dm @@ -48,7 +48,7 @@ add_fingerprint(user) if(on && user.zone_sel.selecting == "eyes") - if(((CLUMSY in user.mutations) || (DUMB in user.mutations)) && prob(50)) //too dumb to use flashlight properly + if(((user.is_clumsy()) || (DUMB in user.mutations)) && prob(50)) //too dumb to use flashlight properly return ..() //just hit them in the head var/mob/living/carbon/human/H = M //mob has protective eyewear @@ -284,7 +284,7 @@ /obj/item/device/flashlight/glowstick/attack_self(var/mob/living/user) - if(((CLUMSY in user.mutations)) && prob(50)) + if(((user.is_clumsy())) && prob(50)) to_chat(user, "You break \the [src] apart, spilling its contents everywhere!") fuel = 0 new /obj/effect/decal/cleanable/greenglow(get_turf(user)) diff --git a/code/game/objects/items/devices/scanners.dm b/code/game/objects/items/devices/scanners.dm index bb6de64ad90..f6926891073 100644 --- a/code/game/objects/items/devices/scanners.dm +++ b/code/game/objects/items/devices/scanners.dm @@ -33,7 +33,7 @@ BREATH ANALYZER return /proc/health_scan_mob(var/mob/living/M, var/mob/living/user, var/visible_msg, var/ignore_clumsiness, var/show_limb_damage = TRUE) - if ( ((CLUMSY in user.mutations) || (DUMB in user.mutations)) && prob(50)) + if ( ((user.is_clumsy()) || (DUMB in user.mutations)) && prob(50)) to_chat(user, text("You try to analyze the floor's vitals!")) for(var/mob/O in viewers(M, null)) O.show_message("\The [user] has analyzed the floor's vitals!", 1) @@ -419,7 +419,7 @@ BREATH ANALYZER to_chat(user,"You can't find a way to use \the [src] on [H]!") return - if ( ((CLUMSY in user.mutations) || (DUMB in user.mutations)) && prob(20)) + if ( ((user.is_clumsy()) || (DUMB in user.mutations)) && prob(20)) to_chat(user,"Your hand slips from clumsiness!") eyestab(H,user) to_chat(user,"Alert: No breathing detected.") diff --git a/code/game/objects/items/weapons/grenades/grenade.dm b/code/game/objects/items/weapons/grenades/grenade.dm index 7d0e69248d6..575bec889b1 100644 --- a/code/game/objects/items/weapons/grenades/grenade.dm +++ b/code/game/objects/items/weapons/grenades/grenade.dm @@ -14,7 +14,7 @@ var/fake = FALSE /obj/item/weapon/grenade/proc/clown_check(var/mob/living/user) - if((CLUMSY in user.mutations) && prob(50)) + if((user.is_clumsy()) && prob(50)) to_chat(user, "Huh? How does this thing work?") activate(user) diff --git a/code/game/objects/items/weapons/handcuffs.dm b/code/game/objects/items/weapons/handcuffs.dm index bb88d670a54..9fd78785401 100644 --- a/code/game/objects/items/weapons/handcuffs.dm +++ b/code/game/objects/items/weapons/handcuffs.dm @@ -24,7 +24,7 @@ if(!user.IsAdvancedToolUser()) return - if ((CLUMSY in user.mutations) && prob(50)) + if ((user.is_clumsy()) && prob(50)) to_chat(user, "Uh ... how do those things work?!") place_handcuffs(user, user) return diff --git a/code/game/objects/items/weapons/material/kitchen.dm b/code/game/objects/items/weapons/material/kitchen.dm index 34a8e44cdd0..55bd1b98bce 100644 --- a/code/game/objects/items/weapons/material/kitchen.dm +++ b/code/game/objects/items/weapons/material/kitchen.dm @@ -29,7 +29,7 @@ if(user.a_intent != I_HELP) if(target_zone == "head" || target_zone == "eyes") - if((CLUMSY in user.mutations) && prob(50)) + if((user.is_clumsy()) && prob(50)) M = user return eyestab(M,user) else @@ -101,7 +101,7 @@ unbreakable = 1 /obj/item/weapon/material/kitchen/utensil/knife/attack(target as mob, mob/living/user as mob, var/target_zone) - if ((CLUMSY in user.mutations) && prob(50)) + if ((user.is_clumsy()) && prob(50)) to_chat(user, "You accidentally cut yourself with \the [src].") user.take_organ_damage(20) return @@ -124,7 +124,7 @@ thrown_force_divisor = 1 // as above /obj/item/weapon/material/kitchen/rollingpin/attack(mob/living/M as mob, mob/living/user as mob, var/target_zone) - if ((CLUMSY in user.mutations) && prob(50)) + if ((user.is_clumsy()) && prob(50)) to_chat(user, "\The [src] slips out of your hand and hits your head.") user.drop_from_inventory(src) user.take_organ_damage(10) diff --git a/code/game/objects/items/weapons/material/knives.dm b/code/game/objects/items/weapons/material/knives.dm index 619f5152e20..965e0c38b5b 100644 --- a/code/game/objects/items/weapons/material/knives.dm +++ b/code/game/objects/items/weapons/material/knives.dm @@ -20,7 +20,7 @@ if(active == 1) if(target_zone != "eyes" && target_zone != "head") return ..() - if((CLUMSY in user.mutations) && prob(50)) + if((user.is_clumsy()) && prob(50)) M = user return eyestab(M,user) diff --git a/code/game/objects/items/weapons/melee/energy.dm b/code/game/objects/items/weapons/melee/energy.dm index b366483d8af..4eab083b0b2 100644 --- a/code/game/objects/items/weapons/melee/energy.dm +++ b/code/game/objects/items/weapons/melee/energy.dm @@ -39,7 +39,7 @@ /obj/item/weapon/melee/energy/attack_self(mob/living/user as mob) if (active) - if ((CLUMSY in user.mutations) && prob(50)) + if ((user.is_clumsy()) && prob(50)) user.visible_message("\The [user] accidentally cuts \himself with \the [src].",\ "You accidentally cut yourself with \the [src].") user.take_organ_damage(5,5) diff --git a/code/game/objects/items/weapons/shields.dm b/code/game/objects/items/weapons/shields.dm index e6fc0aa4e0f..60e3fe46684 100644 --- a/code/game/objects/items/weapons/shields.dm +++ b/code/game/objects/items/weapons/shields.dm @@ -194,7 +194,7 @@ return base_block_chance /obj/item/weapon/shield/energy/attack_self(mob/living/user as mob) - if ((CLUMSY in user.mutations) && prob(50)) + if ((user.is_clumsy()) && prob(50)) to_chat(user, "You beat yourself in the head with [src].") user.take_organ_damage(5) active = !active diff --git a/code/game/objects/items/weapons/stunbaton.dm b/code/game/objects/items/weapons/stunbaton.dm index 507b61c0b8d..359a04c0644 100644 --- a/code/game/objects/items/weapons/stunbaton.dm +++ b/code/game/objects/items/weapons/stunbaton.dm @@ -102,7 +102,7 @@ /obj/item/weapon/melee/baton/attack(mob/living/L, mob/user, var/hit_zone) if(!L) return - if(status && (CLUMSY in user.mutations) && prob(50)) + if(status && (user.is_clumsy()) && prob(50)) to_chat(user, "You accidentally hit yourself with the [src]!") user.Weaken(30) deductcharge(hitcost) diff --git a/code/game/objects/items/weapons/swords_axes_etc.dm b/code/game/objects/items/weapons/swords_axes_etc.dm index a99b18aac58..f6a06260ab9 100644 --- a/code/game/objects/items/weapons/swords_axes_etc.dm +++ b/code/game/objects/items/weapons/swords_axes_etc.dm @@ -18,7 +18,7 @@ force = 10 /obj/item/weapon/melee/classic_baton/attack(mob/M as mob, mob/living/user as mob, var/target_zone) - if ((CLUMSY in user.mutations) && prob(50)) + if ((user.is_clumsy()) && prob(50)) to_chat(user, "You club yourself over the head.") user.Weaken(3 * force) if(ishuman(user)) @@ -85,7 +85,7 @@ /obj/item/weapon/melee/telebaton/attack(mob/target as mob, mob/living/user as mob, var/target_zone) if(on) - if ((CLUMSY in user.mutations) && prob(50)) + if ((user.is_clumsy()) && prob(50)) to_chat(user, "You club yourself over the head.") user.Weaken(3 * force) if(ishuman(user)) diff --git a/code/game/objects/items/weapons/tools.dm b/code/game/objects/items/weapons/tools.dm index 3ec5f4343bf..6906b95ffb4 100644 --- a/code/game/objects/items/weapons/tools.dm +++ b/code/game/objects/items/weapons/tools.dm @@ -89,7 +89,7 @@ return ..() if(target_zone != "eyes" && target_zone != "head") return ..() - if((CLUMSY in user.mutations) && prob(50)) + if((user.is_clumsy()) && prob(50)) M = user return eyestab(M,user) diff --git a/code/game/objects/items/weapons/trays.dm b/code/game/objects/items/weapons/trays.dm index 26ec7df0712..3225b4efd53 100644 --- a/code/game/objects/items/weapons/trays.dm +++ b/code/game/objects/items/weapons/trays.dm @@ -41,7 +41,7 @@ spill(user, M.loc) //Note: Added a robot check to all stun/weaken procs, beccause weakening a robot causes its active modules to bug out - if((CLUMSY in user.mutations) && prob(50)) //What if he's a clown? + if((user.is_clumsy()) && prob(50)) //What if he's a clown? to_chat(M, "You accidentally slam yourself with the [src]!") if (!issilicon(M)) M.Weaken(1) diff --git a/code/game/objects/items/weapons/weaponry.dm b/code/game/objects/items/weapons/weaponry.dm index 6de65dd6b14..56cace95403 100644 --- a/code/game/objects/items/weapons/weaponry.dm +++ b/code/game/objects/items/weapons/weaponry.dm @@ -72,7 +72,7 @@ to_chat(user, "You don't have the dexterity to do this!") return - if ((CLUMSY in user.mutations) && prob(50)) + if ((user.is_clumsy()) && prob(50)) to_chat(user, "The rod slips out of your hand and hits your head.") user.take_organ_damage(10) user.Paralyse(20) diff --git a/code/modules/assembly/mousetrap.dm b/code/modules/assembly/mousetrap.dm index ed0bec32312..58a1ecbcf1f 100644 --- a/code/modules/assembly/mousetrap.dm +++ b/code/modules/assembly/mousetrap.dm @@ -58,7 +58,7 @@ if(!armed) to_chat(user, "You arm [src].") else - if(((CLUMSY in user.mutations) || (DUMB in user.mutations)) && prob(50)) + if(((user.is_clumsy()) || (DUMB in user.mutations)) && prob(50)) var/which_hand = "l_hand" if(!user.hand) which_hand = "r_hand" @@ -74,7 +74,7 @@ /obj/item/device/assembly/mousetrap/attack_hand(mob/living/user as mob) if(armed) - if(((CLUMSY in user.mutations) || (DUMB in user.mutations)) && prob(50)) + if(((user.is_clumsy()) || (DUMB in user.mutations)) && prob(50)) var/which_hand = "l_hand" if(!user.hand) which_hand = "r_hand" diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index 191aa8191f5..885fb7acfd4 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -460,3 +460,4 @@ return FALSE return TRUE + diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index b907741f1ee..cedd2dcf75c 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -1599,4 +1599,16 @@ . = B.cure_all_traumas(cure_permanent, cure_type) /mob/living/carbon/human/get_metabolism(metabolism) - return ..() * (species ? species.metabolism_mod : 1) \ No newline at end of file + return ..() * (species ? species.metabolism_mod : 1) + +/mob/living/carbon/human/is_clumsy() + if(CLUMSY in mutations) + return TRUE + + var/bac = get_blood_alcohol() + var/SR = species.ethanol_resistance + + if(bac > INTOX_REACTION*SR) + return TRUE + + return FALSE \ No newline at end of file diff --git a/code/modules/mob/living/carbon/human/intoxication.dm b/code/modules/mob/living/carbon/human/intoxication.dm index f4c3123ae58..4e2ea28fa1f 100644 --- a/code/modules/mob/living/carbon/human/intoxication.dm +++ b/code/modules/mob/living/carbon/human/intoxication.dm @@ -44,12 +44,10 @@ var/mob/living/carbon/human/alcohol_clumsy = 0 to_chat(src,"You feel uncoordinated and unsteady on your feet!") confused = max(confused, 10) slurring = max(slurring, 50) - if (!alcohol_clumsy && !(CLUMSY in mutations)) - mutations.Add(CLUMSY) + if (!alcohol_clumsy) alcohol_clumsy = 1 else if (alcohol_clumsy) to_chat(src,"You feel more sober and steady.") - mutations.Remove(CLUMSY) alcohol_clumsy = 0 if(bac > INTOX_VOMIT*SR) diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index 8f69800d09e..056c06c7777 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -837,4 +837,4 @@ default behaviour is: stomach_contents = null QDEL_NULL(ingested) - return ..() \ No newline at end of file + return ..() diff --git a/code/modules/mob/living/silicon/robot/analyzer.dm b/code/modules/mob/living/silicon/robot/analyzer.dm index 896fc025875..561a8f52a83 100644 --- a/code/modules/mob/living/silicon/robot/analyzer.dm +++ b/code/modules/mob/living/silicon/robot/analyzer.dm @@ -17,7 +17,7 @@ var/mode = 1; /obj/item/device/robotanalyzer/attack(mob/living/M as mob, mob/living/user as mob) - if( ((CLUMSY in user.mutations) || (DUMB in user.mutations)) && prob(50)) + if( ((user.is_clumsy()) || (DUMB in user.mutations)) && prob(50)) to_chat(user, text("You try to analyze the floor's vitals!")) for(var/mob/O in viewers(M, null)) O.show_message(text("[user] has analyzed the floor's vitals!"), 1) diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 3ce8b7aff0c..b0b0c7911bc 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -1286,6 +1286,13 @@ mob/proc/yank_out_object() return + +/mob/proc/is_clumsy() + if(CLUMSY in mutations) + return TRUE + + return FALSE + //Helper proc for figuring out if the active hand (or given hand) is usable. /mob/proc/can_use_hand() return 1 diff --git a/code/modules/paperwork/paper.dm b/code/modules/paperwork/paper.dm index a6283f8c346..2a91ebe53e3 100644 --- a/code/modules/paperwork/paper.dm +++ b/code/modules/paperwork/paper.dm @@ -111,7 +111,7 @@ set category = "Object" set src in usr - if((CLUMSY in usr.mutations) && prob(50)) + if((usr.is_clumsy()) && prob(50)) to_chat(usr, span("warning", "You cut yourself on the paper.")) return var/n_name = sanitizeSafe(input(usr, "What would you like to label the paper?", "Paper Labelling", null) as text, MAX_NAME_LEN) diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm index d1f7c6ef243..f7aba636edc 100644 --- a/code/modules/projectiles/gun.dm +++ b/code/modules/projectiles/gun.dm @@ -142,7 +142,7 @@ to_chat(A, "[A.martial_art.no_guns_message]") return 0 - if((CLUMSY in M.mutations) && prob(40)) //Clumsy handling + if((M.is_clumsy()) && prob(40)) //Clumsy handling var/obj/P = consume_next_projectile() if(P) if(process_projectile(P, user, user, pick("l_foot", "r_foot"))) diff --git a/code/modules/reagents/reagent_containers/inhaler.dm b/code/modules/reagents/reagent_containers/inhaler.dm index 115879182d2..06320401589 100644 --- a/code/modules/reagents/reagent_containers/inhaler.dm +++ b/code/modules/reagents/reagent_containers/inhaler.dm @@ -34,7 +34,7 @@ to_chat(user,"\The [src] is empty.") return - if ( ((CLUMSY in user.mutations) || (DUMB in user.mutations)) && prob(10)) + if ( ((user.is_clumsy()) || (DUMB in user.mutations)) && prob(10)) to_chat(user,"Your hand slips from clumsiness!") eyestab(H,user) if(H.reagents) diff --git a/code/modules/reagents/reagent_containers/inhaler_advanced.dm b/code/modules/reagents/reagent_containers/inhaler_advanced.dm index 62071dc9807..91642c0d063 100644 --- a/code/modules/reagents/reagent_containers/inhaler_advanced.dm +++ b/code/modules/reagents/reagent_containers/inhaler_advanced.dm @@ -110,7 +110,7 @@ to_chat(user,"\The [src]'s cartridge is empty!") return - if (((CLUMSY in user.mutations) || (DUMB in user.mutations)) && prob(10)) + if (((user.is_clumsy()) || (DUMB in user.mutations)) && prob(10)) to_chat(user,"Your hand slips from clumsiness!") eyestab(M,user) user.visible_message("[user] accidentally sticks \the [src] in [M]'s eye!","You accidentally stick the [src] in [M]'s eye!") diff --git a/code/modules/reagents/reagent_containers/syringes.dm b/code/modules/reagents/reagent_containers/syringes.dm index e694896d949..84d5e2cee59 100644 --- a/code/modules/reagents/reagent_containers/syringes.dm +++ b/code/modules/reagents/reagent_containers/syringes.dm @@ -63,7 +63,7 @@ return if(user.a_intent == I_HURT && ishuman(user)) - if((CLUMSY in user.mutations) && prob(50)) + if((user.is_clumsy()) && prob(50)) target = user syringestab(target, user) return diff --git a/code/modules/virus2/items_devices.dm b/code/modules/virus2/items_devices.dm index 1ad7829b69a..07cbded8ad4 100644 --- a/code/modules/virus2/items_devices.dm +++ b/code/modules/virus2/items_devices.dm @@ -24,7 +24,7 @@ report("Scan Complete: No antibodies detected.", user) return - if (CLUMSY in user.mutations && prob(50)) + if (user.is_clumsy() && prob(50)) // I was tempted to be really evil and rot13 the output. report("Antibodies detected: [reverse_text(antigens2string(C.antibodies))]", user) else diff --git a/html/changelogs/alberyk-drinking.yml b/html/changelogs/alberyk-drinking.yml new file mode 100644 index 00000000000..17629f9bf0e --- /dev/null +++ b/html/changelogs/alberyk-drinking.yml @@ -0,0 +1,6 @@ +author: Alberyk + +delete-after: True + +changes: + - bugfix: "Clumsy drunkness should no longer stay forever."