From bd5b0d66edf177e66bbdf36b818203c0f68bf63d Mon Sep 17 00:00:00 2001 From: Ghom <42542238+Ghommie@users.noreply.github.com> Date: Fri, 30 Jul 2021 21:42:23 +0200 Subject: [PATCH] Fixes e-bolas being unblockable and not ensnaring flying mobs. (#60160) Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com> --- code/__DEFINES/traits.dm | 3 +- code/game/objects/items/defib.dm | 2 +- code/game/objects/items/handcuffs.dm | 78 ++++++++++--------- .../mob/living/carbon/carbon_defense.dm | 2 +- 4 files changed, 45 insertions(+), 40 deletions(-) diff --git a/code/__DEFINES/traits.dm b/code/__DEFINES/traits.dm index c499c088f23..a0d1320c585 100644 --- a/code/__DEFINES/traits.dm +++ b/code/__DEFINES/traits.dm @@ -434,6 +434,8 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai #define TRAIT_FOOD_GRILLED "food_grilled" /// The items needs two hands to be carried #define TRAIT_NEEDS_TWO_HANDS "needstwohands" +/// Can't be catched when thrown +#define TRAIT_UNCATCHABLE "uncatchable" /// Fish in this won't die #define TRAIT_FISH_SAFE_STORAGE "fish_case" /// Stuff that can go inside fish cases @@ -516,7 +518,6 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai // common trait sources #define TRAIT_GENERIC "generic" -#define GENERIC_ITEM_TRAIT "generic_item" #define UNCONSCIOUS_TRAIT "unconscious" #define EYE_DAMAGE "eye_damage" #define EAR_DAMAGE "ear_damage" diff --git a/code/game/objects/items/defib.dm b/code/game/objects/items/defib.dm index 65ce92a6b6f..733e9ed32be 100644 --- a/code/game/objects/items/defib.dm +++ b/code/game/objects/items/defib.dm @@ -402,7 +402,7 @@ /obj/item/shockpaddles/Initialize() . = ..() - ADD_TRAIT(src, TRAIT_NO_STORAGE_INSERT, GENERIC_ITEM_TRAIT) //stops shockpaddles from being inserted in BoH + ADD_TRAIT(src, TRAIT_NO_STORAGE_INSERT, TRAIT_GENERIC) //stops shockpaddles from being inserted in BoH RegisterSignal(src, COMSIG_TWOHANDED_WIELD, .proc/on_wield) RegisterSignal(src, COMSIG_TWOHANDED_UNWIELD, .proc/on_unwield) if(!req_defib) diff --git a/code/game/objects/items/handcuffs.dm b/code/game/objects/items/handcuffs.dm index 2d34ad53c2d..e8d653eb428 100644 --- a/code/game/objects/items/handcuffs.dm +++ b/code/game/objects/items/handcuffs.dm @@ -338,38 +338,42 @@ update_appearance() playsound(src, 'sound/effects/snap.ogg', 50, TRUE) -/obj/item/restraints/legcuffs/beartrap/proc/spring_trap(datum/source, AM as mob|obj) +/obj/item/restraints/legcuffs/beartrap/proc/spring_trap(datum/source, atom/movable/AM, thrown_at = FALSE) SIGNAL_HANDLER - if(armed && isturf(loc)) - if(isliving(AM)) - var/mob/living/L = AM - var/snap = TRUE - if(istype(L.buckled, /obj/vehicle)) - var/obj/vehicle/ridden_vehicle = L.buckled - if(!ridden_vehicle.are_legs_exposed) //close the trap without injuring/trapping the rider if their legs are inside the vehicle at all times. - close_trap() - ridden_vehicle.visible_message(span_danger("[ridden_vehicle] triggers \the [src].")) + if(!armed || !isturf(loc) || !isliving(AM)) + return + var/mob/living/L = AM + var/snap = TRUE + if(istype(L.buckled, /obj/vehicle)) + var/obj/vehicle/ridden_vehicle = L.buckled + if(!ridden_vehicle.are_legs_exposed) //close the trap without injuring/trapping the rider if their legs are inside the vehicle at all times. + close_trap() + ridden_vehicle.visible_message(span_danger("[ridden_vehicle] triggers \the [src].")) - if(L.movement_type & (FLYING|FLOATING)) //don't close the trap if they're flying/floating over it. - snap = FALSE + if(!thrown_at && L.movement_type & (FLYING|FLOATING)) //don't close the trap if they're flying/floating over it. + snap = FALSE - var/def_zone = BODY_ZONE_CHEST - if(snap && iscarbon(L)) - var/mob/living/carbon/C = L - if(C.body_position == STANDING_UP) - def_zone = pick(BODY_ZONE_L_LEG, BODY_ZONE_R_LEG) - if(!C.legcuffed && C.num_legs >= 2) //beartrap can't cuff your leg if there's already a beartrap or legcuffs, or you don't have two legs. - INVOKE_ASYNC(C, /mob/living/carbon.proc/equip_to_slot, src, ITEM_SLOT_LEGCUFFED) - SSblackbox.record_feedback("tally", "handcuffs", 1, type) - else if(snap && isanimal(L)) - var/mob/living/simple_animal/SA = L - if(SA.mob_size <= MOB_SIZE_TINY) //don't close the trap if they're as small as a mouse. - snap = FALSE - if(snap) - close_trap() - L.visible_message(span_danger("[L] triggers \the [src]."), \ - span_userdanger("You trigger \the [src]!")) - L.apply_damage(trap_damage, BRUTE, def_zone) + var/def_zone = BODY_ZONE_CHEST + if(snap && iscarbon(L)) + var/mob/living/carbon/C = L + if(C.body_position == STANDING_UP) + def_zone = pick(BODY_ZONE_L_LEG, BODY_ZONE_R_LEG) + if(!C.legcuffed && C.num_legs >= 2) //beartrap can't cuff your leg if there's already a beartrap or legcuffs, or you don't have two legs. + INVOKE_ASYNC(C, /mob/living/carbon.proc/equip_to_slot, src, ITEM_SLOT_LEGCUFFED) + SSblackbox.record_feedback("tally", "handcuffs", 1, type) + else if(snap && isanimal(L)) + var/mob/living/simple_animal/SA = L + if(SA.mob_size <= MOB_SIZE_TINY) //don't close the trap if they're as small as a mouse. + snap = FALSE + if(snap) + close_trap() + if(!thrown_at) + L.visible_message(span_danger("[L] triggers \the [src]."), \ + span_userdanger("You trigger \the [src]!")) + else + L.visible_message(span_danger("\The [src] ensnares [L]!"), \ + span_userdanger("\The [src] ensnares you!")) + L.apply_damage(trap_damage, BRUTE, def_zone) /** * # Energy snare @@ -439,10 +443,9 @@ */ /obj/item/restraints/legcuffs/bola/proc/ensnare(mob/living/carbon/C) if(!C.legcuffed && C.num_legs >= 2) - visible_message(span_danger("\The [src] ensnares [C]!")) + visible_message(span_danger("\The [src] ensnares [C]!"), span_userdanger("\The [src] ensnares you!")) C.equip_to_slot(src, ITEM_SLOT_LEGCUFFED) SSblackbox.record_feedback("tally", "handcuffs", 1, type) - to_chat(C, span_userdanger("\The [src] ensnares you!")) C.Knockdown(knockdown) playsound(src, 'sound/effects/snap.ogg', 50, TRUE) @@ -474,13 +477,14 @@ breakouttime = 6 SECONDS custom_price = PAYCHECK_HARD * 0.35 -/obj/item/restraints/legcuffs/bola/energy/throw_impact(atom/hit_atom, datum/thrownthing/throwingdatum) - if(iscarbon(hit_atom)) - var/obj/item/restraints/legcuffs/beartrap/B = new /obj/item/restraints/legcuffs/beartrap/energy/cyborg(get_turf(hit_atom)) - B.spring_trap(null, hit_atom) - qdel(src) - return +/obj/item/restraints/legcuffs/bola/energy/Initialize() . = ..() + ADD_TRAIT(src, TRAIT_UNCATCHABLE, TRAIT_GENERIC) // People said energy bolas being uncatchable is a feature. + +/obj/item/restraints/legcuffs/bola/energy/ensnare(atom/hit_atom) + var/obj/item/restraints/legcuffs/beartrap/energy/cyborg/B = new (get_turf(hit_atom)) + B.spring_trap(null, hit_atom, TRUE) + qdel(src) /** * A pacifying variant of the bola. diff --git a/code/modules/mob/living/carbon/carbon_defense.dm b/code/modules/mob/living/carbon/carbon_defense.dm index 02a093d75f6..9faddd2e628 100644 --- a/code/modules/mob/living/carbon/carbon_defense.dm +++ b/code/modules/mob/living/carbon/carbon_defense.dm @@ -59,7 +59,7 @@ return TRUE /mob/living/carbon/hitby(atom/movable/AM, skipcatch, hitpush = TRUE, blocked = FALSE, datum/thrownthing/throwingdatum) - if(!skipcatch && can_catch_item() && istype(AM, /obj/item) && isturf(AM.loc)) + if(!skipcatch && can_catch_item() && istype(AM, /obj/item) && !HAS_TRAIT(AM, TRAIT_UNCATCHABLE) && isturf(AM.loc)) var/obj/item/I = AM I.attack_hand(src) if(get_active_held_item() == I) //if our attack_hand() picks up the item...