Files
Bubberstation/code/game/objects/items/weapons/storage/fancy.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

297 lines
9.3 KiB
Plaintext

/*
* The 'fancy' path is for objects like donut boxes that show how many items are in the storage item on the sprite itself
* .. Sorry for the shitty path name, I couldnt think of a better one.
*
* WARNING: var/icon_type is used for both examine text and sprite name. Please look at the procs below and adjust your sprite names accordingly
* TODO: Cigarette boxes should be ported to this standard
*
* Contains:
* Donut Box
* Egg Box
* Candle Box
* Cigarette Box
* Cigar Case
*/
/obj/item/weapon/storage/fancy
icon = 'icons/obj/food/containers.dmi'
icon_state = "donutbox6"
name = "donut box"
resistance_flags = FLAMMABLE
var/icon_type = "donut"
var/spawn_type = null
var/fancy_open = FALSE
/obj/item/weapon/storage/fancy/New()
..()
for(var/i = 1 to storage_slots)
new spawn_type(src)
/obj/item/weapon/storage/fancy/update_icon(itemremoved = 0)
if(fancy_open)
var/total_contents = src.contents.len - itemremoved
icon_state = "[icon_type]box[total_contents]"
else
icon_state = "[icon_type]box"
/obj/item/weapon/storage/fancy/examine(mob/user)
..()
if(fancy_open)
if(contents.len == 1)
user << "There is one [src.icon_type] left."
else
user << "There are [contents.len <= 0 ? "no" : "[src.contents.len]"] [src.icon_type]s left."
/obj/item/weapon/storage/fancy/attack_self(mob/user)
fancy_open = !fancy_open
update_icon()
/obj/item/weapon/storage/fancy/content_can_dump(atom/dest_object, mob/user)
. = ..()
if(.)
fancy_open = TRUE
update_icon()
/obj/item/weapon/storage/fancy/handle_item_insertion(obj/item/W, prevent_warning = 0, mob/user)
fancy_open = TRUE
return ..()
/obj/item/weapon/storage/fancy/remove_from_storage(obj/item/W, atom/new_location, burn = 0)
fancy_open = TRUE
return ..()
/*
* Donut Box
*/
/obj/item/weapon/storage/fancy/donut_box
icon = 'icons/obj/food/containers.dmi'
icon_state = "donutbox6"
icon_type = "donut"
name = "donut box"
storage_slots = 6
can_hold = list(/obj/item/weapon/reagent_containers/food/snacks/donut)
spawn_type = /obj/item/weapon/reagent_containers/food/snacks/donut
fancy_open = TRUE
/*
* Egg Box
*/
/obj/item/weapon/storage/fancy/egg_box
icon = 'icons/obj/food/containers.dmi'
icon_state = "eggbox"
icon_type = "egg"
name = "egg box"
storage_slots = 12
can_hold = list(/obj/item/weapon/reagent_containers/food/snacks/egg)
spawn_type = /obj/item/weapon/reagent_containers/food/snacks/egg
/*
* Candle Box
*/
/obj/item/weapon/storage/fancy/candle_box
name = "candle pack"
desc = "A pack of red candles."
icon = 'icons/obj/candle.dmi'
icon_state = "candlebox5"
icon_type = "candle"
item_state = "candlebox5"
storage_slots = 5
throwforce = 2
slot_flags = SLOT_BELT
spawn_type = /obj/item/candle
fancy_open = TRUE
/obj/item/weapon/storage/fancy/candle_box/attack_self(mob_user)
return
////////////
//CIG PACK//
////////////
/obj/item/weapon/storage/fancy/cigarettes
name = "Space Cigarettes"
desc = "The most popular brand of cigarettes, sponsors of the Space Olympics."
icon = 'icons/obj/cigarettes.dmi'
icon_state = "cig"
item_state = "cigpacket"
w_class = 1
throwforce = 0
slot_flags = SLOT_BELT
storage_slots = 6
can_hold = list(/obj/item/clothing/mask/cigarette, /obj/item/weapon/lighter)
icon_type = "cigarette"
spawn_type = /obj/item/clothing/mask/cigarette
/obj/item/weapon/storage/fancy/cigarettes/New()
..()
create_reagents(15 * storage_slots)//so people can inject cigarettes without opening a packet, now with being able to inject the whole one
reagents.set_reacting(FALSE)
for(var/obj/item/clothing/mask/cigarette/cig in src)
cig.desc = "\An [name] brand [cig.name]."
name = "\improper [name] packet"
/obj/item/weapon/storage/fancy/cigarettes/AltClick(mob/user)
if(user.get_active_held_item())
return
for(var/obj/item/weapon/lighter/lighter in src)
remove_from_storage(lighter, user.loc)
user.put_in_active_hand(lighter)
break
/obj/item/weapon/storage/fancy/cigarettes/update_icon()
if(fancy_open || !contents.len)
cut_overlays()
if(!contents.len)
icon_state = "[initial(icon_state)]_empty"
else
icon_state = initial(icon_state)
add_overlay("[icon_state]_open")
var/i = contents.len
for(var/C in contents)
if(istype(C, /obj/item/weapon/lighter/greyscale))
add_overlay(image(icon = src.icon, icon_state = "lighter_in", pixel_x = 1 * (i -1)))
else if(istype(C, /obj/item/weapon/lighter))
add_overlay(image(icon = src.icon, icon_state = "zippo_in", pixel_x = 1 * (i -1)))
else
add_overlay(image(icon = src.icon, icon_state = "cigarette", pixel_x = 1 * (i -1)))
i--
else
cut_overlays()
/obj/item/weapon/storage/fancy/cigarettes/remove_from_storage(obj/item/W, atom/new_location)
if(istype(W,/obj/item/clothing/mask/cigarette))
if(reagents)
reagents.trans_to(W,(reagents.total_volume/contents.len))
fancy_open = TRUE
..()
/obj/item/weapon/storage/fancy/cigarettes/attack(mob/living/carbon/M as mob, mob/living/carbon/user as mob)
if(!istype(M, /mob))
return
var/obj/item/clothing/mask/cigarette/cig = locate(/obj/item/clothing/mask/cigarette) in contents
if(cig)
if(M == user && contents.len > 0 && !user.wear_mask)
var/obj/item/clothing/mask/cigarette/W = cig
remove_from_storage(W, M)
M.equip_to_slot_if_possible(W, slot_wear_mask)
contents -= W
user << "<span class='notice'>You take a [icon_type] out of the pack.</span>"
else
..()
else
user << "<span class='notice'>There are no [icon_type]s left in the pack.</span>"
/obj/item/weapon/storage/fancy/cigarettes/dromedaryco
name = "DromedaryCo"
desc = "A packet of six imported DromedaryCo cancer sticks. A label on the packaging reads, \"Wouldn't a slow death make a change?\""
icon_state = "dromedary"
/obj/item/weapon/storage/fancy/cigarettes/cigpack_uplift
name = "Uplift Smooth"
desc = "Your favorite brand, now menthol flavored."
icon_state = "uplift"
/obj/item/weapon/storage/fancy/cigarettes/cigpack_robust
name = "Robust"
desc = "Smoked by the robust."
icon_state = "robust"
/obj/item/weapon/storage/fancy/cigarettes/cigpack_robustgold
name = "Robust Gold"
desc = "Smoked by the truly robust."
icon_state = "robustg"
/obj/item/weapon/storage/fancy/cigarettes/cigpack_robustgold/New()
..()
for(var/i = 1 to storage_slots)
reagents.add_reagent("gold",1)
/obj/item/weapon/storage/fancy/cigarettes/cigpack_carp
name = "Carp Classic"
desc = "Since 2313."
icon_state = "carp"
/obj/item/weapon/storage/fancy/cigarettes/cigpack_syndicate
name = "unknown"
desc = "An obscure brand of cigarettes."
icon_state = "syndie"
/obj/item/weapon/storage/fancy/cigarettes/cigpack_syndicate/New()
..()
for(var/i = 1 to storage_slots)
reagents.add_reagent("omnizine",15)
name = "cigarette packet"
/obj/item/weapon/storage/fancy/cigarettes/cigpack_midori
name = "Midori Tabako"
desc = "You can't understand the runes, but the packet smells funny."
icon_state = "midori"
spawn_type = /obj/item/clothing/mask/cigarette/rollie
/obj/item/weapon/storage/fancy/cigarettes/cigpack_shadyjims
name ="Shady Jim's Super Slims"
desc = "Is your weight slowing you down? Having trouble running away from gravitational singularities? Can't stop stuffing your mouth? Smoke Shady Jim's Super Slims and watch all that fat burn away. Guaranteed results!"
icon_state = "shadyjim"
/obj/item/weapon/storage/fancy/cigarettes/cigpack_shadyjims/New()
..()
for(var/i = 1 to storage_slots)
reagents.add_reagent("lipolicide",4)
reagents.add_reagent("ammonia",2)
reagents.add_reagent("plantbgone",1)
reagents.add_reagent("toxin",1.5)
/obj/item/weapon/storage/fancy/rollingpapers
name = "rolling paper pack"
desc = "A pack of NanoTrasen brand rolling papers."
w_class = 1
icon = 'icons/obj/cigarettes.dmi'
icon_state = "cig_paper_pack"
storage_slots = 10
icon_type = "rolling paper"
can_hold = list(/obj/item/weapon/rollingpaper)
spawn_type = /obj/item/weapon/rollingpaper
/obj/item/weapon/storage/fancy/rollingpapers/update_icon()
cut_overlays()
if(!contents.len)
add_overlay("[icon_state]_empty")
/////////////
//CIGAR BOX//
/////////////
/obj/item/weapon/storage/fancy/cigarettes/cigars
name = "\improper premium cigar case"
desc = "A case of premium cigars. Very expensive."
icon = 'icons/obj/cigarettes.dmi'
icon_state = "cigarcase"
w_class = 3
storage_slots = 5
can_hold = list(/obj/item/clothing/mask/cigarette/cigar)
icon_type = "premium cigar"
spawn_type = /obj/item/clothing/mask/cigarette/cigar
/obj/item/weapon/storage/fancy/cigarettes/cigars/update_icon()
if(fancy_open)
cut_overlays()
add_overlay("[icon_state]_open")
for(var/c = contents.len, c >= 1, c--)
add_overlay(image(icon = src.icon, icon_state = icon_type, pixel_x = 4 * (c -1)))
else
cut_overlays()
icon_state = "cigarcase"
/obj/item/weapon/storage/fancy/cigarettes/cigars/cohiba
name = "\improper cohiba robusto cigar case"
desc = "A case of imported Cohiba cigars, renowned for their strong flavor."
spawn_type = /obj/item/clothing/mask/cigarette/cigar/cohiba
/obj/item/weapon/storage/fancy/cigarettes/cigars/havana
name = "\improper premium havanian cigar case"
desc = "A case of classy Havanian cigars."
spawn_type = /obj/item/clothing/mask/cigarette/cigar/havana