diff --git a/code/modules/mob/living/carbon/human/human_defense.dm b/code/modules/mob/living/carbon/human/human_defense.dm index 21928e3e188..8bf0160ee78 100644 --- a/code/modules/mob/living/carbon/human/human_defense.dm +++ b/code/modules/mob/living/carbon/human/human_defense.dm @@ -113,7 +113,11 @@ emp_act /mob/living/carbon/human/proc/attacked_by(var/obj/item/I, var/mob/living/user, var/def_zone) if(!I || !user) return 0 - var/datum/organ/external/affecting = get_organ(ran_zone(user.zone_sel.selecting)) + var/target_zone = get_zone_with_miss_chance(user.zone_sel.selecting) + if(!target_zone) + visible_message("\red [user] misses [src] with \the [I]!") + + var/datum/organ/external/affecting = get_organ(target_zone) if (!affecting) return if(affecting.status & ORGAN_DESTROYED) diff --git a/code/modules/mob/mob_helpers.dm b/code/modules/mob/mob_helpers.dm index 508a58c03c0..8b683c88082 100644 --- a/code/modules/mob/mob_helpers.dm +++ b/code/modules/mob/mob_helpers.dm @@ -163,6 +163,52 @@ proc/hasorgans(A) if(prob(probability * 0.75)) return zone return "chest" +// Emulates targetting a specific body part, and miss chances +// May return null if missed +/proc/get_zone_with_miss_chance(zone, var/mob/target) + zone = check_zone(zone) + + // you can only miss if your target is standing and not restrained + if(!target.buckled && !target.lying) + var/miss_chance = 10 + switch(zone) + if("head") + miss_chance = 40 + if("l_leg") + miss_chance = 20 + if("r_leg") + miss_chance = 20 + if("l_arm") + miss_chance = 20 + if("r_arm") + miss_chance = 20 + if("l_hand") + miss_chance = 50 + if("r_hand") + miss_chance = 50 + if("l_foot") + miss_chance = 50 + if("r_foot") + miss_chance = 50 + if(prob(miss_chance)) + if(prob(70)) + return null + else + var/t = rand(1, 10) + switch(t) + if(1) return "head" + if(2) return "l_arm" + if(3) return "r_arm" + if(4) return "chest" + if(5) return "l_foot" + if(6) return "r_foot" + if(7) return "l_hand" + if(8) return "r_hand" + if(9) return "l_leg" + if(10) return "r_leg" + + return zone + /proc/stars(n, pr) if (pr == null)