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

Extracts some specific effects properties into an element, adds afterimage effect #7220

Merged
merged 3 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 0 additions & 1 deletion code/__HELPERS/icons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,6 @@ world
swapped = 1
return result


/image/proc/flick_overlay(atom/A, duration) //originally code related to goonPS. This isn't the original code, but has the same effect
A.overlays.Add(src)
addtimer(CALLBACK(src, PROC_REF(flick_remove_overlay), A), duration)
Expand Down
4 changes: 2 additions & 2 deletions code/datums/elements/drop_retrieval.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

/datum/element/drop_retrieval/Attach(datum/target)
. = ..()
if(!is_type_in_list(target, compatible_types))
if (!is_type_in_list(target, compatible_types))
return ELEMENT_INCOMPATIBLE
RegisterSignal(target, COMSIG_MOVABLE_PRE_THROW, PROC_REF(cancel_throw))
RegisterSignal(target, COMSIG_ITEM_DROPPED, PROC_REF(dropped))
Expand Down Expand Up @@ -40,7 +40,7 @@

/datum/element/drop_retrieval/gun/Attach(datum/target, slot)
. = ..()
if(.)
if (.)
return
retrieval_slot = slot

Expand Down
16 changes: 16 additions & 0 deletions code/datums/elements/effects/copy_appearance.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/// Assigns an effects appearance to the appearance of a target atom
/datum/element/copy_appearance

/datum/element/copy_appearance/Attach(datum/target, atom/to_copy)
. = ..()
if (. == ELEMENT_INCOMPATIBLE)
return
if (!istype(target, /obj/effect))
return ELEMENT_INCOMPATIBLE
if (!isatom(to_copy))
return ELEMENT_INCOMPATIBLE
var/obj/effect/effect = target
effect.name = to_copy.name
effect.appearance = to_copy.appearance
effect.setDir(to_copy.dir)
effect.mouse_opacity = MOUSE_OPACITY_TRANSPARENT
10 changes: 10 additions & 0 deletions code/datums/elements/effects/fading.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/// Causes effect to fade over a specific duration
/datum/element/fading

/datum/element/fading/Attach(datum/target, duration)
. = ..()
if (. == ELEMENT_INCOMPATIBLE)
return
if (!istype(target, /obj/effect))
return ELEMENT_INCOMPATIBLE
animate(target, alpha = 0, time = duration)
24 changes: 24 additions & 0 deletions code/datums/elements/effects/pixel_shifting.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/// Does a pixel shift animation towards a specific target
/datum/element/pixel_shifting

/**
* Function to attach the `shifting` element to the effect
*
* Params:
* - target (/datum): The effect we are attaching to, should be of type /obj/effect unless you messed up
* - to_shift_towards (/atom): The atom the effect will pixel shift towards
* - distance_ratio (num): The percentage of the distance between the effect and `to_shift_towards` that the effect should cover (0 <= distance_ratio <= 1)
* - duration (num): Duration of the animation (i.e. how fast the effect will pixel shift to its destination)
*/
/datum/element/pixel_shifting/Attach(datum/target, atom/to_shift_towards, distance_ratio = 1, duration)
. = ..()
if (. == ELEMENT_INCOMPATIBLE)
return
if (!istype(target, /obj/effect))
return ELEMENT_INCOMPATIBLE
if (!istype(to_shift_towards))
return ELEMENT_INCOMPATIBLE
var/obj/effect/effect = target
var/x_displacement = floor((to_shift_towards.x - effect.x) * distance_ratio * world.icon_size)
var/y_displacement = floor((to_shift_towards.y - effect.y) * distance_ratio * world.icon_size)
animate(target, pixel_x = x_displacement, pixel_y = y_displacement, time = duration)
15 changes: 15 additions & 0 deletions code/datums/elements/effects/temporary.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/// Sets an effect to delete itself after a specific amount of time
/datum/element/temporary

/datum/element/temporary/Attach(datum/target, duration)
. = ..()
if (. == ELEMENT_INCOMPATIBLE)
return
if (!istype(target, /obj/effect))
return ELEMENT_INCOMPATIBLE
addtimer(CALLBACK(src, PROC_REF(delete_effect), WEAKREF(target)), duration)

/datum/element/temporary/proc/delete_effect(datum/weakref/target_ref)
SIGNAL_HANDLER
if (target_ref.resolve())
qdel(target_ref)
20 changes: 20 additions & 0 deletions code/game/objects/effects/afterimage.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/obj/effect/afterimage
as_image = TRUE

/**
* Params:
* - mapload: Whether effect is maploaded
* - to_copy: The atom that has an afterimage
* - fading_duration: How long it takes for afterimage to fade
* - fading_to_shift_ratio: How quickly afterimage will reach its target atom before fading (relative to the fading time)
*/
/obj/effect/afterimage/Initialize(mapload, atom/to_copy, fading_duration, fading_to_shift_ratio = 0.5)
. = ..()
if (!to_copy)
log_debug("Created a [type] without `to_copy`")
qdel(src)
return
AddElement(/datum/element/temporary, fading_duration)
AddElement(/datum/element/copy_appearance, to_copy)
AddElement(/datum/element/fading, fading_duration)
AddElement(/datum/element/pixel_shifting, to_copy, 1, floor(fading_duration * fading_to_shift_ratio))
67 changes: 67 additions & 0 deletions code/game/objects/effects/bloodsplatter.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//------------------------------------------
//BLOOD HITS
//------------------------------------------

/obj/effect/bloodsplatter
icon = 'icons/effects/blood.dmi'
var/duration = 5
layer = ABOVE_XENO_LAYER
var/splatter_type = "splatter"

/obj/effect/bloodsplatter/Initialize(mapload, set_dir, fx_duration, color_override)
. = ..()
if(color_override)
color = color_override
if(IS_DIAGONAL_DIR(set_dir))
icon_state = "[splatter_type][pick(1, 2, 6)]"
else
icon_state = "[splatter_type][pick(3, 4, 5)]"
if(fx_duration)
duration = fx_duration
setDir(set_dir)
AddElement(/datum/element/temporary, duration)
var/target_pixel_x = 0
var/target_pixel_y = 0
switch(set_dir)
if(NORTH)
target_pixel_y = 16
if(SOUTH)
target_pixel_y = -16
if(EAST)
target_pixel_x = 16
if(WEST)
target_pixel_x = -16
if(NORTHEAST)
target_pixel_x = 16
target_pixel_y = 16
if(NORTHWEST)
target_pixel_x = -16
target_pixel_y = 16
if(SOUTHEAST)
target_pixel_x = 16
target_pixel_y = -16
if(SOUTHWEST)
target_pixel_x = -16
target_pixel_y = -16
animate(src, pixel_x = target_pixel_x, pixel_y = target_pixel_y, alpha = 0, time = duration)


/obj/effect/bloodsplatter/xenosplatter
splatter_type = "csplatter"
color = BLOOD_COLOR_XENO

/obj/effect/bloodsplatter/human
splatter_type = "csplatter"
color = BLOOD_COLOR_HUMAN

/obj/effect/bloodsplatter/hellhound
splatter_type = "csplatter"
color = BLOOD_COLOR_YAUTJA

/obj/effect/bloodsplatter/yautjasplatter
splatter_type = "csplatter"
color = BLOOD_COLOR_YAUTJA_DARK

/obj/effect/bloodsplatter/synthsplatter
splatter_type = "csplatter"
color = BLOOD_COLOR_SYNTHETIC
2 changes: 2 additions & 0 deletions code/game/objects/effects/effect.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
icon = 'icons/effects/effects.dmi'
blocks_emissive = EMISSIVE_BLOCK_GENERIC

var/as_image = FALSE

/obj/effect/get_applying_acid_time()
return -1
17 changes: 4 additions & 13 deletions code/game/objects/effects/portals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,18 @@
anchored = TRUE

/obj/effect/portal/Collided(atom/movable/AM)
spawn(0)
teleport(AM)
return
return
INVOKE_ASYNC(src, PROC_REF(teleport), AM)

/obj/effect/portal/Crossed(AM as mob|obj)
spawn(0)
src.teleport(AM)
return
return
INVOKE_ASYNC(src, PROC_REF(teleport), AM)

/obj/effect/portal/attack_hand(mob/user as mob)
spawn(0)
src.teleport(user)
return
return
INVOKE_ASYNC(src, PROC_REF(teleport), user)

/obj/effect/portal/Initialize(mapload, ...)
. = ..()
GLOB.portal_list += src
QDEL_IN(src, 30 SECONDS)
AddElement(/datum/element/temporary, 30 SECONDS)

/obj/effect/portal/Destroy()
GLOB.portal_list -= src
Expand Down
22 changes: 22 additions & 0 deletions code/game/objects/effects/shockwave.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//------------------------------------------
//Shockwaves
//------------------------------------------

/obj/effect/shockwave
icon = 'icons/effects/light_overlays/shockwave.dmi'
icon_state = "shockwave"
plane = DISPLACEMENT_PLATE_RENDER_LAYER
pixel_x = -496
pixel_y = -496

/obj/effect/shockwave/Initialize(mapload, radius, speed, easing_type = LINEAR_EASING, y_offset, x_offset)
. = ..()
if(!speed)
speed = 1
if(y_offset)
pixel_y += y_offset
if(x_offset)
pixel_x += x_offset
AddElement(/datum/element/temporary, 0.5 * radius * speed)
transform = matrix().Scale(32 / 1024, 32 / 1024)
animate(src, time = 0.5 * radius * speed, transform=matrix().Scale((32 / 1024) * radius * 1.5, (32 / 1024) * radius * 1.5), easing = easing_type)
121 changes: 0 additions & 121 deletions code/game/objects/effects/temporary_visuals.dm

This file was deleted.

4 changes: 2 additions & 2 deletions code/modules/mob/living/carbon/human/species/species.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
var/gibbed_anim = "gibbed-h"
var/dusted_anim = "dust-h"
var/remains_type = /obj/effect/decal/remains/xeno
var/bloodsplatter_type = /obj/effect/temp_visual/dir_setting/bloodsplatter/human
var/bloodsplatter_type = /obj/effect/bloodsplatter/human
var/death_sound
var/death_message = "seizes up and falls limp, their eyes dead and lifeless..."

Expand Down Expand Up @@ -483,7 +483,7 @@
if(D)
color_override = D.color

var/obj/effect/temp_visual/dir_setting/bloodsplatter/bloodsplatter = new bloodsplatter_type(human.loc, splatter_dir, 5, color_override)
var/obj/effect/bloodsplatter/bloodsplatter = new bloodsplatter_type(human.loc, splatter_dir, 5, color_override)
return bloodsplatter

/datum/species/proc/get_status_tab_items()
Expand Down
Loading
Loading