Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Port] More cool visuals for ballistics #520

Merged
merged 9 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions code/__DEFINES/is_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ GLOBAL_LIST_INIT(turfs_openspace, typecacheof(list(

#define islava(A) (istype(A, /turf/open/lava))

#define iswater(A)istype(A, /turf/open/water)

#define ischasm(A) (istype(A, /turf/open/chasm))

#define isplatingturf(A) (istype(A, /turf/open/floor/plating))
Expand Down
7 changes: 7 additions & 0 deletions code/__DEFINES/particles.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@

/// If we're inside something inside a mob, display off that mob too
#define PARTICLE_ATTACH_MOB (1<<0)

#define DEBRIS_SPARKS "spark"
QuacksQ marked this conversation as resolved.
Show resolved Hide resolved
#define DEBRIS_WOOD "wood"
#define DEBRIS_ROCK "rock"
#define DEBRIS_GLASS "glass"
#define DEBRIS_LEAF "leaf"
#define DEBRIS_SNOW "snow"
14 changes: 6 additions & 8 deletions code/controllers/subsystem/explosions.dm
Original file line number Diff line number Diff line change
Expand Up @@ -365,14 +365,12 @@ SUBSYSTEM_DEF(explosions)
if(!silent)
shake_the_room(epicenter, orig_max_distance, far_dist, devastation_range, heavy_impact_range)

if(heavy_impact_range > 1)
var/datum/effect_system/explosion/E
if(smoke)
E = new /datum/effect_system/explosion/smoke
else
E = new
E.set_up(epicenter)
E.start()
if(devastation_range > 0)
new /obj/effect/temp_visual/explosion(epicenter, max_range, LIGHT_COLOR_LAVA, FALSE, TRUE)
else if(heavy_impact_range > 0)
new /obj/effect/temp_visual/explosion(epicenter, max_range, LIGHT_COLOR_LAVA, FALSE, FALSE)
else if(light_impact_range > 0)
new /obj/effect/temp_visual/explosion(epicenter, max_range, LIGHT_COLOR_LAVA, TRUE, FALSE)

//flash mobs
if(flash_range)
Expand Down
95 changes: 95 additions & 0 deletions code/datums/elements/debris.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/particles/debris
icon = 'icons/effects/particles/generic.dmi'
width = 500
height = 500
count = 10
spawning = 10
lifespan = 0.7 SECONDS
fade = 0.4 SECONDS
drift = generator(GEN_CIRCLE, 0, 7)
scale = 0.7
velocity = list(50, 0)
friction = generator(GEN_NUM, 0.1, 0.15)
spin = generator(GEN_NUM, -20, 20)

/particles/impact_smoke
icon = 'icons/effects/effects.dmi'
icon_state = "smoke"
width = 500
height = 500
count = 20
spawning = 20
lifespan = 0.7 SECONDS
fade = 8 SECONDS
grow = 0.1
scale = 0.2
spin = generator(GEN_NUM, -20, 20)
velocity = list(50, 0)
friction = generator(GEN_NUM, 0.1, 0.5)

/datum/element/debris
element_flags = ELEMENT_BESPOKE
id_arg_index = 2

///Icon state of debris when impacted by a projectile
var/debris = null
///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/element/debris/Attach(datum/target, _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(target, COMSIG_ATOM_BULLET_ACT, PROC_REF(register_for_impact))

/datum/element/debris/Detach(datum/source, force)
. = ..()
UnregisterSignal(source, COMSIG_ATOM_BULLET_ACT)

/datum/element/debris/proc/register_for_impact(datum/source, obj/projectile/proj)
SIGNAL_HANDLER
INVOKE_ASYNC(src, PROC_REF(on_impact), source, proj)

/datum/element/debris/proc/on_impact(datum/source, obj/projectile/P)
//if(!P.ammo.ping)
// return
QuacksQ marked this conversation as resolved.
Show resolved Hide resolved
var/angle = !isnull(P.Angle) ? P.Angle : round(get_angle(P.starting, source), 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(source, /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.ammo.flags_ammo_behavior & AMMO_ENERGY || P.ammo.flags_ammo_behavior & AMMO_XENO))
debris_visuals = new(source, /particles/debris)
debris_visuals.particles.position = generator(GEN_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
/*
if(P.ammo.sound_bounce)
var/pitch = 0
if(P.ammo.flags_ammo_behavior & AMMO_SOUND_PITCH)
pitch = 55000
playsound(source, P.ammo.sound_bounce, 50, 1, frequency = pitch)
*/
QuacksQ marked this conversation as resolved.
Show resolved Hide resolved
addtimer(CALLBACK(src, PROC_REF(remove_ping), src, smoke_visuals, debris_visuals), 0.7 SECONDS)

/datum/element/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)
3 changes: 3 additions & 0 deletions code/game/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2078,3 +2078,6 @@
*/
/atom/proc/start_cleaning(datum/source, atom/target, mob/living/user, clean_target = TRUE)
SEND_SIGNAL(source, COMSIG_START_CLEANING, target, user, clean_target)

/atom/proc/add_debris_element()
AddElement(/datum/element/debris, null, -15, 8, 0.7)
Loading