diff --git a/code/modules/clothing/spacesuits/rig/modules/vision.dm b/code/modules/clothing/spacesuits/rig/modules/vision.dm
index 9ba365b34fa..c32832d403e 100644
--- a/code/modules/clothing/spacesuits/rig/modules/vision.dm
+++ b/code/modules/clothing/spacesuits/rig/modules/vision.dm
@@ -163,10 +163,16 @@
. = ..()
if(holder)
holder.visor = src
+ holder.verbs |= /obj/item/rig/proc/toggle_vision
+ if(length(vision_modes) > 1) // don't add it if we have no modes to switch between
+ holder.verbs |= /obj/item/rig/proc/switch_vision_mode
/obj/item/rig_module/vision/removed()
if(holder)
holder.visor = null
+ holder.verbs -= /obj/item/rig/proc/toggle_vision
+ // let's always remove it, just in case.
+ holder.verbs -= /obj/item/rig/proc/switch_vision_mode
. = ..()
/obj/item/rig_module/vision/engage()
diff --git a/code/modules/clothing/spacesuits/rig/rig_verbs.dm b/code/modules/clothing/spacesuits/rig/rig_verbs.dm
index 7f643eddf8b..6c6dfca28f2 100644
--- a/code/modules/clothing/spacesuits/rig/rig_verbs.dm
+++ b/code/modules/clothing/spacesuits/rig/rig_verbs.dm
@@ -9,22 +9,14 @@
if(wearer && wearer.get_equipped_item(slot_back_str) == src)
ui_interact(usr)
-/obj/item/rig/verb/toggle_vision()
+/obj/item/rig/proc/toggle_vision()
set name = "Toggle Visor"
set desc = "Turns your rig visor off or on."
set category = "Hardsuit"
set src = usr.contents
- if(!istype(wearer) || wearer.get_equipped_item(slot_back_str) != src)
- to_chat(usr, "The hardsuit is not being worn.")
- return
-
- if(!check_power_cost(usr))
- return
-
- if(canremove)
- to_chat(usr, "The suit is not active.")
+ if(!check_usable(usr))
return
if(!check_suit_access(usr))
@@ -106,16 +98,12 @@
set category = "Hardsuit"
set src = usr.contents
- if(!istype(wearer) || wearer.get_equipped_item(slot_back_str) != src)
- to_chat(usr, "The hardsuit is not being worn.")
+ if(!check_usable(usr))
return
if(!check_suit_access(usr))
return
- if(!check_power_cost(usr))
- return
-
deploy(wearer)
/obj/item/rig/verb/toggle_seals_verb()
@@ -134,21 +122,14 @@
toggle_seals(wearer)
-/obj/item/rig/verb/switch_vision_mode()
+/obj/item/rig/proc/switch_vision_mode()
set name = "Switch Vision Mode"
set desc = "Switches between available vision modes."
set category = "Hardsuit"
set src = usr.contents
- if(malfunction_check(usr))
- return
-
- if(!check_power_cost(usr, 0, 0, 0, 0))
- return
-
- if(canremove)
- to_chat(usr, "The suit is not active.")
+ if(!check_usable(usr))
return
if(!visor)
@@ -171,15 +152,7 @@
set category = "Hardsuit"
set src = usr.contents
- if(malfunction_check(usr))
- return
-
- if(canremove)
- to_chat(usr, "The suit is not active.")
- return
-
- if(!istype(wearer) || wearer.get_equipped_item(slot_back_str) != src)
- to_chat(usr, "The hardsuit is not being worn.")
+ if(!check_usable(usr))
return
if(!speech)
@@ -188,6 +161,40 @@
speech.engage()
+/obj/item/rig/proc/check_usable(mob/user)
+ if(malfunction_check(user))
+ return FALSE
+
+ if(!check_power_cost(user))
+ return FALSE
+
+ if(canremove)
+ to_chat(user, SPAN_WARNING("The suit is not active."))
+ return FALSE
+
+ if(!istype(wearer) || wearer.get_equipped_item(slot_back_str) != src)
+ to_chat(user, SPAN_WARNING("The hardsuit is not being worn."))
+ return FALSE
+ return TRUE
+
+/obj/item/rig/proc/get_selectable_modules(mob/user)
+ . = list()
+ for(var/obj/item/rig_module/module in installed_modules)
+ if(module.selectable)
+ . |= module
+
+/obj/item/rig/proc/get_toggleable_modules(mob/user)
+ . = list()
+ for(var/obj/item/rig_module/module in installed_modules)
+ if(module.toggleable)
+ . |= module
+
+/obj/item/rig/proc/get_usable_modules(mob/user)
+ . = list()
+ for(var/obj/item/rig_module/module in installed_modules)
+ if(module.usable)
+ . |= module
+
/obj/item/rig/verb/select_module()
set name = "Select Module"
@@ -195,24 +202,10 @@
set category = "Hardsuit"
set src = usr.contents
- if(malfunction_check(usr))
- return
-
- if(!check_power_cost(usr, 0, 0, 0, 0))
- return
-
- if(canremove)
- to_chat(usr, "The suit is not active.")
- return
-
- if(!istype(wearer) || wearer.get_equipped_item(slot_back_str) != src)
- to_chat(usr, "The hardsuit is not being worn.")
+ if(!check_usable(usr))
return
- var/list/selectable = list()
- for(var/obj/item/rig_module/module in installed_modules)
- if(module.selectable)
- selectable |= module
+ var/list/selectable = get_selectable_modules()
var/obj/item/rig_module/module = input("Which module do you wish to select?") as null|anything in selectable
@@ -232,26 +225,12 @@
set category = "Hardsuit"
set src = usr.contents
- if(malfunction_check(usr))
+ if(!check_usable(usr))
return
- if(!check_power_cost(usr, 0, 0, 0, 0))
- return
+ var/list/toggleable = get_toggleable_modules()
- if(canremove)
- to_chat(usr, "The suit is not active.")
- return
-
- if(!istype(wearer) || wearer.get_equipped_item(slot_back_str) != src)
- to_chat(usr, "The hardsuit is not being worn.")
- return
-
- var/list/selectable = list()
- for(var/obj/item/rig_module/module in installed_modules)
- if(module.toggleable)
- selectable |= module
-
- var/obj/item/rig_module/module = input("Which module do you wish to toggle?") as null|anything in selectable
+ var/obj/item/rig_module/module = input("Which module do you wish to toggle?") as null|anything in toggleable
if(!istype(module))
return
@@ -270,24 +249,10 @@
set category = "Hardsuit"
set src = usr.contents
- if(malfunction_check(usr))
- return
-
- if(canremove)
- to_chat(usr, "The suit is not active.")
+ if(!check_usable(usr))
return
- if(!istype(wearer) || wearer.get_equipped_item(slot_back_str) != src)
- to_chat(usr, "The hardsuit is not being worn.")
- return
-
- if(!check_power_cost(usr, 0, 0, 0, 0))
- return
-
- var/list/selectable = list()
- for(var/obj/item/rig_module/module in installed_modules)
- if(module.usable)
- selectable |= module
+ var/list/selectable = get_usable_modules()
var/obj/item/rig_module/module = input("Which module do you wish to engage?") as null|anything in selectable