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

295 lines
9.2 KiB
Plaintext

/* Cards
* Contains:
* DATA CARD
* ID CARD
* FINGERPRINT CARD HOLDER
* FINGERPRINT CARD
*/
/*
* DATA CARDS - Used for the teleporter
*/
/obj/item/weapon/card
name = "card"
desc = "Does card things."
icon = 'icons/obj/card.dmi'
w_class = 1
var/list/files = list()
/obj/item/weapon/card/data
name = "data disk"
desc = "A disk of data."
icon_state = "data"
var/function = "storage"
var/data = "null"
var/special = null
item_state = "card-id"
/obj/item/weapon/card/data/verb/label(t as text)
set name = "Label Disk"
set category = "Object"
set src in usr
if(usr.stat || !usr.canmove || usr.restrained())
return
if (t)
src.name = "data disk- '[t]'"
else
src.name = "data disk"
src.add_fingerprint(usr)
return
/*
* ID CARDS
*/
/obj/item/weapon/card/emag
desc = "It's a card with a magnetic strip attached to some circuitry."
name = "cryptographic sequencer"
icon_state = "emag"
item_state = "card-id"
origin_tech = "magnets=2;syndicate=2"
flags = NOBLUDGEON
var/prox_check = TRUE //If the emag requires you to be in range
/obj/item/weapon/card/emag/bluespace
name = "bluespace cryptographic sequencer"
desc = "It's a blue card with a magnetic strip attached to some circuitry. It appears to have some sort of transmitter attached to it."
color = rgb(40, 130, 255)
origin_tech = "bluespace=4;magnets=4;syndicate=5"
prox_check = FALSE
/obj/item/weapon/card/emag/attack()
return
/obj/item/weapon/card/emag/afterattack(atom/target, mob/user, proximity)
var/atom/A = target
if(!proximity && prox_check)
return
A.emag_act(user)
/obj/item/weapon/card/id
name = "identification card"
desc = "A card used to provide ID and determine access across the station."
icon_state = "id"
item_state = "card-id"
slot_flags = SLOT_ID
armor = list(melee = 0, bullet = 0, laser = 0, energy = 0, bomb = 0, bio = 0, rad = 0, fire = 100, acid = 100)
resistance_flags = FIRE_PROOF | ACID_PROOF
var/mining_points = 0 //For redeeming at mining equipment vendors
var/list/access = list()
var/registered_name = null // The name registered_name on the card
var/assignment = null
var/dorm = 0 // determines if this ID has claimed a dorm already
/obj/item/weapon/card/id/attack_self(mob/user)
user.visible_message("<span class='notice'>[user] shows you: \icon[src] [src.name].</span>", \
"<span class='notice'>You show \the [src.name].</span>")
src.add_fingerprint(user)
return
/obj/item/weapon/card/id/examine(mob/user)
..()
if(mining_points)
user << "There's [mining_points] mining equipment redemption point\s loaded onto this card."
/obj/item/weapon/card/id/GetAccess()
return access
/obj/item/weapon/card/id/GetID()
return src
/*
Usage:
update_label()
Sets the id name to whatever registered_name and assignment is
update_label("John Doe", "Clowny")
Properly formats the name and occupation and sets the id name to the arguments
*/
/obj/item/weapon/card/id/proc/update_label(newname, newjob)
if(newname || newjob)
name = "[(!newname) ? "identification card" : "[newname]'s ID Card"][(!newjob) ? "" : " ([newjob])"]"
return
name = "[(!registered_name) ? "identification card" : "[registered_name]'s ID Card"][(!assignment) ? "" : " ([assignment])"]"
/obj/item/weapon/card/id/silver
name = "silver identification card"
desc = "A silver card which shows honour and dedication."
icon_state = "silver"
item_state = "silver_id"
/obj/item/weapon/card/id/gold
name = "gold identification card"
desc = "A golden card which shows power and might."
icon_state = "gold"
item_state = "gold_id"
/obj/item/weapon/card/id/syndicate
name = "agent card"
access = list(access_maint_tunnels, access_syndicate)
origin_tech = "syndicate=1"
/obj/item/weapon/card/id/syndicate/New()
..()
var/datum/action/item_action/chameleon/change/chameleon_action = new(src)
chameleon_action.chameleon_type = /obj/item/weapon/card/id
chameleon_action.chameleon_name = "ID Card"
chameleon_action.initialize_disguises()
/obj/item/weapon/card/id/syndicate/afterattack(obj/item/weapon/O, mob/user, proximity)
if(!proximity)
return
if(istype(O, /obj/item/weapon/card/id))
var/obj/item/weapon/card/id/I = O
src.access |= I.access
if(isliving(user) && user.mind)
if(user.mind.special_role)
usr << "<span class='notice'>The card's microscanners activate as you pass it over the ID, copying its access.</span>"
/obj/item/weapon/card/id/syndicate/attack_self(mob/user)
if(isliving(user) && user.mind)
if(user.mind.special_role)
if(alert(user, "Action", "Agent ID", "Show", "Forge") == "Forge")
var t = copytext(sanitize(input(user, "What name would you like to put on this card?", "Agent card name", registered_name ? registered_name : (ishuman(user) ? user.real_name : user.name))as text | null),1,26)
if(!t || t == "Unknown" || t == "floor" || t == "wall" || t == "r-wall") //Same as mob/new_player/prefrences.dm
if (t)
alert("Invalid name.")
return
registered_name = t
var u = copytext(sanitize(input(user, "What occupation would you like to put on this card?\nNote: This will not grant any access levels other than Maintenance.", "Agent card job assignment", "Assistant")as text | null),1,MAX_MESSAGE_LEN)
if(!u)
registered_name = ""
return
assignment = u
update_label()
user << "<span class='notice'>You successfully forge the ID card.</span>"
return
..()
/obj/item/weapon/card/id/syndicate_command
name = "syndicate ID card"
desc = "An ID straight from the Syndicate."
registered_name = "Syndicate"
assignment = "Syndicate Overlord"
access = list(access_syndicate)
/obj/item/weapon/card/id/captains_spare
name = "captain's spare ID"
desc = "The spare ID of the High Lord himself."
icon_state = "gold"
item_state = "gold_id"
registered_name = "Captain"
assignment = "Captain"
/obj/item/weapon/card/id/captains_spare/New()
var/datum/job/captain/J = new/datum/job/captain
access = J.get_access()
..()
/obj/item/weapon/card/id/centcom
name = "\improper Centcom ID"
desc = "An ID straight from Cent. Com."
icon_state = "centcom"
registered_name = "Central Command"
assignment = "General"
/obj/item/weapon/card/id/centcom/New()
access = get_all_centcom_access()
..()
/obj/item/weapon/card/id/ert
name = "\improper Centcom ID"
desc = "A ERT ID card"
icon_state = "centcom"
registered_name = "Emergency Response Team Commander"
assignment = "Emergency Response Team Commander"
/obj/item/weapon/card/id/ert/New()
access = get_all_accesses()+get_ert_access("commander")-access_change_ids
/obj/item/weapon/card/id/ert/Security
registered_name = "Security Response Officer"
assignment = "Security Response Officer"
/obj/item/weapon/card/id/ert/Security/New()
access = get_all_accesses()+get_ert_access("sec")-access_change_ids
/obj/item/weapon/card/id/ert/Engineer
registered_name = "Engineer Response Officer"
assignment = "Engineer Response Officer"
/obj/item/weapon/card/id/ert/Engineer/New()
access = get_all_accesses()+get_ert_access("eng")-access_change_ids
/obj/item/weapon/card/id/ert/Medical
registered_name = "Medical Response Officer"
assignment = "Medical Response Officer"
/obj/item/weapon/card/id/ert/Medical/New()
access = get_all_accesses()+get_ert_access("med")-access_change_ids
/obj/item/weapon/card/id/prisoner
name = "prisoner ID card"
desc = "You are a number, you are not a free man."
icon_state = "orange"
item_state = "orange-id"
assignment = "Prisoner"
registered_name = "Scum"
var/goal = 0 //How far from freedom?
var/points = 0
/obj/item/weapon/card/id/prisoner/attack_self(mob/user)
usr << "<span class='notice'>You have accumulated [points] out of the [goal] points you need for freedom.</span>"
/obj/item/weapon/card/id/prisoner/one
name = "Prisoner #13-001"
registered_name = "Prisoner #13-001"
/obj/item/weapon/card/id/prisoner/two
name = "Prisoner #13-002"
registered_name = "Prisoner #13-002"
/obj/item/weapon/card/id/prisoner/three
name = "Prisoner #13-003"
registered_name = "Prisoner #13-003"
/obj/item/weapon/card/id/prisoner/four
name = "Prisoner #13-004"
registered_name = "Prisoner #13-004"
/obj/item/weapon/card/id/prisoner/five
name = "Prisoner #13-005"
registered_name = "Prisoner #13-005"
/obj/item/weapon/card/id/prisoner/six
name = "Prisoner #13-006"
registered_name = "Prisoner #13-006"
/obj/item/weapon/card/id/prisoner/seven
name = "Prisoner #13-007"
registered_name = "Prisoner #13-007"
/obj/item/weapon/card/id/mining
name = "mining ID"
access = list(access_mining, access_mining_station, access_mineral_storeroom)
/obj/item/weapon/card/id/away
name = "a perfectly generic identification card"
desc = "A perfectly generic identification card. Looks like it could use some flavor."
access = list(access_away_general)
/obj/item/weapon/card/id/away/hotel
name = "Staff ID"
desc = "A staff ID used to access the hotel's doors."
access = list(access_away_general, access_away_maint)
/obj/item/weapon/card/id/away/hotel/securty
name = "Officer ID"
access = list(access_away_general, access_away_maint, access_away_sec)