Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silicon Medical and Security HUDs! #4525

Merged
merged 5 commits into from Sep 8, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion code/_globalvars/lists/objects.dm
Expand Up @@ -12,4 +12,6 @@ var/global/list/active_diseases = list()
var/global/list/chemical_reactions_list //list of all /datum/chemical_reaction datums. Used during chemical reactions
var/global/list/chemical_reagents_list //list of all /datum/reagent datums indexed by reagent id. Used by chemistry stuff
var/global/list/surgeries_list = list() //list of all surgeries by name, associated with their path.
var/global/list/table_recipes = list() //list of all table craft recipes
var/global/list/table_recipes = list() //list of all table craft recipes
var/global/list/med_hud_users = list() //list of all entities using a medical HUD.
var/global/list/sec_hud_users = list() //list of all entities using a security HUD.
30 changes: 16 additions & 14 deletions code/_onclick/hud/_defines.dm
Expand Up @@ -44,6 +44,7 @@
#define ui_storage1 "CENTER+1:18,SOUTH:5"
#define ui_storage2 "CENTER+2:20,SOUTH:5"

#define ui_borg_sensor "CENTER-3:16, SOUTH:5" //borgs
#define ui_inv1 "CENTER-2:16,SOUTH:5" //borgs
#define ui_inv2 "CENTER-1 :16,SOUTH:5" //borgs
#define ui_inv3 "CENTER :16,SOUTH:5" //borgs
Expand Down Expand Up @@ -94,20 +95,21 @@

// AI

#define ui_ai_core "SOUTH:6,WEST:16"
#define ui_ai_camera_list "SOUTH:6,WEST+1:16"
#define ui_ai_track_with_camera "SOUTH:6,WEST+2:16"
#define ui_ai_camera_light "SOUTH:6,WEST+3:16"
#define ui_ai_crew_monitor "SOUTH:6,WEST+4:16"
#define ui_ai_crew_manifest "SOUTH:6,WEST+5:16"
#define ui_ai_alerts "SOUTH:6,WEST+6:16"
#define ui_ai_announcement "SOUTH:6,WEST+7:16"
#define ui_ai_shuttle "SOUTH:6,WEST+8:16"
#define ui_ai_state_laws "SOUTH:6,WEST+9:16"
#define ui_ai_pda_send "SOUTH:6,WEST+10:16"
#define ui_ai_pda_log "SOUTH:6,WEST+11:16"
#define ui_ai_take_picture "SOUTH:6,WEST+12:16"
#define ui_ai_view_images "SOUTH:6,WEST+13:16"
#define ui_ai_core "SOUTH:6,WEST"
#define ui_ai_camera_list "SOUTH:6,WEST+1"
#define ui_ai_track_with_camera "SOUTH:6,WEST+2"
#define ui_ai_camera_light "SOUTH:6,WEST+3"
#define ui_ai_crew_monitor "SOUTH:6,WEST+4"
#define ui_ai_crew_manifest "SOUTH:6,WEST+5"
#define ui_ai_alerts "SOUTH:6,WEST+6"
#define ui_ai_announcement "SOUTH:6,WEST+7"
#define ui_ai_shuttle "SOUTH:6,WEST+8"
#define ui_ai_state_laws "SOUTH:6,WEST+9"
#define ui_ai_pda_send "SOUTH:6,WEST+10"
#define ui_ai_pda_log "SOUTH:6,WEST+11"
#define ui_ai_take_picture "SOUTH:6,WEST+12"
#define ui_ai_view_images "SOUTH:6,WEST+13"
#define ui_ai_sensor "SOUTH:6,WEST+14"

//Pop-up inventory
#define ui_shoes "WEST+1:8,SOUTH:5"
Expand Down
11 changes: 10 additions & 1 deletion code/_onclick/hud/ai.dm
Expand Up @@ -130,6 +130,15 @@
using.layer = 20
adding += using

mymob.client.screen += adding + other

//Medical/Security sensors
using = new /obj/screen()
using.name = "Sensor Augmentation"
using.icon = 'icons/mob/screen_ai.dmi'
using.icon_state = "ai_sensor"
using.screen_loc = ui_ai_sensor
using.layer = 20
adding += using

mymob.client.screen += adding + other
return
9 changes: 9 additions & 0 deletions code/_onclick/hud/robot.dm
Expand Up @@ -63,6 +63,15 @@
using.layer = 20
adding += using

//Sec/Med HUDs
using = new /obj/screen()
using.name = "Sensor Augmentation"
using.icon = 'icons/mob/screen_ai.dmi'
using.icon_state = "ai_sensor"
using.screen_loc = ui_borg_sensor
using.layer = 20
adding += using

//Intent
using = new /obj/screen()
using.name = "act_intent"
Expand Down
4 changes: 4 additions & 0 deletions code/_onclick/hud/screen_objects.dm
Expand Up @@ -367,6 +367,10 @@
var/mob/living/silicon/robot/R = usr
R.aicamera.viewpictures()

if("Sensor Augmentation")
if(issilicon(usr))
var/mob/living/silicon/S = usr
S.sensor_mode()
else
return 0
return 1
Expand Down
181 changes: 181 additions & 0 deletions code/game/data_huds.dm
@@ -0,0 +1,181 @@
/* Using the HUD procs is simple. Call these procs in the life.dm of the intended mob.
Use the regular_hud_updates() proc before process_med_hud(mob) or process_sec_hud(mob) so
the HUD updates properly! */

//Deletes the current HUD images so they can be refreshed with new ones.
mob/proc/regular_hud_updates() //Used in the life.dm of mobs that can use HUDs.
if(client)
for(var/image/hud in client.images)
if(copytext(hud.icon_state,1,4) == "hud")
client.images -= hud
med_hud_users -= src
sec_hud_users -= src


//Medical HUD procs

proc/RoundHealth(health)

switch(health)
if(100 to INFINITY)
return "health100"
if(70 to 100)
return "health80"
if(50 to 70)
return "health60"
if(30 to 50)
return "health40"
if(18 to 30)
return "health25"
if(5 to 18)
return "health10"
if(1 to 5)
return "health1"
if(-99 to 0)
return "health0"
else
return "health-100"
return "0"

/*Called by the Life() proc of the mob using it, usually. Items can call it as well.
Called with this syntax: (The user mob, the type of hud in use, the advanced or basic version of the hud,eye object in the case of an AI) */

proc/process_data_hud(var/mob/M, var/hud_type, var/hud_mode, var/mob/eye)
#define DATA_HUD_MEDICAL 1
#define DATA_HUD_SECURITY 2

#define DATA_HUD_BASIC 1
#define DATA_HUD_ADVANCED 2

if(!M)
return
if(!M.client)
return

var/turf/T
if(eye)
T = get_turf(eye)
else
T = get_turf(M)


for(var/mob/living/carbon/human/H in mob_list)
if(get_dist(H, T) > M.client.view) //Ignores any humans outside of the user's view distance.
continue

switch(hud_type)
if(DATA_HUD_MEDICAL)
med_hud_users |= M
process_med_hud(M,hud_mode,T,H)

if(DATA_HUD_SECURITY)
sec_hud_users |= M //Used for Security HUD alerts.
process_sec_hud(M,hud_mode,T,H)

/***********************************************
Medical HUD outputs! Advanced mode ignores suit sensors.
************************************************/
proc/process_med_hud(var/mob/M, var/mode, var/turf/T, var/mob/living/carbon/human/patient)

var/client/C = M.client

if(mode == DATA_HUD_BASIC && !med_hud_suit_sensors(patient)) //Used for the AI's MedHUD, only works if the patient has activated suit sensors.
return


var/foundVirus = med_hud_find_virus(patient) //Detects non-hidden diseases in a patient, returns as a binary value.

C.images += med_hud_get_health(patient) //Generates a patient's health bar.
C.images += med_hud_get_status(patient, foundVirus) //Determines the type of status icon to show.


proc/med_hud_suit_sensors(var/mob/living/carbon/human/patient)
if(istype(patient.w_uniform, /obj/item/clothing/under))
var/obj/item/clothing/under/U = patient.w_uniform
if(U.sensor_mode > 2)
return 1
else
return 0

proc/med_hud_find_virus(var/mob/living/carbon/human/patient)
for(var/datum/disease/D in patient.viruses)
if(!D.hidden[SCANNER])
return 1

proc/med_hud_get_health(var/mob/living/carbon/human/patient)
var/image/holder = patient.hud_list[HEALTH_HUD]
if(patient.stat == 2)
holder.icon_state = "hudhealth-100"
else
holder.icon_state = "hud[RoundHealth(patient.health)]"
return holder

proc/med_hud_get_status(var/mob/living/carbon/human/patient, var/foundVirus)
var/image/holder = patient.hud_list[STATUS_HUD]
if(patient.stat == 2)
holder.icon_state = "huddead"
else if(patient.status_flags & XENO_HOST)
holder.icon_state = "hudxeno"
else if(foundVirus)
holder.icon_state = "hudill"
else
holder.icon_state = "hudhealthy"
return holder


/***********************************************
Security HUDs.
Pass a value for the second argument to enable implant viewing or other special features.
************************************************/
proc/process_sec_hud(var/mob/M, var/mode, var/turf/T, var/mob/living/carbon/human/perp)

var/client/C = M.client

sec_hud_get_ID(C, perp) //Provides the perp's job icon.

if(mode == DATA_HUD_ADVANCED) //If not set to "DATA_HUD_ADVANCED, the Sec HUD will only display the job.
sec_hud_get_implants(C, perp) //Returns the perp's implants, if any.
sec_hud_get_security_status(C, perp) //Gives the perp's arrest record, if there is one.


proc/sec_hud_get_ID(var/client/C, var/mob/living/carbon/human/perp)
var/image/holder
holder = perp.hud_list[ID_HUD]
holder.icon_state = "hudno_id"
if(perp.wear_id)
holder.icon_state = "hud[ckey(perp.wear_id.GetJobName())]"
C.images += holder

proc/sec_hud_get_implants(var/client/C, var/mob/living/carbon/human/perp)
var/image/holder
for(var/obj/item/weapon/implant/I in perp)
if(I.implanted)
if(istype(I,/obj/item/weapon/implant/tracking))
holder = perp.hud_list[IMPTRACK_HUD]
holder.icon_state = "hud_imp_tracking"
else if(istype(I,/obj/item/weapon/implant/loyalty))
holder = perp.hud_list[IMPLOYAL_HUD]
holder.icon_state = "hud_imp_loyal"
else if(istype(I,/obj/item/weapon/implant/chem))
holder = perp.hud_list[IMPCHEM_HUD]
holder.icon_state = "hud_imp_chem"
else
continue
C.images += holder
break

proc/sec_hud_get_security_status(var/client/C, var/mob/living/carbon/human/perp)
var/image/holder
var/perpname = perp.get_face_name(perp.get_id_name(""))
if(perpname)
var/datum/data/record/R = find_record("name", perpname, data_core.security)
if(R)
holder = perp.hud_list[WANTED_HUD]
switch(R.fields["criminal"])
if("*Arrest*") holder.icon_state = "hudwanted"
if("Incarcerated") holder.icon_state = "hudincarcerated"
if("Parolled") holder.icon_state = "hudparolled"
if("Discharged") holder.icon_state = "huddischarged"
else
return
C.images += holder
97 changes: 3 additions & 94 deletions code/modules/clothing/glasses/hud.dm
Expand Up @@ -25,63 +25,12 @@
name = "Health Scanner HUD"
desc = "A heads-up display that scans the humans in view and provides accurate data about their health status."
icon_state = "healthhud"
proc
RoundHealth(health)


RoundHealth(health)
switch(health)
if(100 to INFINITY)
return "health100"
if(70 to 100)
return "health80"
if(50 to 70)
return "health60"
if(30 to 50)
return "health40"
if(18 to 30)
return "health25"
if(5 to 18)
return "health10"
if(1 to 5)
return "health1"
if(-99 to 0)
return "health0"
else
return "health-100"
return "0"
/obj/item/clothing/glasses/hud/health/process_hud(var/mob/M)
process_data_hud(M,DATA_HUD_MEDICAL,DATA_HUD_ADVANCED)


process_hud(var/mob/M)
if(!M) return
if(!M.client) return
var/client/C = M.client
var/image/holder
for(var/mob/living/carbon/human/patient in view(M))
var/foundVirus = 0
for(var/datum/disease/D in patient.viruses)
if(!D.hidden[SCANNER])
foundVirus++
if(!C) continue

holder = patient.hud_list[HEALTH_HUD]
if(patient.stat == 2)
holder.icon_state = "hudhealth-100"
else
holder.icon_state = "hud[RoundHealth(patient.health)]"
C.images += holder

holder = patient.hud_list[STATUS_HUD]
if(patient.stat == 2)
holder.icon_state = "huddead"
else if(patient.status_flags & XENO_HOST)
holder.icon_state = "hudxeno"
else if(foundVirus)
holder.icon_state = "hudill"
else
holder.icon_state = "hudhealthy"
C.images += holder

/obj/item/clothing/glasses/hud/health/night
name = "Night Vision Health Scanner HUD"
desc = "An advanced medical head-up display that allows doctors to find patients in complete darkness."
Expand Down Expand Up @@ -123,44 +72,4 @@
invis_view = 2

/obj/item/clothing/glasses/hud/security/process_hud(var/mob/M)
if(!M) return
if(!M.client) return
var/client/C = M.client
var/image/holder
for(var/mob/living/carbon/human/perp in view(M))
holder = perp.hud_list[ID_HUD]
holder.icon_state = "hudno_id"
if(perp.wear_id)
holder.icon_state = "hud[ckey(perp.wear_id.GetJobName())]"
C.images += holder


for(var/obj/item/weapon/implant/I in perp)
if(I.implanted)
if(istype(I,/obj/item/weapon/implant/tracking))
holder = perp.hud_list[IMPTRACK_HUD]
holder.icon_state = "hud_imp_tracking"
else if(istype(I,/obj/item/weapon/implant/loyalty))
holder = perp.hud_list[IMPLOYAL_HUD]
holder.icon_state = "hud_imp_loyal"
else if(istype(I,/obj/item/weapon/implant/chem))
holder = perp.hud_list[IMPCHEM_HUD]
holder.icon_state = "hud_imp_chem"
else
continue
C.images += holder
break

var/perpname = perp.get_face_name(perp.get_id_name(""))
if(perpname)
var/datum/data/record/R = find_record("name", perpname, data_core.security)
if(R)
holder = perp.hud_list[WANTED_HUD]
switch(R.fields["criminal"])
if("*Arrest*") holder.icon_state = "hudwanted"
if("Incarcerated") holder.icon_state = "hudincarcerated"
if("Parolled") holder.icon_state = "hudparolled"
if("Discharged") holder.icon_state = "huddischarged"
else
continue
C.images += holder
process_data_hud(M,DATA_HUD_SECURITY,DATA_HUD_ADVANCED)