Files
kiwistation/code/game/objects/effects/overlays.dm
T
phil235 5f835bfc26 Obj damaging system, acid damage, and fire damage refactor (WIP) (#20793)
Please refer to #20867 and #20870 for a easier view of the changes. Those two PRs show all meaningful changes (hopefully) and doesn't show the files changed with just 3 lines changed.

This PR does three things:

    It makes all children of /obj/ use the same damage system.
    Previously to make your new machine/structure be destroyable you needed to give it a var/health, and its own version of many damage related proc such as bullet_act(), take_damage(), attacked_by(), attack_animal(), attack_hulk(), ex_act(), etc... But now, all /obj/ use the same version of those procs at the /obj/ level in code/game/obj_defense.dm. All these obj share the same necessary vars: obj_integrity (health), max_integrity, integrity_failure (optional, below that health level failure happens), and the armor list var which was previously only for items, as well as the resistance_flags bitfield. When you want your new object to be destroyable, you only have to give it a value for those vars and maybe override one proc if you want a special behavior but that's it. This reorganization removes a lot of copypasta (most bullet_act() version for each obj were nearly identical). Two new elements are added to the armor list var: fire and acid armor values.
    How much damage an obj take depends on the armor value for each damage category. But some objects are INDESTRUCTIBLE and simply never take any damage no matter the type.
    The armor categories are:
    -melee(punches, item attacks, xeno/animal/hulk attacks, blob attacks, thrown weapons)
    -bullet
    -laser
    -energy (used by projectiles like ionrifle, taser, and also by EMPs)
    -bio (unused for this, only here because clothes use them when worn)
    -rad (same)
    -bomb (self-explanatory)
    -fire (for fire damage, not for heat damage though)
    -acid
    For machines and structures, when their health reaches zero the object is not just deleted but gets somewhat forcedeconstructed (the proc used is shared with the actual deconstruction system) which can drops things. To not frustrates players most of these objects drop most of the elements necessary to rebuild them (think window dropping shards). Machines drop a machine frame and all components for example (but the frame can then be itself smashed to pieces).
    For clothes, when they are damaged, they get a "damaged" overlay, which can also be seen when worn, similar to the "bloody" overlay.

    It refactors acid. See #20537.
    Some objects are ACID_PROOF and take no damage from acid, while others take varying amounts
    of damage depending on their acid armor value. Some objects are even UNACIDABLE, no acid effect can even land on them. Acid on objects can be washed off using water.

    It changes some aspect of damage from fires.
    All /obj/ can now take fire damage and be flammable, instead of just items. And instead of having just FLAMMABLE objs that become ON_FIRE as soon as some fire touch them (paper), we now have objects that are non flammable but do take damage from fire and become ashes if their health reaches zero (only for items). The damage taken varies depending on the obj's fire armor value and total health. There's also still obj and items that are FIRE_PROOF (although some might still be melted by lava if they're not LAVA_PROOF).
    When a mob is on fire, its clothes now take fire damage and can turn to ashes. Similarly, when a mob takes melee damages, its clothes gets damaged a bit and can turn to shreds. You can repair clothes with cloth that is produceable by botany's biogenerator.

    It also does many minor things:
        Clicking a structure/machine with an item on help intent never results in an attack (so you don't destroy a structure while trying to figure out which tool to use).
        I moved a lot of objects away from /obj/effect, it should only be used for visual effects, decals and stuff, not for things you can hit and destroy.
        I tweaked a bit how clothes shredding from bombs work.
        I made a machine or structure un/anchorable with the wrench, I don't remember which object...
        Since I changed the meaning of the FIRE_PROOF bitflag to actually mean fire immune, I'm buffing the slime extract that you apply on items to make them fire proof. well now they're really 100% fire proof!
        animals with environment_smash = 1 no longer one-hit destroy tables and stuff, we give them a decent obj_damage value so they can destroy most obj relatively fast depending on the animal.
        Probably a million things I forgot.

If you want to know how the damage system works all you need is the three obj vars "obj_integrity", "max_integrity", "integrity_failure", as well as the armor list var and the resistance_flags bitfield, and read the file obj_defense.dm
2016-10-10 11:14:59 +13:00

480 lines
11 KiB
Plaintext

/obj/effect/overlay
name = "overlay"
var/i_attached//Added for possible image attachments to objects. For hallucinations and the like.
/obj/effect/overlay/singularity_act()
return
/obj/effect/overlay/singularity_pull()
return
/obj/effect/overlay/beam//Not actually a projectile, just an effect.
name="beam"
icon='icons/effects/beam.dmi'
icon_state="b_beam"
var/atom/BeamSource
/obj/effect/overlay/beam/New()
..()
QDEL_IN(src, 10)
/obj/effect/overlay/temp
icon_state = "nothing"
anchored = 1
layer = ABOVE_MOB_LAYER
mouse_opacity = 0
var/duration = 10 //in deciseconds
var/randomdir = TRUE
var/timerid
/obj/effect/overlay/temp/Destroy()
..()
deltimer(timerid)
return QDEL_HINT_PUTINPOOL
/obj/effect/overlay/temp/New()
..()
if(randomdir)
setDir(pick(cardinal))
flick("[icon_state]", src) //Because we might be pulling it from a pool, flick whatever icon it uses so it starts at the start of the icon's animation.
timerid = QDEL_IN(src, duration)
/obj/effect/overlay/temp/dir_setting
randomdir = FALSE
/obj/effect/overlay/temp/dir_setting/New(loc, set_dir)
if(set_dir)
setDir(set_dir)
..()
/obj/effect/overlay/temp/dir_setting/bloodsplatter
icon = 'icons/effects/blood.dmi'
duration = 5
randomdir = FALSE
layer = BELOW_MOB_LAYER
var/splatter_type = "splatter"
/obj/effect/overlay/temp/dir_setting/bloodsplatter/New(loc, set_dir)
if(set_dir in diagonals)
icon_state = "[splatter_type][pick(1, 2, 6)]"
else
icon_state = "[splatter_type][pick(3, 4, 5)]"
..()
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
layer = ABOVE_MOB_LAYER
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
layer = ABOVE_MOB_LAYER
if(SOUTHWEST)
target_pixel_x = -16
target_pixel_y = -16
layer = ABOVE_MOB_LAYER
animate(src, pixel_x = target_pixel_x, pixel_y = target_pixel_y, alpha = 0, time = duration)
/obj/effect/overlay/temp/dir_setting/bloodsplatter/xenosplatter
splatter_type = "xsplatter"
/obj/effect/overlay/temp/dir_setting/firing_effect
icon = 'icons/effects/effects.dmi'
icon_state = "firing_effect"
duration = 2
/obj/effect/overlay/temp/dir_setting/firing_effect/setDir(newdir)
switch(newdir)
if(NORTH)
layer = BELOW_MOB_LAYER
pixel_x = rand(-3,3)
pixel_y = rand(4,6)
if(SOUTH)
pixel_x = rand(-3,3)
pixel_y = rand(-1,1)
else
pixel_x = rand(-1,1)
pixel_y = rand(-1,1)
..()
/obj/effect/overlay/temp/dir_setting/firing_effect/energy
icon_state = "firing_effect_energy"
duration = 3
/obj/effect/overlay/temp/dir_setting/firing_effect/magic
icon_state = "shieldsparkles"
duration = 3
/obj/effect/overlay/temp/dir_setting/ninja
name = "ninja shadow"
icon = 'icons/mob/mob.dmi'
icon_state = "uncloak"
duration = 9
/obj/effect/overlay/temp/dir_setting/ninja/cloak
icon_state = "cloak"
/obj/effect/overlay/temp/dir_setting/ninja/shadow
icon_state = "shadow"
/obj/effect/overlay/temp/dir_setting/ninja/phase
name = "ninja energy"
icon_state = "phasein"
/obj/effect/overlay/temp/dir_setting/ninja/phase/out
icon_state = "phaseout"
/obj/effect/overlay/temp/dir_setting/wraith
name = "blood"
icon = 'icons/mob/mob.dmi'
icon_state = "phase_shift2"
duration = 12
/obj/effect/overlay/temp/dir_setting/wraith/out
icon_state = "phase_shift"
/obj/effect/overlay/temp/wizard
name = "water"
icon = 'icons/mob/mob.dmi'
icon_state = "reappear"
duration = 5
/obj/effect/overlay/temp/wizard/out
icon_state = "liquify"
duration = 12
/obj/effect/overlay/temp/monkeyify
icon = 'icons/mob/mob.dmi'
icon_state = "h2monkey"
duration = 22
/obj/effect/overlay/temp/monkeyify/humanify
icon_state = "monkey2h"
/obj/effect/overlay/temp/borgflash
icon = 'icons/mob/mob.dmi'
icon_state = "blspell"
duration = 5
/obj/effect/overlay/temp/guardian
randomdir = 0
/obj/effect/overlay/temp/guardian/phase
duration = 5
icon_state = "phasein"
/obj/effect/overlay/temp/guardian/phase/out
icon_state = "phaseout"
/obj/effect/overlay/temp/decoy
desc = "It's a decoy!"
duration = 15
/obj/effect/overlay/temp/decoy/New(loc, atom/mimiced_atom)
..()
alpha = initial(alpha)
if(mimiced_atom)
name = mimiced_atom.name
appearance = mimiced_atom.appearance
setDir(mimiced_atom.dir)
mouse_opacity = 0
/obj/effect/overlay/temp/decoy/fading/New(loc, atom/mimiced_atom)
..()
animate(src, alpha = 0, time = duration)
/obj/effect/overlay/temp/cult
randomdir = 0
duration = 10
/obj/effect/overlay/temp/cult/sparks
randomdir = 1
name = "blood sparks"
icon_state = "bloodsparkles"
/obj/effect/overlay/temp/dir_setting/cult/phase
name = "phase glow"
duration = 7
icon_state = "cultin"
/obj/effect/overlay/temp/dir_setting/cult/phase/out
icon_state = "cultout"
/obj/effect/overlay/temp/cult/sac
name = "maw of Nar-Sie"
icon_state = "sacconsume"
/obj/effect/overlay/temp/cult/door
name = "unholy glow"
icon_state = "doorglow"
layer = CLOSED_FIREDOOR_LAYER //above closed doors
/obj/effect/overlay/temp/cult/door/unruned
icon_state = "unruneddoorglow"
/obj/effect/overlay/temp/cult/turf
name = "unholy glow"
icon_state = "wallglow"
layer = ABOVE_NORMAL_TURF_LAYER
/obj/effect/overlay/temp/cult/turf/floor
icon_state = "floorglow"
duration = 5
/obj/effect/overlay/temp/ratvar
name = "ratvar's light"
duration = 8
randomdir = 0
layer = ABOVE_NORMAL_TURF_LAYER
/obj/effect/overlay/temp/ratvar/door
icon_state = "ratvardoorglow"
layer = CLOSED_FIREDOOR_LAYER //above closed doors
/obj/effect/overlay/temp/ratvar/door/window
icon_state = "ratvarwindoorglow"
/obj/effect/overlay/temp/ratvar/beam
icon_state = "ratvarbeamglow"
/obj/effect/overlay/temp/ratvar/beam/door
layer = CLOSED_FIREDOOR_LAYER //above closed doors
/obj/effect/overlay/temp/ratvar/beam/grille
layer = LOW_ITEM_LAYER //above grilles
/obj/effect/overlay/temp/ratvar/beam/itemconsume
layer = HIGH_OBJ_LAYER
/obj/effect/overlay/temp/ratvar/wall
icon_state = "ratvarwallglow"
/obj/effect/overlay/temp/ratvar/floor
icon_state = "ratvarfloorglow"
/obj/effect/overlay/temp/ratvar/window
icon_state = "ratvarwindowglow"
layer = ABOVE_WINDOW_LAYER //above windows
/obj/effect/overlay/temp/ratvar/grille
icon_state = "ratvargrilleglow"
layer = LOW_ITEM_LAYER //above grilles
/obj/effect/overlay/temp/ratvar/grille/broken
icon_state = "ratvarbrokengrilleglow"
/obj/effect/overlay/temp/ratvar/window/single
icon_state = "ratvarwindowglow_s"
/obj/effect/overlay/temp/ratvar/spearbreak
icon = 'icons/effects/64x64.dmi'
icon_state = "ratvarspearbreak"
layer = BELOW_MOB_LAYER
pixel_y = -16
pixel_x = -16
/obj/effect/overlay/temp/ratvar/sigil
name = "glowing circle"
icon = 'icons/effects/clockwork_effects.dmi'
icon_state = "sigildull"
/obj/effect/overlay/temp/ratvar/sigil/transgression
color = "#FAE48C"
layer = ABOVE_MOB_LAYER
duration = 70
luminosity = 6
/obj/effect/overlay/temp/ratvar/sigil/transgression/New()
..()
var/oldtransform = transform
animate(src, transform = matrix()*2, time = 5)
animate(transform = oldtransform, alpha = 0, time = 65)
/obj/effect/overlay/temp/ratvar/sigil/vitality
color = "#1E8CE1"
icon_state = "sigilactivepulse"
layer = ABOVE_MOB_LAYER
/obj/effect/overlay/temp/ratvar/sigil/accession
color = "#AF0AAF"
layer = ABOVE_MOB_LAYER
duration = 70
icon_state = "sigilactiveoverlay"
alpha = 0
/obj/effect/overlay/temp/revenant
name = "spooky lights"
icon_state = "purplesparkles"
/obj/effect/overlay/temp/revenant/cracks
name = "glowing cracks"
icon_state = "purplecrack"
duration = 6
/obj/effect/overlay/temp/emp
name = "emp sparks"
icon_state = "empdisable"
/obj/effect/overlay/temp/emp/pulse
name = "emp pulse"
icon_state = "emppulse"
duration = 8
randomdir = 0
/obj/effect/overlay/temp/gib_animation
icon = 'icons/mob/mob.dmi'
duration = 15
/obj/effect/overlay/temp/gib_animation/New(loc, gib_icon)
icon_state = gib_icon // Needs to be before ..() so icon is correct
..()
/obj/effect/overlay/temp/gib_animation/ex_act(severity)
return //so the overlay isn't deleted by the explosion that gibbed the mob.
/obj/effect/overlay/temp/gib_animation/animal
icon = 'icons/mob/animal.dmi'
/obj/effect/overlay/temp/dust_animation
icon = 'icons/mob/mob.dmi'
duration = 15
/obj/effect/overlay/temp/dust_animation/New(loc, dust_icon)
icon_state = dust_icon // Before ..() so the correct icon is flick()'d
..()
/obj/effect/overlay/temp/sparkle
icon = 'icons/effects/effects.dmi'
icon_state = "shieldsparkles"
mouse_opacity = 0
density = 0
duration = 10
var/atom/movable/attached_to
/obj/effect/overlay/temp/sparkle/New(atom/movable/AM)
..()
if(istype(AM))
attached_to = AM
attached_to.overlays += src
/obj/effect/overlay/temp/sparkle/Destroy()
if(attached_to)
attached_to.overlays -= src
attached_to = null
. = ..()
/obj/effect/overlay/temp/sparkle/tailsweep
icon_state = "tailsweep"
/obj/effect/overlay/temp/heal //color is white by default, set to whatever is needed
name = "healing glow"
icon_state = "heal"
duration = 15
/obj/effect/overlay/temp/heal/New(loc, colour)
..()
pixel_x = rand(-12, 12)
pixel_y = rand(-9, 0)
if(colour)
color = colour
/obj/effect/overlay/temp/kinetic_blast
name = "kinetic explosion"
icon = 'icons/obj/projectiles.dmi'
icon_state = "kinetic_blast"
layer = ABOVE_ALL_MOB_LAYER
duration = 4
/obj/effect/overlay/temp/explosion
name = "explosion"
icon = 'icons/effects/96x96.dmi'
icon_state = "explosion"
pixel_x = -32
pixel_y = -32
duration = 8
/obj/effect/overlay/temp/explosion/fast
icon_state = "explosionfast"
duration = 4
/obj/effect/overlay/temp/blob
name = "blob"
icon_state = "blob_attack"
alpha = 140
randomdir = 0
duration = 6
/obj/effect/overlay/temp/impact_effect
icon = 'icons/effects/effects.dmi'
icon_state = "impact_bullet"
duration = 5
/obj/effect/overlay/temp/impact_effect/New(loc, atom/target, obj/item/projectile/P)
if(target == P.original) //the projectile hit the target originally clicked
pixel_x = P.p_x + target.pixel_x - 16 + rand(-4,4)
pixel_y = P.p_y + target.pixel_y - 16 + rand(-4,4)
else
pixel_x = target.pixel_x + rand(-4,4)
pixel_y = target.pixel_y + rand(-4,4)
..()
/obj/effect/overlay/temp/impact_effect/red_laser
icon_state = "impact_laser"
duration = 4
/obj/effect/overlay/temp/impact_effect/blue_laser
icon_state = "impact_laser_blue"
duration = 4
/obj/effect/overlay/temp/impact_effect/green_laser
icon_state = "impact_laser_green"
duration = 4
/obj/effect/overlay/temp/impact_effect/purple_laser
icon_state = "impact_laser_purple"
duration = 4
/obj/effect/overlay/temp/impact_effect/ion
icon_state = "shieldsparkles"
duration = 6
/obj/effect/overlay/palmtree_r
name = "Palm tree"
icon = 'icons/misc/beach2.dmi'
icon_state = "palm1"
density = 1
layer = WALL_OBJ_LAYER
anchored = 1
/obj/effect/overlay/palmtree_l
name = "Palm tree"
icon = 'icons/misc/beach2.dmi'
icon_state = "palm2"
density = 1
layer = WALL_OBJ_LAYER
anchored = 1
/obj/effect/overlay/coconut
name = "Coconuts"
icon = 'icons/misc/beach.dmi'
icon_state = "coconuts"