diff --git a/code/__DEFINES/mobs.dm b/code/__DEFINES/mobs.dm index 1bd030313a43..072738184807 100644 --- a/code/__DEFINES/mobs.dm +++ b/code/__DEFINES/mobs.dm @@ -417,3 +417,4 @@ var/list/default_xeno_onmob_icons = list( #define HANDLING_LIMBS list("l_arm","l_hand", "r_arm", "r_hand") #define EXTREMITY_LIMBS list("l_leg","l_foot","r_leg","r_foot","l_arm","l_hand","r_arm","r_hand") #define CORE_LIMBS list("chest","head","groin") + diff --git a/code/modules/mob/mob_helpers.dm b/code/modules/mob/mob_helpers.dm index 3d74673c5308..56951097a12c 100644 --- a/code/modules/mob/mob_helpers.dm +++ b/code/modules/mob/mob_helpers.dm @@ -28,7 +28,7 @@ //TODO: Integrate defence zones and targeting body parts with the actual organ system, move these into organ definitions. -//The base miss chance for the different defence zones +/// The base miss chance for the different defence zones var/list/global/base_miss_chance = list( "head" = 10, "chest" = 0, diff --git a/code/modules/projectiles/projectile.dm b/code/modules/projectiles/projectile.dm index b01203d0f4d8..adb97e3a1c43 100644 --- a/code/modules/projectiles/projectile.dm +++ b/code/modules/projectiles/projectile.dm @@ -455,12 +455,31 @@ if(hit_chance) // Calculated from combination of both ammo accuracy and gun accuracy var/hit_roll = rand(1,100) + var/direct_hit = FALSE - if(original != L || hit_roll > hit_chance-base_miss_chance[def_zone]-20) // If hit roll is high or the firer wasn't aiming at this mob, we still hit but now we might hit the wrong body part + // Wasn't the clicked target + if(original != L) def_zone = rand_zone() + + // Xenos get a RNG limb miss chance regardless of being clicked target or not, see below + else if(isxeno(L) && hit_roll > hit_chance - 20) + def_zone = rand_zone() + + // Other targets do the same roll with penalty - a near hit will hit but redirected to another limb + else if(!isxeno(L) && hit_roll > hit_chance - 20 - base_miss_chance[def_zone]) + def_zone = rand_zone() + else + direct_hit = TRUE SEND_SIGNAL(firer, COMSIG_BULLET_DIRECT_HIT, L) - hit_chance -= base_miss_chance[def_zone] // Reduce accuracy based on spot. + + // At present, Xenos have no inherent effects or localized damage stemming from limb targeting + // Therefore we exempt the shooter from direct hit accuracy penalties as well, + // simply to avoid them from resetting target to chest every time they want to shoot a xeno + + if(!direct_hit || !isxeno(L)) // For normal people or direct hits we apply the limb accuracy penalty + hit_chance -= base_miss_chance[def_zone] + // else for direct hits on xenos, we skip it, pretending it's a chest shot with zero penalty #if DEBUG_HIT_CHANCE to_world(SPAN_DEBUG("([L]) Hit chance: [hit_chance] | Roll: [hit_roll]"))