Files
Bubberstation/code/datums/components/shrink.dm
Watermelon914 375a20e49b Refactors most spans into span procs (#59645)
Converts most spans into span procs. Mostly used regex for this and sorted out any compile time errors afterwards so there could be some bugs.
Was initially going to do defines, but ninja said to make it into a proc, and if there's any overhead, they can easily be changed to defines.

Makes it easier to control the formatting and prevents typos when creating spans as it'll runtime if you misspell instead of silently failing.
Reduces the code you need to write when writing spans, as you don't need to close the span as that's automatically handled by the proc.

(Note from Lemon: This should be converted to defines once we update the minimum version to 514. Didn't do it now because byond pain and such)
2021-06-14 13:03:53 -07:00

42 lines
1.5 KiB
Plaintext

/datum/component/shrink
var/olddens
var/oldopac
dupe_mode = COMPONENT_DUPE_HIGHLANDER
/datum/component/shrink/Initialize(shrink_time)
if(!isatom(parent))
return COMPONENT_INCOMPATIBLE
var/atom/parent_atom = parent
parent_atom.transform = parent_atom.transform.Scale(0.5,0.5)
olddens = parent_atom.density
oldopac = parent_atom.opacity
parent_atom.density = 0
parent_atom.set_opacity(FALSE)
if(isliving(parent_atom))
var/mob/living/L = parent_atom
L.add_movespeed_modifier(/datum/movespeed_modifier/shrink_ray)
if(iscarbon(L))
var/mob/living/carbon/C = L
C.unequip_everything()
C.visible_message(span_warning("[C]'s belongings fall off of [C.p_them()] as they shrink down!"),
span_userdanger("Your belongings fall away as everything grows bigger!"))
if(ishuman(C))
var/mob/living/carbon/human/H = C
H.physiology.damage_resistance -= 100//carbons take double damage while shrunk
parent_atom.visible_message(span_warning("[parent_atom] shrinks down to a tiny size!"),
span_userdanger("Everything grows bigger!"))
QDEL_IN(src, shrink_time)
/datum/component/shrink/Destroy()
var/atom/parent_atom = parent
parent_atom.transform = parent_atom.transform.Scale(2,2)
parent_atom.density = olddens
parent_atom.set_opacity(oldopac)
if(isliving(parent_atom))
var/mob/living/L = parent_atom
L.remove_movespeed_modifier(/datum/movespeed_modifier/shrink_ray)
if(ishuman(L))
var/mob/living/carbon/human/H = L
H.physiology.damage_resistance += 100
..()