Files
Bubberstation/code/game/objects/structures/girders.dm
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

374 lines
13 KiB
Plaintext

#define GIRDER_NORMAL 0
#define GIRDER_REINF_STRUTS 1
#define GIRDER_REINF 2
#define GIRDER_DISPLACED 3
#define GIRDER_DISASSEMBLED 4
/obj/structure/girder
name = "girder"
icon_state = "girder"
anchored = 1
density = 1
layer = BELOW_OBJ_LAYER
var/state = GIRDER_NORMAL
var/girderpasschance = 20 // percentage chance that a projectile passes through the girder.
var/can_displace = TRUE //If the girder can be moved around by wrenching it
obj_integrity = 200
max_integrity = 200
/obj/structure/girder/attackby(obj/item/W, mob/user, params)
add_fingerprint(user)
if(istype(W, /obj/item/weapon/screwdriver))
if(state == GIRDER_DISPLACED)
playsound(src.loc, 'sound/items/Screwdriver.ogg', 100, 1)
user.visible_message("<span class='warning'>[user] disassembles the girder.</span>", \
"<span class='notice'>You start to disassemble the girder...</span>", "You hear clanking and banging noises.")
if(do_after(user, 40/W.toolspeed, target = src))
if(state != GIRDER_DISPLACED)
return
state = GIRDER_DISASSEMBLED
user << "<span class='notice'>You disassemble the girder.</span>"
var/obj/item/stack/sheet/metal/M = new (loc, 2)
M.add_fingerprint(user)
qdel(src)
else if(state == GIRDER_REINF)
playsound(src.loc, 'sound/items/Screwdriver.ogg', 100, 1)
user << "<span class='notice'>You start unsecuring support struts...</span>"
if(do_after(user, 40/W.toolspeed, target = src))
if(state != GIRDER_REINF)
return
user << "<span class='notice'>You unsecure the support struts.</span>"
state = GIRDER_REINF_STRUTS
else if(istype(W, /obj/item/weapon/wrench))
if(state == GIRDER_DISPLACED)
if(!isfloorturf(loc))
user << "<span class='warning'>A floor must be present to secure the girder!</span>"
return
playsound(src.loc, 'sound/items/Ratchet.ogg', 100, 1)
user << "<span class='notice'>You start securing the girder...</span>"
if(do_after(user, 40/W.toolspeed, target = src))
user << "<span class='notice'>You secure the girder.</span>"
var/obj/structure/girder/G = new (loc)
transfer_fingerprints_to(G)
qdel(src)
else if(state == GIRDER_NORMAL && can_displace)
playsound(src.loc, 'sound/items/Ratchet.ogg', 100, 1)
user << "<span class='notice'>You start unsecuring the girder...</span>"
if(do_after(user, 40/W.toolspeed, target = src))
user << "<span class='notice'>You unsecure the girder.</span>"
var/obj/structure/girder/displaced/D = new (loc)
transfer_fingerprints_to(D)
qdel(src)
else if(istype(W, /obj/item/weapon/gun/energy/plasmacutter))
user << "<span class='notice'>You start slicing apart the girder...</span>"
playsound(src, 'sound/items/Welder.ogg', 100, 1)
if(do_after(user, 30, target = src))
user << "<span class='notice'>You slice apart the girder.</span>"
var/obj/item/stack/sheet/metal/M = new (loc, 2)
M.add_fingerprint(user)
qdel(src)
else if(istype(W, /obj/item/weapon/pickaxe/drill/jackhammer))
var/obj/item/weapon/pickaxe/drill/jackhammer/D = W
user << "<span class='notice'>You smash through the girder!</span>"
new /obj/item/stack/sheet/metal(get_turf(src))
D.playDigSound()
qdel(src)
else if(istype(W, /obj/item/weapon/wirecutters) && state == GIRDER_REINF_STRUTS)
playsound(src.loc, 'sound/items/Wirecutter.ogg', 100, 1)
user << "<span class='notice'>You start removing support struts...</span>"
if(do_after(user, 40/W.toolspeed, target = src))
user << "<span class='notice'>You remove the support struts.</span>"
new /obj/item/stack/sheet/plasteel(get_turf(src))
var/obj/structure/girder/G = new (loc)
transfer_fingerprints_to(G)
qdel(src)
else if(istype(W, /obj/item/stack))
if(iswallturf(loc))
user << "<span class='warning'>There is already a wall present!</span>"
return
if(!isfloorturf(src.loc))
user << "<span class='warning'>A floor must be present to build a false wall!</span>"
return
if (locate(/obj/structure/falsewall) in src.loc.contents)
user << "<span class='warning'>There is already a false wall present!</span>"
return
if(istype(W,/obj/item/stack/rods))
var/obj/item/stack/rods/S = W
if(state == GIRDER_DISPLACED)
if(S.get_amount() < 2)
user << "<span class='warning'>You need at least two rods to create a false wall!</span>"
return
user << "<span class='notice'>You start building a reinforced false wall...</span>"
if(do_after(user, 20, target = src))
if(!src.loc || !S || S.get_amount() < 2)
return
S.use(2)
user << "<span class='notice'>You create a false wall. Push on it to open or close the passage.</span>"
var/obj/structure/falsewall/iron/FW = new (loc)
transfer_fingerprints_to(FW)
qdel(src)
else
if(S.get_amount() < 5)
user << "<span class='warning'>You need at least five rods to add plating!</span>"
return
user << "<span class='notice'>You start adding plating...</span>"
if (do_after(user, 40, target = src))
if(!src.loc || !S || S.get_amount() < 5)
return
S.use(5)
user << "<span class='notice'>You add the plating.</span>"
var/turf/T = get_turf(src)
T.ChangeTurf(/turf/closed/wall/mineral/iron)
transfer_fingerprints_to(T)
qdel(src)
return
if(!istype(W,/obj/item/stack/sheet))
return
var/obj/item/stack/sheet/S = W
if(istype(S,/obj/item/stack/sheet/metal))
if(state == GIRDER_DISPLACED)
if(S.get_amount() < 2)
user << "<span class='warning'>You need two sheets of metal to create a false wall!</span>"
return
user << "<span class='notice'>You start building a false wall...</span>"
if(do_after(user, 20, target = src))
if(!src.loc || !S || S.get_amount() < 2)
return
S.use(2)
user << "<span class='notice'>You create a false wall. Push on it to open or close the passage.</span>"
var/obj/structure/falsewall/F = new (loc)
transfer_fingerprints_to(F)
qdel(src)
else
if(S.get_amount() < 2)
user << "<span class='warning'>You need two sheets of metal to finish a wall!</span>"
return
user << "<span class='notice'>You start adding plating...</span>"
if (do_after(user, 40, target = src))
if(loc == null || S.get_amount() < 2)
return
S.use(2)
user << "<span class='notice'>You add the plating.</span>"
var/turf/T = get_turf(src)
T.ChangeTurf(/turf/closed/wall)
transfer_fingerprints_to(T)
qdel(src)
return
if(istype(S,/obj/item/stack/sheet/plasteel))
if(state == GIRDER_DISPLACED)
if(S.get_amount() < 2)
user << "<span class='warning'>You need at least two sheets to create a false wall!</span>"
return
user << "<span class='notice'>You start building a reinforced false wall...</span>"
if(do_after(user, 20, target = src))
if(!src.loc || !S || S.get_amount() < 2)
return
S.use(2)
user << "<span class='notice'>You create a reinforced false wall. Push on it to open or close the passage.</span>"
var/obj/structure/falsewall/reinforced/FW = new (loc)
transfer_fingerprints_to(FW)
qdel(src)
else
if(state == GIRDER_REINF)
if(S.get_amount() < 1)
return
user << "<span class='notice'>You start finalizing the reinforced wall...</span>"
if(do_after(user, 50, target = src))
if(!src.loc || !S || S.get_amount() < 1)
return
S.use(1)
user << "<span class='notice'>You fully reinforce the wall.</span>"
var/turf/T = get_turf(src)
T.ChangeTurf(/turf/closed/wall/r_wall)
transfer_fingerprints_to(T)
qdel(src)
return
else
if(S.get_amount() < 1)
return
user << "<span class='notice'>You start reinforcing the girder...</span>"
if (do_after(user, 60, target = src))
if(!src.loc || !S || S.get_amount() < 1)
return
S.use(1)
user << "<span class='notice'>You reinforce the girder.</span>"
var/obj/structure/girder/reinforced/R = new (loc)
transfer_fingerprints_to(R)
qdel(src)
return
if(S.sheettype)
var/M = S.sheettype
if(state == GIRDER_DISPLACED)
if(S.get_amount() < 2)
user << "<span class='warning'>You need at least two sheets to create a false wall!</span>"
return
if(do_after(user, 20, target = src))
if(!src.loc || !S || S.get_amount() < 2)
return
S.use(2)
user << "<span class='notice'>You create a false wall. Push on it to open or close the passage.</span>"
var/F = text2path("/obj/structure/falsewall/[M]")
var/obj/structure/FW = new F (loc)
transfer_fingerprints_to(FW)
qdel(src)
else
if(S.get_amount() < 2)
user << "<span class='warning'>You need at least two sheets to add plating!</span>"
return
user << "<span class='notice'>You start adding plating...</span>"
if (do_after(user, 40, target = src))
if(!src.loc || !S || S.get_amount() < 2)
return
S.use(2)
user << "<span class='notice'>You add the plating.</span>"
var/turf/T = get_turf(src)
T.ChangeTurf(text2path("/turf/closed/wall/mineral/[M]"))
transfer_fingerprints_to(T)
qdel(src)
return
add_hiddenprint(user)
else if(istype(W, /obj/item/pipe))
var/obj/item/pipe/P = W
if (P.pipe_type in list(0, 1, 5)) //simple pipes, simple bends, and simple manifolds.
if(!user.drop_item())
return
P.loc = src.loc
user << "<span class='notice'>You fit the pipe into \the [src].</span>"
else
return ..()
/obj/structure/girder/CanPass(atom/movable/mover, turf/target, height=0)
if(height==0)
return 1
if(istype(mover) && mover.checkpass(PASSGRILLE))
return prob(girderpasschance)
else
if(istype(mover, /obj/item/projectile))
return prob(girderpasschance)
else
return 0
/obj/structure/girder/CanAStarPass(ID, dir, caller)
. = !density
if(ismovableatom(caller))
var/atom/movable/mover = caller
. = . || mover.checkpass(PASSGRILLE)
/obj/structure/girder/deconstruct(disassembled = TRUE)
if(!(flags & NODECONSTRUCT))
var/remains = pick(/obj/item/stack/rods,/obj/item/stack/sheet/metal)
new remains(loc)
qdel(src)
/obj/structure/girder/narsie_act()
if(prob(25))
new /obj/structure/girder/cult(loc)
qdel(src)
/obj/structure/girder/displaced
name = "displaced girder"
icon_state = "displaced"
anchored = 0
state = GIRDER_DISPLACED
girderpasschance = 25
obj_integrity = 120
max_integrity = 120
/obj/structure/girder/reinforced
name = "reinforced girder"
icon_state = "reinforced"
state = GIRDER_REINF
girderpasschance = 0
obj_integrity = 350
max_integrity = 350
//////////////////////////////////////////// cult girder //////////////////////////////////////////////
/obj/structure/girder/cult
name = "runed girder"
desc = "Framework made of a strange and shockingly cold metal. It doesn't seem to have any bolts."
icon = 'icons/obj/cult.dmi'
icon_state= "cultgirder"
can_displace = FALSE
/obj/structure/girder/cult/attackby(obj/item/W, mob/user, params)
add_fingerprint(user)
if(istype(W, /obj/item/weapon/tome) && iscultist(user)) //Cultists can demolish cult girders instantly with their tomes
user.visible_message("<span class='warning'>[user] strikes [src] with [W]!</span>", "<span class='notice'>You demolish [src].</span>")
var/obj/item/stack/sheet/runed_metal/R = new(get_turf(src))
R.amount = 1
qdel(src)
else if(istype(W, /obj/item/weapon/weldingtool))
var/obj/item/weapon/weldingtool/WT = W
if(WT.remove_fuel(0,user))
playsound(src.loc, 'sound/items/Welder2.ogg', 50, 1)
user << "<span class='notice'>You start slicing apart the girder...</span>"
if(do_after(user, 40/W.toolspeed, target = src))
if( !WT.isOn() )
return
user << "<span class='notice'>You slice apart the girder.</span>"
var/obj/item/stack/sheet/runed_metal/R = new(get_turf(src))
R.amount = 1
transfer_fingerprints_to(R)
qdel(src)
else if(istype(W, /obj/item/weapon/gun/energy/plasmacutter))
user << "<span class='notice'>You start slicing apart the girder...</span>"
playsound(src, 'sound/items/Welder.ogg', 100, 1)
if(do_after(user, 30, target = src))
user << "<span class='notice'>You slice apart the girder.</span>"
var/obj/item/stack/sheet/runed_metal/R = new(get_turf(src))
R.amount = 1
transfer_fingerprints_to(R)
qdel(src)
else if(istype(W, /obj/item/weapon/pickaxe/drill/jackhammer))
var/obj/item/weapon/pickaxe/drill/jackhammer/D = W
user << "<span class='notice'>Your jackhammer smashes through the girder!</span>"
var/obj/item/stack/sheet/runed_metal/R = new(get_turf(src))
R.amount = 2
transfer_fingerprints_to(R)
D.playDigSound()
qdel(src)
else if(istype(W, /obj/item/stack/sheet/runed_metal))
var/obj/item/stack/sheet/runed_metal/R = W
if(R.get_amount() < 1)
user << "<span class='warning'>You need at least one sheet of runed metal to construct a runed wall!</span>"
return 0
user.visible_message("<span class='notice'>[user] begins laying runed metal on [src]...</span>", "<span class='notice'>You begin constructing a runed wall...</span>")
if(do_after(user, 50, target = src))
if(R.get_amount() < 1 || !R)
return
user.visible_message("<span class='notice'>[user] plates [src] with runed metal.</span>", "<span class='notice'>You construct a runed wall.</span>")
R.use(1)
var/turf/T = get_turf(src)
T.ChangeTurf(/turf/closed/wall/mineral/cult)
qdel(src)
else
return ..()
/obj/structure/girder/cult/narsie_act()
return
/obj/structure/girder/cult/deconstruct(disassembled = TRUE)
if(!(flags & NODECONSTRUCT))
new/obj/item/stack/sheet/runed_metal/(get_turf(src), 1)
qdel(src)