ID card/agent ID rework

This commit is contained in:
Markolie
2015-08-09 23:42:55 +02:00
parent 541c662296
commit 034cf8ef69
16 changed files with 348 additions and 172 deletions
+294 -138
View File
@@ -96,7 +96,7 @@
//alt titles are handled a bit weirdly in order to unobtrusively integrate into existing ID system
var/assignment = null //can be alt title or the actual job
var/rank = null //actual job
var/dorm = 0 // determines if this ID has claimed a dorm already
var/dorm = 0 // determines if this ID has claimed a dorm already
var/datum/data/record/active1 = null
var/sex
@@ -105,58 +105,61 @@
var/icon/front
var/icon/side
var/dat
var/stamped=0
var/stamped = 0
/obj/item/weapon/card/id/New()
..()
spawn(30)
updatedat()
if(ishuman(loc))
var/mob/living/carbon/human/H = loc
SetOwnerInfo(H)
/obj/item/weapon/card/id/proc/updatedat()
if(istype(loc, /mob/living/carbon/human))
blood_type = loc:dna:b_type
dna_hash = loc:dna:unique_enzymes
fingerprint_hash = md5(loc:dna:uni_identity)
dat = ("<table><tr><td>")
dat +=text("Name: []</A><BR>", registered_name)
dat +=text("Sex: []</A><BR>\n", sex)
dat +=text("Age: []</A><BR>\n", age)
dat +=text("Rank: []</A><BR>\n", assignment)
dat +=text("Fingerprint: []</A><BR>\n", fingerprint_hash)
dat +=text("Blood Type: []<BR>\n", blood_type)
dat +=text("DNA Hash: []<BR><BR>\n", dna_hash)
dat +="<td align = center valign = top>Photo:<br><img src=front.png height=80 width=80 border=4> \
<img src=side.png height=80 width=80 border=4></td></tr></table>"
/obj/item/weapon/card/id/examine()
/obj/item/weapon/card/id/examine(mob/user)
set src in oview(1)
if(in_range(usr, src))
show(usr)
usr << desc
else
usr << "<span class='notice'>It is too far away.</span>"
usr << "<span class='warning'>It is too far away.</span>"
/obj/item/weapon/card/id/proc/show(mob/user as mob)
if(!front)
front = new(photo, dir = SOUTH)
if(!side)
side = new(photo, dir = WEST)
user << browse_rsc(front, "front.png")
user << browse_rsc(side, "side.png")
var/datum/browser/popup = new(user, "idcard", name, 600, 400)
popup.set_content(dat)
popup.set_title_image(usr.browse_rsc_icon(src.icon, src.icon_state))
popup.open()
return
/obj/item/weapon/card/id/attack_self(mob/user as mob)
for(var/mob/O in viewers(user, null))
O.show_message(text("[] shows you: \icon[] []. The assignment on the card: []", user, src, src.name, src.assignment), 1)
user.visible_message("[user] shows you: \icon[src] [src.name]. The assignment on the card: [src.assignment]",\
"You flash your ID card: \icon[src] [src.name]. The assignment on the card: [src.assignment]")
if(mining_points)
user << "There's [mining_points] mining equipment redemption points loaded onto this card."
src.add_fingerprint(user)
return
/obj/item/weapon/card/id/proc/UpdateName()
name = "[src.registered_name]'s ID Card ([src.assignment])"
/obj/item/weapon/card/id/proc/SetOwnerInfo(var/mob/living/carbon/human/H)
if(!H || !H.dna)
return
sex = capitalize(H.gender)
age = H.age
blood_type = H.dna.b_type
dna_hash = H.dna.unique_enzymes
fingerprint_hash = md5(H.dna.uni_identity)
dat = ("<table><tr><td>")
dat += text("Name: []</A><BR>", registered_name)
dat += text("Sex: []</A><BR>\n", sex)
dat += text("Age: []</A><BR>\n", age)
dat += text("Rank: []</A><BR>\n", assignment)
dat += text("Fingerprint: []</A><BR>\n", fingerprint_hash)
dat += text("Blood Type: []<BR>\n", blood_type)
dat += text("DNA Hash: []<BR><BR>\n", dna_hash)
dat += "</td></tr></table>"
/obj/item/weapon/card/id/GetAccess()
return access
@@ -187,19 +190,6 @@
else
usr << "This ID has already been stamped!"
/obj/item/weapon/card/id/verb/read()
set name = "Read ID Card"
set category = "Object"
set src in usr
usr << text("\icon[] []: The current assignment on the card is [].", src, src.name, src.assignment)
usr << "The blood type on the card is [blood_type]."
usr << "The DNA hash on the card is [dna_hash]."
usr << "The fingerprint hash on the card is [fingerprint_hash]."
return
/obj/item/weapon/card/id/silver
name = "identification card"
desc = "A silver card which shows honour and dedication."
@@ -214,122 +204,181 @@
/obj/item/weapon/card/id/syndicate
name = "agent card"
access = list(access_maint_tunnels, access_syndicate)
access = list(access_maint_tunnels, access_syndicate, access_external_airlocks)
origin_tech = "syndicate=3"
var/registered_user=null
/obj/item/weapon/card/id/syndicate/New(mob/user as mob)
// ..() - Intentionally does not call parent, doesn't need to
if(!isnull(user) && iscarbon(user)) // Runtime prevention on laggy starts or where users log out because of lag at round start. Also stops the ID from inheriting anything but a mob name
registered_name = ishuman(user) ? user.real_name : user.name
else
registered_name = "Agent Card"
assignment = "Agent"
name = "[registered_name]'s ID Card ([assignment])"
var/registered_user= n ull
/obj/item/weapon/card/id/syndicate/afterattack(var/obj/item/weapon/O as obj, mob/user as mob, proximity)
if(!proximity) return
if(!proximity)
return
if(istype(O, /obj/item/weapon/card/id))
var/obj/item/weapon/card/id/I = O
src.access |= I.access
if(istype(user, /mob/living) && user.mind)
if(user.mind.special_role)
usr << "\blue The card's microscanners activate as you pass it over the ID, copying its access."
usr << "<span class='notice'>The card's microscanners activate as you pass it over \the [I], copying its access.</span>"
src.access |= I.access //Don't copy access if user isn't an antag -- to prevent metagaming
/obj/item/weapon/card/id/syndicate/attack_self(mob/user as mob)
if(!src.registered_name)
//Stop giving the players unsanitized unputs! You are giving ways for players to intentionally crash clients! -Nodrak
var t = reject_bad_name(input(user, "What name would you like to put on this card?", "Agent card name", ishuman(user) ? user.real_name : user.name))
if(!t) //Same as mob/new_player/prefrences.dm
alert("Invalid name.")
var t = reject_bad_name(input(user, "What name would you like to use on this card?", "Agent Card name", ishuman(user) ? user.real_name : user.name))
if(!t)
user << "<span class='warning'>Invalid name.</span>"
return
src.registered_name = t
var u = sanitize(copytext(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", "Civilian"),1,MAX_MESSAGE_LEN))
var u = sanitize(stripped_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", "Agent", MAX_MESSAGE_LEN))
if(!u)
alert("Invalid assignment.")
user << "<span class='warning'>Invalid assignment.</span>"
src.registered_name = ""
return
src.assignment = u
src.name = "[src.registered_name]'s ID Card ([src.assignment])"
user << "<span class='notice'>You successfully forge the ID card.</span>"
registered_user = user
var/s = input(user, "Would you like to update this card's details with your own?\nNote: This will take a picture of how you currently look, so put any items in your hand down first (other than this ID), and it will assume your age, and gender.", "Agent card update choice", "No") in list("Yes","No")
if(s == "Yes")
src.setupdat()
spawn(0)
src.updatedat()
user << "\blue You successfully forge the ID card."
else if(!registered_user || registered_user == user)
if(!registered_user)
registered_user = user
if(!registered_user) registered_user = user //
switch(alert("Would you like to display the ID, or retitle it?","Choose.","Rename","Show"))
if("Rename")
var t = sanitize(copytext(input(user, "What name would you like to put on this card?", "Agent card name", ishuman(user) ? user.real_name : user.name),1,26))
if(!t || t == "Unknown" || t == "floor" || t == "wall" || t == "r-wall") //Same as mob/new_player/prefrences.dm
alert("Invalid name.")
return
src.registered_name = t
var u = sanitize(copytext(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", "Civilian"),1,MAX_MESSAGE_LEN))
if(!u)
alert("Invalid assignment.")
src.registered_name = ""
return
src.assignment = u
src.name = "[src.registered_name]'s ID Card ([src.assignment])"
var/s = input(user, "Would you like to update this card's details with your own?\nNote: This will take a picture of how you currently look, so put any items in your hand down first (other than this ID), and it will assume your age, and gender.", "Agent card update choice", "No") in list("Yes","No")
if(s == "Yes")
src.setupdat()
spawn(0)
src.updatedat()
user << "\blue You successfully forge the ID card."
return
switch(alert(user,"Would you like to display \the [src] or edit it?","Choose","Show","Edit"))
if("Show")
..()
return ..()
if("Edit")
switch(input(user,"What would you like to edit on \the [src]?") in list("Name","Appearance","Sex","Age","Occupation","Money Account","Blood Type","DNA Hash","Fingerprint Hash","Reset Card"))
if("Name")
var/new_name = reject_bad_name(input(user,"What name would you like to put on this card?","Agent Card Name", ishuman(user) ? user.real_name : user.name))
if(!Adjacent(user))
return
src.registered_name = new_name
UpdateName()
user << "<span class='notice'>Name changed to [new_name].</span>"
if("Appearance")
var/list/appearances = list(
"data",
"id",
"gold",
"silver",
"centcom",
"centcom_old",
"security",
"medical",
"HoS",
"research",
"engineering",
"CMO",
"RD",
"CE",
"clown",
"mime",
"prisoner",
"syndie",
"deathsquad",
"commander",
"ERT_leader",
"ERT_security",
"ERT_engineering",
"ERT_medical",
"ERT_janitorial",
)
var/choice = input(user, "Select the appearance for this card.", "Agent Card Appearance") in appearances
if(!Adjacent(user))
return
if(!choice)
return
src.icon_state = choice
usr << "<span class='notice'>Appearance changed to [choice].</span>"
if("Sex")
var/new_sex = sanitize(stripped_input(user,"What sex would you like to put on this card?","Agent Card Sex", ishuman(user) ? capitalize(user.gender) : "Male", MAX_MESSAGE_LEN))
if(!Adjacent(user))
return
src.sex = new_sex
user << "<span class='notice'>Sex changed to [new_sex].</span>"
if("Age")
var/new_age = sanitize(stripped_input(user,"What age would you like to put on this card?","Agent Card Age","21", MAX_MESSAGE_LEN))
if(!Adjacent(user))
return
src.age = new_age
user << "<span class='notice'>Age changed to [new_age].</span>"
if("Occupation")
var/new_job = sanitize(stripped_input(user,"What job would you like to put on this card?\nChanging occupation will not grant or remove any access levels.","Agent Card Occupation", "Assistant", MAX_MESSAGE_LEN))
if(!Adjacent(user))
return
src.assignment = new_job
user << "<span class='notice'>Occupation changed to [new_job].</span>"
UpdateName()
if("Money Account")
var/new_account = input(user,"What money account would you like to link to this card?","Agent Card Account",12345) as num
if(!Adjacent(user))
return
associated_account_number = new_account
user << "<span class='notice'>Linked money account changed to [new_account].</span>"
if("Blood Type")
var/default = "\[UNSET\]"
if(ishuman(user))
var/mob/living/carbon/human/H = user
if(H.dna)
default = H.dna.b_type
var/new_blood_type = sanitize(input(user,"What blood type would you like to be written on this card?","Agent Card Blood Type",default) as text)
if(!Adjacent(user))
return
src.blood_type = new_blood_type
user << "<span class='notice'>Blood type changed to [new_blood_type].</span>"
if("DNA Hash")
var/default = "\[UNSET\]"
if(ishuman(user))
var/mob/living/carbon/human/H = user
if(H.dna)
default = H.dna.unique_enzymes
var/new_dna_hash = sanitize(input(user,"What DNA hash would you like to be written on this card?","Agent Card DNA Hash",default) as text)
if(!Adjacent(user))
return
src.dna_hash = new_dna_hash
user << "<span class='notice'>DNA hash changed to [new_dna_hash].</span>"
if("Fingerprint Hash")
var/default = "\[UNSET\]"
if(ishuman(user))
var/mob/living/carbon/human/H = user
if(H.dna)
default = md5(H.dna.uni_identity)
var/new_fingerprint_hash = sanitize(input(user,"What fingerprint hash would you like to be written on this card?","Agent Card Fingerprint Hash",default) as text)
if(!Adjacent(user))
return
src.fingerprint_hash = new_fingerprint_hash
user << "<span class='notice'>Fingerprint hash changed to [new_fingerprint_hash].</span>"
if("Reset Card")
name = initial(name)
registered_name = initial(registered_name)
icon_state = initial(icon_state)
sex = initial(sex)
age = initial(age)
assignment = initial(assignment)
associated_account_number = initial(associated_account_number)
blood_type = initial(blood_type)
dna_hash = initial(dna_hash)
fingerprint_hash = initial(fingerprint_hash)
access = initial(access)
registered_user = null
user << "<span class='notice'>All information has been deleted from \the [src].</span>"
else
..()
/obj/item/weapon/card/id/syndicate/proc/setupdat() //fake initilization, taken mostly from job_controller.dm
if(istype(src.loc, /mob/living/carbon/human)) //just adopt the syndie stuff, it would be annoying to ask them to set all of this, and the use would be limited
var/mob/living/carbon/human/H = loc
src.sex = capitalize(H.gender)
src.rank = src.assignment
src.age = H.age
src.photo = fake_id_photo(H)
var/icon/photoside = fake_id_photo(H,1)
front = new(photo)
side = new(photoside)
/obj/item/weapon/card/id/syndicate/proc/fake_id_photo(var/mob/living/carbon/human/H, var/side=0)//get_id_photo wouldn't work correctly
if(!istype(H))
return
var/storedDir = H.dir //don't want to lose track of this
var/icon/faked
if(!side)
if(!H.equip_to_slot_if_possible(src, slot_l_store, 0, 1))
H << "<span class='warning'>You need to empty your pockets before taking the ID picture.</span>"
return
if(side)
H.dir = WEST //ensure the icon is actually the proper direction before copying it
faked = getFlatIcon(H)
H.dir = storedDir //reset the user back to their original direction, not even noticable they changed
H.equip_to_slot_if_possible(src, slot_l_hand, 0, 1)
else
H.dir = SOUTH
faked = getFlatIcon(H)
H.dir = storedDir
return faked
/obj/item/weapon/card/id/syndicate_command
name = "syndicate ID card"
desc = "An ID straight from the Syndicate."
registered_name = "Syndicate"
icon_state = "syndie"
assignment = "Syndicate Overlord"
access = list(access_syndicate, access_external_airlocks)
@@ -340,10 +389,22 @@
item_state = "gold_id"
registered_name = "Captain"
assignment = "Captain"
New()
var/datum/job/captain/J = new/datum/job/captain
access = J.get_access()
..()
/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/admin
name = "admin ID card"
icon_state = "admin"
item_state = "gold_id"
registered_name = "Admin"
assignment = "Testing Shit"
/obj/item/weapon/card/id/admin/New()
access = get_absolutely_all_accesses()
..()
/obj/item/weapon/card/id/centcom
name = "central command ID card"
@@ -351,14 +412,15 @@
icon_state = "centcom"
registered_name = "Central Command"
assignment = "General"
New()
access = get_all_centcom_access()
..()
/obj/item/weapon/card/id/centcom/New()
access = get_all_centcom_access()
..()
/obj/item/weapon/card/id/prisoner
name = "prisoner ID card"
desc = "You are a number, you are not a free man."
icon_state = "orange"
icon_state = "prisoner"
item_state = "orange-id"
assignment = "Prisoner"
registered_name = "Scum"
@@ -403,6 +465,100 @@
desc = "Finders, keepers."
access = list(access_salvage_captain)
/obj/item/weapon/card/id/medical
name = "Medical ID"
registered_name = "Medic"
icon_state = "medical"
access = list(access_medical, access_morgue, access_surgery, access_chemistry, access_virology, access_genetics, access_mineral_storeroom)
/obj/item/weapon/card/id/security
name = "Security ID"
registered_name = "Officer"
icon_state = "security"
access = list(access_security, access_sec_doors, access_brig, access_court, access_maint_tunnels, access_morgue, access_weapons)
/obj/item/weapon/card/id/research
name = "Research ID"
registered_name = "Scientist"
icon_state = "research"
access = list(access_robotics, access_tox, access_tox_storage, access_research, access_xenobiology, access_xenoarch, access_mineral_storeroom)
/obj/item/weapon/card/id/supply
name = "Supply ID"
registered_name = "Cargonian"
icon_state = "cargo"
access = list(access_maint_tunnels, access_mailsorting, access_cargo, access_cargo_bot, access_qm, access_mint, access_mining, access_mining_station, access_mineral_storeroom)
/obj/item/weapon/card/id/engineering
name = "Engineering ID"
registered_name = "Engineer"
icon_state = "engineering"
access = list(access_eva, access_engine, access_engine_equip, access_tech_storage, access_maint_tunnels, access_external_airlocks, access_construction, access_atmospherics)
/obj/item/weapon/card/id/hos
name = "Head of Security ID"
registered_name = "HoS"
icon_state = "HoS"
access = list(access_security, access_sec_doors, access_brig, access_armory, access_court,
access_forensics_lockers, access_pilot, access_morgue, access_maint_tunnels, access_all_personal_lockers,
access_research, access_engine, access_mining, access_medical, access_construction, access_mailsorting,
access_heads, access_hos, access_RC_announce, access_keycard_auth, access_gateway, access_weapons)
/obj/item/weapon/card/id/cmo
name = "Chief Medical Officer ID"
registered_name = "CMO"
icon_state = "CMO"
access = list(access_medical, access_morgue, access_genetics, access_heads,
access_chemistry, access_virology, access_cmo, access_surgery, access_RC_announce,
access_keycard_auth, access_sec_doors, access_psychiatrist, access_paramedic, access_mineral_storeroom)
/obj/item/weapon/card/id/rd
name = "Research Director ID"
registered_name = "RD"
icon_state = "RD"
access = list(access_rd, access_heads, access_tox, access_genetics, access_morgue,
access_tox_storage, access_tech_storage, access_teleporter, access_sec_doors,
access_research, access_robotics, access_xenobiology, access_ai_upload,
access_RC_announce, access_keycard_auth, access_tcomsat, access_gateway, access_xenoarch, access_minisat, access_mineral_storeroom)
/obj/item/weapon/card/id/ce
name = "Chief Engineer ID"
registered_name = "CE"
icon_state = "CE"
access = list(access_engine, access_engine_equip, access_tech_storage, access_maint_tunnels,
access_teleporter, access_external_airlocks, access_atmospherics, access_emergency_storage, access_eva,
access_heads, access_construction, access_sec_doors,
access_ce, access_RC_announce, access_keycard_auth, access_tcomsat, access_minisat, access_mechanic, access_mineral_storeroom)
/obj/item/weapon/card/id/clown
name = "Pink ID"
registered_name = "HONK!"
icon_state = "clown"
desc = "Even looking at the card strikes you with deep fear."
access = list(access_clown, access_theatre, access_maint_tunnels)
/obj/item/weapon/card/id/mime
name = "Black and White ID"
registered_name = "..."
icon_state = "mime"
desc = "..."
access = list(access_mime, access_theatre, access_maint_tunnels)
/obj/item/weapon/card/id/thunderdome/red
name = "Thunderdome Red ID"
registered_name = "Red Team Fighter"
assignment = "Red Team Fighter"
icon_state = "TDred"
desc = "This ID card is given to those who fought inside the thunderdome for the Red Team. Not many have lived to see one of those, even fewer lived to keep it."
/obj/item/weapon/card/id/thunderdome/green
name = "Thunderdome Green ID"
registered_name = "Green Team Fighter"
assignment = "Green Team Fighter"
icon_state = "TDgreen"
desc = "This ID card is given to those who fought inside the thunderdome for the Green Team. Not many have lived to see one of those, even fewer lived to keep it."
// Decals
/obj/item/weapon/id_decal
name = "identification card decal"
desc = "A modification kit to make your ID cards look snazzy.."
@@ -429,7 +585,7 @@
/obj/item/weapon/id_decal/prisoner
name = "prisoner ID card decal"
decal_desc = "You are a number, you are not a free man."
decal_icon_state = "orange"
decal_icon_state = "prisoner"
decal_item_state = "orange-id"
/obj/item/weapon/id_decal/centcom