From 24a33975bf73e50199f0c0ded94ba557bdbd9e3d Mon Sep 17 00:00:00 2001 From: Gristlebee <56049844+Gristlebee@users.noreply.github.com> Date: Sun, 25 Aug 2024 19:46:52 -0700 Subject: [PATCH 01/14] as intended --- .../modules/projectiles/ammunition/_firing.dm | 19 ++++++---- code/modules/projectiles/gun.dm | 36 +++++++++++++++++++ code/modules/projectiles/guns/ballistic.dm | 5 +++ code/modules/projectiles/guns/energy.dm | 4 +++ 4 files changed, 58 insertions(+), 6 deletions(-) diff --git a/code/modules/projectiles/ammunition/_firing.dm b/code/modules/projectiles/ammunition/_firing.dm index 93fa4208d571..509bd47ab6e3 100644 --- a/code/modules/projectiles/ammunition/_firing.dm +++ b/code/modules/projectiles/ammunition/_firing.dm @@ -15,11 +15,11 @@ return FALSE AddComponent(/datum/component/pellet_cloud, projectile_type, pellets) SEND_SIGNAL(src, COMSIG_PELLET_CLOUD_INIT, target, user, fired_from, randomspread, spread, zone_override, params, distro) + if(user) + if(click_cooldown_override) + user.changeNext_move(click_cooldown_override) - if(click_cooldown_override) - user.changeNext_move(click_cooldown_override) - - user.newtonian_move(get_dir(target, user)) + user.newtonian_move(get_dir(target, user)) update_appearance() return TRUE @@ -45,7 +45,11 @@ qdel(reagents) /obj/item/ammo_casing/proc/throw_proj(atom/target, turf/targloc, mob/living/user, params, spread) - var/turf/curloc = get_turf(user) + var/turf/curloc + if(user) + curloc = get_turf(user) + else + curloc = get_turf(src) if (!istype(targloc) || !istype(curloc) || !BB) return FALSE @@ -60,7 +64,10 @@ if(target) //if the target is right on our location we'll skip the travelling code in the proj's fire() direct_target = target if(!direct_target) - BB.preparePixelProjectile(target, user, params, spread) + if(user) + BB.preparePixelProjectile(target, user, params, spread) + else + BB.preparePixelProjectile(target, curloc, params, spread) BB.fire(null, direct_target) BB = null return TRUE diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm index ca1a1a89b8c9..3a7d36f4d9ea 100644 --- a/code/modules/projectiles/gun.dm +++ b/code/modules/projectiles/gun.dm @@ -961,6 +961,42 @@ flash_loc.vis_contents -= muzzle_flash muzzle_flash.applied = FALSE + +/obj/item/gun/proc/go_off() + var/target + if(!safety) + // someone is very unlucky and about to be shot + if(prob(50)) + for(var/mob/living/target_mob in range(6, src.loc)) + if(!isInSight(src, target_mob)) + continue + target = target_mob + break + if(!target) + var/fire_dir = pick(GLOB.alldirs) + target = get_ranged_target_turf(src,fire_dir,6) + if(!chambered) + visible_message(span_danger("The [src] suddenly goes off without it's safties on! Luckily it wasn't loaded.")) + else + visible_message(span_danger("\The [src] suddenly goes off without it's safties on!")) + unsafe_shot(target) + +/obj/item/gun/proc/unsafe_shot(target) + if(chambered) + chambered.fire_casing(target, , null, , suppressed, ran_zone(BODY_ZONE_CHEST), 0, src) + playsound(src, fire_sound, 100, TRUE) + //if(chambered.BB) + // var/obj/projectile/shot = chambered.BB + // chambered.ready_proj() + // shot.trajectory_ignore_forcemove = TRUE + // shot.forceMove(get_turf(src)) + // shot.trajectory_ignore_forcemove = FALSE + // shot.starting = get_turf(src) + // shot.fire(direct_target = target) + // chambered.BB = null + // playsound(src, fire_sound, 100, TRUE) + // chambered.update_appearance() + //I need to refactor this into an attachment /datum/action/toggle_scope_zoom name = "Toggle Scope" diff --git a/code/modules/projectiles/guns/ballistic.dm b/code/modules/projectiles/guns/ballistic.dm index 1790ba25a858..5e0cde24147c 100644 --- a/code/modules/projectiles/guns/ballistic.dm +++ b/code/modules/projectiles/guns/ballistic.dm @@ -373,3 +373,8 @@ GLOBAL_LIST_INIT(gun_saw_types, typecacheof(list( if(AC.BB) process_fire(user, user, FALSE) . = TRUE + +/obj/item/gun/ballistic/unsafe_shot(target, empty_chamber = TRUE) + . = ..() + process_chamber(empty_chamber,TRUE) + diff --git a/code/modules/projectiles/guns/energy.dm b/code/modules/projectiles/guns/energy.dm index abe3e3fd7b43..6305f6522f72 100644 --- a/code/modules/projectiles/guns/energy.dm +++ b/code/modules/projectiles/guns/energy.dm @@ -323,3 +323,7 @@ . += "\The [name] has [round(cell.charge/shot.e_cost)] shots remaining on [shot.select_name] mode." else . += span_notice("\The [name] doesn't seem to have a cell!") + +/obj/item/gun/energy/unsafe_shot(target) + . = ..() + process_chamber() From bc4a3ac0f8efbb2461b569a1cdb2f7cc88253cc9 Mon Sep 17 00:00:00 2001 From: Gristlebee <56049844+Gristlebee@users.noreply.github.com> Date: Sun, 25 Aug 2024 22:49:36 -0700 Subject: [PATCH 02/14] triggers --- code/modules/projectiles/gun.dm | 26 ++++++++++++------------- code/modules/projectiles/guns/energy.dm | 2 ++ code/modules/shuttle/on_move.dm | 9 +++++++++ 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm index 3a7d36f4d9ea..9842914e5240 100644 --- a/code/modules/projectiles/gun.dm +++ b/code/modules/projectiles/gun.dm @@ -1,3 +1,7 @@ +#define GUN_NO_SAFETY_MALFUNCTION_CHANCE_LOW 5 +#define GUN_NO_SAFETY_MALFUNCTION_CHANCE_MEDIUM 40 +#define GUN_NO_SAFETY_MALFUNCTION_CHANCE_HIGH 80 + /obj/item/gun name = "gun" desc = "It's a gun. It's pretty terrible, though." @@ -722,6 +726,13 @@ azoom.Remove(user) if(zoomed) zoom(user, user.dir) + if(!safety && prob(GUN_NO_SAFETY_MALFUNCTION_CHANCE_LOW)) + go_off() + +/obj/item/gun/throw_impact(atom/hit_atom, datum/thrownthing/throwingdatum) + . = ..() + if(prob(GUN_NO_SAFETY_MALFUNCTION_CHANCE_HIGH)) + go_off() /obj/item/gun/update_overlays() . = ..() @@ -962,11 +973,11 @@ muzzle_flash.applied = FALSE -/obj/item/gun/proc/go_off() +/obj/item/gun/proc/go_off(seek_chance = 100) var/target if(!safety) // someone is very unlucky and about to be shot - if(prob(50)) + if(prob(seek_chance)) for(var/mob/living/target_mob in range(6, src.loc)) if(!isInSight(src, target_mob)) continue @@ -985,17 +996,6 @@ if(chambered) chambered.fire_casing(target, , null, , suppressed, ran_zone(BODY_ZONE_CHEST), 0, src) playsound(src, fire_sound, 100, TRUE) - //if(chambered.BB) - // var/obj/projectile/shot = chambered.BB - // chambered.ready_proj() - // shot.trajectory_ignore_forcemove = TRUE - // shot.forceMove(get_turf(src)) - // shot.trajectory_ignore_forcemove = FALSE - // shot.starting = get_turf(src) - // shot.fire(direct_target = target) - // chambered.BB = null - // playsound(src, fire_sound, 100, TRUE) - // chambered.update_appearance() //I need to refactor this into an attachment /datum/action/toggle_scope_zoom diff --git a/code/modules/projectiles/guns/energy.dm b/code/modules/projectiles/guns/energy.dm index 6305f6522f72..0cd88e7df1e3 100644 --- a/code/modules/projectiles/guns/energy.dm +++ b/code/modules/projectiles/guns/energy.dm @@ -39,6 +39,8 @@ /obj/item/gun/energy/emp_act(severity) . = ..() if(!(. & EMP_PROTECT_CONTENTS)) + if(prob(GUN_NO_SAFETY_MALFUNCTION_CHANCE_HIGH)) + go_off() cell.use(round(cell.charge / severity)) chambered = null //we empty the chamber recharge_newshot() //and try to charge a new shot diff --git a/code/modules/shuttle/on_move.dm b/code/modules/shuttle/on_move.dm index f4d68520c879..5fbd747c723f 100644 --- a/code/modules/shuttle/on_move.dm +++ b/code/modules/shuttle/on_move.dm @@ -299,6 +299,11 @@ All ShuttleMove procs go here if (oldT && !is_reserved_level(oldT)) unlocked = TRUE +/obj/item/gun/lateShuttleMove(turf/oldT, list/movement_force, move_dir) + . = ..() + if(!safety && prob(GUN_NO_SAFETY_MALFUNCTION_CHANCE_MEDIUM)) + go_off() + /************************************Mob move procs************************************/ /mob/onShuttleMove(turf/newT, turf/oldT, list/movement_force, move_dir, obj/docking_port/stationary/old_dock, obj/docking_port/mobile/moving_dock, list/obj/docking_port/mobile/towed_shuttles) @@ -325,6 +330,10 @@ All ShuttleMove procs go here var/knockdown = movement_force["KNOCKDOWN"] if(knockdown) Paralyze(knockdown) + for(var/obj/item/gun/at_risk in contents) + if(at_risk.safety == FALSE && prob(GUN_NO_SAFETY_MALFUNCTION_CHANCE_MEDIUM)) + at_risk.visible_message("\The [at_risk.name] is jostled by the force of the take off and suddenly goes off into [src]'s leg! Should've had the safties on.") + at_risk.process_fire(src,src,FALSE, spread_override = pick(BODY_ZONE_L_LEG,BODY_ZONE_R_LEG)) /mob/living/simple_animal/hostile/megafauna/onShuttleMove(turf/newT, turf/oldT, list/movement_force, move_dir, obj/docking_port/stationary/old_dock, obj/docking_port/mobile/moving_dock, list/obj/docking_port/mobile/towed_shuttles) From 5e0f621f71718726cd3747bb062b1b5373d293bc Mon Sep 17 00:00:00 2001 From: Gristlebee <56049844+Gristlebee@users.noreply.github.com> Date: Mon, 26 Aug 2024 15:41:01 -0700 Subject: [PATCH 03/14] proc --- .../mob/living/carbon/carbon_movement.dm | 1 + code/modules/projectiles/gun.dm | 23 +++++++++++-------- code/modules/projectiles/guns/energy.dm | 2 +- code/modules/shuttle/on_move.dm | 9 +++----- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/code/modules/mob/living/carbon/carbon_movement.dm b/code/modules/mob/living/carbon/carbon_movement.dm index 7f65b79ddca1..70eb13b958df 100644 --- a/code/modules/mob/living/carbon/carbon_movement.dm +++ b/code/modules/mob/living/carbon/carbon_movement.dm @@ -3,6 +3,7 @@ return FALSE if(!(lube&SLIDE_ICE)) log_combat(src, (O ? O : get_turf(src)), "slipped on the", null, ((lube & SLIDE) ? "(LUBE)" : null)) + trip_with_gun() return loc.handle_slip(src, knockdown_amount, O, lube, paralyze, force_drop) /mob/living/carbon/Process_Spacemove(movement_dir = 0) diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm index 9842914e5240..121051fe257e 100644 --- a/code/modules/projectiles/gun.dm +++ b/code/modules/projectiles/gun.dm @@ -726,13 +726,11 @@ azoom.Remove(user) if(zoomed) zoom(user, user.dir) - if(!safety && prob(GUN_NO_SAFETY_MALFUNCTION_CHANCE_LOW)) - go_off() /obj/item/gun/throw_impact(atom/hit_atom, datum/thrownthing/throwingdatum) . = ..() if(prob(GUN_NO_SAFETY_MALFUNCTION_CHANCE_HIGH)) - go_off() + go_off("hits the ground hard") /obj/item/gun/update_overlays() . = ..() @@ -972,8 +970,8 @@ flash_loc.vis_contents -= muzzle_flash muzzle_flash.applied = FALSE - -/obj/item/gun/proc/go_off(seek_chance = 100) +// for guns firing on their own without a user +/obj/item/gun/proc/go_off(cause, seek_chance = 50) var/target if(!safety) // someone is very unlucky and about to be shot @@ -986,17 +984,24 @@ if(!target) var/fire_dir = pick(GLOB.alldirs) target = get_ranged_target_turf(src,fire_dir,6) - if(!chambered) - visible_message(span_danger("The [src] suddenly goes off without it's safties on! Luckily it wasn't loaded.")) + if(!chambered || !chambered.BB) + visible_message(span_danger("\The [src] [cause ? "[cause], suddenly going off" : "suddenly goes off"] without its safties on! Luckily it wasn't live.")) + playsound(src, dry_fire_sound, 30, TRUE) else - visible_message(span_danger("\The [src] suddenly goes off without it's safties on!")) + visible_message(span_danger("\The [src] [cause ? "[cause], suddenly going off" : "suddenly goes off"] without its safties on!")) unsafe_shot(target) /obj/item/gun/proc/unsafe_shot(target) if(chambered) - chambered.fire_casing(target, , null, , suppressed, ran_zone(BODY_ZONE_CHEST), 0, src) + chambered.fire_casing(target,null, null, null, suppressed, ran_zone(BODY_ZONE_CHEST, 50), 0, src) playsound(src, fire_sound, 100, TRUE) +/mob/living/proc/trip_with_gun() + for(var/obj/item/gun/at_risk in get_all_contents()) + if(at_risk.safety == FALSE && prob(GUN_NO_SAFETY_MALFUNCTION_CHANCE_MEDIUM)) + visible_message(span_danger("\The [at_risk.name]'s trigger gets caught as [src] falls, suddenly going off into [src]'s leg! Should have had the safties on."), span_danger("\The [at_risk.name]'s trigger gets caught on something as you fall, suddenly going off into your leg without it's safties on!")) + at_risk.process_fire(src,src,FALSE, null, pick(BODY_ZONE_L_LEG,BODY_ZONE_R_LEG)) + //I need to refactor this into an attachment /datum/action/toggle_scope_zoom name = "Toggle Scope" diff --git a/code/modules/projectiles/guns/energy.dm b/code/modules/projectiles/guns/energy.dm index 0cd88e7df1e3..449738cee5b1 100644 --- a/code/modules/projectiles/guns/energy.dm +++ b/code/modules/projectiles/guns/energy.dm @@ -40,7 +40,7 @@ . = ..() if(!(. & EMP_PROTECT_CONTENTS)) if(prob(GUN_NO_SAFETY_MALFUNCTION_CHANCE_HIGH)) - go_off() + go_off("malfuctions from the EMP") cell.use(round(cell.charge / severity)) chambered = null //we empty the chamber recharge_newshot() //and try to charge a new shot diff --git a/code/modules/shuttle/on_move.dm b/code/modules/shuttle/on_move.dm index 5fbd747c723f..4c409072a34d 100644 --- a/code/modules/shuttle/on_move.dm +++ b/code/modules/shuttle/on_move.dm @@ -301,8 +301,8 @@ All ShuttleMove procs go here /obj/item/gun/lateShuttleMove(turf/oldT, list/movement_force, move_dir) . = ..() - if(!safety && prob(GUN_NO_SAFETY_MALFUNCTION_CHANCE_MEDIUM)) - go_off() + if(prob(GUN_NO_SAFETY_MALFUNCTION_CHANCE_MEDIUM)) + go_off("is thrown around by the force of the take off") /************************************Mob move procs************************************/ @@ -330,10 +330,7 @@ All ShuttleMove procs go here var/knockdown = movement_force["KNOCKDOWN"] if(knockdown) Paralyze(knockdown) - for(var/obj/item/gun/at_risk in contents) - if(at_risk.safety == FALSE && prob(GUN_NO_SAFETY_MALFUNCTION_CHANCE_MEDIUM)) - at_risk.visible_message("\The [at_risk.name] is jostled by the force of the take off and suddenly goes off into [src]'s leg! Should've had the safties on.") - at_risk.process_fire(src,src,FALSE, spread_override = pick(BODY_ZONE_L_LEG,BODY_ZONE_R_LEG)) + trip_with_gun() /mob/living/simple_animal/hostile/megafauna/onShuttleMove(turf/newT, turf/oldT, list/movement_force, move_dir, obj/docking_port/stationary/old_dock, obj/docking_port/mobile/moving_dock, list/obj/docking_port/mobile/towed_shuttles) From 709cb1fa4e3ab439ea9c0a23935f31b0ec0da887 Mon Sep 17 00:00:00 2001 From: Gristlebee <56049844+Gristlebee@users.noreply.github.com> Date: Mon, 26 Aug 2024 15:42:26 -0700 Subject: [PATCH 04/14] typo --- code/modules/projectiles/gun.dm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm index 121051fe257e..20d99352f933 100644 --- a/code/modules/projectiles/gun.dm +++ b/code/modules/projectiles/gun.dm @@ -985,10 +985,10 @@ var/fire_dir = pick(GLOB.alldirs) target = get_ranged_target_turf(src,fire_dir,6) if(!chambered || !chambered.BB) - visible_message(span_danger("\The [src] [cause ? "[cause], suddenly going off" : "suddenly goes off"] without its safties on! Luckily it wasn't live.")) + visible_message(span_danger("\The [src] [cause ? "[cause], suddenly going off" : "suddenly goes off"] without its safteies on! Luckily it wasn't live.")) playsound(src, dry_fire_sound, 30, TRUE) else - visible_message(span_danger("\The [src] [cause ? "[cause], suddenly going off" : "suddenly goes off"] without its safties on!")) + visible_message(span_danger("\The [src] [cause ? "[cause], suddenly going off" : "suddenly goes off"] without its safeties on!")) unsafe_shot(target) /obj/item/gun/proc/unsafe_shot(target) @@ -999,7 +999,7 @@ /mob/living/proc/trip_with_gun() for(var/obj/item/gun/at_risk in get_all_contents()) if(at_risk.safety == FALSE && prob(GUN_NO_SAFETY_MALFUNCTION_CHANCE_MEDIUM)) - visible_message(span_danger("\The [at_risk.name]'s trigger gets caught as [src] falls, suddenly going off into [src]'s leg! Should have had the safties on."), span_danger("\The [at_risk.name]'s trigger gets caught on something as you fall, suddenly going off into your leg without it's safties on!")) + visible_message(span_danger("\The [at_risk.name]'s trigger gets caught as [src] falls, suddenly going off into [src]'s leg! Should have had the safeties on."), span_danger("\The [at_risk.name]'s trigger gets caught on something as you fall, suddenly going off into your leg without it's safeties on!")) at_risk.process_fire(src,src,FALSE, null, pick(BODY_ZONE_L_LEG,BODY_ZONE_R_LEG)) //I need to refactor this into an attachment From b53111afb83c89381224cd18040df4d5c2de7819 Mon Sep 17 00:00:00 2001 From: Gristlebee <56049844+Gristlebee@users.noreply.github.com> Date: Mon, 26 Aug 2024 16:00:11 -0700 Subject: [PATCH 05/14] seek and ye shall find --- code/modules/projectiles/gun.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm index 20d99352f933..cd170c1a7021 100644 --- a/code/modules/projectiles/gun.dm +++ b/code/modules/projectiles/gun.dm @@ -730,7 +730,7 @@ /obj/item/gun/throw_impact(atom/hit_atom, datum/thrownthing/throwingdatum) . = ..() if(prob(GUN_NO_SAFETY_MALFUNCTION_CHANCE_HIGH)) - go_off("hits the ground hard") + go_off("hits the ground hard", 80) /obj/item/gun/update_overlays() . = ..() From 89fb7de7aeb37651138407e8820c1b0a01bbba52 Mon Sep 17 00:00:00 2001 From: Gristlebee <56049844+Gristlebee@users.noreply.github.com> Date: Mon, 26 Aug 2024 16:10:04 -0700 Subject: [PATCH 06/14] proc name, chances --- code/modules/projectiles/gun.dm | 6 +++--- code/modules/projectiles/guns/energy.dm | 2 +- code/modules/shuttle/on_move.dm | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm index cd170c1a7021..cae18c975705 100644 --- a/code/modules/projectiles/gun.dm +++ b/code/modules/projectiles/gun.dm @@ -730,7 +730,7 @@ /obj/item/gun/throw_impact(atom/hit_atom, datum/thrownthing/throwingdatum) . = ..() if(prob(GUN_NO_SAFETY_MALFUNCTION_CHANCE_HIGH)) - go_off("hits the ground hard", 80) + discharge("hits the ground hard", 80) /obj/item/gun/update_overlays() . = ..() @@ -971,7 +971,7 @@ muzzle_flash.applied = FALSE // for guns firing on their own without a user -/obj/item/gun/proc/go_off(cause, seek_chance = 50) +/obj/item/gun/proc/discharge(cause, seek_chance = 50) var/target if(!safety) // someone is very unlucky and about to be shot @@ -998,7 +998,7 @@ /mob/living/proc/trip_with_gun() for(var/obj/item/gun/at_risk in get_all_contents()) - if(at_risk.safety == FALSE && prob(GUN_NO_SAFETY_MALFUNCTION_CHANCE_MEDIUM)) + if(at_risk.safety == FALSE && prob(GUN_NO_SAFETY_MALFUNCTION_CHANCE_HIGH)) visible_message(span_danger("\The [at_risk.name]'s trigger gets caught as [src] falls, suddenly going off into [src]'s leg! Should have had the safeties on."), span_danger("\The [at_risk.name]'s trigger gets caught on something as you fall, suddenly going off into your leg without it's safeties on!")) at_risk.process_fire(src,src,FALSE, null, pick(BODY_ZONE_L_LEG,BODY_ZONE_R_LEG)) diff --git a/code/modules/projectiles/guns/energy.dm b/code/modules/projectiles/guns/energy.dm index 449738cee5b1..967a07df60fd 100644 --- a/code/modules/projectiles/guns/energy.dm +++ b/code/modules/projectiles/guns/energy.dm @@ -40,7 +40,7 @@ . = ..() if(!(. & EMP_PROTECT_CONTENTS)) if(prob(GUN_NO_SAFETY_MALFUNCTION_CHANCE_HIGH)) - go_off("malfuctions from the EMP") + discharge("malfuctions from the EMP") cell.use(round(cell.charge / severity)) chambered = null //we empty the chamber recharge_newshot() //and try to charge a new shot diff --git a/code/modules/shuttle/on_move.dm b/code/modules/shuttle/on_move.dm index 4c409072a34d..bda0ed6d70d6 100644 --- a/code/modules/shuttle/on_move.dm +++ b/code/modules/shuttle/on_move.dm @@ -302,7 +302,7 @@ All ShuttleMove procs go here /obj/item/gun/lateShuttleMove(turf/oldT, list/movement_force, move_dir) . = ..() if(prob(GUN_NO_SAFETY_MALFUNCTION_CHANCE_MEDIUM)) - go_off("is thrown around by the force of the take off") + discharge("is thrown around by the force of the take off") /************************************Mob move procs************************************/ From e26ec121af1cac14cbfb1ca967c188d79b122ac8 Mon Sep 17 00:00:00 2001 From: Gristlebee <56049844+Gristlebee@users.noreply.github.com> Date: Mon, 26 Aug 2024 22:47:27 -0700 Subject: [PATCH 07/14] moves defines to proper place, discharges account for storage, holstered guns less likely to go off --- code/__DEFINES/guns.dm | 5 +++++ code/game/objects/items.dm | 4 ++++ code/modules/projectiles/gun.dm | 18 ++++++++++-------- code/modules/shuttle/on_move.dm | 9 ++++++++- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/code/__DEFINES/guns.dm b/code/__DEFINES/guns.dm index 01cfa1e5bd5c..63246814ed83 100644 --- a/code/__DEFINES/guns.dm +++ b/code/__DEFINES/guns.dm @@ -69,6 +69,11 @@ #define MANUFACTURER_PGF "the Etherbor Industries emblem" #define MANUFACTURER_IMPORT "Lanchester Import Co." +// Misfire chances if the gun's safety is off +#define GUN_NO_SAFETY_MALFUNCTION_CHANCE_LOW 5 +#define GUN_NO_SAFETY_MALFUNCTION_CHANCE_MEDIUM 40 +#define GUN_NO_SAFETY_MALFUNCTION_CHANCE_HIGH 80 + ///////////////// // ATTACHMENTS // ///////////////// diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index 6a47415140fe..5f097668cf4f 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -742,6 +742,10 @@ GLOBAL_VAR_INIT(embedpocalypse, FALSE) // if true, all items will be able to emb else playsound(src, drop_sound, YEET_SOUND_VOLUME, ignore_walls = FALSE) + + for(var/obj/item/gun/at_risk in get_all_contents()) + if(at_risk.safety == FALSE && prob(GUN_NO_SAFETY_MALFUNCTION_CHANCE_HIGH)) + at_risk.discharge("hits the ground hard") return hit_atom.hitby(src, 0, itempush, throwingdatum=throwingdatum) /obj/item/throw_at(atom/target, range, speed, mob/thrower, spin=1, diagonals_first = 0, datum/callback/callback, force, gentle = FALSE, quickstart = TRUE) diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm index 52d99cecb1bd..2bb716c3eb95 100644 --- a/code/modules/projectiles/gun.dm +++ b/code/modules/projectiles/gun.dm @@ -1,7 +1,3 @@ -#define GUN_NO_SAFETY_MALFUNCTION_CHANCE_LOW 5 -#define GUN_NO_SAFETY_MALFUNCTION_CHANCE_MEDIUM 40 -#define GUN_NO_SAFETY_MALFUNCTION_CHANCE_HIGH 80 - /obj/item/gun name = "gun" desc = "It's a gun. It's pretty terrible, though." @@ -960,19 +956,19 @@ if(!safety) // someone is very unlucky and about to be shot if(prob(seek_chance)) - for(var/mob/living/target_mob in range(6, src.loc)) + for(var/mob/living/target_mob in range(6, get_turf(src))) if(!isInSight(src, target_mob)) continue target = target_mob break if(!target) var/fire_dir = pick(GLOB.alldirs) - target = get_ranged_target_turf(src,fire_dir,6) + target = get_ranged_target_turf(get_turf(src),fire_dir,6) if(!chambered || !chambered.BB) visible_message(span_danger("\The [src] [cause ? "[cause], suddenly going off" : "suddenly goes off"] without its safteies on! Luckily it wasn't live.")) playsound(src, dry_fire_sound, 30, TRUE) else - visible_message(span_danger("\The [src] [cause ? "[cause], suddenly going off" : "suddenly goes off"] without its safeties on!")) + visible_message(span_danger("\The [src] [cause ? "[cause], suddenly going off" : "suddenly goes off"] without its safeties on!")) unsafe_shot(target) /obj/item/gun/proc/unsafe_shot(target) @@ -982,7 +978,13 @@ /mob/living/proc/trip_with_gun() for(var/obj/item/gun/at_risk in get_all_contents()) - if(at_risk.safety == FALSE && prob(GUN_NO_SAFETY_MALFUNCTION_CHANCE_HIGH)) + var/chance_to_fire = GUN_NO_SAFETY_MALFUNCTION_CHANCE_HIGH + if(ishuman(src)) + var/mob/living/carbon/human/holder = src + // the gun is slightly more secure in a holster + if(at_risk == holder.s_store) + chance_to_fire = GUN_NO_SAFETY_MALFUNCTION_CHANCE_MEDIUM + if(at_risk.safety == FALSE && prob(chance_to_fire)) visible_message(span_danger("\The [at_risk.name]'s trigger gets caught as [src] falls, suddenly going off into [src]'s leg! Should have had the safeties on."), span_danger("\The [at_risk.name]'s trigger gets caught on something as you fall, suddenly going off into your leg without it's safeties on!")) at_risk.process_fire(src,src,FALSE, null, pick(BODY_ZONE_L_LEG,BODY_ZONE_R_LEG)) diff --git a/code/modules/shuttle/on_move.dm b/code/modules/shuttle/on_move.dm index bda0ed6d70d6..c40fc6e62500 100644 --- a/code/modules/shuttle/on_move.dm +++ b/code/modules/shuttle/on_move.dm @@ -291,6 +291,7 @@ All ShuttleMove procs go here /************************************Item move procs************************************/ + /obj/item/storage/pod/afterShuttleMove(turf/oldT, list/movement_force, shuttle_dir, shuttle_preferred_direction, move_dir, rotation) . = ..() // If the pod was launched, the storage will always open. The reserved_level check @@ -301,9 +302,15 @@ All ShuttleMove procs go here /obj/item/gun/lateShuttleMove(turf/oldT, list/movement_force, move_dir) . = ..() - if(prob(GUN_NO_SAFETY_MALFUNCTION_CHANCE_MEDIUM)) + if(prob(GUN_NO_SAFETY_MALFUNCTION_CHANCE_HIGH)) discharge("is thrown around by the force of the take off") +/obj/item/lateShuttleMove(turf/oldT, list/movement_force, move_dir) + . = ..() + for(var/obj/item/gun/at_risk in get_all_contents()) + if(at_risk.safety == FALSE && prob(GUN_NO_SAFETY_MALFUNCTION_CHANCE_HIGH)) + at_risk.discharge("is thrown around by the force of the take off") + /************************************Mob move procs************************************/ /mob/onShuttleMove(turf/newT, turf/oldT, list/movement_force, move_dir, obj/docking_port/stationary/old_dock, obj/docking_port/mobile/moving_dock, list/obj/docking_port/mobile/towed_shuttles) From bbad2a11828be3a38446bfa22911631261d312fd Mon Sep 17 00:00:00 2001 From: Gristlebee <56049844+Gristlebee@users.noreply.github.com> Date: Mon, 26 Aug 2024 23:06:09 -0700 Subject: [PATCH 08/14] more sane --- code/game/objects/items.dm | 4 ---- code/game/objects/items/storage/storage.dm | 6 ++++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index 5f097668cf4f..6a47415140fe 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -742,10 +742,6 @@ GLOBAL_VAR_INIT(embedpocalypse, FALSE) // if true, all items will be able to emb else playsound(src, drop_sound, YEET_SOUND_VOLUME, ignore_walls = FALSE) - - for(var/obj/item/gun/at_risk in get_all_contents()) - if(at_risk.safety == FALSE && prob(GUN_NO_SAFETY_MALFUNCTION_CHANCE_HIGH)) - at_risk.discharge("hits the ground hard") return hit_atom.hitby(src, 0, itempush, throwingdatum=throwingdatum) /obj/item/throw_at(atom/target, range, speed, mob/thrower, spin=1, diagonals_first = 0, datum/callback/callback, force, gentle = FALSE, quickstart = TRUE) diff --git a/code/game/objects/items/storage/storage.dm b/code/game/objects/items/storage/storage.dm index c2619eef4c14..f0e5665b446b 100644 --- a/code/game/objects/items/storage/storage.dm +++ b/code/game/objects/items/storage/storage.dm @@ -28,6 +28,12 @@ if(EXPLODE_LIGHT) SSexplosions.lowobj += A +/obj/item/storage/throw_impact(atom/hit_atom, datum/thrownthing/throwingdatum) + . = ..() + for(var/obj/item/gun/at_risk in get_all_contents()) + if(at_risk.safety == FALSE && prob(GUN_NO_SAFETY_MALFUNCTION_CHANCE_HIGH)) + at_risk.discharge("is hits the ground hard") + /obj/item/storage/canStrip(mob/who) . = ..() if(!. && rummage_if_nodrop) From 808f6f92230369e408dec60c595f7bf1d9a9c9d2 Mon Sep 17 00:00:00 2001 From: Gristlebee <56049844+Gristlebee@users.noreply.github.com> Date: Tue, 27 Aug 2024 18:46:10 -0700 Subject: [PATCH 09/14] scream --- code/modules/projectiles/gun.dm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm index 2bb716c3eb95..b0ebc902f954 100644 --- a/code/modules/projectiles/gun.dm +++ b/code/modules/projectiles/gun.dm @@ -985,8 +985,9 @@ if(at_risk == holder.s_store) chance_to_fire = GUN_NO_SAFETY_MALFUNCTION_CHANCE_MEDIUM if(at_risk.safety == FALSE && prob(chance_to_fire)) - visible_message(span_danger("\The [at_risk.name]'s trigger gets caught as [src] falls, suddenly going off into [src]'s leg! Should have had the safeties on."), span_danger("\The [at_risk.name]'s trigger gets caught on something as you fall, suddenly going off into your leg without it's safeties on!")) - at_risk.process_fire(src,src,FALSE, null, pick(BODY_ZONE_L_LEG,BODY_ZONE_R_LEG)) + if(at_risk.process_fire(src,src,FALSE, null, pick(BODY_ZONE_L_LEG,BODY_ZONE_R_LEG)) == TRUE) + visible_message(span_danger("\The [at_risk.name]'s trigger gets caught as [src] falls, suddenly going off into [src]'s leg! Should have had the safeties on."), span_danger("\The [at_risk.name]'s trigger gets caught on something as you fall, suddenly going off into your leg without it's safeties on!")) + emote("scream") //I need to refactor this into an attachment /datum/action/toggle_scope_zoom From b6aafd3cb31e95d92bb88612d694376d82184b55 Mon Sep 17 00:00:00 2001 From: Gristlebee <56049844+Gristlebee@users.noreply.github.com> Date: Wed, 28 Aug 2024 17:06:37 -0700 Subject: [PATCH 10/14] reduced seeking gun chances --- code/modules/projectiles/gun.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm index b0ebc902f954..97309ded90d3 100644 --- a/code/modules/projectiles/gun.dm +++ b/code/modules/projectiles/gun.dm @@ -729,7 +729,7 @@ /obj/item/gun/throw_impact(atom/hit_atom, datum/thrownthing/throwingdatum) . = ..() if(prob(GUN_NO_SAFETY_MALFUNCTION_CHANCE_HIGH)) - discharge("hits the ground hard", 80) + discharge("hits the ground hard", 50) /obj/item/gun/update_overlays() . = ..() @@ -951,7 +951,7 @@ muzzle_flash.applied = FALSE // for guns firing on their own without a user -/obj/item/gun/proc/discharge(cause, seek_chance = 50) +/obj/item/gun/proc/discharge(cause, seek_chance = 10) var/target if(!safety) // someone is very unlucky and about to be shot From 5282ab3521d1ae3b18bb78a6a1a4dddcc2c3595e Mon Sep 17 00:00:00 2001 From: Gristlebee <56049844+Gristlebee@users.noreply.github.com> Date: Thu, 29 Aug 2024 15:08:50 -0700 Subject: [PATCH 11/14] suggested changes --- code/__DEFINES/guns.dm | 4 ++-- code/datums/status_effects/debuffs.dm | 2 ++ .../modules/mob/living/carbon/carbon_movement.dm | 1 - code/modules/projectiles/gun.dm | 16 +++++++++------- code/modules/projectiles/guns/energy.dm | 2 +- code/modules/shuttle/on_move.dm | 9 +-------- 6 files changed, 15 insertions(+), 19 deletions(-) diff --git a/code/__DEFINES/guns.dm b/code/__DEFINES/guns.dm index 63246814ed83..d1cea0d28de4 100644 --- a/code/__DEFINES/guns.dm +++ b/code/__DEFINES/guns.dm @@ -71,8 +71,8 @@ // Misfire chances if the gun's safety is off #define GUN_NO_SAFETY_MALFUNCTION_CHANCE_LOW 5 -#define GUN_NO_SAFETY_MALFUNCTION_CHANCE_MEDIUM 40 -#define GUN_NO_SAFETY_MALFUNCTION_CHANCE_HIGH 80 +#define GUN_NO_SAFETY_MALFUNCTION_CHANCE_MEDIUM 10 +#define GUN_NO_SAFETY_MALFUNCTION_CHANCE_HIGH 15 ///////////////// // ATTACHMENTS // diff --git a/code/datums/status_effects/debuffs.dm b/code/datums/status_effects/debuffs.dm index 02b96c1b81de..ca9a7b25035b 100644 --- a/code/datums/status_effects/debuffs.dm +++ b/code/datums/status_effects/debuffs.dm @@ -49,6 +49,7 @@ . = ..() if(!.) return + owner.trip_with_gun() ADD_TRAIT(owner, TRAIT_FLOORED, TRAIT_STATUS_EFFECT(id)) /datum/status_effect/incapacitating/knockdown/on_remove() @@ -79,6 +80,7 @@ . = ..() if(!.) return + owner.trip_with_gun() ADD_TRAIT(owner, TRAIT_INCAPACITATED, TRAIT_STATUS_EFFECT(id)) ADD_TRAIT(owner, TRAIT_IMMOBILIZED, TRAIT_STATUS_EFFECT(id)) ADD_TRAIT(owner, TRAIT_FLOORED, TRAIT_STATUS_EFFECT(id)) diff --git a/code/modules/mob/living/carbon/carbon_movement.dm b/code/modules/mob/living/carbon/carbon_movement.dm index 70eb13b958df..7f65b79ddca1 100644 --- a/code/modules/mob/living/carbon/carbon_movement.dm +++ b/code/modules/mob/living/carbon/carbon_movement.dm @@ -3,7 +3,6 @@ return FALSE if(!(lube&SLIDE_ICE)) log_combat(src, (O ? O : get_turf(src)), "slipped on the", null, ((lube & SLIDE) ? "(LUBE)" : null)) - trip_with_gun() return loc.handle_slip(src, knockdown_amount, O, lube, paralyze, force_drop) /mob/living/carbon/Process_Spacemove(movement_dir = 0) diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm index 97309ded90d3..ad71c607f6b1 100644 --- a/code/modules/projectiles/gun.dm +++ b/code/modules/projectiles/gun.dm @@ -729,7 +729,7 @@ /obj/item/gun/throw_impact(atom/hit_atom, datum/thrownthing/throwingdatum) . = ..() if(prob(GUN_NO_SAFETY_MALFUNCTION_CHANCE_HIGH)) - discharge("hits the ground hard", 50) + discharge("hits the ground hard") /obj/item/gun/update_overlays() . = ..() @@ -977,16 +977,18 @@ playsound(src, fire_sound, 100, TRUE) /mob/living/proc/trip_with_gun() + var/chance_to_fire = GUN_NO_SAFETY_MALFUNCTION_CHANCE_HIGH + var/mob/living/carbon/human/human_holder + if(ishuman(src)) + holder = src for(var/obj/item/gun/at_risk in get_all_contents()) - var/chance_to_fire = GUN_NO_SAFETY_MALFUNCTION_CHANCE_HIGH - if(ishuman(src)) - var/mob/living/carbon/human/holder = src - // the gun is slightly more secure in a holster - if(at_risk == holder.s_store) + if(human_holder) + // gun is less likely to go off in a holster + if(at_risk == human_holder.s_store) chance_to_fire = GUN_NO_SAFETY_MALFUNCTION_CHANCE_MEDIUM if(at_risk.safety == FALSE && prob(chance_to_fire)) if(at_risk.process_fire(src,src,FALSE, null, pick(BODY_ZONE_L_LEG,BODY_ZONE_R_LEG)) == TRUE) - visible_message(span_danger("\The [at_risk.name]'s trigger gets caught as [src] falls, suddenly going off into [src]'s leg! Should have had the safeties on."), span_danger("\The [at_risk.name]'s trigger gets caught on something as you fall, suddenly going off into your leg without it's safeties on!")) + visible_message(span_danger("\The [at_risk.name]'s trigger gets caught as [src] falls, suddenly going off into [src]'s leg without it's safties on!"), span_danger("\The [at_risk.name]'s trigger gets caught on something as you fall, suddenly going off into your leg without it's safeties on!")) emote("scream") //I need to refactor this into an attachment diff --git a/code/modules/projectiles/guns/energy.dm b/code/modules/projectiles/guns/energy.dm index 967a07df60fd..aaf37d4c9556 100644 --- a/code/modules/projectiles/guns/energy.dm +++ b/code/modules/projectiles/guns/energy.dm @@ -40,7 +40,7 @@ . = ..() if(!(. & EMP_PROTECT_CONTENTS)) if(prob(GUN_NO_SAFETY_MALFUNCTION_CHANCE_HIGH)) - discharge("malfuctions from the EMP") + discharge("malfunctions from the EMP") cell.use(round(cell.charge / severity)) chambered = null //we empty the chamber recharge_newshot() //and try to charge a new shot diff --git a/code/modules/shuttle/on_move.dm b/code/modules/shuttle/on_move.dm index c40fc6e62500..6cb9f7304585 100644 --- a/code/modules/shuttle/on_move.dm +++ b/code/modules/shuttle/on_move.dm @@ -302,15 +302,9 @@ All ShuttleMove procs go here /obj/item/gun/lateShuttleMove(turf/oldT, list/movement_force, move_dir) . = ..() - if(prob(GUN_NO_SAFETY_MALFUNCTION_CHANCE_HIGH)) + if(prob(GUN_NO_SAFETY_MALFUNCTION_CHANCE_MEDIUM)) discharge("is thrown around by the force of the take off") -/obj/item/lateShuttleMove(turf/oldT, list/movement_force, move_dir) - . = ..() - for(var/obj/item/gun/at_risk in get_all_contents()) - if(at_risk.safety == FALSE && prob(GUN_NO_SAFETY_MALFUNCTION_CHANCE_HIGH)) - at_risk.discharge("is thrown around by the force of the take off") - /************************************Mob move procs************************************/ /mob/onShuttleMove(turf/newT, turf/oldT, list/movement_force, move_dir, obj/docking_port/stationary/old_dock, obj/docking_port/mobile/moving_dock, list/obj/docking_port/mobile/towed_shuttles) @@ -337,7 +331,6 @@ All ShuttleMove procs go here var/knockdown = movement_force["KNOCKDOWN"] if(knockdown) Paralyze(knockdown) - trip_with_gun() /mob/living/simple_animal/hostile/megafauna/onShuttleMove(turf/newT, turf/oldT, list/movement_force, move_dir, obj/docking_port/stationary/old_dock, obj/docking_port/mobile/moving_dock, list/obj/docking_port/mobile/towed_shuttles) From 2e8a6997b947761a11791c5eb77f2733cf6eb476 Mon Sep 17 00:00:00 2001 From: Gristlebee <56049844+Gristlebee@users.noreply.github.com> Date: Thu, 29 Aug 2024 15:26:00 -0700 Subject: [PATCH 12/14] makes trip chances a smidge lower --- code/modules/projectiles/gun.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm index ad71c607f6b1..40af5e9689e1 100644 --- a/code/modules/projectiles/gun.dm +++ b/code/modules/projectiles/gun.dm @@ -977,7 +977,7 @@ playsound(src, fire_sound, 100, TRUE) /mob/living/proc/trip_with_gun() - var/chance_to_fire = GUN_NO_SAFETY_MALFUNCTION_CHANCE_HIGH + var/chance_to_fire = GUN_NO_SAFETY_MALFUNCTION_CHANCE_MEDIUM var/mob/living/carbon/human/human_holder if(ishuman(src)) holder = src @@ -985,7 +985,7 @@ if(human_holder) // gun is less likely to go off in a holster if(at_risk == human_holder.s_store) - chance_to_fire = GUN_NO_SAFETY_MALFUNCTION_CHANCE_MEDIUM + chance_to_fire = GUN_NO_SAFETY_MALFUNCTION_CHANCE_LOW if(at_risk.safety == FALSE && prob(chance_to_fire)) if(at_risk.process_fire(src,src,FALSE, null, pick(BODY_ZONE_L_LEG,BODY_ZONE_R_LEG)) == TRUE) visible_message(span_danger("\The [at_risk.name]'s trigger gets caught as [src] falls, suddenly going off into [src]'s leg without it's safties on!"), span_danger("\The [at_risk.name]'s trigger gets caught on something as you fall, suddenly going off into your leg without it's safeties on!")) From 01971a8c3dfcecc67e1bf6f1c27e596e5d2fba9c Mon Sep 17 00:00:00 2001 From: Gristlebee <56049844+Gristlebee@users.noreply.github.com> Date: Thu, 29 Aug 2024 16:30:05 -0700 Subject: [PATCH 13/14] vars, grammar --- code/modules/projectiles/gun.dm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm index 40af5e9689e1..398b0373f80c 100644 --- a/code/modules/projectiles/gun.dm +++ b/code/modules/projectiles/gun.dm @@ -977,18 +977,18 @@ playsound(src, fire_sound, 100, TRUE) /mob/living/proc/trip_with_gun() - var/chance_to_fire = GUN_NO_SAFETY_MALFUNCTION_CHANCE_MEDIUM var/mob/living/carbon/human/human_holder if(ishuman(src)) - holder = src + human_holder = src for(var/obj/item/gun/at_risk in get_all_contents()) + var/chance_to_fire = GUN_NO_SAFETY_MALFUNCTION_CHANCE_MEDIUM if(human_holder) // gun is less likely to go off in a holster if(at_risk == human_holder.s_store) chance_to_fire = GUN_NO_SAFETY_MALFUNCTION_CHANCE_LOW if(at_risk.safety == FALSE && prob(chance_to_fire)) if(at_risk.process_fire(src,src,FALSE, null, pick(BODY_ZONE_L_LEG,BODY_ZONE_R_LEG)) == TRUE) - visible_message(span_danger("\The [at_risk.name]'s trigger gets caught as [src] falls, suddenly going off into [src]'s leg without it's safties on!"), span_danger("\The [at_risk.name]'s trigger gets caught on something as you fall, suddenly going off into your leg without it's safeties on!")) + visible_message(span_danger("\The [at_risk.name]'s trigger gets caught as [src] falls, suddenly going off into [src]'s leg without its safties on!"), span_danger("\The [at_risk.name]'s trigger gets caught on something as you fall, suddenly going off into your leg without its safeties on!")) emote("scream") //I need to refactor this into an attachment From 1e85e61889c625057cab030b5a69e60306fcf50e Mon Sep 17 00:00:00 2001 From: Gristlebee <56049844+Gristlebee@users.noreply.github.com> Date: Sat, 7 Sep 2024 13:40:40 -0700 Subject: [PATCH 14/14] logging --- code/__DEFINES/guns.dm | 6 +++--- code/datums/status_effects/debuffs.dm | 4 ++-- code/modules/projectiles/ammunition/_firing.dm | 7 ++++--- code/modules/projectiles/gun.dm | 6 ++++-- code/modules/projectiles/projectile.dm | 6 +++++- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/code/__DEFINES/guns.dm b/code/__DEFINES/guns.dm index d1cea0d28de4..b98da0bc1d18 100644 --- a/code/__DEFINES/guns.dm +++ b/code/__DEFINES/guns.dm @@ -70,9 +70,9 @@ #define MANUFACTURER_IMPORT "Lanchester Import Co." // Misfire chances if the gun's safety is off -#define GUN_NO_SAFETY_MALFUNCTION_CHANCE_LOW 5 -#define GUN_NO_SAFETY_MALFUNCTION_CHANCE_MEDIUM 10 -#define GUN_NO_SAFETY_MALFUNCTION_CHANCE_HIGH 15 +#define GUN_NO_SAFETY_MALFUNCTION_CHANCE_LOW 100 +#define GUN_NO_SAFETY_MALFUNCTION_CHANCE_MEDIUM 100 +#define GUN_NO_SAFETY_MALFUNCTION_CHANCE_HIGH 100 ///////////////// // ATTACHMENTS // diff --git a/code/datums/status_effects/debuffs.dm b/code/datums/status_effects/debuffs.dm index ca9a7b25035b..17e2208cdebe 100644 --- a/code/datums/status_effects/debuffs.dm +++ b/code/datums/status_effects/debuffs.dm @@ -49,7 +49,7 @@ . = ..() if(!.) return - owner.trip_with_gun() + owner.trip_with_gun("knockdown") ADD_TRAIT(owner, TRAIT_FLOORED, TRAIT_STATUS_EFFECT(id)) /datum/status_effect/incapacitating/knockdown/on_remove() @@ -80,7 +80,7 @@ . = ..() if(!.) return - owner.trip_with_gun() + owner.trip_with_gun("paralyze") ADD_TRAIT(owner, TRAIT_INCAPACITATED, TRAIT_STATUS_EFFECT(id)) ADD_TRAIT(owner, TRAIT_IMMOBILIZED, TRAIT_STATUS_EFFECT(id)) ADD_TRAIT(owner, TRAIT_FLOORED, TRAIT_STATUS_EFFECT(id)) diff --git a/code/modules/projectiles/ammunition/_firing.dm b/code/modules/projectiles/ammunition/_firing.dm index 509bd47ab6e3..bdc5254f13c9 100644 --- a/code/modules/projectiles/ammunition/_firing.dm +++ b/code/modules/projectiles/ammunition/_firing.dm @@ -1,7 +1,7 @@ -/obj/item/ammo_casing/proc/fire_casing(atom/target, mob/living/user, params, distro, quiet, zone_override, spread, atom/fired_from) +/obj/item/ammo_casing/proc/fire_casing(atom/target, mob/living/user, params, distro, quiet, zone_override, spread, atom/fired_from, misfire = FALSE) distro += variance var/targloc = get_turf(target) - ready_proj(target, user, quiet, zone_override, fired_from) + ready_proj(target, user, quiet, zone_override, fired_from, misfire) if(pellets == 1) if(distro) //We have to spread a pixel-precision bullet. throw_proj was called before so angles should exist by now... if(randomspread) @@ -23,11 +23,12 @@ update_appearance() return TRUE -/obj/item/ammo_casing/proc/ready_proj(atom/target, mob/living/user, quiet, zone_override = "", atom/fired_from) +/obj/item/ammo_casing/proc/ready_proj(atom/target, mob/living/user, quiet, zone_override = "", atom/fired_from, misfire = FALSE) if (!BB) return BB.original = target BB.firer = user + BB.misfire = misfire BB.fired_from = fired_from if (zone_override) BB.def_zone = zone_override diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm index 398b0373f80c..6e32ef1136ed 100644 --- a/code/modules/projectiles/gun.dm +++ b/code/modules/projectiles/gun.dm @@ -973,21 +973,23 @@ /obj/item/gun/proc/unsafe_shot(target) if(chambered) - chambered.fire_casing(target,null, null, null, suppressed, ran_zone(BODY_ZONE_CHEST, 50), 0, src) + chambered.fire_casing(target,null, null, null, suppressed, ran_zone(BODY_ZONE_CHEST, 50), 0, src,TRUE) playsound(src, fire_sound, 100, TRUE) -/mob/living/proc/trip_with_gun() +/mob/living/proc/trip_with_gun(cause) var/mob/living/carbon/human/human_holder if(ishuman(src)) human_holder = src for(var/obj/item/gun/at_risk in get_all_contents()) var/chance_to_fire = GUN_NO_SAFETY_MALFUNCTION_CHANCE_MEDIUM + var/did_fire = FALSE if(human_holder) // gun is less likely to go off in a holster if(at_risk == human_holder.s_store) chance_to_fire = GUN_NO_SAFETY_MALFUNCTION_CHANCE_LOW if(at_risk.safety == FALSE && prob(chance_to_fire)) if(at_risk.process_fire(src,src,FALSE, null, pick(BODY_ZONE_L_LEG,BODY_ZONE_R_LEG)) == TRUE) + log_combat(src,src,"misfired",at_risk,"caused by [cause]") visible_message(span_danger("\The [at_risk.name]'s trigger gets caught as [src] falls, suddenly going off into [src]'s leg without its safties on!"), span_danger("\The [at_risk.name]'s trigger gets caught on something as you fall, suddenly going off into your leg without its safeties on!")) emote("scream") diff --git a/code/modules/projectiles/projectile.dm b/code/modules/projectiles/projectile.dm index 66adeb53ac59..533f88c98da6 100644 --- a/code/modules/projectiles/projectile.dm +++ b/code/modules/projectiles/projectile.dm @@ -24,6 +24,8 @@ resistance_flags = LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF var/def_zone = "" //Aiming at var/atom/movable/firer = null//Who shot it + // if the projectile was the result of a misfire. For logging. + var/misfire = FALSE var/atom/fired_from = null // the atom that the projectile was fired from (gun, turret) var/suppressed = FALSE //Attack message var/yo = null @@ -280,7 +282,9 @@ for(var/datum/reagent/R in reagents.reagent_list) reagent_note += "[R.name] ([num2text(R.volume)])" - if(ismob(firer)) + if(misfire) + L.log_message("has been hit by a misfired [src] from \a [fired_from] last touched by [fired_from.fingerprintslast]", LOG_ATTACK, color = "orange") + else if(ismob(firer)) log_combat(firer, L, "shot", src, reagent_note) else L.log_message("has been shot by [firer] with [src]", LOG_ATTACK, color="orange")