This repository has been archived by the owner on Sep 12, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 66
/
human_helpers.dm
270 lines (230 loc) · 9.64 KB
/
human_helpers.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
/mob/living/carbon/human/canBeHandcuffed()
if(num_hands < 2)
return FALSE
return TRUE
//gets assignment from ID or ID inside PDA or PDA itself
//Useful when player do something with computers
/mob/living/carbon/human/proc/get_assignment(if_no_id = "No id", if_no_job = "No job", hand_first = TRUE)
var/obj/item/card/id/id = get_idcard(hand_first)
if(id)
. = id.assignment
else
var/obj/item/pda/pda = wear_id
if(istype(pda))
. = pda.ownjob
else
return if_no_id
if(!.)
return if_no_job
//gets name from ID or ID inside PDA or PDA itself
//Useful when player do something with computers
/mob/living/carbon/human/proc/get_authentification_name(if_no_id = "Unknown")
var/obj/item/card/id/id = get_idcard(FALSE)
if(id)
return id.registered_name
var/obj/item/pda/pda = wear_id
if(istype(pda))
return pda.owner
return if_no_id
//repurposed proc. Now it combines get_id_name() and get_face_name() to determine a mob's name variable. Made into a separate proc as it'll be useful elsewhere
/mob/living/carbon/human/get_visible_name()
var/face_name = get_face_name("")
var/id_name = get_id_name("")
if(name_override)
return name_override
if(face_name)
if(id_name && (id_name != face_name))
return "[face_name] (as [id_name])"
return face_name
if(id_name)
return id_name
return "Unknown"
//Returns "Unknown" if facially disfigured and real_name if not. Useful for setting name when Fluacided or when updating a human's name variable
/mob/living/carbon/human/proc/get_face_name(if_no_face="Unknown")
if( wear_mask && (wear_mask.flags_inv&HIDEFACE) ) //Wearing a mask which hides our face, use id-name if possible
return if_no_face
if( head && (head.flags_inv&HIDEFACE) )
return if_no_face //Likewise for hats
var/obj/item/bodypart/O = get_bodypart(BODY_ZONE_HEAD)
if( !O || (HAS_TRAIT(src, TRAIT_DISFIGURED)) || (O.brutestate+O.burnstate)>2 || cloneloss>50 || !real_name ) //disfigured. use id-name if possible
return if_no_face
return real_name
//gets name from ID or PDA itself, ID inside PDA doesn't matter
//Useful when player is being seen by other mobs
/mob/living/carbon/human/proc/get_id_name(if_no_id = "Unknown")
var/obj/item/storage/wallet/wallet = wear_id
var/obj/item/pda/pda = wear_id
var/obj/item/card/id/id = wear_id
var/obj/item/modular_computer/tablet/tablet = wear_id
if(istype(wallet))
id = wallet.front_id
if(istype(id))
. = id.registered_name
else if(istype(pda))
. = pda.owner
else if(istype(tablet))
var/obj/item/computer_hardware/card_slot/card_slot = tablet.all_components[MC_CARD]
if(card_slot && (card_slot.stored_card2 || card_slot.stored_card))
if(card_slot.stored_card2) //The second card is the one used for authorization in the ID changing program, so we prioritize it here for consistency
. = card_slot.stored_card2.registered_name
else
if(card_slot.stored_card)
. = card_slot.stored_card.registered_name
if(!.)
. = if_no_id //to prevent null-names making the mob unclickable
return
//Gets ID card from a human. If hand_first is false the one in the id slot is prioritized, otherwise inventory slots go first.
/mob/living/carbon/human/get_idcard(hand_first = TRUE)
//Check hands
var/obj/item/card/id/id_card
var/obj/item/held_item
held_item = get_active_held_item()
if(held_item) //Check active hand
id_card = held_item.GetID()
if(!id_card) //If there is no id, check the other hand
held_item = get_inactive_held_item()
if(held_item)
id_card = held_item.GetID()
if(id_card)
if(hand_first)
return id_card
else
. = id_card
//Check inventory slots
if(wear_id)
id_card = wear_id.GetID()
if(id_card)
return id_card
else if(belt)
id_card = belt.GetID()
if(id_card)
return id_card
/mob/living/carbon/human/get_id_in_hand()
var/obj/item/held_item = get_active_held_item()
if(!held_item)
return
return held_item.GetID()
/mob/living/carbon/human/IsAdvancedToolUser()
if(HAS_TRAIT(src, TRAIT_MONKEYLIKE))
return FALSE
return TRUE//Humans can use guns and such
/mob/living/carbon/human/reagent_check(datum/reagent/R)
return dna.species.handle_chemicals(R,src)
// if it returns 0, it will run the usual on_mob_life for that reagent. otherwise, it will stop after running handle_chemicals for the species.
/mob/living/carbon/human/can_track(mob/living/user)
if(wear_id && istype(wear_id.GetID(), /obj/item/card/id/syndicate))
return 0
if(istype(head, /obj/item/clothing/head))
var/obj/item/clothing/head/hat = head
if(hat.blockTracking)
return 0
return ..()
/mob/living/carbon/human/can_use_guns(obj/item/G)
. = ..()
if(G.trigger_guard == TRIGGER_GUARD_NORMAL)
if(HAS_TRAIT(src, TRAIT_CHUNKYFINGERS))
to_chat(src, "<span class='warning'>Your meaty finger is much too large for the trigger guard!</span>")
return FALSE
if(HAS_TRAIT(src, TRAIT_NOGUNS))
to_chat(src, "<span class='warning'>You can't bring yourself to use a ranged weapon!</span>")
return FALSE
/mob/living/carbon/human/get_bank_account(hand_first)
RETURN_TYPE(/datum/bank_account)
var/datum/bank_account/account
var/obj/item/card/id/I = get_idcard(hand_first)
if(I && I.registered_account)
account = I.registered_account
return account
return FALSE
/mob/living/carbon/human/get_policy_keywords()
. = ..()
. += "[dna.species.type]"
/mob/living/carbon/human/can_see_reagents()
. = ..()
if(.) //No need to run through all of this if it's already true.
return
if(isclothing(glasses) && (glasses.clothing_flags & SCAN_REAGENTS))
return TRUE
if(isclothing(head) && (head.clothing_flags & SCAN_REAGENTS))
return TRUE
if(isclothing(wear_mask) && (wear_mask.clothing_flags & SCAN_REAGENTS))
return TRUE
/// When we're joining the game in [/mob/dead/new_player/proc/create_character], we increment our scar slot then store the slot in our mind datum.
/mob/living/carbon/human/proc/increment_scar_slot()
var/check_ckey = ckey || client?.ckey
if(!check_ckey || !mind || !client?.prefs.persistent_scars)
return
var/path = "data/player_saves/[check_ckey[1]]/[check_ckey]/scars.sav"
var/index = mind.current_scar_slot_index
if(!index)
if(fexists(path))
var/savefile/F = new /savefile(path)
index = F["current_scar_index"] || 1
else
index = 1
mind.current_scar_slot_index = (index % PERSISTENT_SCAR_SLOTS) + 1 || 1
/// For use formatting all of the scars this human has for saving for persistent scarring, returns a string with all current scars/missing limb amputation scars for saving or loading purposes
/mob/living/carbon/human/proc/format_scars()
var/list/missing_bodyparts = get_missing_limbs()
if(!all_scars && !length(missing_bodyparts))
return
var/scars = ""
for(var/i in missing_bodyparts)
var/datum/scar/scaries = new
scars += "[scaries.format_amputated(i)]"
for(var/i in all_scars)
var/datum/scar/iter_scar = i
if(!iter_scar.fake)
scars += "[iter_scar.format()];"
return scars
/// Takes a single scar from the persistent scar loader and recreates it from the saved data
/mob/living/carbon/human/proc/load_scar(scar_line, specified_char_index)
var/list/scar_data = splittext(scar_line, "|")
if(LAZYLEN(scar_data) != SCAR_SAVE_LENGTH)
return // invalid, should delete
var/version = text2num(scar_data[SCAR_SAVE_VERS])
if(!version || version < SCAR_CURRENT_VERSION) // get rid of old scars
return
if(specified_char_index && (mind?.original_character_slot_index != specified_char_index))
return
var/obj/item/bodypart/the_part = get_bodypart("[scar_data[SCAR_SAVE_ZONE]]")
var/datum/scar/scaries = new
return scaries.load(the_part, scar_data[SCAR_SAVE_VERS], scar_data[SCAR_SAVE_DESC], scar_data[SCAR_SAVE_PRECISE_LOCATION], text2num(scar_data[SCAR_SAVE_SEVERITY]), text2num(scar_data[SCAR_SAVE_BIOLOGY]), text2num(scar_data[SCAR_SAVE_CHAR_SLOT]))
/// Read all the scars we have for the designated character/scar slots, verify they're good/dump them if they're old/wrong format, create them on the user, and write the scars that passed muster back to the file
/mob/living/carbon/human/proc/load_persistent_scars()
if(!ckey || !mind?.original_character_slot_index || !client?.prefs.persistent_scars)
return
var/path = "data/player_saves/[ckey[1]]/[ckey]/scars.sav"
var/loaded_char_slot = client.prefs.default_slot
if(!loaded_char_slot || !fexists(path))
return FALSE
var/savefile/F = new /savefile(path)
if(!F)
return
var/char_index = mind.original_character_slot_index
var/scar_index = mind.current_scar_slot_index || F["current_scar_index"] || 1
var/scar_string = F["scar[char_index]-[scar_index]"]
var/valid_scars = ""
for(var/scar_line in splittext(sanitize_text(scar_string), ";"))
if(load_scar(scar_line, char_index))
valid_scars += "[scar_line];"
WRITE_FILE(F["scar[char_index]-[scar_index]"], sanitize_text(valid_scars))
/// Save any scars we have to our designated slot, then write our current slot so that the next time we call [/mob/living/carbon/human/proc/increment_scar_slot] (the next round we join), we'll be there
/mob/living/carbon/human/proc/save_persistent_scars(nuke=FALSE)
if(!ckey || !mind?.original_character_slot_index || !client?.prefs.persistent_scars)
return
var/path = "data/player_saves/[ckey[1]]/[ckey]/scars.sav"
var/savefile/F = new /savefile(path)
var/char_index = mind.original_character_slot_index
var/scar_index = mind.current_scar_slot_index || F["current_scar_index"] || 1
if(nuke)
WRITE_FILE(F["scar[char_index]-[scar_index]"], "")
return
for(var/k in all_wounds)
var/datum/wound/iter_wound = k
iter_wound.remove_wound() // so we can get the scars for open wounds
var/valid_scars = format_scars()
WRITE_FILE(F["scar[char_index]-[scar_index]"], sanitize_text(valid_scars))
WRITE_FILE(F["current_scar_index"], sanitize_integer(scar_index))
/mob/living/carbon/human/get_biological_state()
return dna.species.get_biological_state()