diff --git a/code/game/objects/items/devices/helmet_visors.dm b/code/game/objects/items/devices/helmet_visors.dm index 4d1b38491791..7b61df3291ef 100644 --- a/code/game/objects/items/devices/helmet_visors.dm +++ b/code/game/objects/items/devices/helmet_visors.dm @@ -238,6 +238,7 @@ on_light = new(attached_helmet) on_light.set_light_on(TRUE) START_PROCESSING(SSobj, src) + RegisterSignal(user, COMSIG_MOB_CHANGE_VIEW, PROC_REF(change_view)) /obj/item/device/helmet_visor/night_vision/deactivate_visor(obj/item/clothing/head/helmet/marine/attached_helmet, mob/living/carbon/human/user) user.remove_client_color_matrix("nvg_visor", 1 SECONDS) @@ -247,6 +248,7 @@ if(visor_glows) qdel(on_light) UnregisterSignal(user, COMSIG_HUMAN_POST_UPDATE_SIGHT) + UnregisterSignal(user, COMSIG_MOB_CHANGE_VIEW) user.update_sight() STOP_PROCESSING(SSobj, src) @@ -271,6 +273,10 @@ if(!.) return + if(user.client.view > 7) + to_chat(user, SPAN_WARNING("You cannot use [src] while using optics.")) + return FALSE + if(!NVG_VISOR_USAGE(FALSE)) to_chat(user, SPAN_NOTICE("Your [src] is out of power! You'll need to recharge it.")) return FALSE @@ -290,6 +296,21 @@ user.lighting_alpha = lighting_alpha user.sync_lighting_plane_alpha() +/obj/item/device/helmet_visor/night_vision/proc/change_view(mob/user, new_size) + SIGNAL_HANDLER + if(new_size > 7) // cannot use binos with NVO + var/obj/item/clothing/head/helmet/marine/attached_helmet = loc + if(!istype(attached_helmet)) + return + deactivate_visor(attached_helmet, user) + to_chat(user, SPAN_NOTICE("You deactivate [src] on [attached_helmet].")) + playsound_client(user.client, toggle_off_sound, null, 75) + attached_helmet.active_visor = null + attached_helmet.update_icon() + var/datum/action/item_action/cycle_helmet_huds/cycle_action = locate() in attached_helmet.actions + if(cycle_action) + cycle_action.set_default_overlay() + #undef NVG_VISOR_USAGE /atom/movable/nvg_light diff --git a/code/modules/clothing/head/helmet.dm b/code/modules/clothing/head/helmet.dm index 26c92f632ee2..aab882049df8 100644 --- a/code/modules/clothing/head/helmet.dm +++ b/code/modules/clothing/head/helmet.dm @@ -676,6 +676,7 @@ GLOBAL_LIST_INIT(allowed_helmet_items, list( var/list/total_visors = built_in_visors + inserted_visors if(!length(total_visors)) + to_chat(user, SPAN_WARNING("There are no visors to swap to.")) return FALSE if(active_visor) @@ -692,6 +693,11 @@ GLOBAL_LIST_INIT(allowed_helmet_items, list( skipped_hud = TRUE continue + if(!next_visor.can_toggle(user)) + iterator++ + skipped_hud = TRUE + continue + active_visor = next_visor toggle_visor(user, visor_to_deactivate, silent = TRUE) // disables the old visor toggle_visor(user) @@ -703,15 +709,19 @@ GLOBAL_LIST_INIT(allowed_helmet_items, list( iterator++ for(var/obj/item/device/helmet_visor/new_visor in total_visors) - if(!isnull(GLOB.huds[new_visor.hud_type]?.hudusers[user])) continue + if(!new_visor.can_toggle(user)) + continue + active_visor = new_visor toggle_visor(user) return active_visor + to_chat(user, SPAN_WARNING("There are no visors to swap to currently.")) return FALSE + /datum/action/item_action/cycle_helmet_huds/New(Target, obj/item/holder) . = ..() name = "Cycle helmet HUD"