Skip to content

Commit

Permalink
Suit sensors with locked sensors cannot be removed from clothing.
Browse files Browse the repository at this point in the history
  • Loading branch information
MistakeNot4892 committed Dec 1, 2023
1 parent 277dbe2 commit c73e361
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 22 deletions.
4 changes: 2 additions & 2 deletions code/datums/extensions/multitool/items/clothing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
if(!sensor)
to_chat(user, SPAN_WARNING("\The [uniform] doesn't have a vitals sensors attached."))
return
sensor.sensors_locked = !sensor.sensors_locked
user.visible_message(SPAN_NOTICE("\The [user] [sensor.sensors_locked ? "" : "un"]locks \the [user]'s suit sensor controls."), range = 2)
sensor.toggle_sensors_locked()
user.visible_message(SPAN_NOTICE("\The [user] [sensor.get_sensors_locked() ? "" : "un"]locks \the [user]'s suit sensor controls."), range = 2)
2 changes: 1 addition & 1 deletion code/datums/outfits/outfit.dm
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ var/global/list/outfits_decls_by_type_
succeeded = TRUE
qdel(wear_uniform)
if(!succeeded)
. += "outfit is flagged for sensors, but uniform do not accept sensors"
. += "outfit is flagged for sensors, but uniform does not accept sensors"
qdel(sensor)

/decl/hierarchy/outfit/proc/pre_equip(mob/living/carbon/human/H)
Expand Down
4 changes: 2 additions & 2 deletions code/modules/clothing/_clothing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,10 @@
var/obj/item/clothing/accessory/vitals_sensor/sensor = locate() in old_clothes.accessories
if(!sensor)
return
sensor.removable = TRUE // This will be refreshed by remove_accessory/attach_accessory
old_clothes.remove_accessory(null, sensor)
attach_accessory(null, sensor)
if(!(sensor in accessories))
qdel(sensor)


/decl/interaction_handler/clothing_set_sensors
name = "Set Sensors Level"
Expand Down
18 changes: 14 additions & 4 deletions code/modules/clothing/clothing_accessories.dm
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
update_clothing_icon()

/obj/item/clothing/proc/remove_accessory(mob/user, obj/item/clothing/accessory/A)
if(!A || !(A in accessories))
if(!A || !(A in accessories) || !A.removable || !A.canremove)
return

A.on_removed(user)
Expand All @@ -94,11 +94,21 @@
if(!LAZYLEN(accessories))
return

var/list/removable_accessories = list()
for(var/obj/item/clothing/accessory/accessory in accessories)
if(accessory.canremove && accessory.removable)
removable_accessories += accessory

if(!length(removable_accessories))
to_chat(usr, SPAN_WARNING("You have no removable accessories."))
verbs -= /obj/item/clothing/proc/removetie_verb
return

var/obj/item/clothing/accessory/A
if(LAZYLEN(accessories) > 1)
A = show_radial_menu(M, M, make_item_radial_menu_choices(accessories), radius = 42, tooltips = TRUE)
if(LAZYLEN(removable_accessories) > 1)
A = show_radial_menu(M, M, make_item_radial_menu_choices(removable_accessories), radius = 42, tooltips = TRUE)
else
A = accessories[1]
A = removable_accessories[1]

remove_accessory(usr, A)

Expand Down
33 changes: 30 additions & 3 deletions code/modules/clothing/under/accessories/vitals_sensor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,23 @@
"Tracking beacon"
)

/obj/item/clothing/accessory/vitals_sensor/Initialize()
. = ..()
if(isnull(sensor_mode) || sensor_mode < VITALS_SENSOR_OFF || sensor_mode > VITALS_SENSOR_TRACKING)
set_sensor_mode(rand(VITALS_SENSOR_OFF, VITALS_SENSOR_TRACKING))
update_removable()

/obj/item/clothing/accessory/vitals_sensor/proc/toggle_sensors_locked()
set_sensors_locked(!get_sensors_locked())

/obj/item/clothing/accessory/vitals_sensor/proc/get_sensors_locked()
return sensors_locked

/obj/item/clothing/accessory/vitals_sensor/proc/set_sensors_locked(new_state)
if(get_sensors_locked() != new_state)
sensors_locked = new_state
update_removable()

/obj/item/clothing/accessory/vitals_sensor/examine(mob/user)
. = ..()
switch(sensor_mode)
Expand All @@ -26,10 +43,20 @@
if(VITALS_SENSOR_TRACKING)
to_chat(user, "Its vital tracker and tracking beacon appear to be enabled.")

/obj/item/clothing/accessory/vitals_sensor/Initialize()
/obj/item/clothing/accessory/vitals_sensor/on_attached(obj/item/clothing/S, mob/user)
. = ..()
if(isnull(sensor_mode) || sensor_mode < VITALS_SENSOR_OFF || sensor_mode > VITALS_SENSOR_TRACKING)
set_sensor_mode(rand(VITALS_SENSOR_OFF, VITALS_SENSOR_TRACKING))
update_removable()

/obj/item/clothing/accessory/vitals_sensor/on_removed(mob/user)
. = ..()
update_removable()

/obj/item/clothing/accessory/vitals_sensor/proc/update_removable()
var/obj/item/clothing/clothes = loc
if(istype(clothes) && (src in clothes.accessories))
removable = !sensors_locked
else
removable = TRUE

/obj/item/clothing/accessory/vitals_sensor/proc/set_sensor_mode(var/new_sensor_mode)
if(sensor_mode != new_sensor_mode)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/clothing/under/color.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/obj/item/clothing/under/color/orange/Initialize()
. = ..()
var/obj/item/clothing/accessory/vitals_sensor/sensor = new(src)
sensor.sensors_locked = TRUE
sensor.set_sensors_locked(TRUE)
sensor.set_sensor_mode(VITALS_SENSOR_TRACKING)
attach_accessory(null, sensor)

Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/human/npcs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
/obj/item/clothing/under/color/white/blank/Initialize()
. = ..()
var/obj/item/clothing/accessory/vitals_sensor/sensor = new(src)
sensor.sensors_locked = TRUE
sensor.set_sensors_locked(TRUE)
sensor.set_sensor_mode(VITALS_SENSOR_OFF)
attach_accessory(null, sensor)

Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/mob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@
dat += "<BR><b>Pockets:</b> <A href='?src=\ref[src];item=pockets'>Empty or Place Item</A>"
var/obj/item/clothing/accessory/vitals_sensor/sensor = get_vitals_sensor()
if(sensor)
if(sensor.sensors_locked)
if(sensor.get_sensors_locked())
dat += "<BR><A href='?src=\ref[src];item=lock_sensors'>Unlock vitals sensors</A>"
else if(user.get_multitool())
dat += "<BR><A href='?src=\ref[src];item=lock_sensors'>Lock vitals sensors</A>"
Expand Down
12 changes: 5 additions & 7 deletions code/modules/mob/stripping.dm
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
var/obj/item/clothing/accessory/vitals_sensor/sensor = get_vitals_sensor()
if (!istype(sensor))
return
visible_message(SPAN_DANGER("\The [user] is trying to [sensor.sensors_locked ? "un" : ""]lock \the [src]'s sensors!"))
visible_message(SPAN_DANGER("\The [user] is trying to [sensor.get_sensors_locked() ? "un" : ""]lock \the [src]'s sensors!"))
if (do_after(user, HUMAN_STRIP_DELAY, src, progress = 0))
if(QDELETED(sensor) || sensor != get_vitals_sensor())
to_chat(user, SPAN_WARNING("\The [src] is not wearing \the [sensor] anymore."))
Expand All @@ -43,8 +43,8 @@
if (!istype(user_multitool))
to_chat(user, SPAN_WARNING("You need a multitool to lock \the [src]'s sensors."))
return
sensor.sensors_locked = !sensor.sensors_locked
visible_message(SPAN_NOTICE("\The [user] [sensor.sensors_locked ? "" : "un"]locks \the [src]'s vitals sensor controls."), range = 2)
sensor.toggle_sensors_locked()
visible_message(SPAN_NOTICE("\The [user] [sensor.get_sensors_locked() ? "" : "un"]locks \the [src]'s vitals sensor controls."), range = 2)
return
if("internals")
visible_message("<span class='danger'>\The [usr] is trying to set \the [src]'s internals!</span>")
Expand Down Expand Up @@ -137,7 +137,7 @@
var/obj/item/clothing/accessory/vitals_sensor/sensor = get_vitals_sensor()
if(!istype(sensor))
to_chat(user, SPAN_WARNING("\The [src] is not wearing a vitals sensor."))
if (sensor.sensors_locked)
if (sensor.get_sensors_locked())
to_chat(user, SPAN_WARNING("\The [src]'s suit sensor controls are locked."))
return
admin_attack_log(user, src, "Toggled their suit sensors.", "Toggled their suit sensors.", "toggled the suit sensors of")
Expand All @@ -147,6 +147,4 @@
for(var/check_slot in global.vitals_sensor_equip_slots)
var/obj/item/clothing/equipped = get_equipped_item(check_slot)
if(istype(equipped))
var/sensor = locate(/obj/item/clothing/accessory/vitals_sensor) in equipped.accessories
if(sensor)
return sensor
return (locate(/obj/item/clothing/accessory/vitals_sensor) in equipped.accessories)

0 comments on commit c73e361

Please sign in to comment.