/
data_huds.dm
433 lines (368 loc) · 12.7 KB
/
data_huds.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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
/* Data HUDs have been rewritten in a more generic way.
* In short, they now use an observer-listener pattern.
* See code/datum/hud.dm for the generic hud datum.
* Update the HUD icons when needed with the appropriate hook. (see below)
*/
/* DATA HUD DATUMS */
/atom/proc/add_to_all_human_data_huds()
for(var/datum/atom_hud/data/human/hud in huds) hud.add_to_hud(src)
/atom/proc/remove_from_all_data_huds()
for(var/datum/atom_hud/data/hud in huds) hud.remove_from_hud(src)
/datum/atom_hud/data
/datum/atom_hud/data/human/medical
hud_icons = list(HEALTH_HUD, STATUS_HUD)
/datum/atom_hud/data/human/medical/basic
/datum/atom_hud/data/human/medical/basic/proc/check_sensors(mob/living/carbon/human/H)
if(!istype(H)) return 0
var/obj/item/clothing/under/U = H.w_uniform
if(!istype(U)) return 0
if(U.sensor_mode <= 2) return 0
return 1
/datum/atom_hud/data/human/medical/basic/add_to_single_hud(mob/M, mob/living/carbon/H)
if(check_sensors(H) || istype(M,/mob/dead/observer) )
..()
/datum/atom_hud/data/human/medical/basic/proc/update_suit_sensors(mob/living/carbon/H)
check_sensors(H) ? add_to_hud(H) : remove_from_hud(H)
/datum/atom_hud/data/human/medical/advanced
/datum/atom_hud/data/human/security
/datum/atom_hud/data/human/security/basic
hud_icons = list(ID_HUD)
/datum/atom_hud/data/human/security/advanced
hud_icons = list(ID_HUD, IMPTRACK_HUD, IMPMINDSHIELD_HUD, IMPCHEM_HUD, WANTED_HUD)
/datum/atom_hud/data/diagnostic
hud_icons = list (DIAG_HUD, DIAG_STAT_HUD, DIAG_BATT_HUD, DIAG_MECH_HUD, DIAG_BOT_HUD, DIAG_TRACK_HUD)
/datum/atom_hud/data/diagnostic/advanced
hud_icons = list (DIAG_HUD, DIAG_STAT_HUD, DIAG_BATT_HUD, DIAG_MECH_HUD, DIAG_BOT_HUD, DIAG_TRACK_HUD, DIAG_PATH_HUD)
/datum/atom_hud/data/bot_path
hud_icons = list(DIAG_PATH_HUD)
/datum/atom_hud/data/hydroponic
hud_icons = list (PLANT_NUTRIENT_HUD, PLANT_WATER_HUD, PLANT_STATUS_HUD, PLANT_HEALTH_HUD, PLANT_TOXIN_HUD, PLANT_PEST_HUD, PLANT_WEED_HUD)
/* MED/SEC/DIAG HUD HOOKS */
/*
* THESE HOOKS SHOULD BE CALLED BY THE MOB SHOWING THE HUD
*/
/***********************************************
Medical HUD! Basic mode needs suit sensors on.
************************************************/
//HELPERS
//called when a carbon changes virus
/mob/living/carbon/proc/check_virus()
for(var/thing in viruses)
var/datum/disease/D = thing
if((!(D.visibility_flags & HIDDEN_SCANNER)) && (D.severity != NONTHREAT))
return 1
return 0
//helper for getting the appropriate health status UPDATED BY PUCKABOO2 TO INCLUDE NEGATIVES.
/proc/RoundHealth(mob/living/M)
if(M.stat == DEAD || (M.status_flags & FAKEDEATH))
return "health-100" //what's our health? it doesn't matter, we're dead, or faking
var/maxi_health = M.maxHealth
if(iscarbon(M) && M.health < 0)
maxi_health = 100 //so crit shows up right for aliens and other high-health carbon mobs; noncarbons don't have crit.
var/resulthealth = (M.health / maxi_health) * 100
switch(resulthealth)
if(100 to INFINITY)
return "health100"
if(95 to 100)
return "health95" //For telling patients to eat a warm donk pocket and go on with their shift.
if(90 to 95)
return "health90"
if(80 to 90)
return "health80"
if(70 to 80)
return "health70"
if(60 to 70)
return "health60"
if(50 to 60)
return "health50"
if(40 to 50)
return "health40"
if(30 to 40)
return "health30"
if(20 to 30)
return "health20"
if(10 to 20)
return "health10"
if(0 to 10)
return "health0"
if(-10 to 0)
return "health-0" //The health bar will turn a brilliant red and flash as usual, but deducted health will be black.
if(-20 to -10)
return "health-10"
if(-30 to -20)
return "health-20"
if(-40 to -30)
return "health-30"
if(-50 to -40)
return "health-40"
if(-60 to -50)
return "health-50"
if(-70 to -60)
return "health-60"
if(-80 to -70)
return "health-70" //Doc?
if(-90 to -80)
return "health-80" //Hey, doc?
if(-100 to -90)
return "health-90" //HURRY UP, DOC!
else
return "health-100" //doc u had 1 job
return "0"
///HOOKS
//called when a human changes suit sensors
/mob/living/carbon/proc/update_suit_sensors()
var/datum/atom_hud/data/human/medical/basic/B = huds[DATA_HUD_MEDICAL_BASIC]
B.update_suit_sensors(src)
//called when a living mob changes health
/mob/living/proc/med_hud_set_health()
var/image/holder = hud_list[HEALTH_HUD]
holder.icon_state = "hud[RoundHealth(src)]"
//called when a carbon changes stat, virus or XENO_HOST
/mob/living/proc/med_hud_set_status()
var/image/holder = hud_list[STATUS_HUD]
if(stat == DEAD)
holder.icon_state = "huddead"
else
holder.icon_state = "hudhealthy"
//called when a carbon changes stat, virus or XENO_HOST
/mob/living/carbon/med_hud_set_status()
var/image/holder = hud_list[STATUS_HUD]
var/mob/living/simple_animal/borer/B = has_brain_worms()
if(stat == DEAD)
holder.icon_state = "huddead"
else if(status_flags & XENO_HOST)
holder.icon_state = "hudxeno"
else if(check_virus())
holder.icon_state = "hudill"
else if(B && B.controlling)
holder.icon_state = "hudbrainworm"
else
holder.icon_state = "hudhealthy"
/***********************************************
Security HUDs! Basic mode shows only the job.
************************************************/
//HOOKS
/mob/living/carbon/human/proc/sec_hud_set_ID()
var/image/holder = hud_list[ID_HUD]
holder.icon_state = "hudunknown"
if(wear_id)
holder.icon_state = "hud[ckey(wear_id.GetJobName())]"
sec_hud_set_security_status()
/mob/living/carbon/human/proc/sec_hud_set_implants()
var/image/holder
for(var/i in list(IMPTRACK_HUD, IMPMINDSHIELD_HUD, IMPCHEM_HUD))
holder = hud_list[i]
holder.icon_state = null
for(var/obj/item/implant/I in src)
if(I.implanted)
if(istype(I,/obj/item/implant/tracking))
holder = hud_list[IMPTRACK_HUD]
holder.icon_state = "hud_imp_tracking"
else if(istype(I,/obj/item/implant/mindshield))
holder = hud_list[IMPMINDSHIELD_HUD]
holder.icon_state = "hud_imp_loyal"
else if(istype(I,/obj/item/implant/chem))
holder = hud_list[IMPCHEM_HUD]
holder.icon_state = "hud_imp_chem"
/mob/living/carbon/human/proc/sec_hud_set_security_status()
var/image/holder = hud_list[WANTED_HUD]
var/perpname = get_visible_name(TRUE) //gets the name of the perp, works if they have an id or if their face is uncovered
if(!ticker) return //wait till the game starts or the monkeys runtime....
if(perpname)
var/datum/data/record/R = find_record("name", perpname, data_core.security)
if(R)
switch(R.fields["criminal"])
if("*Execute*")
holder.icon_state = "hudexecute"
return
if("*Arrest*")
holder.icon_state = "hudwanted"
return
if("Incarcerated")
holder.icon_state = "hudprisoner"
return
if("Parolled")
holder.icon_state = "hudparolled"
return
if("Released")
holder.icon_state = "hudreleased"
return
holder.icon_state = null
/***********************************************
Diagnostic HUDs!
************************************************/
//For Diag health and cell bars!
/proc/RoundDiagBar(value)
switch(value * 100)
if(95 to INFINITY)
return "max"
if(80 to 100)
return "good"
if(60 to 80)
return "high"
if(40 to 60)
return "med"
if(20 to 40)
return "low"
if(1 to 20)
return "crit"
else
return "dead"
return "dead"
//Sillycone hooks
/mob/living/silicon/proc/diag_hud_set_health()
var/image/holder = hud_list[DIAG_HUD]
if(stat == DEAD)
holder.icon_state = "huddiagdead"
else
holder.icon_state = "huddiag[RoundDiagBar(health/maxHealth)]"
/mob/living/silicon/proc/diag_hud_set_status()
var/image/holder = hud_list[DIAG_STAT_HUD]
switch(stat)
if(CONSCIOUS)
holder.icon_state = "hudstat"
if(UNCONSCIOUS)
holder.icon_state = "hudoffline"
else
holder.icon_state = "huddead2"
//Borgie battery tracking!
/mob/living/silicon/robot/proc/diag_hud_set_borgcell()
var/image/holder = hud_list[DIAG_BATT_HUD]
if(cell)
var/chargelvl = (cell.charge/cell.maxcharge)
holder.icon_state = "hudbatt[RoundDiagBar(chargelvl)]"
else
holder.icon_state = "hudnobatt"
/*~~~~~~~~~~~~~~~~~~~~
BIG STOMPY MECHS
~~~~~~~~~~~~~~~~~~~~~*/
/obj/mecha/proc/diag_hud_set_mechhealth()
var/image/holder = hud_list[DIAG_MECH_HUD]
holder.icon_state = "huddiag[RoundDiagBar(health/initial(health))]"
/obj/mecha/proc/diag_hud_set_mechcell()
var/image/holder = hud_list[DIAG_BATT_HUD]
if(cell)
var/chargelvl = cell.charge/cell.maxcharge
holder.icon_state = "hudbatt[RoundDiagBar(chargelvl)]"
else
holder.icon_state = "hudnobatt"
/obj/mecha/proc/diag_hud_set_mechstat()
var/image/holder = hud_list[DIAG_STAT_HUD]
holder.icon_state = null
if(internal_damage)
holder.icon_state = "hudwarn"
/obj/mecha/proc/diag_hud_set_mechtracking() //Shows tracking beacons on the mech
var/image/holder = hud_list[DIAG_TRACK_HUD]
var/new_icon_state //This var exists so that the holder's icon state is set only once in the event of multiple mech beacons.
for(var/obj/item/mecha_parts/mecha_tracking/T in trackers)
if(T.ai_beacon) //Beacon with AI uplink
new_icon_state = "hudtrackingai"
break //Immediately terminate upon finding an AI beacon to ensure it is always shown over the normal one, as mechs can have several trackers.
else
new_icon_state = "hudtracking"
holder.icon_state = new_icon_state
/*~~~~~~~~~
Bots!
~~~~~~~~~~*/
/mob/living/simple_animal/bot/proc/diag_hud_set_bothealth()
var/image/holder = hud_list[DIAG_HUD]
if(stat == DEAD)
holder.icon_state = "huddiagdead"
else
holder.icon_state = "huddiag[RoundDiagBar(health/maxHealth)]"
/mob/living/simple_animal/bot/proc/diag_hud_set_botstat() //On (With wireless on or off), Off, EMP'ed
var/image/holder = hud_list[DIAG_STAT_HUD]
if(on)
holder.icon_state = "hudstat"
else if(stat) //Generally EMP causes this
holder.icon_state = "hudoffline"
else //Bot is off
holder.icon_state = "huddead2"
/mob/living/simple_animal/bot/proc/diag_hud_set_botmode() //Shows a bot's current operation
var/image/holder = hud_list[DIAG_BOT_HUD]
if(client) //If the bot is player controlled, it will not be following mode logic!
holder.icon_state = "hudsentient"
return
switch(mode)
if(BOT_SUMMON, BOT_RESPONDING) //Responding to PDA or AI summons
holder.icon_state = "hudcalled"
if(BOT_CLEANING, BOT_REPAIRING, BOT_HEALING) //Cleanbot cleaning, Floorbot fixing, or Medibot Healing
holder.icon_state = "hudworking"
if(BOT_PATROL, BOT_START_PATROL) //Patrol mode
holder.icon_state = "hudpatrol"
if(BOT_PREP_ARREST, BOT_ARREST, BOT_HUNT, BOT_BLOCKED, BOT_NO_ROUTE) //STOP RIGHT THERE, CRIMINAL SCUM!
holder.icon_state = "hudalert"
if(BOT_MOVING, BOT_DELIVER, BOT_GO_HOME, BOT_NAV, BOT_WAIT_FOR_NAV) //Moving to target for normal bots, moving to deliver or go home for MULES.
holder.icon_state = "hudmove"
else
holder.icon_state = ""
/*~~~~~~~~~~~~~~
PLANT HUD
~~~~~~~~~~~~~~~*/
/proc/RoundPlantBar(value)
switch(value * 100)
if(1 to 10)
return "10"
if(10 to 20)
return "20"
if(20 to 30)
return "30"
if(30 to 40)
return "40"
if(40 to 50)
return "50"
if(50 to 60)
return "60"
if(60 to 70)
return "70"
if(70 to 80)
return "80"
if(80 to 90)
return "90"
if(90 to INFINITY)
return "max"
else
return "zero"
return "zero"
/obj/machinery/hydroponics/proc/plant_hud_set_nutrient()
var/image/holder = hud_list[PLANT_NUTRIENT_HUD]
holder.icon_state = "hudnutrient[RoundPlantBar(nutrilevel/maxnutri)]"
/obj/machinery/hydroponics/proc/plant_hud_set_water()
var/image/holder = hud_list[PLANT_WATER_HUD]
holder.icon_state = "hudwater[RoundPlantBar(waterlevel/maxwater)]"
/obj/machinery/hydroponics/proc/plant_hud_set_status()
var/image/holder = hud_list[PLANT_STATUS_HUD]
if(!myseed)
holder.icon_state = ""
return
if(harvest)
holder.icon_state = "hudharvest"
return
if(dead)
holder.icon_state = "huddead"
return
holder.icon_state = ""
/obj/machinery/hydroponics/proc/plant_hud_set_health()
var/image/holder = hud_list[PLANT_HEALTH_HUD]
if(!myseed)
holder.icon_state = ""
return
holder.icon_state = "hudplanthealth[RoundPlantBar(plant_health/myseed.endurance)]"
/obj/machinery/hydroponics/proc/plant_hud_set_toxin()
var/image/holder = hud_list[PLANT_TOXIN_HUD]
if(toxic < 10) // You don't want to see these icons if the value is small
holder.icon_state = ""
return
holder.icon_state = "hudtoxin[RoundPlantBar(toxic/100)]"
/obj/machinery/hydroponics/proc/plant_hud_set_pest()
var/image/holder = hud_list[PLANT_PEST_HUD]
if(pestlevel < 1) // You don't want to see these icons if the value is small
holder.icon_state = ""
return
holder.icon_state = "hudpest[RoundPlantBar(pestlevel/10)]"
/obj/machinery/hydroponics/proc/plant_hud_set_weed()
var/image/holder = hud_list[PLANT_WEED_HUD]
if(weedlevel < 1) // You don't want to see these icons if the value is small
holder.icon_state = ""
return
holder.icon_state = "hudweed[RoundPlantBar(weedlevel/10)]"