diff --git a/code/game/objects/items/weapons/grenades/fragmentation.dm b/code/game/objects/items/weapons/grenades/fragmentation.dm index 22dbe53e81..7ed4080085 100644 --- a/code/game/objects/items/weapons/grenades/fragmentation.dm +++ b/code/game/objects/items/weapons/grenades/fragmentation.dm @@ -6,25 +6,9 @@ base_spread = 0 //hit any target zone randomly spread_step = 0 - //step_delay = 10 silenced = 1 - //hitscan = 1 muzzle_type = null -/obj/item/projectile/bullet/pellet/fragment/Move() - . = ..() - - //Allow mobs that are prone close to the starting turf a chance to get hit, too - - if(. && isturf(loc)) - var/distance = get_dist(loc, starting) - var/chance = max(100 - (distance - 1)*20, 0) - if(prob(chance)) - for(var/mob/living/M in loc) - if(Bump(M)) //Bump will make sure we don't hit a mob multiple times - return - - /obj/item/weapon/grenade/frag name = "fragmentation grenade" desc = "A military fragmentation grenade, designed to explode in a deadly shower of fragments." @@ -76,10 +60,12 @@ var/location = loc //store our current loc since qdel will move the grenade to nullspace spawn(0) P.launch(target) + /* if(!isturf(location)) P.Bump(location) for(var/atom/movable/AM in source) P.Bump(AM) + */ /* //the vector system doesn't play well with very large angle offsets, so generate projectiles along each of the 8 directions diff --git a/code/modules/projectiles/projectile/bullets.dm b/code/modules/projectiles/projectile/bullets.dm index de40396544..76a84b19e9 100644 --- a/code/modules/projectiles/projectile/bullets.dm +++ b/code/modules/projectiles/projectile/bullets.dm @@ -70,21 +70,32 @@ //icon_state = "bullet" //TODO: would be nice to have it's own icon state var/pellets = 4 //number of pellets var/range_step = 2 //projectile will lose a fragment each time it travels this distance. Can be a non-integer. - var/base_spread = 90 //lower means the pellets spread more across body parts + var/base_spread = 90 //lower means the pellets spread more across body parts. If zero then this is considered a shrapnel explosion instead of a shrapnel cone var/spread_step = 10 //higher means the pellets spread more across body parts with distance /obj/item/projectile/bullet/pellet/Bumped() . = ..() bumped = 0 //can hit all mobs in a tile. pellets is decremented inside attack_mob so this should be fine. -/obj/item/projectile/bullet/pellet/attack_mob(var/mob/living/target_mob, var/distance) +/obj/item/projectile/bullet/pellet/attack_mob(var/mob/living/target_mob, var/distance, var/prone = 0) if (pellets < 0) return 1 var/pellet_loss = round((distance - 1)/range_step) //pellets lost due to distance var/total_pellets = max(pellets - pellet_loss, 1) var/spread = max(base_spread - (spread_step*distance), 0) + + //shrapnel explosions miss prone mobs with a chance that increases with distance + var/prone_chance = 0 + if(!base_spread) + prone_chance = max(spread_step*(distance - 2), 0) + + world << "[src]: attacking [target_mob] > target_mob.lying = [target_mob.lying], original = [original], prone_chance = [prone_chance]" + var/hits = 0 for (var/i in 1 to total_pellets) + if(target_mob.lying && target_mob != original && prob(prone_chance)) + continue + //pellet hits spread out across different zones, but 'aim at' the targeted zone with higher probability //whether the pellet actually hits the def_zone or a different zone should still be determined by the parent using get_zone_with_miss_chance(). var/old_zone = def_zone @@ -92,12 +103,20 @@ if (..()) hits++ def_zone = old_zone //restore the original zone the projectile was aimed at - //world << "[src]: hitting [target_mob], [hits] of [pellets] hits." pellets -= hits //each hit reduces the number of pellets left if (hits >= total_pellets || pellets <= 0) return 1 return 0 +/obj/item/projectile/bullet/pellet/Move() + . = ..() + + //If this is a shrapnel explosion, allow mobs that are prone to get hit, too + if(. && !base_spread && isturf(loc)) + for(var/mob/living/M in loc) + if(M.lying && Bump(M)) //Bump will make sure we don't hit a mob multiple times + return + /* short-casing projectiles, like the kind used in pistols or SMGs */ /obj/item/projectile/bullet/pistol