Adds bullet impact particle effects! (#25177)

* Initial commit

* Cleaning up + more debris

* Adds missing trailing newline

* CI doesn't like these and starts an infinite loop it seems

* Hacky solution? I call it fixing CI

* Final fixes
This commit is contained in:
DGamerL
2024-05-06 21:44:14 +02:00
committed by GitHub
parent a750e3596e
commit b04bdf4ff9
14 changed files with 187 additions and 3 deletions
+93
View File
@@ -0,0 +1,93 @@
/*
* In this file you can find the particle component for bullet hits
* Originally from https://github.com/tgstation/TerraGov-Marine-Corps/pull/12752
*/
/particles/debris
icon = 'icons/effects/particles/generic_particles.dmi'
width = 500
height = 500
count = 10
spawning = 10
lifespan = 0.5 SECONDS
fade = 0.3 SECONDS
drift = generator("circle", 0, 7)
scale = 0.3
velocity = list(50, 0)
friction = generator("num", 0.1, 0.15)
spin = generator("num", -20, 20)
/particles/impact_smoke
icon = 'icons/effects/effects.dmi'
icon_state = "smoke"
width = 500
height = 500
count = 20
spawning = 20
lifespan = 0.8 SECONDS
fade = 10 SECONDS
grow = 0.1
scale = 0.2
spin = generator("num", -20, 20)
velocity = list(50, 0)
friction = generator("num", 0.1, 0.5)
/datum/component/debris
/// Icon state of debris when impacted by a projectile
var/debris
/// Velocity of debris particles
var/debris_velocity = -15
/// Amount of debris particles
var/debris_amount = 8
/// Scale of particle debris
var/debris_scale = 0.7
/datum/component/debris/Initialize(_debris_icon_state, _debris_velocity = -15, _debris_amount = 8, _debris_scale = 0.7)
. = ..()
debris = _debris_icon_state
debris_velocity = _debris_velocity
debris_amount = _debris_amount
debris_scale = _debris_scale
RegisterSignal(parent, COMSIG_ATOM_BULLET_ACT, PROC_REF(register_for_impact))
/datum/component/debris/Destroy(force)
. = ..()
if(parent)
UnregisterSignal(parent, COMSIG_ATOM_BULLET_ACT)
/datum/component/debris/proc/register_for_impact(datum/source, obj/item/projectile/proj)
SIGNAL_HANDLER // COMSIG_ATOM_BULLET_ACT
INVOKE_ASYNC(src, PROC_REF(on_impact), proj)
/datum/component/debris/proc/on_impact(obj/item/projectile/P)
var/angle = !isnull(P.Angle) ? P.Angle : round(get_angle(P.starting, parent), 1)
var/x_component = sin(angle) * debris_velocity
var/y_component = cos(angle) * debris_velocity
var/x_component_smoke = sin(angle) * -15
var/y_component_smoke = cos(angle) * -15
var/obj/effect/abstract/particle_holder/debris_visuals
var/obj/effect/abstract/particle_holder/smoke_visuals
var/position_offset = rand(-6, 6)
smoke_visuals = new(parent, /particles/impact_smoke)
smoke_visuals.particles.position = list(position_offset, position_offset)
smoke_visuals.particles.velocity = list(x_component_smoke, y_component_smoke)
if(debris && !(P.damage_type == BURN))
debris_visuals = new(parent, /particles/debris)
debris_visuals.particles.position = generator("circle", position_offset, position_offset)
debris_visuals.particles.velocity = list(x_component, y_component)
debris_visuals.layer = ABOVE_OBJ_LAYER + 0.02
debris_visuals.particles.icon_state = debris
debris_visuals.particles.count = debris_amount
debris_visuals.particles.spawning = debris_amount
debris_visuals.particles.scale = debris_scale
smoke_visuals.layer = ABOVE_OBJ_LAYER + 0.01
addtimer(CALLBACK(src, PROC_REF(remove_ping), src, smoke_visuals, debris_visuals), 0.5 SECONDS)
/datum/component/debris/proc/remove_ping(hit, obj/effect/abstract/particle_holder/smoke_visuals, obj/effect/abstract/particle_holder/debris_visuals)
QDEL_NULL(smoke_visuals)
if(debris_visuals)
QDEL_NULL(debris_visuals)