From 58c054acb511ecf0e56a955635a64a8064fdd833 Mon Sep 17 00:00:00 2001 From: Joan Lung Date: Wed, 21 Jun 2017 20:50:46 -0400 Subject: [PATCH] Stun is now a status effect (#28654) * Stun is now a status effect * I'D RATHER NOT * smart * very smart * pideyview * small fixes * slight fix --- code/__DEFINES/status_effects.dm | 2 + code/__HELPERS/mobs.dm | 2 +- code/_onclick/cyborg.dm | 2 +- code/_onclick/hud/screen_objects.dm | 2 +- code/datums/action.dm | 2 +- code/datums/martial/sleeping_carp.dm | 2 +- code/datums/status_effects/debuffs.dm | 4 + code/game/gamemodes/gang/recaller.dm | 2 +- code/game/gamemodes/wizard/spellbook.dm | 4 +- code/game/machinery/computer/arcade.dm | 4 +- code/game/mecha/mecha.dm | 2 +- .../objects/items/weapons/storage/backpack.dm | 4 +- code/game/objects/items/weapons/tools.dm | 4 +- code/game/objects/structures.dm | 2 +- .../crates_lockers/closets/cardboardbox.dm | 2 +- code/modules/assembly/flash.dm | 16 +-- code/modules/mining/lavaland/ruins/gym.dm | 4 +- .../living/carbon/alien/larva/update_icons.dm | 4 +- code/modules/mob/living/carbon/human/human.dm | 2 +- .../mob/living/carbon/human/human_defense.dm | 4 +- .../mob/living/carbon/human/interactive.dm | 6 +- .../carbon/human/species_types/angel.dm | 2 +- .../mob/living/carbon/monkey/combat.dm | 2 +- code/modules/mob/living/death.dm | 1 - code/modules/mob/living/life.dm | 4 +- code/modules/mob/living/living.dm | 41 ++++++- .../modules/mob/living/silicon/robot/robot.dm | 4 +- .../mob/living/simple_animal/bot/ed209bot.dm | 2 +- .../mob/living/simple_animal/bot/medbot.dm | 23 ++-- .../mob/living/simple_animal/bot/secbot.dm | 2 +- .../mob/living/simple_animal/simple_animal.dm | 2 +- code/modules/mob/mob.dm | 52 +-------- code/modules/mob/mob_defines.dm | 1 - code/modules/mob/status_procs.dm | 106 +++++++++++++----- code/modules/mob/transform_procs.dm | 4 +- code/modules/paperwork/paperplane.dm | 2 +- .../surgery/organs/augments_internal.dm | 2 +- 37 files changed, 183 insertions(+), 143 deletions(-) diff --git a/code/__DEFINES/status_effects.dm b/code/__DEFINES/status_effects.dm index e8a8155012a..77b8b2194b2 100644 --- a/code/__DEFINES/status_effects.dm +++ b/code/__DEFINES/status_effects.dm @@ -30,6 +30,8 @@ // DEBUFFS // ///////////// +#define STATUS_EFFECT_STUN /datum/status_effect/incapacitating/stun //the affected is stunned + #define STATUS_EFFECT_SLEEPING /datum/status_effect/incapacitating/sleeping //the affected is asleep #define STATUS_EFFECT_BELLIGERENT /datum/status_effect/belligerent //forces the affected to walk, doing damage if they try to run diff --git a/code/__HELPERS/mobs.dm b/code/__HELPERS/mobs.dm index dfac9303e54..d14d68f7844 100644 --- a/code/__HELPERS/mobs.dm +++ b/code/__HELPERS/mobs.dm @@ -307,7 +307,7 @@ Proc for attack log creation, because really why not drifting = 0 Uloc = user.loc - if(QDELETED(user) || user.stat || user.knockdown || user.stun || (!drifting && user.loc != Uloc) || (extra_checks && !extra_checks.Invoke())) + if(QDELETED(user) || user.stat || user.knockdown || user.IsStun() || (!drifting && user.loc != Uloc) || (extra_checks && !extra_checks.Invoke())) . = 0 break diff --git a/code/_onclick/cyborg.dm b/code/_onclick/cyborg.dm index 5a0f3f6ed1f..b7420da923c 100644 --- a/code/_onclick/cyborg.dm +++ b/code/_onclick/cyborg.dm @@ -15,7 +15,7 @@ if(call(client.click_intercept,"InterceptClickOn")(src,params,A)) return - if(stat || lockcharge || knockdown || stun || unconscious) + if(stat || lockcharge || knockdown || IsStun() || unconscious) return var/list/modifiers = params2list(params) diff --git a/code/_onclick/hud/screen_objects.dm b/code/_onclick/hud/screen_objects.dm index 236fb7b637f..8a98a5943e7 100644 --- a/code/_onclick/hud/screen_objects.dm +++ b/code/_onclick/hud/screen_objects.dm @@ -348,7 +348,7 @@ /obj/screen/storage/Click(location, control, params) if(world.time <= usr.next_move) return 1 - if(usr.stat || usr.unconscious || usr.stun || usr.knockdown) + if(usr.stat || usr.unconscious || usr.knockdown || usr.IsStun()) return 1 if (istype(usr.loc,/obj/mecha)) // stops inventory actions in a mech return 1 diff --git a/code/datums/action.dm b/code/datums/action.dm index e51029113ef..cee2d2c6121 100644 --- a/code/datums/action.dm +++ b/code/datums/action.dm @@ -73,7 +73,7 @@ if(owner.restrained()) return 0 if(check_flags & AB_CHECK_STUN) - if(owner.stun || owner.knockdown) + if(owner.knockdown || owner.IsStun()) return 0 if(check_flags & AB_CHECK_LYING) if(owner.lying) diff --git a/code/datums/martial/sleeping_carp.dm b/code/datums/martial/sleeping_carp.dm index 348b2c35af1..6c545153f5b 100644 --- a/code/datums/martial/sleeping_carp.dm +++ b/code/datums/martial/sleeping_carp.dm @@ -35,7 +35,7 @@ return 0 /datum/martial_art/the_sleeping_carp/proc/wristWrench(mob/living/carbon/human/A, mob/living/carbon/human/D) - if(!D.stat && !D.stun && !D.knockdown) + if(!D.stat && !D.IsStun() && !D.knockdown) A.do_attack_animation(D, ATTACK_EFFECT_PUNCH) D.visible_message("[A] grabs [D]'s wrist and wrenches it sideways!", \ "[A] grabs your wrist and violently wrenches it to the side!") diff --git a/code/datums/status_effects/debuffs.dm b/code/datums/status_effects/debuffs.dm index fdef66dc333..b752696bf07 100644 --- a/code/datums/status_effects/debuffs.dm +++ b/code/datums/status_effects/debuffs.dm @@ -16,6 +16,10 @@ if(update_canmove) owner.update_canmove() +//STUN +/datum/status_effect/incapacitating/stun + id = "stun" + //SLEEPING /datum/status_effect/incapacitating/sleeping id = "sleeping" diff --git a/code/game/gamemodes/gang/recaller.dm b/code/game/gamemodes/gang/recaller.dm index 92a3993ada0..c06f935603b 100644 --- a/code/game/gamemodes/gang/recaller.dm +++ b/code/game/gamemodes/gang/recaller.dm @@ -226,7 +226,7 @@ /obj/item/device/gangtool/proc/can_use(mob/living/carbon/human/user) if(!istype(user)) return 0 - if(user.restrained() || user.lying || user.stat || user.stun || user.knockdown) + if(user.restrained() || user.lying || user.stat || user.IsStun() || user.knockdown) return 0 if(!(src in user.contents)) return 0 diff --git a/code/game/gamemodes/wizard/spellbook.dm b/code/game/gamemodes/wizard/spellbook.dm index ef2015777df..d1c2fa2c0d2 100644 --- a/code/game/gamemodes/wizard/spellbook.dm +++ b/code/game/gamemodes/wizard/spellbook.dm @@ -838,10 +838,10 @@ icon_state ="bookforcewall" desc = "This book has a dedication to mimes everywhere inside the front cover." -/obj/item/weapon/spellbook/oneuse/forcewall/recoil(mob/user) +/obj/item/weapon/spellbook/oneuse/forcewall/recoil(mob/living/user) ..() to_chat(user,"You suddenly feel very solid!") - user.Stun(40) + user.Stun(40, ignore_canstun = TRUE) user.petrify(30) /obj/item/weapon/spellbook/oneuse/knock diff --git a/code/game/machinery/computer/arcade.dm b/code/game/machinery/computer/arcade.dm index 5798797d576..5617c41202b 100644 --- a/code/game/machinery/computer/arcade.dm +++ b/code/game/machinery/computer/arcade.dm @@ -618,7 +618,9 @@ if(emagged) //has to be here because otherwise it doesn't work playsound(loc, 'sound/effects/supermatter.ogg', 100, 1) say("A miniature black hole suddenly appears in front of [src], devouring [usr] alive!") - usr.Stun(200) //you can't run :^) + if(isliving(usr)) + var/mob/living/L = usr + L.Stun(200, ignore_canstun = TRUE) //you can't run :^) var/S = new /obj/singularity/academy(usr.loc) emagged = 0 //immediately removes emagged status so people can't kill themselves by sprinting up and interacting sleep(50) diff --git a/code/game/mecha/mecha.dm b/code/game/mecha/mecha.dm index 79ea560bb1c..d360be0f730 100644 --- a/code/game/mecha/mecha.dm +++ b/code/game/mecha/mecha.dm @@ -905,7 +905,7 @@ if(!user.transferItemToLoc(mmi_as_oc, src)) to_chat(user, "\the [mmi_as_oc] is stuck to your hand, you cannot put it in \the [src]!") return FALSE - var/mob/brainmob = mmi_as_oc.brainmob + var/mob/living/brainmob = mmi_as_oc.brainmob mmi_as_oc.mecha = src occupant = brainmob brainmob.forceMove(src) //should allow relaymove diff --git a/code/game/objects/items/weapons/storage/backpack.dm b/code/game/objects/items/weapons/storage/backpack.dm index cbc5fcfe991..14789a0268e 100644 --- a/code/game/objects/items/weapons/storage/backpack.dm +++ b/code/game/objects/items/weapons/storage/backpack.dm @@ -41,10 +41,10 @@ armor = list(melee = 0, bullet = 0, laser = 0, energy = 0, bomb = 0, bio = 0, rad = 0, fire = 60, acid = 50) -/obj/item/weapon/storage/backpack/holding/suicide_act(mob/user) +/obj/item/weapon/storage/backpack/holding/suicide_act(mob/living/user) user.visible_message("[user] is jumping into [src]! It looks like [user.p_theyre()] trying to commit suicide.") user.drop_item() - user.Stun(100) + user.Stun(100, ignore_canstun = TRUE) sleep(20) playsound(src, "rustle", 50, 1, -5) qdel(user) diff --git a/code/game/objects/items/weapons/tools.dm b/code/game/objects/items/weapons/tools.dm index 5fcaa450249..5edea69c19f 100755 --- a/code/game/objects/items/weapons/tools.dm +++ b/code/game/objects/items/weapons/tools.dm @@ -91,13 +91,13 @@ origin_tech = "materials=1;engineering=1;biotech=3" attack_verb = list("wrenched", "medicaled", "tapped", "jabbed", "whacked") -/obj/item/weapon/wrench/medical/suicide_act(mob/user) +/obj/item/weapon/wrench/medical/suicide_act(mob/living/user) user.visible_message("[user] is praying to the medical wrench to take [user.p_their()] soul. It looks like [user.p_theyre()] trying to commit suicide!") // TODO Make them glow with the power of the M E D I C A L W R E N C H // during their ascension // Stun stops them from wandering off - user.Stun(100) + user.Stun(100, ignore_canstun = TRUE) playsound(loc, 'sound/effects/pray.ogg', 50, 1, -1) // Let the sound effect finish playing diff --git a/code/game/objects/structures.dm b/code/game/objects/structures.dm index 1b96a334825..2fa19570bf9 100644 --- a/code/game/objects/structures.dm +++ b/code/game/objects/structures.dm @@ -68,7 +68,7 @@ . = step(A,get_dir(A,src.loc)) density = 1 -/obj/structure/proc/climb_structure(mob/user) +/obj/structure/proc/climb_structure(mob/living/user) src.add_fingerprint(user) user.visible_message("[user] starts climbing onto [src].", \ "You start climbing onto [src]...") diff --git a/code/game/objects/structures/crates_lockers/closets/cardboardbox.dm b/code/game/objects/structures/crates_lockers/closets/cardboardbox.dm index b186cc5e03a..82e988c1fb5 100644 --- a/code/game/objects/structures/crates_lockers/closets/cardboardbox.dm +++ b/code/game/objects/structures/crates_lockers/closets/cardboardbox.dm @@ -20,7 +20,7 @@ var/egged = 0 /obj/structure/closet/cardboard/relaymove(mob/user, direction) - if(opened || move_delay || user.stat || user.stun || user.knockdown || user.unconscious || !isturf(loc) || !has_gravity(loc)) + if(opened || move_delay || user.stat || user.IsStun() || user.knockdown || user.unconscious || !isturf(loc) || !has_gravity(loc)) return move_delay = 1 if(step(src, direction)) diff --git a/code/modules/assembly/flash.dm b/code/modules/assembly/flash.dm index 2fe1dd4c050..5c4e3087707 100644 --- a/code/modules/assembly/flash.dm +++ b/code/modules/assembly/flash.dm @@ -142,17 +142,17 @@ ..() -/obj/item/device/assembly/flash/proc/terrible_conversion_proc(mob/M, mob/user) - if(ishuman(M) && ishuman(user) && M.stat != DEAD) +/obj/item/device/assembly/flash/proc/terrible_conversion_proc(mob/living/carbon/human/H, mob/user) + if(istype(H) && ishuman(user) && H.stat != DEAD) if(user.mind && (user.mind in SSticker.mode.head_revolutionaries)) - if(M.client) - if(M.stat == CONSCIOUS) - M.mind_initialize() //give them a mind datum if they don't have one. + if(H.client) + if(H.stat == CONSCIOUS) + H.mind_initialize() //give them a mind datum if they don't have one. var/resisted - if(!M.isloyal()) + if(!H.isloyal()) if(user.mind in SSticker.mode.head_revolutionaries) - if(SSticker.mode.add_revolutionary(M.mind)) - M.Stun(60) + if(SSticker.mode.add_revolutionary(H.mind)) + H.Stun(60) times_used -- //Flashes less likely to burn out for headrevs when used for conversion else resisted = 1 diff --git a/code/modules/mining/lavaland/ruins/gym.dm b/code/modules/mining/lavaland/ruins/gym.dm index 1c3fa57d84f..8ca16b8dfb8 100644 --- a/code/modules/mining/lavaland/ruins/gym.dm +++ b/code/modules/mining/lavaland/ruins/gym.dm @@ -20,7 +20,7 @@ density = 1 anchored = 1 -/obj/structure/stacklifter/attack_hand(mob/user as mob) +/obj/structure/stacklifter/attack_hand(mob/living/user) if(in_use) to_chat(user, "It's already in use - wait a bit.") return @@ -58,7 +58,7 @@ density = 1 anchored = 1 -/obj/structure/weightlifter/attack_hand(mob/user as mob) +/obj/structure/weightlifter/attack_hand(mob/living/user) if(in_use) to_chat(user, "It's already in use - wait a bit.") return diff --git a/code/modules/mob/living/carbon/alien/larva/update_icons.dm b/code/modules/mob/living/carbon/alien/larva/update_icons.dm index dbe2237459e..7897cbf9693 100644 --- a/code/modules/mob/living/carbon/alien/larva/update_icons.dm +++ b/code/modules/mob/living/carbon/alien/larva/update_icons.dm @@ -12,11 +12,11 @@ if(stat == DEAD) icon_state = "larva[state]_dead" - else if (handcuffed || legcuffed) //This should be an overlay. Who made this an icon_state? + else if(handcuffed || legcuffed) //This should be an overlay. Who made this an icon_state? icon_state = "larva[state]_cuff" else if(stat == UNCONSCIOUS || lying || resting) icon_state = "larva[state]_sleep" - else if (stun) + else if(IsStun()) icon_state = "larva[state]_stun" else icon_state = "larva[state]" diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index 6f8fc6dbebf..8c3e42f394c 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -501,7 +501,7 @@ to_chat(usr, "Unable to locate a data core entry for this person.") /mob/living/carbon/human/proc/canUseHUD() - return !(src.stat || src.knockdown || src.stun || src.restrained()) + return !(src.stat || src.knockdown || IsStun() || src.restrained()) /mob/living/carbon/human/can_inject(mob/user, error_msg, target_zone, var/penetrate_thick = 0) . = 1 // Default to returning true. diff --git a/code/modules/mob/living/carbon/human/human_defense.dm b/code/modules/mob/living/carbon/human/human_defense.dm index 239edb959f0..feb9e783ac1 100644 --- a/code/modules/mob/living/carbon/human/human_defense.dm +++ b/code/modules/mob/living/carbon/human/human_defense.dm @@ -105,9 +105,7 @@ /mob/living/carbon/human/proc/check_block() if(mind) - if(mind.martial_art && mind.martial_art.block_chance \ - && prob(mind.martial_art.block_chance) && in_throw_mode \ - && !stat && !knockdown && !stun) + if(mind.martial_art && prob(mind.martial_art.block_chance) && in_throw_mode && !stat && !knockdown && !IsStun()) return TRUE return FALSE diff --git a/code/modules/mob/living/carbon/human/interactive.dm b/code/modules/mob/living/carbon/human/interactive.dm index 7296c0680ee..90b843cbb61 100644 --- a/code/modules/mob/living/carbon/human/interactive.dm +++ b/code/modules/mob/living/carbon/human/interactive.dm @@ -452,7 +452,7 @@ return 1 if(unconscious) return 1 - if(stun) + if(IsStun()) return 1 if(stat) return 1 @@ -1536,8 +1536,8 @@ if(ispath(A,/obj/item/ammo_casing/energy/electrode)) stunning = 1 var/shouldFire = 1 - var/mob/stunCheck = TARGET - if(stunning && stunCheck.stun) + var/mob/living/stunCheck = TARGET + if(stunning && isliving(stunCheck) && stunCheck.IsStun()) shouldFire = 0 if(shouldFire) if(P.cell.charge <= 10) // can shoot seems to bug out for tasers, using this hacky method instead diff --git a/code/modules/mob/living/carbon/human/species_types/angel.dm b/code/modules/mob/living/carbon/human/species_types/angel.dm index 08bd615ed7c..c420c087a6d 100644 --- a/code/modules/mob/living/carbon/human/species_types/angel.dm +++ b/code/modules/mob/living/carbon/human/species_types/angel.dm @@ -47,7 +47,7 @@ return 0 /datum/species/angel/proc/CanFly(mob/living/carbon/human/H) - if(H.stat || H.stun || H.knockdown) + if(H.stat || H.IsStun() || H.knockdown) return 0 if(H.wear_suit && ((H.wear_suit.flags_inv & HIDEJUMPSUIT) && (!H.wear_suit.species_exception || !is_type_in_list(src, H.wear_suit.species_exception)))) //Jumpsuits have tail holes, so it makes sense they have wing holes too to_chat(H, "Your suit blocks your wings from extending!") diff --git a/code/modules/mob/living/carbon/monkey/combat.dm b/code/modules/mob/living/carbon/monkey/combat.dm index af1b0c0db30..75ffdea8310 100644 --- a/code/modules/mob/living/carbon/monkey/combat.dm +++ b/code/modules/mob/living/carbon/monkey/combat.dm @@ -55,7 +55,7 @@ return 1 if(unconscious) return 1 - if(stun) + if(IsStun()) return 1 if(stat) return 1 diff --git a/code/modules/mob/living/death.dm b/code/modules/mob/living/death.dm index 597a92261e3..131e035010d 100644 --- a/code/modules/mob/living/death.dm +++ b/code/modules/mob/living/death.dm @@ -61,7 +61,6 @@ if(!gibbed) GLOB.dead_mob_list += src unconscious = 0 - stun = 0 knockdown = 0 set_drugginess(0) SetSleeping(0, 0) diff --git a/code/modules/mob/living/life.dm b/code/modules/mob/living/life.dm index 03d31fa4f2c..0cca6184b40 100644 --- a/code/modules/mob/living/life.dm +++ b/code/modules/mob/living/life.dm @@ -97,10 +97,8 @@ /mob/living/proc/handle_stomach() return -//this updates all special effects: stun, sleeping, knockdown, druggy, stuttering, etc.. +//this updates all special effects: knockdown, druggy, stuttering, etc.. /mob/living/proc/handle_status_effects() - if(stun) - AdjustStun(-20, 1, 1) if(knockdown) AdjustKnockdown(-20, 1, 1) if(unconscious) diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index b5aafeef138..3e95820b216 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -237,7 +237,7 @@ death() /mob/living/incapacitated(ignore_restraints, ignore_grab) - if(stat || unconscious || stun || knockdown || (!ignore_restraints && restrained(ignore_grab))) + if(stat || unconscious || IsStun() || knockdown || (!ignore_restraints && restrained(ignore_grab))) return 1 /mob/living/proc/InCritical() @@ -931,3 +931,42 @@ /mob/living/can_be_pulled() return ..() && !(buckled && buckled.buckle_prevents_pull) + +//Updates canmove, lying and icons. Could perhaps do with a rename but I can't think of anything to describe it. +//Robots, animals and brains have their own version so don't worry about them +/mob/living/proc/update_canmove() + var/ko = knockdown || unconscious || stat || (status_flags & FAKEDEATH) + var/chokehold = pulledby && pulledby.grab_state >= GRAB_NECK + var/buckle_lying = !(buckled && !buckled.buckle_lying) + var/has_legs = get_num_legs() + var/has_arms = get_num_arms() + var/ignore_legs = get_leg_ignore() + if(ko || resting || has_status_effect(STATUS_EFFECT_STUN) || chokehold) + drop_all_held_items() + unset_machine() + if(pulling) + stop_pulling() + else if(has_legs || ignore_legs) + lying = 0 + + if(buckled) + lying = 90*buckle_lying + else if(!lying) + if(resting) + fall() + else if(ko || (!has_legs && !ignore_legs) || chokehold) + fall(forced = 1) + canmove = !(ko || resting || has_status_effect(STATUS_EFFECT_STUN) || has_status_effect(/datum/status_effect/freon) || chokehold || buckled || (!has_legs && !ignore_legs && !has_arms)) + density = !lying + if(lying) + if(layer == initial(layer)) //to avoid special cases like hiding larvas. + layer = LYING_MOB_LAYER //so mob lying always appear behind standing mobs + else + if(layer == LYING_MOB_LAYER) + layer = initial(layer) + update_transform() + if(!lying && lying_prev) + if(client) + client.move_delay = world.time + movement_delay() + lying_prev = lying + return canmove diff --git a/code/modules/mob/living/silicon/robot/robot.dm b/code/modules/mob/living/silicon/robot/robot.dm index 931e80689bf..6b4b552b38b 100644 --- a/code/modules/mob/living/silicon/robot/robot.dm +++ b/code/modules/mob/living/silicon/robot/robot.dm @@ -591,7 +591,7 @@ /mob/living/silicon/robot/update_icons() cut_overlays() icon_state = module.cyborg_base_icon - if(stat != DEAD && !(unconscious || stun || knockdown || low_power_mode)) //Not dead, not stunned. + if(stat != DEAD && !(unconscious || IsStun() || knockdown || low_power_mode)) //Not dead, not stunned. if(!eye_lights) eye_lights = new() if(lamp_intensity > 2) @@ -917,7 +917,7 @@ if(health <= -maxHealth) //die only once death() return - if(unconscious || stun || knockdown || getOxyLoss() > maxHealth*0.5) + if(unconscious || IsStun() || knockdown || getOxyLoss() > maxHealth*0.5) if(stat == CONSCIOUS) stat = UNCONSCIOUS blind_eyes(1) diff --git a/code/modules/mob/living/simple_animal/bot/ed209bot.dm b/code/modules/mob/living/simple_animal/bot/ed209bot.dm index a49e917e4a3..52ebdbb2507 100644 --- a/code/modules/mob/living/simple_animal/bot/ed209bot.dm +++ b/code/modules/mob/living/simple_animal/bot/ed209bot.dm @@ -504,7 +504,7 @@ Auto Patrol[]"}, return if(iscarbon(A)) var/mob/living/carbon/C = A - if(!C.stun || arrest_type) + if(!C.IsStun() || arrest_type) stun_attack(A) else if(C.canBeHandcuffed() && !C.handcuffed) cuff(A) diff --git a/code/modules/mob/living/simple_animal/bot/medbot.dm b/code/modules/mob/living/simple_animal/bot/medbot.dm index 2a9754622d4..e4ddb91ecca 100644 --- a/code/modules/mob/living/simple_animal/bot/medbot.dm +++ b/code/modules/mob/living/simple_animal/bot/medbot.dm @@ -14,6 +14,8 @@ maxHealth = 20 pass_flags = PASSMOB + status_flags = (CANPUSH | CANSTUN) + radio_key = /obj/item/device/encryptionkey/headset_med radio_channel = "Medical" @@ -77,6 +79,9 @@ if(!on) icon_state = "medibot0" return + if(IsStun()) + icon_state = "medibota" + return if(mode == BOT_HEALING) icon_state = "medibots[stationary_mode]" return @@ -97,6 +102,10 @@ prev_access = access_card.access qdel(J) +/mob/living/simple_animal/bot/medbot/update_canmove() + . = ..() + update_icon() + /mob/living/simple_animal/bot/medbot/bot_reset() ..() patient = null @@ -265,17 +274,10 @@ if(mode == BOT_HEALING) return - if(stun) - icon_state = "medibota" - stun-- - + if(IsStun()) oldpatient = patient patient = null mode = BOT_IDLE - - if(stun <= 0) - update_icon() - stun = 0 return if(frustration > 8) @@ -504,11 +506,6 @@ return 1 return 0 -/mob/living/simple_animal/bot/medbot/bullet_act(obj/item/projectile/Proj) - if(Proj.flag == "taser") - stun = min(stun+10,20) - ..() - /mob/living/simple_animal/bot/medbot/explode() on = 0 visible_message("[src] blows apart!") diff --git a/code/modules/mob/living/simple_animal/bot/secbot.dm b/code/modules/mob/living/simple_animal/bot/secbot.dm index da5b0103a5a..4d439afdf72 100644 --- a/code/modules/mob/living/simple_animal/bot/secbot.dm +++ b/code/modules/mob/living/simple_animal/bot/secbot.dm @@ -190,7 +190,7 @@ Auto Patrol: []"}, return if(iscarbon(A)) var/mob/living/carbon/C = A - if(!C.stun || arrest_type) + if(!C.IsStun() || arrest_type) stun_attack(A) else if(C.canBeHandcuffed() && !C.handcuffed) cuff(A) diff --git a/code/modules/mob/living/simple_animal/simple_animal.dm b/code/modules/mob/living/simple_animal/simple_animal.dm index d1b5d5d99ed..695070bf7ae 100644 --- a/code/modules/mob/living/simple_animal/simple_animal.dm +++ b/code/modules/mob/living/simple_animal/simple_animal.dm @@ -387,7 +387,7 @@ ..() /mob/living/simple_animal/update_canmove() - if(unconscious || stun || knockdown || stat || resting) + if(unconscious || IsStun() || knockdown || stat || resting) drop_all_held_items() canmove = 0 else if(buckled) diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index d8311277a03..92daf30aee1 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -369,9 +369,9 @@ if(pulling) pulling.pulledby = null - if(ismob(pulling)) - var/mob/M = pulling - M.update_canmove()// mob gets up if it was lyng down in a chokehold + if(isliving(pulling)) + var/mob/living/L = pulling + L.update_canmove()// mob gets up if it was lyng down in a chokehold pulling = null grab_state = 0 update_pull_hud_icon() @@ -657,52 +657,6 @@ return 0 return 1 - -//Updates canmove, lying and icons. Could perhaps do with a rename but I can't think of anything to describe it. -//Robots, animals and brains have their own version so don't worry about them -/mob/proc/update_canmove() - var/ko = knockdown || unconscious || stat || (status_flags & FAKEDEATH) - var/chokehold = pulledby && pulledby.grab_state >= GRAB_NECK - var/buckle_lying = !(buckled && !buckled.buckle_lying) - var/has_legs = get_num_legs() - var/has_arms = get_num_arms() - var/ignore_legs = get_leg_ignore() - if(ko || resting || stun || chokehold) - drop_all_held_items() - unset_machine() - if(pulling) - stop_pulling() - else if(has_legs || ignore_legs) - lying = 0 - - if(buckled) - lying = 90*buckle_lying - else if(!lying) - if(resting) - fall() - else if(ko || (!has_legs && !ignore_legs) || chokehold) - fall(forced = 1) - canmove = !(ko || resting || stun || chokehold || buckled || (!has_legs && !ignore_legs && !has_arms)) - density = !lying - if(lying) - if(layer == initial(layer)) //to avoid special cases like hiding larvas. - layer = LYING_MOB_LAYER //so mob lying always appear behind standing mobs - else - if(layer == LYING_MOB_LAYER) - layer = initial(layer) - update_transform() - update_action_buttons_icon(status_only=TRUE) - if(isliving(src)) - var/mob/living/L = src - if(L.has_status_effect(/datum/status_effect/freon)) - canmove = 0 - if(!lying && lying_prev) - if(client) - client.move_delay = world.time + movement_delay() - lying_prev = lying - return canmove - - /mob/proc/fall(forced) drop_all_held_items() diff --git a/code/modules/mob/mob_defines.dm b/code/modules/mob/mob_defines.dm index ee9b8208c5a..8e94cbfc193 100644 --- a/code/modules/mob/mob_defines.dm +++ b/code/modules/mob/mob_defines.dm @@ -69,7 +69,6 @@ var/overeatduration = 0 // How long this guy is overeating //Carbon var/unconscious = 0 - var/stun = 0 var/knockdown = 0 var/losebreath = 0//Carbon var/a_intent = INTENT_HELP//Living diff --git a/code/modules/mob/status_procs.dm b/code/modules/mob/status_procs.dm index 88feb185550..1a403072b2d 100644 --- a/code/modules/mob/status_procs.dm +++ b/code/modules/mob/status_procs.dm @@ -7,50 +7,88 @@ /////////////////////////////////// STUN //////////////////////////////////// -/mob/proc/Stun(amount, updating = 1, ignore_canstun = 0) - if(status_flags & CANSTUN || ignore_canstun) - stun = max(max(stun,amount * STUN_TIME_MULTIPLIER),0) //can't go below 0, getting a low amount of stun doesn't lower your current stun - if(updating) - update_canmove() - return TRUE +/mob/proc/IsStun() //non-living mobs shouldn't be stunned + return FALSE -/mob/proc/SetStun(amount, updating = 1, ignore_canstun = 0) //if you REALLY need to set stun to a set amount without the whole "can't go below current stun" - if(status_flags & CANSTUN || ignore_canstun) - stun = max(amount * STUN_TIME_MULTIPLIER,0) - if(updating) - update_canmove() - return TRUE +/mob/living/IsStun() //If we're stunned + return has_status_effect(STATUS_EFFECT_STUN) -/mob/proc/AdjustStun(amount, updating = 1, ignore_canstun = 0) - if(status_flags & CANSTUN || ignore_canstun) - stun = max(stun + (amount * STUN_TIME_MULTIPLIER),0) - if(updating) - update_canmove() - return TRUE +/mob/living/proc/AmountStun() //How many deciseconds remain in our stun + var/datum/status_effect/incapacitating/stun/S = IsStun() + if(S) + return S.duration - world.time + return 0 + +/mob/living/proc/Stun(amount, updating = TRUE, ignore_canstun = FALSE) //Can't go below remaining duration + if((status_flags & CANSTUN) || ignore_canstun) + var/datum/status_effect/incapacitating/stun/S = IsStun() + if(S) + var/remaining_duration = world.time - S.duration + S.duration = world.time + max(amount, remaining_duration) + else if(amount > 0) + S = apply_status_effect(STATUS_EFFECT_STUN) + S.duration = amount + S.update_canmove = updating + return S + +/mob/living/proc/SetStun(amount, updating = TRUE, ignore_canstun = FALSE) //Sets remaining duration + if((status_flags & CANSTUN) || ignore_canstun) + var/datum/status_effect/incapacitating/stun/S = IsStun() + if(amount <= 0) + if(S) + S.update_canmove = updating + qdel(S) + else if(S) + S.duration = world.time + amount + else + S = apply_status_effect(STATUS_EFFECT_STUN) + S.duration = amount + S.update_canmove = updating + return S + +/mob/living/proc/AdjustStun(amount, updating = TRUE, ignore_canstun = FALSE) //Adds to remaining duration + if((status_flags & CANSTUN) || ignore_canstun) + var/datum/status_effect/incapacitating/stun/S = IsStun() + if(S) + S.duration += amount + else if(amount > 0) + S = apply_status_effect(STATUS_EFFECT_STUN) + S.duration = amount + S.update_canmove = updating + return S /////////////////////////////////// KNOCKDOWN //////////////////////////////////// -/mob/proc/Knockdown(amount, updating = 1, ignore_canknockdown = 0) +/mob/proc/Knockdown(amount, updating = TRUE, ignore_canknockdown = FALSE) if((status_flags & CANKNOCKDOWN) || ignore_canknockdown) knockdown = max(max(knockdown,amount * STUN_TIME_MULTIPLIER),0) - if(updating) - update_canmove() //updates lying, canmove and icons return TRUE -/mob/proc/SetKnockdown(amount, updating = 1, ignore_canknockdown = 0) +/mob/living/Knockdown(amount, updating = TRUE, ignore_canknockdown = FALSE) + . = ..() + if(. && updating) + update_canmove() //updates lying, canmove and icons + +/mob/proc/SetKnockdown(amount, updating = TRUE, ignore_canknockdown = FALSE) if(status_flags & CANKNOCKDOWN || ignore_canknockdown) knockdown = max(amount * STUN_TIME_MULTIPLIER,0) - if(updating) - update_canmove() //updates lying, canmove and icons return TRUE -/mob/proc/AdjustKnockdown(amount, updating = 1, ignore_canknockdown = 0) +/mob/living/SetKnockdown(amount, updating = TRUE, ignore_canknockdown = FALSE) + . = ..() + if(. && updating) + update_canmove() //updates lying, canmove and icons + +/mob/proc/AdjustKnockdown(amount, updating = TRUE, ignore_canknockdown = FALSE) if((status_flags & CANKNOCKDOWN) || ignore_canknockdown) knockdown = max(knockdown + (amount * STUN_TIME_MULTIPLIER) ,0) - if(updating) - update_canmove() //updates lying, canmove and icons return TRUE +/mob/living/AdjustKnockdown(amount, updating = TRUE, ignore_canknockdown = FALSE) + . = ..() + if(. && updating) + update_canmove() //updates lying, canmove and icons + /////////////////////////////////// UNCONSCIOUS //////////////////////////////////// /mob/proc/Unconscious(amount, updating = TRUE, ignore_canunconscious = FALSE) @@ -88,7 +126,7 @@ /mob/living/proc/AmountSleeping() //How many deciseconds remain in our sleep var/datum/status_effect/incapacitating/sleeping/S = IsSleeping() if(S) - return world.time - S.duration + return S.duration - world.time return 0 /mob/living/proc/Sleeping(amount, updating = TRUE) //Can't go below remaining duration @@ -108,9 +146,10 @@ if(S) S.update_canmove = updating qdel(S) + else if(S) + S.duration = world.time + amount else S = apply_status_effect(STATUS_EFFECT_SLEEPING) - if(S) S.duration = amount S.update_canmove = updating return S @@ -129,14 +168,23 @@ /mob/proc/Resting(amount) resting = max(max(resting,amount),0) + +/mob/living/Resting(amount) + ..() update_canmove() /mob/proc/SetResting(amount) resting = max(amount,0) + +/mob/living/SetResting(amount) + ..() update_canmove() /mob/proc/AdjustResting(amount) resting = max(resting + amount,0) + +/mob/living/AdjustResting(amount) + ..() update_canmove() /////////////////////////////////// JITTERINESS //////////////////////////////////// diff --git a/code/modules/mob/transform_procs.dm b/code/modules/mob/transform_procs.dm index 3562cc6a9f3..36134db7867 100644 --- a/code/modules/mob/transform_procs.dm +++ b/code/modules/mob/transform_procs.dm @@ -31,7 +31,7 @@ //Make mob invisible and spawn animation notransform = 1 canmove = 0 - stun = 1 + Stun(22, ignore_canstun = TRUE) icon = null cut_overlays() invisibility = INVISIBILITY_MAXIMUM @@ -182,7 +182,7 @@ //Make mob invisible and spawn animation notransform = 1 canmove = 0 - stun = 1 + Stun(22, ignore_canstun = TRUE) icon = null cut_overlays() invisibility = INVISIBILITY_MAXIMUM diff --git a/code/modules/paperwork/paperplane.dm b/code/modules/paperwork/paperplane.dm index afdfbfab7fa..473f1620feb 100644 --- a/code/modules/paperwork/paperplane.dm +++ b/code/modules/paperwork/paperplane.dm @@ -32,7 +32,7 @@ internalPaper = null return ..() -/obj/item/weapon/paperplane/suicide_act(mob/user) +/obj/item/weapon/paperplane/suicide_act(mob/living/user) user.Stun(200) user.visible_message("[user] jams the [src] in [user.p_their()] nose. It looks like [user.p_theyre()] trying to commit suicide!") user.adjust_blurriness(6) diff --git a/code/modules/surgery/organs/augments_internal.dm b/code/modules/surgery/organs/augments_internal.dm index 8de6507e286..29727bf6a2e 100644 --- a/code/modules/surgery/organs/augments_internal.dm +++ b/code/modules/surgery/organs/augments_internal.dm @@ -108,7 +108,7 @@ if(crit_fail) return - if(owner.stun > STUN_CHECK_AMOUNT) + if(owner.AmountStun() > STUN_SET_AMOUNT) owner.SetStun(STUN_SET_AMOUNT) if(owner.knockdown > STUN_CHECK_AMOUNT) owner.SetKnockdown(STUN_SET_AMOUNT)