From fac12639cd8b2c0c9a2ff6f9e2c656a4d5427608 Mon Sep 17 00:00:00 2001 From: Matt Atlas Date: Tue, 26 Jul 2022 16:37:59 +0200 Subject: [PATCH] Fixes pointblank shots being able to miss. (#14486) --- .../mob/living/carbon/human/human_defense.dm | 2 +- code/modules/mob/mob_helpers.dm | 4 +- code/modules/projectiles/projectile.dm | 2 +- html/changelogs/mattatlas-gunfix.yml | 41 +++++++++++++++++++ 4 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 html/changelogs/mattatlas-gunfix.yml diff --git a/code/modules/mob/living/carbon/human/human_defense.dm b/code/modules/mob/living/carbon/human/human_defense.dm index a1b774a512f..e43bda97e8a 100644 --- a/code/modules/mob/living/carbon/human/human_defense.dm +++ b/code/modules/mob/living/carbon/human/human_defense.dm @@ -355,7 +355,7 @@ emp_act if (O.throw_source) var/distance = get_dist(O.throw_source, loc) miss_chance = 15 * (distance - 2) - zone = get_zone_with_miss_chance(zone, src, miss_chance, ranged_attack=1) + zone = get_zone_with_miss_chance(zone, src, miss_chance, 1) if(zone && O.thrower != src) var/shield_check = check_shields(throw_damage, O, thrower, zone, "[O]") diff --git a/code/modules/mob/mob_helpers.dm b/code/modules/mob/mob_helpers.dm index 777b1410afd..bb3e91943f4 100644 --- a/code/modules/mob/mob_helpers.dm +++ b/code/modules/mob/mob_helpers.dm @@ -314,7 +314,7 @@ var/list/global/organ_rel_size = list( // Emulates targetting a specific body part, and miss chances // May return null if missed // miss_chance_mod may be negative. -/proc/get_zone_with_miss_chance(zone, var/mob/target, var/miss_chance_mod = 0, var/ranged_attack=0) +/proc/get_zone_with_miss_chance(zone, var/mob/target, var/miss_chance_mod = 0, var/ranged_attack=0, var/point_blank = FALSE) zone = check_zone(zone) if(!ranged_attack) @@ -325,6 +325,8 @@ var/list/global/organ_rel_size = list( for(var/obj/item/grab/G in target.grabbed_by) if(G.state >= GRAB_AGGRESSIVE) return zone + if(point_blank) + return zone //Point blank shots don't miss. var/miss_chance = 10 if (zone in base_miss_chance) diff --git a/code/modules/projectiles/projectile.dm b/code/modules/projectiles/projectile.dm index 2095f22acf9..bafdebc7738 100644 --- a/code/modules/projectiles/projectile.dm +++ b/code/modules/projectiles/projectile.dm @@ -193,7 +193,7 @@ //roll to-hit miss_modifier = max(15*(distance-1) - round(25*accuracy) + miss_modifier, 0) - hit_zone = get_zone_with_miss_chance(def_zone, target_mob, miss_modifier, ranged_attack=(distance > 1 || original != target_mob)) //if the projectile hits a target we weren't originally aiming at then retain the chance to miss + hit_zone = get_zone_with_miss_chance(def_zone, target_mob, miss_modifier, (distance > 1 || original != target_mob), point_blank) //if the projectile hits a target we weren't originally aiming at then retain the chance to miss var/result = PROJECTILE_FORCE_MISS if(hit_zone) diff --git a/html/changelogs/mattatlas-gunfix.yml b/html/changelogs/mattatlas-gunfix.yml new file mode 100644 index 00000000000..c0edf3cde4d --- /dev/null +++ b/html/changelogs/mattatlas-gunfix.yml @@ -0,0 +1,41 @@ +################################ +# Example Changelog File +# +# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb. +# +# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.) +# When it is, any changes listed below will disappear. +# +# Valid Prefixes: +# bugfix +# wip (For works in progress) +# tweak +# soundadd +# sounddel +# rscadd (general adding of nice things) +# rscdel (general deleting of nice things) +# imageadd +# imagedel +# maptweak +# spellcheck (typo fixes) +# experiment +# balance +# admin +# backend +# security +# refactor +################################# + +# Your name. +author: MattAtlas + +# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. +delete-after: True + +# Any changes you've made. See valid prefix list above. +# INDENT WITH TWO SPACES. NOT TABS. SPACES. +# SCREW THIS UP AND IT WON'T WORK. +# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries. +# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog. +changes: + - bugfix: "Pointblank shots no longer have a chance to miss."