Projectile refactoring madness (#19878)

Refactored the projectile code, mostly in line with TG's now.
Refactored various procs that are used or depends on it.
Projectiles can now ricochet if enabled to.
Damage falloffs with distance.
Homing projectiles can now have accuracy falloff with distance.
Projectiles have a maximum range.
Muzzle flash is configurable per projectile.
Impact effect of the projectile is configurable per projectile.
Accuracy decreases with distance.
Projectiles work with signals and emits them, for easy hooking up from
other parts of the code.
Meatshielding is now less effective .
Impact sound is now configurable per projectile.

High risk.
This commit is contained in:
Fluffy
2024-09-23 10:12:57 +00:00
committed by GitHub
parent 914f69dcc8
commit c24b4c7097
203 changed files with 2925 additions and 1590 deletions
+13 -5
View File
@@ -56,8 +56,13 @@
return ..()
/obj/machinery/shield/CanPass(atom/movable/mover, turf/target, height, air_group)
if(!height || air_group) return FALSE
else return ..()
if(mover?.movement_type & PHASING)
return TRUE
if(!height || air_group)
return FALSE
else
return ..()
/obj/machinery/shield/attackby(obj/item/attacking_item, mob/user)
user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN)
@@ -74,9 +79,12 @@
..()
/obj/machinery/shield/bullet_act(var/obj/projectile/Proj)
health -= Proj.get_structure_damage()
..()
/obj/machinery/shield/bullet_act(obj/projectile/hitting_projectile, def_zone, piercing_hit)
. = ..()
if(. != BULLET_ACT_HIT)
return .
health -= hitting_projectile.get_structure_damage()
check_failure()
opacity = 1
spawn(20) if(src) opacity = FALSE
+8 -7
View File
@@ -54,8 +54,12 @@
/obj/effect/energy_field/ex_act(var/severity)
Stress(0.5 + severity)
/obj/effect/energy_field/bullet_act(var/obj/projectile/Proj)
Stress(Proj.get_structure_damage() / 10)
/obj/effect/energy_field/bullet_act(obj/projectile/hitting_projectile, def_zone, piercing_hit)
. = ..()
if(. != BULLET_ACT_HIT)
return .
Stress(hitting_projectile.get_structure_damage() / 10)
/obj/effect/energy_field/proc/Stress(var/severity)
strength -= severity
@@ -115,10 +119,7 @@
diffuse_check()
/obj/effect/energy_field/CanPass(atom/movable/mover, turf/target, height=1.5, air_group = 0)
//Purpose: Determines if the object (or airflow) can pass this atom.
//Called by: Movement, airflow.
//Inputs: The moving atom (optional), target turf, "height" and air group
//Outputs: Boolean if can pass.
if(mover?.movement_type & PHASING)
return TRUE
//return (!density || !height || air_group)
return (!density || air_group)
+16 -8
View File
@@ -195,11 +195,14 @@
alldir_cleanup()
return ..()
/obj/machinery/shieldwallgen/bullet_act(var/obj/projectile/Proj)
storedpower -= 400 * Proj.get_structure_damage()
/obj/machinery/shieldwallgen/bullet_act(obj/projectile/hitting_projectile, def_zone, piercing_hit)
. = ..()
if(. != BULLET_ACT_HIT)
return .
storedpower -= 400 * hitting_projectile.get_structure_damage()
if(power_state >= POWER_STARTING)
visible_message(SPAN_WARNING("\The [src]'s shielding sparks as \the [Proj] hits it!"))
return ..()
visible_message(SPAN_WARNING("\The [src]'s shielding sparks as \the [hitting_projectile] hits it!"))
/obj/shieldwall
name = "energy shield"
@@ -255,16 +258,19 @@
gen_primary.storedpower -= power_usage / 2
gen_secondary.storedpower -= power_usage / 2
/obj/shieldwall/bullet_act(var/obj/projectile/Proj)
/obj/shieldwall/bullet_act(obj/projectile/hitting_projectile, def_zone, piercing_hit)
. = ..()
if(. != BULLET_ACT_HIT)
return .
if(needs_power)
var/obj/machinery/shieldwallgen/G
if(prob(50))
G = gen_primary
else
G = gen_secondary
visible_message(SPAN_WARNING("\The [src] wobbles precariously as \the [Proj] impacts it!"))
G.storedpower -= 400 * Proj.get_structure_damage()
return ..()
visible_message(SPAN_WARNING("\The [src] wobbles precariously as \the [hitting_projectile] impacts it!"))
G.storedpower -= 400 * hitting_projectile.get_structure_damage()
/obj/shieldwall/ex_act(severity)
if(needs_power)
@@ -294,6 +300,8 @@
/obj/shieldwall/CanPass(atom/movable/mover, turf/target, height=0, air_group=0)
if(air_group || (height==0))
return TRUE
if(mover?.movement_type & PHASING)
return TRUE
if(istype(mover) && mover.pass_flags & PASSGLASS)
return prob(20)
else