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
@@ -65,11 +65,13 @@
to_chat(user,SPAN_NOTICE("You take \the [stored_item] from [src]."))
stored_item = null
/obj/structure/flora/pottedplant/bullet_act(var/obj/projectile/Proj)
if (prob(Proj.damage*2))
/obj/structure/flora/pottedplant/bullet_act(obj/projectile/hitting_projectile, def_zone, piercing_hit)
. = ..()
if(. != BULLET_ACT_HIT)
return .
if (prob(hitting_projectile.damage*2))
death()
return 1
return ..()
// ------------------------------------ dead/empty
@@ -23,11 +23,13 @@
death()
return ..()
/obj/item/flora/pottedplant_small/bullet_act(var/obj/projectile/Proj)
if (prob(Proj.damage*2))
/obj/item/flora/pottedplant_small/bullet_act(obj/projectile/hitting_projectile, def_zone, piercing_hit)
. = ..()
if(. != BULLET_ACT_HIT)
return .
if (prob(hitting_projectile.damage*2))
death()
return 1
return ..()
// ------------------------------------ dead/empty
@@ -255,4 +255,5 @@
pellet.ammo.impact_type = ammo.impact_type
pellet.dir = dir
var/turf/front_turf = get_step(pellet, pellet.dir)
pellet.launch_projectile(front_turf)
pellet.preparePixelProjectile(target_turf, front_turf)
pellet.fire()
@@ -230,7 +230,6 @@
projectile.desc = SA.desc
projectile.ammo = SA
projectile.dir = barrel.dir
projectile.shot_from = name
SA.overmap_target = overmap_target
SA.entry_point = landmark
SA.origin = linked
@@ -243,7 +242,9 @@
SA.heading = barrel.dir
SA.forceMove(projectile)
var/turf/target = get_step(projectile, barrel.dir)
projectile.launch_projectile(target)
projectile.preparePixelProjectile(target, firing_turf)
projectile.fired_from = barrel
projectile.fire()
return TRUE
/obj/machinery/ship_weapon/proc/consume_ammo()
@@ -300,8 +301,12 @@
M.turf_collision(src, throwingdatum.speed)
return
/obj/structure/ship_weapon_dummy/bullet_act(obj/projectile/P, def_zone)
connected.bullet_act(P)
/obj/structure/ship_weapon_dummy/bullet_act(obj/projectile/hitting_projectile, def_zone, piercing_hit)
. = ..()
if(. != BULLET_ACT_HIT)
return .
connected.bullet_act(hitting_projectile)
/obj/structure/ship_weapon_dummy/ex_act(severity)
connected.ex_act(severity)
@@ -128,7 +128,9 @@
widowmaker.on_translate(entry_turf, target_turf)
log_and_message_admins("A projectile ([widowmaker.name]) has entered a z-level at [entry_target.name], with direction [dir2text(widowmaker.dir)]! (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[widowmaker.x];Y=[widowmaker.y];Z=[widowmaker.z]'>JMP</a>)")
say_dead_direct("A projectile ([widowmaker.name]) has entered a z-level at [entry_target.name], with direction [dir2text(widowmaker.dir)]!")
widowmaker.launch_projectile(target_turf)
widowmaker.preparePixelProjectile(target_turf, T)
widowmaker.fired_from = src
widowmaker.fire()
qdel(src)
if(istype(A, /obj/effect/overmap/event))
var/obj/effect/overmap/event/EV = A
@@ -152,9 +152,7 @@
penetrating = 6
stun = 4
weaken = 4
maiming = TRUE
maim_rate = 3
maim_type = DROPLIMB_BLUNT
anti_materiel_potential = 2
/obj/projectile/ship_ammo/bruiser/real/on_hit(atom/target, blocked, def_zone, is_landmark_hit)
@@ -164,8 +162,10 @@
if(ammo.impact_type == SHIP_AMMO_IMPACT_AP)
explosion(target, 0, 2, 4)
/obj/projectile/ship_ammo/bruiser/real/beehive/on_hit(atom/movable/target, blocked, def_zone, is_landmark_hit)
if(istype(target))
var/throwdir = dir
target.throw_at(get_edge_target_turf(target, throwdir),9,8)
/obj/projectile/ship_ammo/bruiser/real/beehive/on_hit(atom/target, blocked, def_zone, is_landmark_hit)
. = ..()
if(ismovable(target))
var/atom/movable/M = target
M.throw_at(get_edge_target_turf(target, dir),9,8)
return 1
@@ -64,6 +64,6 @@
armor_penetration = 50
penetrating = 1
/obj/projectile/ship_ammo/francisca/frag/on_impact(var/atom/A)
/obj/projectile/ship_ammo/francisca/frag/on_hit(atom/target, blocked, def_zone, is_landmark_hit)
fragem(src, 70, 70, 1, 2, 10, 4, TRUE)
..()
. = ..()
@@ -151,6 +151,8 @@
impact_type = /obj/effect/projectile/impact/pulse
/obj/projectile/ship_ammo/leviathan/on_hit(atom/target, blocked, def_zone, is_landmark_hit)
. = ..()
if(!is_landmark_hit)
if(ismob(target))
var/mob/M = target
@@ -17,7 +17,7 @@
armor_penetration = 1000
var/penetrated = FALSE
/obj/projectile/ship_ammo/longbow/launch_projectile(atom/target, target_zone, mob/user, params, angle_override, forced_spread)
/obj/projectile/ship_ammo/longbow/fire_projectile(projectile_type, atom/target, sound, firer, list/ignore_targets)
if(ammo.impact_type == SHIP_AMMO_IMPACT_AP)
penetrating = 1
if(ammo.impact_type == SHIP_AMMO_IMPACT_BUNKERBUSTER)
@@ -140,9 +140,12 @@
if(prob(10))
cookoff(FALSE)
/obj/item/warhead/longbow/bullet_act(obj/projectile/P, def_zone)
/obj/item/warhead/longbow/bullet_act(obj/projectile/hitting_projectile, def_zone, piercing_hit)
. = ..()
if(P.damage > 5)
if(. != BULLET_ACT_HIT)
return .
if(hitting_projectile.damage > 5)
cookoff(TRUE)
/obj/item/warhead/longbow/attackby(obj/item/attacking_item, mob/user)
@@ -503,9 +503,12 @@
else if(health < max_health * 0.75)
. += "\The [src] shows signs of damage!"
/obj/machinery/shipsensors/bullet_act(var/obj/projectile/Proj)
take_damage(Proj.get_structure_damage())
..()
/obj/machinery/shipsensors/bullet_act(obj/projectile/hitting_projectile, def_zone, piercing_hit)
. = ..()
if(. != BULLET_ACT_HIT)
return .
take_damage(hitting_projectile.get_structure_damage())
/obj/machinery/shipsensors/proc/toggle()
if(use_power) // reset desired range when turning off
@@ -113,7 +113,9 @@
return 0
/obj/machinery/atmospherics/unary/engine/CanPass(atom/movable/mover, turf/target, height=0, air_group=0)
return 0
if(mover?.movement_type & PHASING)
return TRUE
return FALSE
/obj/machinery/atmospherics/unary/engine/atmos_init()
..()