diff --git a/code/game/mecha/equipment/weapons/weapons.dm b/code/game/mecha/equipment/weapons/weapons.dm index 5f2b7254e4..7b665efbe9 100644 --- a/code/game/mecha/equipment/weapons/weapons.dm +++ b/code/game/mecha/equipment/weapons/weapons.dm @@ -71,13 +71,7 @@ if(!istype(P)) return - // Certain statuses make it harder to aim, blindness especially. Same chances as melee, however guns accuracy uses multiples of 15. - if(user.eye_blind) - P.accuracy -= 75 - if(user.eye_blurry) - P.accuracy -= 30 - if(user.confused) - P.accuracy -= 45 + P.accuracy -= user.get_accuracy_penalty() // Some modifiers make it harder or easier to hit things. for(var/datum/modifier/M in user.modifiers) diff --git a/code/modules/mob/living/carbon/human/human_attackhand.dm b/code/modules/mob/living/carbon/human/human_attackhand.dm index a2c725b5bd..4789136d66 100644 --- a/code/modules/mob/living/carbon/human/human_attackhand.dm +++ b/code/modules/mob/living/carbon/human/human_attackhand.dm @@ -24,8 +24,8 @@ // Should this all be in Touch()? if(istype(H)) - if(get_accuracy_penalty(H) && H != src) //Should only trigger if they're not aiming well - var/hit_zone = get_zone_with_miss_chance(H.zone_sel.selecting, src, get_accuracy_penalty(H)) + if(H.get_accuracy_penalty() && H != src) //Should only trigger if they're not aiming well + var/hit_zone = get_zone_with_miss_chance(H.zone_sel.selecting, src, H.get_accuracy_penalty()) if(!hit_zone) H.do_attack_animation(src) playsound(loc, 'sound/weapons/punchmiss.ogg', 25, 1, -1) @@ -235,7 +235,7 @@ H.visible_message("[attack_message]") playsound(loc, ((miss_type) ? (miss_type == 1 ? attack.miss_sound : 'sound/weapons/thudswoosh.ogg') : attack.attack_sound), 25, 1, -1) - + add_attack_logs(H,src,"Melee attacked with fists (miss/block)") if(miss_type) diff --git a/code/modules/mob/living/carbon/human/human_defense.dm b/code/modules/mob/living/carbon/human/human_defense.dm index 64cd6a0dc1..21589fc791 100644 --- a/code/modules/mob/living/carbon/human/human_defense.dm +++ b/code/modules/mob/living/carbon/human/human_defense.dm @@ -187,18 +187,6 @@ emp_act if(.) return return 0 -/mob/living/carbon/human/proc/get_accuracy_penalty(mob/living/user) - // Certain statuses make it harder to score a hit. These are the same as gun accuracy, however melee doesn't use multiples of 15. - var/accuracy_penalty = 0 - if(user.eye_blind) - accuracy_penalty += 75 - if(user.eye_blurry) - accuracy_penalty += 30 - if(user.confused) - accuracy_penalty += 45 - - return accuracy_penalty - /mob/living/carbon/human/resolve_item_attack(obj/item/I, mob/living/user, var/target_zone) if(check_neckgrab_attack(I, user, target_zone)) return null @@ -206,7 +194,7 @@ emp_act if(user == src) // Attacking yourself can't miss return target_zone - var/hit_zone = get_zone_with_miss_chance(target_zone, src, get_accuracy_penalty(user)) + var/hit_zone = get_zone_with_miss_chance(target_zone, src, user.get_accuracy_penalty()) if(!hit_zone) user.do_attack_animation(src) @@ -349,13 +337,14 @@ emp_act if(istype(AM,/obj/)) var/obj/O = AM - if(in_throw_mode && !get_active_hand() && speed <= THROWFORCE_SPEED_DIVISOR) //empty active hand and we're in throw mode + if(in_throw_mode && speed <= THROWFORCE_SPEED_DIVISOR) //empty active hand and we're in throw mode if(canmove && !restrained()) if(isturf(O.loc)) - put_in_active_hand(O) - visible_message("[src] catches [O]!") - throw_mode_off() - return + if(can_catch(O)) + put_in_active_hand(O) + visible_message("[src] catches [O]!") + throw_mode_off() + return var/dtype = O.damtype var/throw_damage = O.throwforce*(speed/THROWFORCE_SPEED_DIVISOR) @@ -450,6 +439,29 @@ emp_act src.anchored = 1 src.pinned += O +// This does a prob check to catch the thing flying at you, with a minimum of 1% +/mob/living/carbon/human/proc/can_catch(var/obj/O) + if(!get_active_hand()) // If active hand is empty + var/obj/item/organ/external/temp = organs_by_name["r_hand"] + if (hand) + temp = organs_by_name["l_hand"] + if(temp && !temp.is_usable()) + return FALSE // The hand isn't working in the first place + + // Alright, our hand works? Time to try the catching. + var/catch_chance = 90 // Default 90% catch rate + + if(O.sharp) + catch_chance -= 50 // Catching knives is hard + + catch_chance -= get_accuracy_penalty() // Same issues with shooting a gun, or swinging a weapon + + catch_chance = between(1, catch_chance, 100) + + if(prob(catch_chance)) + return TRUE + return FALSE + /mob/living/carbon/human/embed(var/obj/O, var/def_zone=null) if(!def_zone) ..() diff --git a/code/modules/mob/living/living_defense.dm b/code/modules/mob/living/living_defense.dm index 08bebc91b2..ea25fc88d5 100644 --- a/code/modules/mob/living/living_defense.dm +++ b/code/modules/mob/living/living_defense.dm @@ -507,3 +507,15 @@ if(!isnull(M.evasion)) result += M.evasion return result + +/mob/living/proc/get_accuracy_penalty() + // Certain statuses make it harder to score a hit. + var/accuracy_penalty = 0 + if(eye_blind) + accuracy_penalty += 75 + if(eye_blurry) + accuracy_penalty += 30 + if(confused) + accuracy_penalty += 45 + + return accuracy_penalty \ No newline at end of file diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm index 68ad8f0fd5..74915ada47 100644 --- a/code/modules/projectiles/gun.dm +++ b/code/modules/projectiles/gun.dm @@ -590,13 +590,7 @@ P.accuracy = accuracy + acc_mod P.dispersion = disp_mod - // Certain statuses make it harder to aim, blindness especially. Same chances as melee, however guns accuracy uses multiples of 15. - if(user.eye_blind) - P.accuracy -= 75 - if(user.eye_blurry) - P.accuracy -= 30 - if(user.confused) - P.accuracy -= 45 + P.accuracy -= user.get_accuracy_penalty() //accuracy bonus from aiming if (aim_targets && (target in aim_targets))