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

Helmet Visors/Optics and built-in HUDs #4156

Merged
merged 20 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions code/__DEFINES/mob_hud.dm
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,12 @@
#define TRACKER_HIVE "Hive Core"
#define TRACKER_LEADER "Leader"
#define TRACKER_TUNNEL "Tunnel"

//These are used to manage the same HUD having multiple sources
#define HUD_SOURCE_HELMET "helmet"
#define HUD_SOURCE_EYEWEAR "eyewear"
#define HUD_SOURCE_HEADSET "headset"
#define HUD_SOURCE_GHOST "ghost"
#define HUD_SOURCE_ADMIN "admin"
#define HUD_SOURCE_MASK "mask"
#define HUD_SOURCE_INNATE "innate"
44 changes: 31 additions & 13 deletions code/datums/mob_hud.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
var/list/datum/mob_hud/huds = list(
MOB_HUD_SECURITY_BASIC = new /datum/mob_hud/security/basic(),
MOB_HUD_SECURITY_ADVANCED = new /datum/mob_hud/security/advanced(),
MOB_HUD_MEDICAL_BASIC = new /datum/mob_hud/medical/basic(),
MOB_HUD_MEDICAL_BASIC = new /datum/mob_hud/medical/basic(), // I don't think this is really needed anymore and it's annoying me, consult with the ancients before merge - Morrow
MOB_HUD_MEDICAL_ADVANCED = new /datum/mob_hud/medical/advanced(),
MOB_HUD_MEDICAL_OBSERVER = new /datum/mob_hud/medical/observer(),
MOB_HUD_XENO_INFECTION = new /datum/mob_hud/xeno_infection(),
Expand All @@ -30,10 +30,18 @@ var/list/datum/mob_hud/huds = list(

// Stop displaying a HUD to a specific person
// (took off medical glasses)
/datum/mob_hud/proc/remove_hud_from(mob/user)
/datum/mob_hud/proc/remove_hud_from(mob/user, source)
if(length(hudusers[user]) && (source in hudusers[user]))
hudusers[user] -= source

if(length(hudusers[user]))
return FALSE

for(var/mob/target in hudmobs)
remove_from_single_hud(user, target)

hudusers -= user
return TRUE

// Stop rendering a HUD on a target
// "unenroll" them so to speak
Expand All @@ -53,8 +61,24 @@ var/list/datum/mob_hud/huds = list(
user.client.images -= target.clone.hud_list[i]

// Allow user to view a HUD (putting on medical glasses)
/datum/mob_hud/proc/add_hud_to(mob/user)
/datum/mob_hud/proc/add_hud_to(mob/user, source)
hudusers |= user
if(hudusers[user])
hudusers[user] |= list(source)
else
hudusers[user] += list(source)

for(var/mob/target in hudmobs)
add_to_single_hud(user, target)

/// Refreshes the HUD, adding user and sources if missing and then calls to add the HUD
/datum/mob_hud/proc/refresh_hud(mob/user, list/source)
hudusers |= user
if(hudusers[user])
hudusers[user] |= source
else
hudusers[user] += source

for(var/mob/target in hudmobs)
add_to_single_hud(user, target)

Expand Down Expand Up @@ -229,27 +253,21 @@ var/list/datum/mob_hud/huds = list(
for(var/datum/mob_hud/hud in huds)
if(istype(hud, /datum/mob_hud/xeno))
hud.remove_from_hud(src)
hud.remove_hud_from(src)
hud.remove_hud_from(src, HUD_SOURCE_INNATE)
else if (istype(hud, /datum/mob_hud/xeno_infection))
hud.remove_hud_from(src)
hud.remove_hud_from(src, HUD_SOURCE_INNATE)
if (xeno_hostile_hud)
xeno_hostile_hud = FALSE
var/datum/mob_hud/hostile_hud = huds[MOB_HUD_XENO_HOSTILE]
hostile_hud.remove_hud_from(src)
hostile_hud.remove_hud_from(src, HUD_SOURCE_INNATE)



/mob/proc/refresh_huds(mob/source_mob)
var/mob/M = source_mob ? source_mob : src
for(var/datum/mob_hud/hud in huds)
if(M in hud.hudusers)
readd_hud(hud)

/mob/proc/readd_hud(datum/mob_hud/hud)
hud.add_hud_to(src)



hud.refresh_hud(src, hud.hudusers[M])

//Medical HUDs

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ GLOBAL_LIST_INIT(cm_vending_clothing_vehicle_crew, list(
list("Gloves", 0, /obj/item/clothing/gloves/yellow, MARINE_CAN_BUY_GLOVES, VENDOR_ITEM_MANDATORY),
list("Tanker Armor", 0, /obj/item/clothing/suit/storage/marine/tanker, MARINE_CAN_BUY_ARMOR, VENDOR_ITEM_MANDATORY),
list("M50 Tanker Helmet", 0, /obj/item/clothing/head/helmet/marine/tech/tanker, MARINE_CAN_BUY_HELMET, VENDOR_ITEM_MANDATORY),
list("SensorMate HUD", 0, /obj/item/clothing/glasses/hud/sensor, MARINE_CAN_BUY_GLASSES, VENDOR_ITEM_MANDATORY),
list("SensorMate HUD", 0, /obj/item/device/helmet_visor/medical, MARINE_CAN_BUY_GLASSES, VENDOR_ITEM_MANDATORY),
list("Welding Kit", 0, /obj/item/tool/weldpack, MARINE_CAN_BUY_BACKPACK, VENDOR_ITEM_MANDATORY),
list("MRE", 0, /obj/item/storage/box/MRE, MARINE_CAN_BUY_MRE, VENDOR_ITEM_MANDATORY),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ GLOBAL_LIST_INIT(cm_vending_gear_intelligence_officer, list(
list("Motion Detector", 15, /obj/item/device/motiondetector, null, VENDOR_ITEM_RECOMMENDED),
list("Plastic Explosive", 10, /obj/item/explosive/plastic, null, VENDOR_ITEM_REGULAR),
list("Welding Goggles", 5, /obj/item/clothing/glasses/welding, null, VENDOR_ITEM_REGULAR),
list("Sensor Medical HUD", 5, /obj/item/clothing/glasses/hud/sensor, null, VENDOR_ITEM_REGULAR),
list("Sensor Medical HUD", 5, /obj/item/device/helmet_visor/medical, null, VENDOR_ITEM_REGULAR),

list("POUCHES", 0, null, null, null),
list("Large Magazine Pouch", 10, /obj/item/storage/pouch/magazine/large, null, VENDOR_ITEM_REGULAR),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ GLOBAL_LIST_INIT(cm_vending_gear_engi, list(
list("M56D Heavy Machine Gun", 24, /obj/item/storage/box/guncase/m56d, null, VENDOR_ITEM_REGULAR),

list("UTILITIES", 0, null, null, null),
list("SensorMate Medical HUD", 12, /obj/item/clothing/glasses/hud/sensor, null, VENDOR_ITEM_REGULAR),
list("SensorMate Medical HUD", 12, /obj/item/device/helmet_visor/medical, null, VENDOR_ITEM_REGULAR),
list("Roller Bed", 5, /obj/item/roller, null, VENDOR_ITEM_REGULAR),
list("Fulton Device Stack", 5, /obj/item/stack/fulton, null, VENDOR_ITEM_REGULAR),
list("M3 B12 Pattern Armor", 24, /obj/item/clothing/suit/storage/marine/leader, null, VENDOR_ITEM_REGULAR),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ GLOBAL_LIST_INIT(cm_vending_gear_leader, list(
list("Injector (Tricord)", 1, /obj/item/reagent_container/hypospray/autoinjector/tricord, null, VENDOR_ITEM_REGULAR),

list("Health Analyzer", 4, /obj/item/device/healthanalyzer, null, VENDOR_ITEM_REGULAR),
list("SensorMate Medical HUD", 4, /obj/item/clothing/glasses/hud/sensor, null, VENDOR_ITEM_RECOMMENDED),
list("SensorMate Medical HUD", 4, /obj/item/device/helmet_visor/medical, null, VENDOR_ITEM_RECOMMENDED),
list("Roller Bed", 2, /obj/item/roller, null, VENDOR_ITEM_REGULAR),

list("SPECIAL AMMUNITION", 0, null, null, null),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ GLOBAL_LIST_INIT(cm_vending_clothing_marine, list(
list("Brown Webbing Vest", 15, /obj/item/clothing/accessory/storage/black_vest/brown_vest, null, VENDOR_ITEM_REGULAR),
list("Black Webbing Vest", 15, /obj/item/clothing/accessory/storage/black_vest, null, VENDOR_ITEM_REGULAR),
list("Drop Pouch", 15, /obj/item/clothing/accessory/storage/droppouch, null, VENDOR_ITEM_REGULAR),
list("SensorMate Medical HUD", 15, /obj/item/clothing/glasses/hud/sensor, null, VENDOR_ITEM_REGULAR),
list("SensorMate Medical HUD", 15, /obj/item/device/helmet_visor/medical, null, VENDOR_ITEM_REGULAR),
list("Roller Bed", 5, /obj/item/roller, null, VENDOR_ITEM_REGULAR),
list("Fulton Device Stack", 5, /obj/item/stack/fulton, null, VENDOR_ITEM_REGULAR),
list("B12 Pattern Marine Armor", 30, /obj/item/clothing/suit/storage/marine/leader, null, VENDOR_ITEM_REGULAR),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ GLOBAL_LIST_INIT(cm_vending_gear_spec, list(

list("UTILITIES", 0, null, null, null),
list("Fire Extinguisher (Portable)", 5, /obj/item/tool/extinguisher/mini, null, VENDOR_ITEM_REGULAR),
list("SensorMate Medical HUD", 15, /obj/item/clothing/glasses/hud/sensor, null, VENDOR_ITEM_REGULAR),
list("SensorMate Medical HUD", 15, /obj/item/device/helmet_visor/medical, null, VENDOR_ITEM_REGULAR),
list("Roller Bed", 5, /obj/item/roller, null, VENDOR_ITEM_REGULAR),
list("Fulton Device Stack", 5, /obj/item/stack/fulton, null, VENDOR_ITEM_REGULAR),
list("Fuel Tank Strap Pouch", 5, /obj/item/storage/pouch/flamertank, null, VENDOR_ITEM_REGULAR),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ GLOBAL_LIST_INIT(cm_vending_gear_tl, list(
list("Motion Detector", 15, /obj/item/device/motiondetector, null, VENDOR_ITEM_RECOMMENDED),
list("Plastic Explosive", 10, /obj/item/explosive/plastic, null, VENDOR_ITEM_REGULAR),
list("Breaching Charge", 10, /obj/item/explosive/plastic/breaching_charge, null, VENDOR_ITEM_REGULAR),
list("SensorMate Medical HUD", 15, /obj/item/clothing/glasses/hud/sensor, null, VENDOR_ITEM_REGULAR),
list("SensorMate Medical HUD", 15, /obj/item/device/helmet_visor/medical, null, VENDOR_ITEM_REGULAR),
list("M2 Night Vision Goggles", 30, /obj/item/prop/helmetgarb/helmet_nvg, null, VENDOR_ITEM_RECOMMENDED),
list("Roller Bed", 5, /obj/item/roller, null, VENDOR_ITEM_REGULAR),
list("Fulton Device Stack", 5, /obj/item/stack/fulton, null, VENDOR_ITEM_REGULAR),
Expand Down
106 changes: 106 additions & 0 deletions code/game/objects/items/devices/helmet_visors.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/obj/item/device/helmet_visor
name = "squad optic"
desc = "An insertable visor HUD into a standard USCM helmet."
icon = 'icons/obj/items/clothing/helmet_visors.dmi'
icon_state = "hud_sight"
w_class = SIZE_TINY

///The type of HUD our visor shows
var/hud_type = MOB_HUD_FACTION_USCM

///The sound when toggling on the visor
var/toggle_on_sound = 'sound/handling/hud_on.ogg'

///The sound when toggling off the visor
var/toggle_off_sound = 'sound/handling/hud_off.ogg'

///The icon name for our helmet's action
var/action_icon_string = "hud_sight_down"

///The overlay name for when our visor is active
var/helmet_overlay = "hud_sight_right"

/// Called to see if the user can even use this visor
/obj/item/device/helmet_visor/proc/can_toggle(mob/living/carbon/human/user)
return TRUE

/// Called to see if this visor is a special non-HUD visor
/obj/item/device/helmet_visor/proc/special_visor_function(obj/item/clothing/head/helmet/marine/attached_helmet, mob/living/carbon/human/user, silent = FALSE)
return FALSE

/obj/item/device/helmet_visor/medical
name = "basic medical optic"
icon_state = "med_sight"
hud_type = MOB_HUD_MEDICAL_ADVANCED
action_icon_string = "med_sight_down"
helmet_overlay = "med_sight_right"

/obj/item/device/helmet_visor/medical/advanced
name = "advanced medical optic"
helmet_overlay = "med_sight_left"

/obj/item/device/helmet_visor/medical/advanced/can_toggle(mob/living/carbon/human/user)
if(!skillcheck(user, SKILL_MEDICAL, SKILL_MEDICAL_MEDIC))
to_chat(user, SPAN_NOTICE("You are not skilled enough to use [src]."))
return FALSE

return TRUE

/obj/item/device/helmet_visor/security
name = "security optic"
icon_state = "sec_sight"
hud_type = MOB_HUD_SECURITY_ADVANCED
action_icon_string = "sec_sight_down"
helmet_overlay = "sec_sight_right"

/obj/item/device/helmet_visor/welding_visor
name = "welding visor"
icon_state = "sight_empty"
hud_type = null
action_icon_string = "blank_hud_sight_down"
helmet_overlay = "weld_visor"

/obj/item/device/helmet_visor/welding_visor/special_visor_function(obj/item/clothing/head/helmet/marine/attached_helmet, mob/living/carbon/human/user, silent = FALSE)
if(attached_helmet.active_visor == type)
attached_helmet.vision_impair = VISION_IMPAIR_MAX
attached_helmet.flags_inventory |= COVEREYES|COVERMOUTH
attached_helmet.flags_inv_hide |= HIDEEYES|HIDEFACE
attached_helmet.eye_protection = EYE_PROTECTION_WELDING
user.update_tint()
if(!silent)
to_chat(user, SPAN_NOTICE("You activate [src] on [attached_helmet]."))
return TRUE

attached_helmet.vision_impair = VISION_IMPAIR_NONE
attached_helmet.flags_inventory &= ~(COVEREYES|COVERMOUTH)
attached_helmet.flags_inv_hide &= ~(HIDEEYES|HIDEFACE)
attached_helmet.eye_protection = EYE_PROTECTION_NONE
if(!silent)
to_chat(user, SPAN_NOTICE("You deactivate [src] on [attached_helmet]."))
user.update_tint()
return TRUE

/obj/item/device/helmet_visor/welding_visor/mercenary
helmet_overlay = ""




/*
TO DO - MORROW

Can toggle checks - done
Make addable and removable from helmets - done
Separate between removable and built in on helmets - done
Engineer helmet visor converted - still needs tanker helmet special sprites
Sec visor gives energy resist - optional, leaning towards no
Medic helmet needs built in advanced - done
CO helmet needs built in all - done
sec helmets need built in sec - done
Verify we have enough overlay space - done
All non-marine helmets need in-built HUDs nullified - Most, TM will find more likely
Replace rifleman medhud - done

Make sure the other HUDs still operate correctly - TM will discover problems I am sure, I *think* I caught a good chunk of them

*/
8 changes: 4 additions & 4 deletions code/game/objects/items/devices/radio/headset.dm
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@
RegisterSignal(user, COMSIG_HUMAN_SET_UNDEFIBBABLE, PROC_REF(update_minimap_icon))
if(headset_hud_on)
var/datum/mob_hud/H = huds[hud_type]
H.add_hud_to(user)
H.add_hud_to(user, HUD_SOURCE_HEADSET)
//squad leader locator is no longer invisible on our player HUD.
if(user.mind && (user.assigned_squad || misc_tracking) && user.hud_used && user.hud_used.locate_leader)
user.show_hud_tracker()
Expand All @@ -257,7 +257,7 @@
))
if(istype(user) && user.has_item_in_ears(src)) //dropped() is called before the inventory reference is update.
var/datum/mob_hud/H = huds[hud_type]
H.remove_hud_from(user)
H.remove_hud_from(user, HUD_SOURCE_HEADSET)
//squad leader locator is invisible again
if(user.hud_used && user.hud_used.locate_leader)
user.hide_hud_tracker()
Expand Down Expand Up @@ -290,14 +290,14 @@
if(user.has_item_in_ears(src)) //worn
var/datum/mob_hud/H = huds[hud_type]
if(headset_hud_on)
H.add_hud_to(usr)
H.add_hud_to(usr, HUD_SOURCE_HEADSET)
if(user.mind && (misc_tracking || user.assigned_squad) && user.hud_used?.locate_leader)
user.show_hud_tracker()
if(misc_tracking)
SStracking.start_misc_tracking(user)
update_minimap_icon()
else
H.remove_hud_from(usr)
H.remove_hud_from(usr, HUD_SOURCE_HEADSET)
if(user.hud_used?.locate_leader)
user.hide_hud_tracker()
if(misc_tracking)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/admin/verbs/mob_verbs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
H = huds[MOB_HUD_XENO_STATUS]
else return

H.add_hud_to(M)
H.add_hud_to(M, HUD_SOURCE_ADMIN)
to_chat(src, SPAN_INFO("[hud_choice] enabled."))
message_admins(SPAN_INFO("[key_name(usr)] has given a [hud_choice] to [M]."))

Expand Down
4 changes: 2 additions & 2 deletions code/modules/client/preferences_toggles.dm
Original file line number Diff line number Diff line change
Expand Up @@ -645,9 +645,9 @@

O.HUD_toggled[hud_choice] = prefs.observer_huds[hud_choice]
if(O.HUD_toggled[hud_choice])
H.add_hud_to(O)
H.add_hud_to(O, HUD_SOURCE_GHOST)
else
H.remove_hud_from(O)
H.remove_hud_from(O, HUD_SOURCE_GHOST)

/client/proc/toggle_ghost_health_scan()
set name = "Toggle Health Scan"
Expand Down
8 changes: 4 additions & 4 deletions code/modules/clothing/glasses/glasses.dm
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@
if(hud_type)
var/datum/mob_hud/MH = huds[hud_type]
if(active)
MH.add_hud_to(H)
MH.add_hud_to(H, HUD_SOURCE_EYEWEAR)
playsound(H, 'sound/handling/hud_on.ogg', 25, 1)
else
MH.remove_hud_from(H)
MH.remove_hud_from(H, HUD_SOURCE_EYEWEAR)
playsound(H, 'sound/handling/hud_off.ogg', 25, 1)
if(active) //turning it on? then add the traits
for(var/trait in clothing_traits)
Expand All @@ -95,15 +95,15 @@

else if(hud_type)
var/datum/mob_hud/MH = huds[hud_type]
MH.add_hud_to(user)
MH.add_hud_to(user, HUD_SOURCE_EYEWEAR)
user.update_sight()
..()

/obj/item/clothing/glasses/dropped(mob/living/carbon/human/user)
if(hud_type && active && istype(user))
if(src == user.glasses) //dropped is called before the inventory reference is updated.
var/datum/mob_hud/H = huds[hud_type]
H.remove_hud_from(user)
H.remove_hud_from(user, HUD_SOURCE_EYEWEAR)
user.glasses = null
user.update_inv_glasses()
user.update_sight()
Expand Down
2 changes: 1 addition & 1 deletion code/modules/clothing/glasses/hud.dm
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
deactive_state = "sensorhud_d"
flags_armor_protection = 0
toggleable = TRUE
hud_type = MOB_HUD_MEDICAL_BASIC
hud_type = MOB_HUD_MEDICAL_ADVANCED
actions_types = list(/datum/action/item_action/toggle)
req_skill = SKILL_MEDICAL
req_skill_level = SKILL_MEDICAL_DEFAULT
Expand Down
Loading
Loading