diff --git a/code/modules/integrated_electronics/core/assemblies.dm b/code/modules/integrated_electronics/core/assemblies.dm index 93ddedebc0..d8bf82a4b4 100644 --- a/code/modules/integrated_electronics/core/assemblies.dm +++ b/code/modules/integrated_electronics/core/assemblies.dm @@ -615,6 +615,11 @@ return ..() +/obj/item/electronic_assembly/can_trigger_gun(mob/living/user) //sanity checks against pocket death weapon circuits + if(!can_fire_equipped || !user.is_holding(src)) + return FALSE + return ..() + /obj/item/electronic_assembly/default //The /default electronic_assemblys are to allow the introduction of the new naming scheme without breaking old saves. name = "type-a electronic assembly" diff --git a/code/modules/integrated_electronics/core/integrated_circuit.dm b/code/modules/integrated_electronics/core/integrated_circuit.dm index cec3e2348e..40bcbe016b 100644 --- a/code/modules/integrated_electronics/core/integrated_circuit.dm +++ b/code/modules/integrated_electronics/core/integrated_circuit.dm @@ -402,3 +402,8 @@ a creative player the means to solve many problems. Circuits are held inside an return TRUE return FALSE + +/obj/item/integrated_circuit/can_trigger_gun(mob/living/user) + if(!user.is_holding(src)) + return FALSE + return ..() diff --git a/code/modules/integrated_electronics/subtypes/weaponized.dm b/code/modules/integrated_electronics/subtypes/weaponized.dm index 7bccbfafcd..350f05914d 100644 --- a/code/modules/integrated_electronics/subtypes/weaponized.dm +++ b/code/modules/integrated_electronics/subtypes/weaponized.dm @@ -81,9 +81,13 @@ to_chat(user, "There's no weapon to remove from the mechanism.") /obj/item/integrated_circuit/weaponized/weapon_firing/do_work() - if(!installed_gun || !installed_gun.handle_pins()) + if(!assembly || !installed_gun) return - if(!isturf(assembly.loc) && !(assembly.can_fire_equipped && ishuman(assembly.loc))) + if(isliving(assembly.loc)) + var/mob/living/L = assembly.loc + if(!assembly.can_fire_equipped || !L.is_holding(assembly) || !installed_gun.can_trigger_gun(L)) //includes pins, hulk and other chunky fingers checks. + return + else if(!isturf(assembly.loc) || !installed_gun.handle_pins()) return set_pin_data(IC_OUTPUT, 1, WEAKREF(installed_gun)) push_data() @@ -92,18 +96,17 @@ var/datum/integrated_io/mode1 = inputs[3] mode = mode1.data - if(assembly) - if(isnum(xo.data)) - xo.data = round(xo.data, 1) - if(isnum(yo.data)) - yo.data = round(yo.data, 1) + if(isnum(xo.data)) + xo.data = round(xo.data, 1) + if(isnum(yo.data)) + yo.data = round(yo.data, 1) - var/turf/T = get_turf(assembly) - var/target_x = CLAMP(T.x + xo.data, 0, world.maxx) - var/target_y = CLAMP(T.y + yo.data, 0, world.maxy) + var/turf/T = get_turf(assembly) + var/target_x = CLAMP(T.x + xo.data, 0, world.maxx) + var/target_y = CLAMP(T.y + yo.data, 0, world.maxy) - assembly.visible_message("[assembly] fires [installed_gun]!") - shootAt(locate(target_x, target_y, T.z)) + assembly.visible_message("[assembly] fires [installed_gun]!") + shootAt(locate(target_x, target_y, T.z)) /obj/item/integrated_circuit/weaponized/weapon_firing/proc/shootAt(turf/target) var/turf/T = get_turf(src) @@ -246,26 +249,30 @@ if(!A || A.anchored || A.throwing || A == assembly || istype(A, /obj/item/twohanded) || istype(A, /obj/item/transfer_valve)) return - if(!AT || !AT.air_contents) + var/obj/item/I = get_object() + var/turf/T = get_turf(I) + if(!T) + return + if(isliving(I.loc)) + var/mob/living/L = I.loc + if(!I.can_trigger_gun(L)) //includes hulk and other chunky fingers checks. + return + if(HAS_TRAIT(L, TRAIT_PACIFISM) && A.throwforce) + to_chat(L, " [I] is lethally chambered! You don't want to risk harming anyone...") + return + else if(T != I.loc) return - if (istype(assembly.loc, /obj/item/implant/storage)) //Prevents the more abusive form of chestgun. + if(!AT || !AT.air_contents) return if(max_w_class && (A.w_class > max_w_class)) return - if(!assembly.can_fire_equipped && ishuman(assembly.loc)) - return - // Is the target inside the assembly or close to it? if(!check_target(A, exclude_components = TRUE)) return - var/turf/T = get_turf(get_object()) - if(!T) - return - // If the item is in mob's inventory, try to remove it from there. if(ismob(A.loc)) var/mob/living/M = A.loc diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm index 026f725e2f..531c6082b0 100644 --- a/code/modules/projectiles/gun.dm +++ b/code/modules/projectiles/gun.dm @@ -198,8 +198,13 @@ /obj/item/gun/can_trigger_gun(mob/living/user) . = ..() + if(!.) + return if(!handle_pins(user)) return FALSE + if(HAS_TRAIT(user, TRAIT_PACIFISM) && chambered?.harmful) // If the user has the pacifist trait, then they won't be able to fire [src] if the round chambered inside of [src] is lethal. + to_chat(user, " [src] is lethally chambered! You don't want to risk harming anyone...") + return FALSE /obj/item/gun/proc/handle_pins(mob/living/user) if(pin) @@ -275,10 +280,6 @@ addtimer(CALLBACK(src, .proc/process_burst, user, target, message, params, zone_override, sprd, randomized_gun_spread, randomized_bonus_spread, rand_spr, i), fire_delay * (i - 1)) else if(chambered) - if(HAS_TRAIT(user, TRAIT_PACIFISM)) // If the user has the pacifist trait, then they won't be able to fire [src] if the round chambered inside of [src] is lethal. - if(chambered.harmful) // Is the bullet chambered harmful? - to_chat(user, " [src] is lethally chambered! You don't want to risk harming anyone...") - return sprd = round((rand() - 0.5) * DUALWIELD_PENALTY_EXTRA_MULTIPLIER * (randomized_gun_spread + randomized_bonus_spread)) if(!chambered.fire_casing(target, user, params, , suppressed, zone_override, sprd, src)) shoot_with_empty_chamber(user)