diff --git a/code/modules/mob/living/carbon/human/human_defense.dm b/code/modules/mob/living/carbon/human/human_defense.dm index 399eabcf04..cb13034af5 100644 --- a/code/modules/mob/living/carbon/human/human_defense.dm +++ b/code/modules/mob/living/carbon/human/human_defense.dm @@ -38,9 +38,9 @@ emp_act return -1 // complete projectile permutation //Shrapnel - if (P.damage_type == BRUTE) + if (P.can_embed()) var/armor = getarmor_organ(organ, "bullet") - if((P.embed && prob(20 + max(P.damage - armor, -10)))) + if(P.embed && prob(20 + max(P.damage - armor, -10))) var/obj/item/weapon/shard/shrapnel/SP = new() SP.name = (P.name != "shrapnel")? "[P.name] shrapnel" : "shrapnel" SP.desc = "[SP.desc] It looks like it was fired from [P.shot_from]." diff --git a/code/modules/projectiles/projectile.dm b/code/modules/projectiles/projectile.dm index f84a66c752..e25b4491da 100644 --- a/code/modules/projectiles/projectile.dm +++ b/code/modules/projectiles/projectile.dm @@ -65,8 +65,19 @@ /obj/item/projectile/proc/on_impact(var/atom/A) return +//Checks if the projectile is eligible for embedding. Not that it necessarily will. +//Mainly used to ensure that projectiles won't embed if they are penetrating the mob. +/obj/item/projectile/proc/can_embed() + //embed must be enabled and damage type must be brute + if(!embed || damage_type != BRUTE) + return 0 + //can't embed if the projectile is penetrating through the mob + if(penetrating > 0 && damage > 20 && prob(damage)) + return 0 + return 1 + //return 1 if the projectile should be allowed to pass through after all, 0 if not. -/obj/item/projectile/proc/on_penetrate(var/atom/A) +/obj/item/projectile/proc/check_penetrate(var/atom/A) return 1 /obj/item/projectile/proc/check_fire(atom/target as mob, var/mob/living/user as mob) //Checks if you can hit them or not. @@ -195,9 +206,9 @@ for(var/mob/M in A) attack_mob(M, distance) - //penetrating projectiles can pass through things that otherwise would not let them + //penetrating projectiles can pass through things that otherwise would not let them if(!passthrough && penetrating > 0) - if(on_penetrate(A)) + if(check_penetrate(A)) passthrough = 1 penetrating-- @@ -300,4 +311,4 @@ trace.firer = user var/output = trace.process() //Test it! del(trace) //No need for it anymore - return output //Send it back to the gun! \ No newline at end of file + return output //Send it back to the gun! diff --git a/code/modules/projectiles/projectile/bullets.dm b/code/modules/projectiles/projectile/bullets.dm index 2b041808f7..6e15021b44 100644 --- a/code/modules/projectiles/projectile/bullets.dm +++ b/code/modules/projectiles/projectile/bullets.dm @@ -13,16 +13,17 @@ var/mob/living/L = target shake_camera(L, 3, 2) -/obj/item/projectile/bullet/on_penetrate(var/atom/A) - if(!A || !A.density) return 1 //if whatever it was got destroyed when we hit it, then I guess we can just keep going +/obj/item/projectile/bullet/check_penetrate(var/atom/A) + if(!A || !A.density) return 1 //if whatever it was got destroyed when we hit it, then I guess we can just keep going if(istype(A, /obj/mecha)) return 1 //mecha have their own penetration handling if(ismob(A)) if(iscarbon(A)) - if (damage <= 20 && !prob(damage)) return 0 - damage *= 0.7 //squishy mobs absorb KE + //squishy mobs absorb KE + if(can_embed()) return 0 + damage *= 0.7 return 1 var/chance = 0