From 424eb48d9ef9e53ac9b31997d4e9379a52b18b70 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Mon, 24 Feb 2020 01:59:45 -0700 Subject: [PATCH] fixes --- code/game/atoms.dm | 10 +- code/game/mecha/mecha.dm | 1 - .../structures/crates_lockers/closets.dm | 2 +- .../living/carbon/alien/humanoid/humanoid.dm | 6 +- code/modules/mob/living/carbon/carbon.dm | 20 ++-- code/modules/mob/living/living.dm | 92 +++++++++++++------ code/modules/mob/living/living_defines.dm | 5 +- code/modules/mob/living/living_mobility.dm | 4 +- code/modules/mob/living/silicon/ai/ai.dm | 2 +- .../mob/living/simple_animal/bot/mulebot.dm | 4 +- code/modules/mob/mob_movement.dm | 6 +- 11 files changed, 95 insertions(+), 57 deletions(-) diff --git a/code/game/atoms.dm b/code/game/atoms.dm index 4adfdf72d2..d4407dea9e 100644 --- a/code/game/atoms.dm +++ b/code/game/atoms.dm @@ -28,7 +28,6 @@ var/list/managed_overlays var/datum/proximity_monitor/proximity_monitor - var/buckle_message_cooldown = 0 var/fingerprintslast var/list/filter_data //For handling persistent filters @@ -356,11 +355,12 @@ . = list() SEND_SIGNAL(src, COMSIG_ATOM_UPDATE_OVERLAYS, .) -/atom/proc/relaymove(mob/user) - if(buckle_message_cooldown <= world.time) - buckle_message_cooldown = world.time + 50 +/atom/proc/relaymove(mob/living/user) + if(!istype(user)) + return //why are you buckling nonliving mobs to atoms? + if(user.buckle_message_cooldown <= world.time) + user.buckle_message_cooldown = world.time + 50 to_chat(user, "You can't move while buckled to [src]!") - return /atom/proc/contents_explosion(severity, target) return //For handling the effects of explosions on contents that would not normally be effected diff --git a/code/game/mecha/mecha.dm b/code/game/mecha/mecha.dm index 3cb3141887..02115d3e30 100644 --- a/code/game/mecha/mecha.dm +++ b/code/game/mecha/mecha.dm @@ -941,7 +941,6 @@ /obj/mecha/container_resist(mob/living/user) go_out() - /obj/mecha/Exited(atom/movable/M, atom/newloc) if(occupant && occupant == M) // The occupant exited the mech without calling go_out() go_out(TRUE, newloc) diff --git a/code/game/objects/structures/crates_lockers/closets.dm b/code/game/objects/structures/crates_lockers/closets.dm index f26045f1f0..254296cd38 100644 --- a/code/game/objects/structures/crates_lockers/closets.dm +++ b/code/game/objects/structures/crates_lockers/closets.dm @@ -511,7 +511,7 @@ user.visible_message("[src] begins to shake violently!", \ "You lean on the back of [src] and start pushing the door open... (this will take about [DisplayTimeText(breakout_time)].)", \ "You hear banging from [src].") - if(do_after(user,(breakout_time), target = src)) + if(do_after(user,(breakout_time), target = src, required_mobility_flags = MOBILITY_RESIST)) if(!user || user.stat != CONSCIOUS || user.loc != src || opened || (!locked && !welded) ) return //we check after a while whether there is a point of resisting anymore and whether the user is capable of resisting diff --git a/code/modules/mob/living/carbon/alien/humanoid/humanoid.dm b/code/modules/mob/living/carbon/alien/humanoid/humanoid.dm index 347106f6c1..048b5062ec 100644 --- a/code/modules/mob/living/carbon/alien/humanoid/humanoid.dm +++ b/code/modules/mob/living/carbon/alien/humanoid/humanoid.dm @@ -69,11 +69,11 @@ playsound(src, 'sound/voice/hiss5.ogg', 40, 1, 1) //Alien roars when starting to break free ..(I, cuff_break = INSTANT_CUFFBREAK) -/mob/living/carbon/alien/humanoid/resist_grab(moving_resist) - if(pulledby.grab_state) +/mob/living/carbon/alien/humanoid/do_resist_grab(moving_resist, forced, silent = FALSE) + if(pulledby.grab_state && !silent) visible_message("[src] has broken free of [pulledby]'s grip!") pulledby.stop_pulling() - . = 0 + return TRUE /mob/living/carbon/alien/humanoid/get_standard_pixel_y_offset(lying = 0) if(leaping) diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index b5f870186a..85d2de9af2 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -281,19 +281,23 @@ return FALSE /mob/living/carbon/resist_buckle() + . = FALSE if(restrained()) - changeNext_move(CLICK_CD_BREAKOUT) - last_special = world.time + CLICK_CD_BREAKOUT + // too soon. + if(last_special > world.time) + return var/buckle_cd = 600 if(handcuffed) var/obj/item/restraints/O = src.get_item_by_slot(SLOT_HANDCUFFED) buckle_cd = O.breakouttime + changeNext_move(min(CLICK_CD_BREAKOUT, buckle_cd)) + last_special = world.time + min(CLICK_CD_BREAKOUT, buckle_cd) visible_message("[src] attempts to unbuckle [p_them()]self!", \ "You attempt to unbuckle yourself... (This will take around [round(buckle_cd/600,1)] minute\s, and you need to stay still.)") if(do_after(src, buckle_cd, 0, target = src, required_mobility_flags = MOBILITY_RESIST)) if(!buckled) return - buckled.user_unbuckle_mob(src,src) + buckled.user_unbuckle_mob(src, src) else if(src && buckled) to_chat(src, "You fail to unbuckle yourself!") @@ -313,9 +317,12 @@ ExtinguishMob() return -/mob/living/carbon/resist_restraints() +/mob/living/carbon/resist_restraints(ignore_delay = FALSE) var/obj/item/I = null var/type = 0 + if(!ignore_delay && (last_special > world.time)) + to_chat(src, "You don't have the energy to resist your restraints that fast!") + return if(handcuffed) I = handcuffed type = 1 @@ -324,14 +331,13 @@ type = 2 if(I) if(type == 1) - changeNext_move(CLICK_CD_BREAKOUT) + changeNext_move(min(CLICK_CD_BREAKOUT, I.breakouttime)) last_special = world.time + CLICK_CD_BREAKOUT if(type == 2) - changeNext_move(CLICK_CD_RANGE) + changeNext_move(min(CLICK_CD_RANGE, I.breakouttime)) last_special = world.time + CLICK_CD_RANGE cuff_resist(I) - /mob/living/carbon/proc/cuff_resist(obj/item/I, breakouttime = 600, cuff_break = 0) if(I.item_flags & BEING_REMOVED) to_chat(src, "You're already attempting to remove [I]!") diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index 76b9135d14..cf39898e23 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -646,66 +646,98 @@ ..(pressure_difference, direction, pressure_resistance_prob_delta) /mob/living/can_resist() - return !((next_move > world.time) || incapacitated(ignore_restraints = TRUE)) + return !((next_move > world.time) || !CHECK_MOBILITY(src, MOBILITY_RESIST)) +/// Resist verb for attempting to get out of whatever is restraining your motion. Gives you resist clickdelay if do_resist() returns true. /mob/living/verb/resist() set name = "Resist" set category = "IC" if(!can_resist()) return - changeNext_move(CLICK_CD_RESIST) + if(do_resist()) + changeNext_move(CLICK_CD_RESIST) + +/// The actual proc for resisting. Return TRUE to give clickdelay. +/mob/living/proc/do_resist() SEND_SIGNAL(src, COMSIG_LIVING_RESIST, src) //resisting grabs (as if it helps anyone...) - if(!restrained(ignore_grab = 1) && pulledby) - visible_message("[src] resists against [pulledby]'s grip!") - log_combat(src, pulledby, "resisted grab") - resist_grab() - return + // only works if you're not cuffed. + if(!restrained(ignore_grab = TRUE) && pulledby) + var/old_gs = pulledby.grab_state + attempt_resist_grab(FALSE) + // Return as we should only resist one thing at a time. Give clickdelay if the grab wasn't passive. + return old_gs? TRUE : FALSE - //unbuckling yourself + // unbuckling yourself. stops the chain if you try it. if(buckled && last_special <= world.time) - resist_buckle() + log_combat(src, buckled, "resisted buckle") + return resist_buckle() - // CIT CHANGE - climbing out of a gut - if(attempt_vr(src,"vore_process_resist",args)) return TRUE + // CIT CHANGE - climbing out of a gut. + if(attempt_vr(src,"vore_process_resist",args)) + //Sure, give clickdelay for anti spam. shouldn't be combat voring anyways. + return TRUE //Breaking out of a container (Locker, sleeper, cryo...) - else if(isobj(loc)) + if(isobj(loc)) var/obj/C = loc C.container_resist(src) + // This shouldn't give clickdelays sometime (e.g. going out of a mech/unwelded and unlocked locker/disposals bin/etc) but there's so many overrides that I am not going to bother right now. + return TRUE - else if(CHECK_BITFIELD(mobility_flags, MOBILITY_MOVE)) + if(CHECK_BITFIELD(mobility_flags, MOBILITY_MOVE)) if(on_fire) resist_fire() //stop, drop, and roll - return - if(resting) //cit change - allows resisting out of resting - resist_a_rest() // ditto - return - if(resist_embedded()) //Citadel Change for embedded removal memes - return - if(last_special <= world.time) - resist_restraints() //trying to remove cuffs. - return + // Give clickdelay + return TRUE + if(resting) //cit change - allows resisting out of resting + resist_a_rest() // ditto + // DO NOT GIVE CLCIKDELAY - resist_a_rest() handles spam prevention. Somewhat. + return FALSE + if(last_special <= world.time) + resist_restraints() //trying to remove cuffs. + // DO NOT GIVE CLICKDELAY - last_special handles this. + return FALSE + if(CHECK_MOBILITY(src, MOBILITY_USE) && resist_embedded()) //Citadel Change for embedded removal memes - requires being able to use items. + // DO NOT GIVE DEFAULT CLICKDELAY - This is a combat action. + changeNext_move(CLICK_CD_MELEE) + return FALSE +/// Proc to resist a grab. moving_resist is TRUE if this began by someone attempting to move. Return FALSE if still grabbed/failed to break out. Use this instead of resist_grab() directly. +/mob/proc/attempt_resist_grab(moving_resist, forced, log = TRUE) + if(!pulledby) //not being grabbed + return TRUE + var/old_gs = pulledby.grab_state //how strong the grab is + var/old_pulled = pulledby + var/success = do_resist_grab(moving_resist, forced) + if(log) + log_combat(src, old_pulled, "[success? "successfully broke free of" : "failed to resist"] a grab of strength [old_gs][moving_resist? " (moving)":""][forced? " (forced)":""]") + return success -/mob/proc/resist_grab(moving_resist) - return 1 //returning 0 means we successfully broke free + /*! + * Proc that actually does the grab resisting. Return TRUE if successful. Does not check that a grab exists! Use attempt_resist_grab() instead of this in general! + * Forced is if something other than the user mashing movement keys/pressing resist button did it, silent is if it makes messages (like "attempted to resist" and "broken free"). + * Forced does NOT force success! + */ -/mob/living/resist_grab(moving_resist) - . = 1 +/mob/proc/do_resist_grab(moving_resist, forced, silent = FALSE) + return FALSE + +/mob/living/do_resist_grab(moving_resist, forced, silent = FALSE) + . = ..() if(pulledby.grab_state) if(CHECK_BITFIELD(mobility_flags, MOBILITY_STAND) && prob(30/pulledby.grab_state)) visible_message("[src] has broken free of [pulledby]'s grip!") - log_combat(pulledby, src, "broke grab") pulledby.stop_pulling() - return 0 - if(moving_resist && client) //we resisted by trying to move + return TRUE + else if(moving_resist && client) //we resisted by trying to move // this is a horrible system and whoever thought using client instead of mob is okay is not an okay person client.move_delay = world.time + 20 + visible_message("[src] resists against [pulledby]'s grip!") else pulledby.stop_pulling() - return 0 + return TRUE /mob/living/proc/resist_buckle() buckled.user_unbuckle_mob(src,src) diff --git a/code/modules/mob/living/living_defines.dm b/code/modules/mob/living/living_defines.dm index 40ebcc5bca..ed46568489 100644 --- a/code/modules/mob/living/living_defines.dm +++ b/code/modules/mob/living/living_defines.dm @@ -114,4 +114,7 @@ var/drag_slowdown = TRUE //Whether the mob is slowed down when dragging another prone mob - var/rotate_on_lying = FALSE \ No newline at end of file + var/rotate_on_lying = FALSE + + /// Next world.time when we can get the "you can't move while buckled to [thing]" message. + var/buckle_message_cooldown = 0 diff --git a/code/modules/mob/living/living_mobility.dm b/code/modules/mob/living/living_mobility.dm index e3e159c179..af9db25011 100644 --- a/code/modules/mob/living/living_mobility.dm +++ b/code/modules/mob/living/living_mobility.dm @@ -78,7 +78,7 @@ standupwarning = "[src] struggles to stand up." var/usernotice = automatic ? "You are now getting up. (Auto)" : "You are now getting up." visible_message("[standupwarning]", usernotice, vision_distance = 5) - if(do_after(src, totaldelay, target = src, required_mobility_flags = MOBILITY_MOVE)) + if(do_after(src, totaldelay, target = src, required_mobility_flags = MOBILITY_RESIST)) set_resting(FALSE, TRUE) attemptingstandup = FALSE return TRUE @@ -110,7 +110,7 @@ var/chokehold = pulledby && pulledby.grab_state >= GRAB_NECK var/restrained = restrained() var/pinned = resting && pulledby && pulledby.grab_state >= GRAB_AGGRESSIVE // Cit change - adds pinning for aggressive-grabbing people on the ground - var/canmove = !immobilize && !stun && conscious && !paralyze && !buckled && (!stat_softcrit || !pulledby) && !chokehold && !IsFrozen() && (has_arms || ignore_legs || has_legs) && !pinned && !recoveringstam + var/canmove = !immobilize && !stun && conscious && !paralyze && (!stat_softcrit || !pulledby) && !chokehold && !IsFrozen() && (has_arms || ignore_legs || has_legs) && !pinned && !recoveringstam var/canresist = !stun && conscious && !stat_softcrit && !paralyze && (has_arms || ignore_legs || has_legs) && !recoveringstam if(canmove) diff --git a/code/modules/mob/living/silicon/ai/ai.dm b/code/modules/mob/living/silicon/ai/ai.dm index be67efe87d..3bb5a25671 100644 --- a/code/modules/mob/living/silicon/ai/ai.dm +++ b/code/modules/mob/living/silicon/ai/ai.dm @@ -989,7 +989,7 @@ deployed_shell.undeploy() diag_hud_set_deployed() -/mob/living/silicon/ai/resist() +/mob/living/silicon/ai/do_resist() return /mob/living/silicon/ai/spawned/Initialize(mapload, datum/ai_laws/L, mob/target_ai) diff --git a/code/modules/mob/living/simple_animal/bot/mulebot.dm b/code/modules/mob/living/simple_animal/bot/mulebot.dm index 4ebbfde318..ab7ce96336 100644 --- a/code/modules/mob/living/simple_animal/bot/mulebot.dm +++ b/code/modules/mob/living/simple_animal/bot/mulebot.dm @@ -747,8 +747,8 @@ else return null -/mob/living/simple_animal/bot/mulebot/resist() - ..() +/mob/living/simple_animal/bot/mulebot/do_resist() + . = ..() if(load) unload() diff --git a/code/modules/mob/mob_movement.dm b/code/modules/mob/mob_movement.dm index 01573fefbb..071ef1f49e 100644 --- a/code/modules/mob/mob_movement.dm +++ b/code/modules/mob/mob_movement.dm @@ -107,9 +107,7 @@ if(P && !ismob(P) && P.density) mob.setDir(turn(mob.dir, 180)) -///Process_Grab() -///Called by client/Move() -///Checks to see if you are being grabbed and if so attemps to break it +/// Process_Grab(): checks for grab, attempts to break if so. Return TRUE to prevent movement. /client/proc/Process_Grab() if(mob.pulledby) if(mob.incapacitated(ignore_restraints = 1)) @@ -120,7 +118,7 @@ to_chat(src, "You're restrained! You can't move!") return TRUE else - return mob.resist_grab(1) + return !mob.attempt_resist_grab(TRUE) ///Process_Incorpmove ///Called by client/Move()