mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-07-20 19:44:46 +01:00
Improves bullet projectile embedding handling
Commit b1546ee3eb contained a rather
bone-headed mistake, that resulted in embedding with penetrating
projectiles to not behave as desired.
This commit fixes that, and provides a cleaner implementation.
This commit is contained in:
@@ -38,9 +38,9 @@ emp_act
|
||||
return -1 // complete projectile permutation
|
||||
|
||||
//Shrapnel
|
||||
if (P.can_embed())
|
||||
if(P.can_embed())
|
||||
var/armor = getarmor_organ(organ, "bullet")
|
||||
if(P.embed && prob(20 + max(P.damage - armor, -10)))
|
||||
if(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]."
|
||||
|
||||
@@ -66,14 +66,10 @@
|
||||
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.
|
||||
@@ -206,9 +202,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(check_penetrate(A))
|
||||
if(check_penetrate(A))
|
||||
passthrough = 1
|
||||
penetrating--
|
||||
|
||||
@@ -311,4 +307,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!
|
||||
return output //Send it back to the gun!
|
||||
@@ -7,23 +7,37 @@
|
||||
check_armour = "bullet"
|
||||
embed = 1
|
||||
sharp = 1
|
||||
var/mob_passthrough_check = 0
|
||||
|
||||
/obj/item/projectile/bullet/on_hit(var/atom/target, var/blocked = 0)
|
||||
if (..(target, blocked))
|
||||
var/mob/living/L = target
|
||||
shake_camera(L, 3, 2)
|
||||
|
||||
/obj/item/projectile/bullet/attack_mob(var/mob/living/target_mob, var/distance, var/miss_modifier)
|
||||
if(penetrating > 0 && damage > 20 && prob(damage))
|
||||
mob_passthrough_check = 1
|
||||
else
|
||||
mob_passthrough_check = 0
|
||||
..()
|
||||
|
||||
/obj/item/projectile/bullet/can_embed()
|
||||
//prevent embedding if the projectile is passing through the mob
|
||||
if(mob_passthrough_check)
|
||||
return 0
|
||||
return ..()
|
||||
|
||||
/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(!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 (!mob_passthrough_check)
|
||||
return 0
|
||||
if(iscarbon(A))
|
||||
//squishy mobs absorb KE
|
||||
if(can_embed()) return 0
|
||||
damage *= 0.7
|
||||
damage *= 0.7 //squishy mobs absorb KE
|
||||
return 1
|
||||
|
||||
var/chance = 0
|
||||
|
||||
Reference in New Issue
Block a user