Files
Bubberstation/code/game/objects/effects/decals/misc.dm
MrMelbert 04b6aad3a9 Dehardcodes microwave cleaning, allows spray cleaner to work on dense objects such as windows (#79354)
## About The Pull Request

- Dehardcodes microwave cleaning
- Instead of hard istyping for a rag, soap, or space cleaner, we just
use `wash`.

- Gets rid of a redundant signal 
- `COMSIG_ATOM_WASHED`: not only was it misleading (only sent to items),
but it was pointless because `COMSIG_COMPONENT_CLEAN_ACT` is the same
signal.

- Improves microwave attackby code, splitting tool stuff into tool-procs

- Allows spray cleaner to work on dense objects such as windows
- Clicking on a dense object or mob adjacent to you with spray cleaner
will spawn the puff cloud on the target, rather than on your own
position.
- This will skip the moveloop and just clean everything on the target
turf alone.
- This means you can spray down a bloody window with a spray bottle, as
janitor gods intended.
- It also means you can fill the spray with other stuff to spray onto
dense objects directly, which might be worth noting. Especially for
stuff like Napalm.

Fixes #79261 

## Why It's Good For The Game

Opens up the sandbox to allow more objects to clean microwaves + better
code.

## Changelog

🆑 Melbert
qol: Clicking on an adjacent dense object (or mob) with Spray Cleaner
will now spritz it rather than doing nothing. This means you can use
Spray Cleaner to clean bloodied windows, as the janitor gods intended.
It also means you can fill a spray bottle with Napalm, I guess.
refactor: Any cleaning object can now clean a microwave. 
/🆑
2023-10-31 14:00:15 +00:00

105 lines
3.0 KiB
Plaintext

//Used by spraybottles.
/obj/effect/decal/chempuff
name = "chemicals"
icon = 'icons/obj/medical/chempuff.dmi'
pass_flags = PASSTABLE | PASSGRILLE
layer = FLY_LAYER
plane = ABOVE_GAME_PLANE
///The mob who sourced this puff, if one exists
var/mob/user
///The sprayer who fired this puff
var/obj/item/reagent_containers/spray/sprayer
///How many interactions we have left before we disappear early
var/lifetime = INFINITY
///Are we a part of a stream?
var/stream
/// String used in combat logs containing reagents present for when the puff hits something
var/logging_string
/obj/effect/decal/chempuff/Destroy(force)
user = null
sprayer = null
return ..()
/obj/effect/decal/chempuff/blob_act(obj/structure/blob/B)
return
/obj/effect/decal/chempuff/proc/end_life(delay = 0.5 SECONDS)
QDEL_IN(src, delay) //Gotta let it stop drifting
animate(src, alpha = 0, time = delay)
/obj/effect/decal/chempuff/proc/loop_ended(datum/move_loop/source)
SIGNAL_HANDLER
if(QDELETED(src))
return
end_life(source.delay)
/obj/effect/decal/chempuff/proc/check_move(datum/move_loop/source, result)
SIGNAL_HANDLER
if(QDELETED(src)) //Reasons PLEASE WORK I SWEAR TO GOD
return
if(result == MOVELOOP_FAILURE) //If we hit something
end_life(source.delay)
return
spray_down_turf(get_turf(src), travelled_max_distance = (source.lifetime - source.delay <= 0))
if(lifetime < 0) // Did we use up all the puff early?
end_life(source.delay)
/**
* Handles going through every movable on the passed turf and calling [spray_down_atom] on them.
*
* [travelled_max_distance] is used to determine if we're at the end of the life, as in some
* contexts an atom may or may not end up being exposed depending on how far we've travelled.
*/
/obj/effect/decal/chempuff/proc/spray_down_turf(turf/spraying, travelled_max_distance = FALSE)
for(var/atom/movable/turf_atom in spraying)
if(turf_atom == src || turf_atom.invisibility) //we ignore the puff itself and stuff below the floor
continue
if(lifetime < 0)
break
if(!stream)
spray_down_atom(turf_atom)
if(ismob(turf_atom))
lifetime -= 1
continue
if(isliving(turf_atom))
var/mob/living/turf_mob = turf_atom
if(!turf_mob.can_inject())
continue
if(turf_mob.body_position != STANDING_UP && !travelled_max_distance)
continue
spray_down_atom(turf_atom)
lifetime -= 1
else if(travelled_max_distance)
spray_down_atom(turf_atom)
lifetime -= 1
if(lifetime >= 0 && (!stream || travelled_max_distance))
spray_down_atom(spraying)
lifetime -= 1
/// Actually handles exposing the passed atom to the reagents and logging
/obj/effect/decal/chempuff/proc/spray_down_atom(atom/spraying)
if(isnull(logging_string))
logging_string = reagents.get_reagent_log_string()
reagents.expose(spraying, VAPOR)
log_combat(user, spraying, "sprayed", sprayer, addition = "which had [logging_string]")
/obj/effect/decal/fakelattice
name = "lattice"
desc = "A lightweight support lattice."
icon = 'icons/obj/smooth_structures/lattice.dmi'
icon_state = "lattice-255"
density = TRUE