From e6e0c870629c80ddfac3424cfaa1129e11735ad5 Mon Sep 17 00:00:00 2001 From: mwerezak Date: Sat, 14 Mar 2015 01:53:11 -0400 Subject: [PATCH] Aggressive grab auto hit only applies to close targets and melee attacks --- .../mob/living/carbon/human/human_defense.dm | 2 +- code/modules/mob/mob_helpers.dm | 9 +++++---- code/modules/projectiles/projectile.dm | 15 ++++++++++----- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/code/modules/mob/living/carbon/human/human_defense.dm b/code/modules/mob/living/carbon/human/human_defense.dm index 83076373e4..6012adb0dd 100644 --- a/code/modules/mob/living/carbon/human/human_defense.dm +++ b/code/modules/mob/living/carbon/human/human_defense.dm @@ -319,7 +319,7 @@ emp_act if (O.throw_source) var/distance = get_dist(O.throw_source, loc) miss_chance = max(15*(distance-2), 0) - zone = get_zone_with_miss_chance(zone, src, miss_chance) + zone = get_zone_with_miss_chance(zone, src, miss_chance, ranged_attack=1) if(!zone) visible_message("\blue \The [O] misses [src] narrowly!") diff --git a/code/modules/mob/mob_helpers.dm b/code/modules/mob/mob_helpers.dm index 35636fb828..95de6cdfb4 100644 --- a/code/modules/mob/mob_helpers.dm +++ b/code/modules/mob/mob_helpers.dm @@ -229,16 +229,17 @@ 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) +/proc/get_zone_with_miss_chance(zone, var/mob/target, var/miss_chance_mod = 0, var/ranged_attack=0) zone = check_zone(zone) // you cannot miss if your target is prone or restrained if(target.buckled || target.lying) return zone // if your target is being grabbed aggressively by someone you cannot miss either - for(var/obj/item/weapon/grab/G in target.grabbed_by) - if(G.state >= GRAB_AGGRESSIVE) - return zone + if(!ranged_attack) + for(var/obj/item/weapon/grab/G in target.grabbed_by) + if(G.state >= GRAB_AGGRESSIVE) + return zone 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 948998c522..23ef9e03c3 100644 --- a/code/modules/projectiles/projectile.dm +++ b/code/modules/projectiles/projectile.dm @@ -135,16 +135,21 @@ xo = new_x - starting_loc.x //Called when the projectile intercepts a mob. Returns 1 if the projectile hit the mob, 0 if it missed and should keep flying. -/obj/item/projectile/proc/attack_mob(var/mob/living/target_mob, var/distance, var/miss_modifier) +/obj/item/projectile/proc/attack_mob(var/mob/living/target_mob, var/distance, var/miss_modifier=0) //accuracy bonus from aiming - if (istype(shot_from, /obj/item/weapon/gun)) //If you aim at someone beforehead, it'll hit more often. - var/obj/item/weapon/gun/daddy = shot_from //Kinda balanced by fact you need like 2 seconds to aim + if (istype(shot_from, /obj/item/weapon/gun)) + var/obj/item/weapon/gun/daddy = shot_from miss_modifier -= round(15*daddy.accuracy) - if (daddy.aim_targets && original in daddy.aim_targets) //As opposed to no-delay pew pew + + //If you aim at someone beforehead, it'll hit more often. + //Kinda balanced by fact you need like 2 seconds to aim + //As opposed to no-delay pew pew + if (daddy.aim_targets && original in daddy.aim_targets) miss_modifier += -30 //roll to-hit - var/hit_zone = get_zone_with_miss_chance(def_zone, target_mob, max(miss_modifier + 15*(distance-2), 0)) + miss_modifier = max(miss_modifier + 15*(distance-2), 0) + var/hit_zone = get_zone_with_miss_chance(def_zone, target_mob, miss_modifier, ranged_attack=(distance > 1)) if(!hit_zone) visible_message("\The [src] misses [target_mob] narrowly!") return 0