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

WIP Helmet HUD Upgrade and Necessity #424

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
18 changes: 15 additions & 3 deletions code/_onclick/hud/screen_objects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -456,17 +456,29 @@
/atom/movable/screen/squad_leader_locator/clicked(mob/living/carbon/human/user, mods)
if(!istype(user))
return

///The object which we're using the tracking options from.
var/obj/item/device/tracker_object

var/obj/item/device/radio/headset/earpiece = user.get_type_in_ears(/obj/item/device/radio/headset)
var/has_access = earpiece.misc_tracking || (user.assigned_squad && user.assigned_squad.radio_freq == earpiece.frequency)
if(!istype(earpiece) || !earpiece.has_hud || !has_access)
var/has_access = earpiece?.misc_tracking || (user.assigned_squad && user.assigned_squad.radio_freq == earpiece?.frequency)
if(istype(earpiece) && earpiece.has_hud && has_access)
tracker_object = earpiece

//visor is the 2nd pick
var/obj/item/device/helmet_visor/visor = locate() in user.head
if(visor?.has_tracker && !tracker_object)
tracker_object = visor

if(!tracker_object)
to_chat(user, SPAN_WARNING("Unauthorized access detected."))
return
if(mods["shift"])
var/area/current_area = get_area(user)
to_chat(user, SPAN_NOTICE("You are currently at: <b>[current_area.name]</b>."))
return
else if(mods["alt"])
earpiece.switch_tracker_target()
tracker_object.switch_tracker_target()
return
if(user.get_active_hand())
return
Expand Down
9 changes: 7 additions & 2 deletions code/controllers/subsystem/tracking.dm
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,15 @@ SUBSYSTEM_DEF(tracking)
if(ishuman(current_mob))
var/mob/living/carbon/human/human_mob = current_mob
var/obj/item/device/radio/headset/almayer/marine/earpiece = human_mob.get_type_in_ears(/obj/item/device/radio/headset)
if(earpiece?.has_hud)
var/has_access = earpiece?.misc_tracking || (human_mob.assigned_squad && human_mob.assigned_squad.radio_freq == earpiece?.frequency)
if(earpiece?.has_hud && has_access)
human_mob.locate_squad_leader(earpiece.locate_setting)
else
human_mob.locate_squad_leader()
var/obj/item/device/helmet_visor/visor = locate() in human_mob.head
if(visor?.has_tracker)
human_mob.locate_squad_leader(visor.locate_setting)
else
human_mob.locate_squad_leader()
else if(isxeno(current_mob))
var/mob/living/carbon/xenomorph/xeno_mob = current_mob
xeno_mob.queen_locator()
Expand Down
46 changes: 45 additions & 1 deletion code/game/objects/items/devices/helmet_visors.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@
///The overlay name for when our visor is active, in 'icons/mob/humans/onmob/helmet_garb.dmi'
var/helmet_overlay = "hud_sight_right"

///Whether the visor allows tracking squad members or not.
var/has_tracker = TRUE

///Default tracking options for the visor.
var/list/tracking_options = list(
"Platoon Commander" = TRACKER_PLTCO,
"Platoon Sergeant" = TRACKER_SL,
"Squad Sergeant" = TRACKER_FTL,
"Landing Zone" = TRACKER_LZ
)

///The target that we are currently tracking.
var/locate_setting = TRACKER_SL

/obj/item/device/helmet_visor/Destroy(force)
if(!istype(loc, /obj/item/clothing/head/helmet/marine))
return ..()
Expand Down Expand Up @@ -64,11 +78,22 @@
var/datum/mob_hud/current_mob_hud = GLOB.huds[hud_type]
current_mob_hud.add_hud_to(user, attached_helmet)

if(has_tracker && user.mind && user.assigned_squad && user.hud_used && user.hud_used.locate_leader)
user.show_hud_tracker()

/// Called by toggle_visor() to deactivate the visor's effects
/obj/item/device/helmet_visor/proc/deactivate_visor(obj/item/clothing/head/helmet/marine/attached_helmet, mob/living/carbon/human/user)
var/datum/mob_hud/current_mob_hud = GLOB.huds[hud_type]
current_mob_hud.remove_hud_from(user, attached_helmet)

if(has_tracker && user.hud_used && user.hud_used.locate_leader)
//if we have a headset that also lets us track targets, do not hide the HUD.
var/obj/item/device/radio/headset/earpiece = user.get_type_in_ears(/obj/item/device/radio/headset)
var/has_access = earpiece?.misc_tracking || (user.assigned_squad && user.assigned_squad.radio_freq == earpiece?.frequency)
if(istype(earpiece) && earpiece.has_hud && has_access)
return
user.hide_hud_tracker()

/// Called by /obj/item/clothing/head/helmet/marine/get_examine_text(mob/user) to get extra examine text for this visor
/obj/item/device/helmet_visor/proc/get_helmet_examine_text()
return SPAN_NOTICE("\A [name] is flipped down.")
Expand All @@ -82,7 +107,25 @@

/obj/item/device/helmet_visor/medical/advanced
name = "advanced medical optic"
helmet_overlay = "med_sight_right"
helmet_overlay = "med_sight_left"
hud_type = list(MOB_HUD_FACTION_MARINE, MOB_HUD_MEDICAL_ADVANCED)

/obj/item/device/helmet_visor/medical/advanced/activate_visor(obj/item/clothing/head/helmet/marine/attached_helmet, mob/living/carbon/human/user)
. = ..()

for(var/type in hud_type)
var/datum/mob_hud/current_mob_hud = huds[type]

Check failure on line 117 in code/game/objects/items/devices/helmet_visors.dm

View workflow job for this annotation

GitHub Actions / Run Linters

undefined var: "huds"
current_mob_hud.add_hud_to(user, attached_helmet)

/obj/item/device/helmet_visor/medical/advanced/deactivate_visor(obj/item/clothing/head/helmet/marine/attached_helmet, mob/living/carbon/human/user)
. = ..()

for(var/type in hud_type)
var/datum/mob_hud/current_mob_hud = huds[type]

Check failure on line 124 in code/game/objects/items/devices/helmet_visors.dm

View workflow job for this annotation

GitHub Actions / Run Linters

undefined var: "huds"
current_mob_hud.remove_hud_from(user, attached_helmet)

/obj/item/device/helmet_visor/medical/advanced/process(delta_time)
return PROCESS_KILL

/obj/item/device/helmet_visor/medical/advanced/can_toggle(mob/living/carbon/human/user)
. = ..()
Expand Down Expand Up @@ -155,6 +198,7 @@
hud_type = null
action_icon_string = "blank_hud_sight_down"
helmet_overlay = "weld_visor"
has_tracker = FALSE

/obj/item/device/helmet_visor/welding_visor/activate_visor(obj/item/clothing/head/helmet/marine/attached_helmet, mob/living/carbon/human/user)
attached_helmet.vision_impair = VISION_IMPAIR_MAX
Expand Down
46 changes: 28 additions & 18 deletions code/game/objects/items/devices/radio/headset.dm
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
if(has_hud)
headset_hud_on = TRUE
verbs += /obj/item/device/radio/headset/proc/toggle_squadhud
verbs += /obj/item/device/radio/headset/proc/switch_tracker_target
verbs += /obj/item/device/proc/switch_tracker_target

if(frequency)
for(var/cycled_channel in GLOB.radiochannels)
Expand Down Expand Up @@ -269,8 +269,13 @@
if(istype(user) && user.has_item_in_ears(src)) //dropped() is called before the inventory reference is update.
var/datum/mob_hud/H = GLOB.huds[hud_type]
H.remove_hud_from(user, src)
//squad leader locator is invisible again
if(user.hud_used && user.hud_used.locate_leader)
var/obj/item/clothing/head/helmet/marine/worn_helmet = user.head
if(!istype(worn_helmet))
// If their hat isn't a marine helmet, we won't take it into account for the next check
worn_helmet = null

//squad leader locator is invisible again unless a visor tracker is active
if(!worn_helmet?.active_visor?.has_tracker && user.hud_used && user.hud_used.locate_leader)
user.hide_hud_tracker()
if(misc_tracking)
SStracking.stop_misc_tracking(user)
Expand Down Expand Up @@ -317,7 +322,7 @@
to_chat(usr, SPAN_NOTICE("You toggle [src]'s headset HUD [headset_hud_on ? "on":"off"]."))
playsound(src,'sound/machines/click.ogg', 20, 1)

/obj/item/device/radio/headset/proc/switch_tracker_target()
/obj/item/device/proc/switch_tracker_target()
set name = "Switch Tracker Target"
set category = "Object"
set src in usr
Expand All @@ -327,12 +332,16 @@

handle_switching_tracker_target(usr)

/obj/item/device/radio/headset/proc/handle_switching_tracker_target(mob/living/carbon/human/user)
var/new_track = tgui_input_list(user, "Choose a new tracking target.", "Tracking Selection", tracking_options)
/obj/item/device/proc/handle_switching_tracker_target(mob/living/carbon/human/user)
if(!is_type_in_list(src, list(/obj/item/device/radio/headset, /obj/item/device/helmet_visor)))
return

var/obj/item/device/radio/headset/tracker_item = src
var/new_track = tgui_input_list(user, "Choose a new tracking target.", "Tracking Selection", tracker_item.tracking_options)
if(!new_track)
return
to_chat(user, SPAN_NOTICE("You set your headset's tracker to point to <b>[new_track]</b>."))
locate_setting = tracking_options[new_track]
to_chat(user, SPAN_NOTICE("You set your tracker to point to <b>[new_track]</b>."))
tracker_item.locate_setting = tracker_item.tracking_options[new_track]

/obj/item/device/radio/headset/proc/update_minimap_icon()
SIGNAL_HANDLER
Expand Down Expand Up @@ -405,7 +414,7 @@
icon_state = "generic_headset"
item_state = "headset"
frequency = PUB_FREQ
has_hud = TRUE
has_hud = FALSE

/obj/item/device/radio/headset/almayer/equipped(mob/living/carbon/human/user, slot)
. = ..()
Expand Down Expand Up @@ -611,6 +620,7 @@
volume = RADIO_VOLUME_CRITICAL
misc_tracking = TRUE
locate_setting = TRACKER_CO
has_hud = FALSE

inbuilt_tracking_options = list(
"Commanding Officer" = TRACKER_CO,
Expand Down Expand Up @@ -906,7 +916,7 @@
frequency = PMC_FREQ
icon_state = "pmc_headset"
initial_keys = list(/obj/item/device/encryptionkey/public, /obj/item/device/encryptionkey/mcom/cl)
has_hud = TRUE
has_hud = FALSE
hud_type = MOB_HUD_FACTION_PMC

misc_tracking = TRUE
Expand All @@ -921,7 +931,7 @@
frequency = CBRN_FREQ
initial_keys = list(/obj/item/device/encryptionkey/public, /obj/item/device/encryptionkey/mcom)
ignore_z = TRUE
has_hud = TRUE
has_hud = FALSE

/obj/item/device/radio/headset/distress/forecon
name = "\improper Force Recon headset"
Expand Down Expand Up @@ -978,7 +988,7 @@
desc = "A special headset used by UPP military. To access the colony channel, use :o."
frequency = UPP_FREQ
initial_keys = list(/obj/item/device/encryptionkey/colony)
has_hud = TRUE
has_hud = FALSE
hud_type = MOB_HUD_FACTION_UPP
minimap_type = MINIMAP_FLAG_UPP

Expand Down Expand Up @@ -1018,7 +1028,7 @@
desc = "A special headset used by small groups of trained operatives. Or terrorists. To access the colony channel use :o."
frequency = CLF_FREQ
initial_keys = list(/obj/item/device/encryptionkey/colony)
has_hud = TRUE
has_hud = FALSE
hud_type = MOB_HUD_FACTION_CLF

/obj/item/device/radio/headset/distress/CLF/cct
Expand Down Expand Up @@ -1049,15 +1059,15 @@
frequency = VAI_FREQ
icon_state = "vai_headset"
initial_keys = list(/obj/item/device/encryptionkey/public, /obj/item/device/encryptionkey/contractor)
has_hud = TRUE
has_hud = FALSE

/obj/item/device/radio/headset/distress/royal_marine
name = "Royal Marine Headset"
desc = "A sleek headset used by the Royal Marines Commando. Low profile enough to fit under their unique helmets."
frequency = RMC_FREQ
icon_state = "vai_headset"
initial_keys = list(/obj/item/device/encryptionkey/public, /obj/item/device/encryptionkey/royal_marine)
has_hud = TRUE
has_hud = FALSE
hud_type = MOB_HUD_FACTION_TWE
volume = RADIO_VOLUME_IMPORTANT

Expand All @@ -1068,7 +1078,7 @@
frequency = CMB_FREQ
icon_state = "cmb_headset"
initial_keys = list(/obj/item/device/encryptionkey/colony)
has_hud = TRUE
has_hud = FALSE
hud_type = MOB_HUD_FACTION_MARINE

/obj/item/device/radio/headset/distress/CMB/limited
Expand Down Expand Up @@ -1113,7 +1123,7 @@
frequency = SOF_FREQ
initial_keys = list(/obj/item/device/encryptionkey/soc/forecon)
volume = RADIO_VOLUME_QUIET
has_hud = TRUE
has_hud = FALSE
hud_type = MOB_HUD_FACTION_MARINE

/obj/item/device/radio/headset/almayer/mcom/vc
Expand All @@ -1130,5 +1140,5 @@
initial_keys = list(/obj/item/device/encryptionkey/upp)
volume = RADIO_VOLUME_QUIET
ignore_z = FALSE
has_hud = TRUE
has_hud = FALSE
hud_type = MOB_HUD_FACTION_UPP
3 changes: 1 addition & 2 deletions code/modules/clothing/head/helmet.dm
Original file line number Diff line number Diff line change
Expand Up @@ -815,8 +815,7 @@ GLOBAL_LIST_INIT(allowed_helmet_items, list(
desc = "M10 combat helmet issued to marine hospital corpsmen. Has a red cross painted on its front for attracting the injured and snipers' attentions alike."
icon_state = "med_helmet"
specialty = "M10 pattern medic"
built_in_visors = list(new /obj/item/device/helmet_visor, new /obj/item/device/helmet_visor/medical/advanced)
start_down_visor_type = /obj/item/device/helmet_visor/medical/advanced
built_in_visors = list(new /obj/item/device/helmet_visor/medical/advanced)

/obj/item/clothing/head/helmet/marine/medic/white
name = "\improper M10 white corpsman helmet"
Expand Down
Loading