mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
Improves the way shrapnel clouds hit prone mobs
This commit is contained in:
@@ -6,25 +6,9 @@
|
|||||||
base_spread = 0 //hit any target zone randomly
|
base_spread = 0 //hit any target zone randomly
|
||||||
spread_step = 0
|
spread_step = 0
|
||||||
|
|
||||||
//step_delay = 10
|
|
||||||
silenced = 1
|
silenced = 1
|
||||||
//hitscan = 1
|
|
||||||
muzzle_type = null
|
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
|
/obj/item/weapon/grenade/frag
|
||||||
name = "fragmentation grenade"
|
name = "fragmentation grenade"
|
||||||
desc = "A military fragmentation grenade, designed to explode in a deadly shower of fragments."
|
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
|
var/location = loc //store our current loc since qdel will move the grenade to nullspace
|
||||||
spawn(0)
|
spawn(0)
|
||||||
P.launch(target)
|
P.launch(target)
|
||||||
|
/*
|
||||||
if(!isturf(location))
|
if(!isturf(location))
|
||||||
P.Bump(location)
|
P.Bump(location)
|
||||||
for(var/atom/movable/AM in source)
|
for(var/atom/movable/AM in source)
|
||||||
P.Bump(AM)
|
P.Bump(AM)
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
//the vector system doesn't play well with very large angle offsets, so generate projectiles along each of the 8 directions
|
//the vector system doesn't play well with very large angle offsets, so generate projectiles along each of the 8 directions
|
||||||
|
|||||||
@@ -70,21 +70,32 @@
|
|||||||
//icon_state = "bullet" //TODO: would be nice to have it's own icon state
|
//icon_state = "bullet" //TODO: would be nice to have it's own icon state
|
||||||
var/pellets = 4 //number of pellets
|
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/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
|
var/spread_step = 10 //higher means the pellets spread more across body parts with distance
|
||||||
|
|
||||||
/obj/item/projectile/bullet/pellet/Bumped()
|
/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.
|
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
|
if (pellets < 0) return 1
|
||||||
|
|
||||||
var/pellet_loss = round((distance - 1)/range_step) //pellets lost due to distance
|
var/pellet_loss = round((distance - 1)/range_step) //pellets lost due to distance
|
||||||
var/total_pellets = max(pellets - pellet_loss, 1)
|
var/total_pellets = max(pellets - pellet_loss, 1)
|
||||||
var/spread = max(base_spread - (spread_step*distance), 0)
|
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
|
var/hits = 0
|
||||||
for (var/i in 1 to total_pellets)
|
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
|
//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().
|
//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
|
var/old_zone = def_zone
|
||||||
@@ -92,12 +103,20 @@
|
|||||||
if (..()) hits++
|
if (..()) hits++
|
||||||
def_zone = old_zone //restore the original zone the projectile was aimed at
|
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
|
pellets -= hits //each hit reduces the number of pellets left
|
||||||
if (hits >= total_pellets || pellets <= 0)
|
if (hits >= total_pellets || pellets <= 0)
|
||||||
return 1
|
return 1
|
||||||
return 0
|
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 */
|
/* short-casing projectiles, like the kind used in pistols or SMGs */
|
||||||
|
|
||||||
/obj/item/projectile/bullet/pistol
|
/obj/item/projectile/bullet/pistol
|
||||||
|
|||||||
Reference in New Issue
Block a user