From 960cd9d5289d0c4210e704e01f2aa00428b32435 Mon Sep 17 00:00:00 2001
From: Zwei <35403274+Gottfrei@users.noreply.github.com>
Date: Wed, 28 Feb 2024 23:32:29 +0200
Subject: [PATCH] bugfix: Hardsuit Fixes (#4496)
Hardsuit Fixes
---
code/datums/outfits/outfit.dm | 4 +-
.../gamemodes/clockwork/clockwork_items.dm | 2 +-
.../contractor/items/contractor_hardsuit.dm | 2 +-
code/modules/clothing/spacesuits/hardsuit.dm | 76 +++++++++----------
code/modules/clothing/suits/hood.dm | 55 +++++++-------
code/modules/mob/inventory.dm | 31 ++++----
code/modules/mob/living/carbon/inventory.dm | 11 +--
code/modules/mob/living/living.dm | 8 +-
.../living/simple_animal/friendly/diona.dm | 2 +-
9 files changed, 91 insertions(+), 100 deletions(-)
diff --git a/code/datums/outfits/outfit.dm b/code/datums/outfits/outfit.dm
index ec9ccf325dc..36bb749e855 100644
--- a/code/datums/outfits/outfit.dm
+++ b/code/datums/outfits/outfit.dm
@@ -136,10 +136,10 @@
if(!H.head && toggle_helmet)
if(istype(H.wear_suit, /obj/item/clothing/suit/space/hardsuit))
var/obj/item/clothing/suit/space/hardsuit/hardsuit = H.wear_suit
- hardsuit.ToggleHelmet()
+ hardsuit.ToggleHelmet(H)
else if(istype(H.wear_suit, /obj/item/clothing/suit/hooded))
var/obj/item/clothing/suit/hooded/S = H.wear_suit
- S.ToggleHood()
+ S.ToggleHood(H)
H.regenerate_icons()
return TRUE
diff --git a/code/game/gamemodes/clockwork/clockwork_items.dm b/code/game/gamemodes/clockwork/clockwork_items.dm
index f61aded9cc0..703e4009de3 100644
--- a/code/game/gamemodes/clockwork/clockwork_items.dm
+++ b/code/game/gamemodes/clockwork/clockwork_items.dm
@@ -717,7 +717,7 @@
to_chat(carbon, "Robe tightens, as it frees you to be flexible around!")
add_attack_logs(user, user, "speed boosted with [src]", ATKLOG_ALL)
else
- ToggleHood()
+ ToggleHood(user)
/obj/item/clothing/suit/hooded/clockrobe/proc/uncloak(mob/user)
animate(user, alpha = 255, time = 1 SECONDS)
diff --git a/code/modules/antagonists/traitor/contractor/items/contractor_hardsuit.dm b/code/modules/antagonists/traitor/contractor/items/contractor_hardsuit.dm
index fdff9359409..cdc96bf4215 100644
--- a/code/modules/antagonists/traitor/contractor/items/contractor_hardsuit.dm
+++ b/code/modules/antagonists/traitor/contractor/items/contractor_hardsuit.dm
@@ -37,7 +37,7 @@
/obj/item/clothing/suit/space/hardsuit/contractor/ui_action_click(user, action)
switch(action)
if(/datum/action/item_action/toggle_helmet)
- ToggleHelmet()
+ ToggleHelmet(user)
return TRUE
if(/datum/action/item_action/advanced/hook_upgrade)
toggle_hook()
diff --git a/code/modules/clothing/spacesuits/hardsuit.dm b/code/modules/clothing/spacesuits/hardsuit.dm
index 3d852b311a1..a39fb4c1287 100644
--- a/code/modules/clothing/spacesuits/hardsuit.dm
+++ b/code/modules/clothing/spacesuits/hardsuit.dm
@@ -47,26 +47,27 @@
icon_state = "[basestate][light_on]-[item_color]"
-/obj/item/clothing/head/helmet/space/hardsuit/equipped(mob/user, slot, initial = FALSE)
- . = ..()
- if(slot != slot_head)
- if(suit)
- suit.RemoveHelmet()
- else
- qdel(src)
+/obj/item/clothing/head/helmet/space/hardsuit/equipped(mob/living/carbon/user, slot, initial = FALSE)
+ . = ..(user, slot, TRUE)
+ if(!suit)
+ qdel(src)
+ return FALSE
+ if(slot != slot_head || user.wear_suit != suit)
+ user.drop_item_ground(src, force = TRUE, silent = TRUE)
+ return FALSE
/obj/item/clothing/head/helmet/space/hardsuit/dropped(mob/user, silent = FALSE)
- . = ..()
- if(suit && loc != suit)
- forceMove(suit)
+ . = ..(user, TRUE)
+ if(suit)
+ suit.RemoveHelmet(user)
else
qdel(src)
/obj/item/clothing/head/helmet/space/hardsuit/MouseDrop(atom/over_object, src_location, over_location, src_control, over_control, params)
if(suit)
- suit.RemoveHelmet()
+ suit.RemoveHelmet(usr)
else
qdel(src)
@@ -80,11 +81,7 @@
light_on = enable
update_icon(UPDATE_ICON_STATE)
update_equipped_item(update_buttons)
-
- if(light_on)
- set_light(brightness_on)
- else
- set_light(0)
+ set_light(light_on ? brightness_on : 0)
/obj/item/clothing/head/helmet/space/hardsuit/item_action_slot_check(slot)
@@ -150,8 +147,7 @@
/obj/item/clothing/suit/space/hardsuit/Destroy()
- if(helmet)
- QDEL_NULL(helmet)
+ QDEL_NULL(helmet)
QDEL_NULL(jetpack)
return ..()
@@ -168,24 +164,21 @@
/obj/item/clothing/suit/space/hardsuit/equipped(mob/user, slot, initial)
. = ..()
- if(suit_adjusted)
- RemoveHelmet()
+ RemoveHelmet(user)
/obj/item/clothing/suit/space/hardsuit/dropped(mob/user, silent = FALSE)
. = ..()
- if(suit_adjusted)
- RemoveHelmet()
+ RemoveHelmet(user)
/obj/item/clothing/suit/space/hardsuit/MouseDrop(atom/over_object, src_location, over_location, src_control, over_control, params)
- if(suit_adjusted)
- RemoveHelmet()
- return ..()
+ RemoveHelmet(usr)
+ . = ..()
/obj/item/clothing/suit/space/hardsuit/ui_action_click(mob/user)
- ToggleHelmet()
+ ToggleHelmet(user)
/obj/item/clothing/suit/space/hardsuit/item_action_slot_check(slot)
@@ -198,33 +191,29 @@
..()
-/obj/item/clothing/suit/space/hardsuit/proc/ToggleHelmet()
- var/mob/living/carbon/human/user = loc
- if(!ishuman(user) || !helmet)
+/obj/item/clothing/suit/space/hardsuit/proc/ToggleHelmet(mob/living/carbon/human/user)
+ if(!helmet || !ishuman(user))
return
- if(taser_proof && taser_proof.ert_mindshield_locked)
+ if(taser_proof?.ert_mindshield_locked)
if(isertmindshielded(user))
to_chat(user, span_notice("Access granted, identity verified..."))
else
to_chat(user, span_warning("Access denied. The user is not identified!"))
return
if(suit_adjusted)
- RemoveHelmet()
+ RemoveHelmet(user)
return
if(user.wear_suit != src)
to_chat(user, span_warning("You must be wearing [src] to engage the helmet!"))
return
- EngageHelmet()
+ EngageHelmet(user)
-/obj/item/clothing/suit/space/hardsuit/proc/EngageHelmet()
- if(!helmet)
- return FALSE
- var/mob/living/carbon/human/user = loc
- if(!ishuman(user))
+/obj/item/clothing/suit/space/hardsuit/proc/EngageHelmet(mob/living/carbon/human/user)
+ if(!helmet || suit_adjusted)
return FALSE
if(user.head)
- to_chat(usr, span_warning("You're already wearing something on your head!"))
+ to_chat(user, span_warning("You're already wearing something on your head!"))
return FALSE
if(!user.equip_to_slot(helmet, slot_head))
return FALSE
@@ -236,14 +225,17 @@
playsound(user, 'sound/items/rig_deploy.ogg', 110, TRUE)
-/obj/item/clothing/suit/space/hardsuit/proc/RemoveHelmet()
+/obj/item/clothing/suit/space/hardsuit/proc/RemoveHelmet(mob/living/carbon/human/user)
if(!helmet)
return FALSE
+ if(!suit_adjusted)
+ if(helmet.loc != src) // in case helmet was dropped on equip and hardsuit is already adjusted
+ helmet.forceMove(src)
+ return FALSE
. = TRUE
suit_adjusted = FALSE
- var/mob/living/carbon/human/user = loc
if(helmet.light_on)
- helmet.toggle_light(enable = FALSE)
+ helmet.toggle_light(enable = FALSE, update_buttons = FALSE)
if(ishuman(user))
user.temporarily_remove_item_from_inventory(helmet, force = TRUE)
user.update_inv_wear_suit()
@@ -474,7 +466,7 @@
desc = "[initial(desc)][on ? "" : alt_desc]"
-/obj/item/clothing/suit/space/hardsuit/syndi/EngageHelmet()
+/obj/item/clothing/suit/space/hardsuit/syndi/EngageHelmet(mob/living/carbon/human/user)
. = ..()
if(. && on)
helmet?.toggle_light(enable = TRUE, update_buttons = FALSE)
diff --git a/code/modules/clothing/suits/hood.dm b/code/modules/clothing/suits/hood.dm
index ebdd618eae4..0fef11d8f22 100644
--- a/code/modules/clothing/suits/hood.dm
+++ b/code/modules/clothing/suits/hood.dm
@@ -33,8 +33,8 @@
icon_state = "[item_color][suit_adjusted ? "_hood" : ""]"
-/obj/item/clothing/suit/hooded/ui_action_click()
- ToggleHood()
+/obj/item/clothing/suit/hooded/ui_action_click(mob/user)
+ ToggleHood(user)
/obj/item/clothing/suit/hooded/item_action_slot_check(slot, mob/user)
@@ -44,40 +44,33 @@
/obj/item/clothing/suit/hooded/equipped(mob/user, slot, initial = FALSE)
. = ..()
- if(suit_adjusted)
- RemoveHood()
+ RemoveHood(user)
/obj/item/clothing/suit/hooded/dropped(mob/user, silent = FALSE)
. = ..()
- if(suit_adjusted)
- RemoveHood()
+ RemoveHood(user)
/obj/item/clothing/suit/hooded/MouseDrop(atom/over_object, src_location, over_location, src_control, over_control, params)
- if(suit_adjusted)
- RemoveHood()
- return ..()
+ RemoveHood(usr)
+ . = ..()
-/obj/item/clothing/suit/hooded/proc/ToggleHood()
- var/mob/living/carbon/human/user = loc
+/obj/item/clothing/suit/hooded/proc/ToggleHood(mob/living/carbon/human/user)
if(!ishuman(user) || !hood)
return
if(suit_adjusted)
- RemoveHood()
+ RemoveHood(user)
return
if(user.wear_suit != src)
to_chat(user, span_warning("You must be wearing [src] to put up the hood!"))
return
- EngageHood()
+ EngageHood(user)
-/obj/item/clothing/suit/hooded/proc/EngageHood()
- if(!hood)
- return FALSE
- var/mob/living/carbon/human/user = loc
- if(!ishuman(user))
+/obj/item/clothing/suit/hooded/proc/EngageHood(mob/living/carbon/human/user)
+ if(!hood || suit_adjusted)
return FALSE
if(user.head)
to_chat(user, span_warning("You're already wearing something on your head!"))
@@ -92,13 +85,16 @@
user.update_inv_wear_suit()
-/obj/item/clothing/suit/hooded/proc/RemoveHood()
+/obj/item/clothing/suit/hooded/proc/RemoveHood(mob/living/carbon/human/user)
if(!hood)
return FALSE
+ if(!suit_adjusted)
+ if(hood.loc != src) // in case hood was dropped on equip and suit is already adjusted
+ hood.forceMove(src)
+ return FALSE
. = TRUE
suit_adjusted = FALSE
update_icon(UPDATE_ICON_STATE)
- var/mob/living/carbon/human/user = loc
if(ishuman(user))
user.temporarily_remove_item_from_inventory(hood, force = TRUE)
user.update_inv_wear_suit()
@@ -117,26 +113,27 @@
return ..()
-/obj/item/clothing/head/hooded/equipped(mob/user, slot, initial = FALSE)
+/obj/item/clothing/head/hooded/equipped(mob/living/carbon/user, slot, initial = FALSE)
. = ..()
- if(slot != slot_head)
- if(suit)
- suit.RemoveHood()
- else
- qdel(src)
+ if(!suit)
+ qdel(src)
+ return FALSE
+ if(slot != slot_head || user.wear_suit != suit)
+ user.drop_item_ground(src, force = TRUE, silent = TRUE)
+ return FALSE
/obj/item/clothing/head/hooded/dropped(mob/user, silent = FALSE)
. = ..()
- if(suit && loc != suit)
- forceMove(suit)
+ if(suit)
+ suit.RemoveHood(user)
else
qdel(src)
/obj/item/clothing/head/hooded/MouseDrop(atom/over, src_location, over_location, src_control, over_control, params)
if(suit)
- suit.RemoveHood()
+ suit.RemoveHood(usr)
else
qdel(src)
diff --git a/code/modules/mob/inventory.dm b/code/modules/mob/inventory.dm
index 74774c23ce3..0bc7fb1fcf6 100644
--- a/code/modules/mob/inventory.dm
+++ b/code/modules/mob/inventory.dm
@@ -292,7 +292,7 @@
* DO NO USE THIS PROC, there are plenty of helpers below: put_in_l_hand, put_in_active_hand, put_in_hands etc.
* Puts an item into hand by `hand_id` ("HAND_LEFT" / "HAND_RIGHT") and calls all necessary triggers/updates. Returns `TRUE` on success.
*/
-/mob/proc/put_in_hand(obj/item/I, hand_id, force = FALSE, ignore_anim = TRUE)
+/mob/proc/put_in_hand(obj/item/I, hand_id, force = FALSE, ignore_anim = TRUE, silent = FALSE)
// Its always 'TRUE' if there is no item, since we are using helpers with this proc in 'if()' statements
if(!I)
@@ -310,7 +310,7 @@
else if(hand_id == "HAND_RIGHT")
hand_item = r_hand
if(hand_item)
- drop_item_ground(hand_item, force = TRUE)
+ drop_item_ground(hand_item, force = TRUE, silent = silent)
I.forceMove(src)
I.pixel_x = initial(I.pixel_x)
@@ -318,11 +318,11 @@
if(hand_id == "HAND_LEFT")
l_hand = I
- I.equipped(src, slot_l_hand)
+ I.equipped(src, slot_l_hand, silent)
update_inv_l_hand()
else if(hand_id == "HAND_RIGHT")
r_hand = I
- I.equipped(src, slot_r_hand)
+ I.equipped(src, slot_r_hand, silent)
update_inv_r_hand()
if(pulling == I)
@@ -347,35 +347,35 @@
/**
* Puts item into `l_hand` if possible and calls all necessary triggers/updates. Returns `TRUE` on success.
*/
-/mob/proc/put_in_l_hand(obj/item/I, force = FALSE, ignore_anim = TRUE)
- return put_in_hand(I, "HAND_LEFT", force, ignore_anim)
+/mob/proc/put_in_l_hand(obj/item/I, force = FALSE, ignore_anim = TRUE, silent = FALSE)
+ return put_in_hand(I, "HAND_LEFT", force, ignore_anim, silent)
/**
* Puts item into `r_hand` if possible and calls all necessary triggers/updates. Returns `TRUE` on success.
*/
-/mob/proc/put_in_r_hand(obj/item/I, force = FALSE, ignore_anim = TRUE)
- return put_in_hand(I, "HAND_RIGHT", force, ignore_anim)
+/mob/proc/put_in_r_hand(obj/item/I, force = FALSE, ignore_anim = TRUE, silent = FALSE)
+ return put_in_hand(I, "HAND_RIGHT", force, ignore_anim, silent)
/**
* Puts item into active hand if possible. Returns `TRUE` on success.
*/
-/mob/proc/put_in_active_hand(obj/item/I, force = FALSE, ignore_anim = TRUE)
+/mob/proc/put_in_active_hand(obj/item/I, force = FALSE, ignore_anim = TRUE, silent = FALSE)
if(hand)
- return put_in_l_hand(I, force, ignore_anim)
+ return put_in_l_hand(I, force, ignore_anim, silent)
else
- return put_in_r_hand(I, force, ignore_anim)
+ return put_in_r_hand(I, force, ignore_anim, silent)
/**
* Puts item into inactive hand if possible. Returns `TRUE` on success.
*/
-/mob/proc/put_in_inactive_hand(obj/item/I, force = FALSE, ignore_anim = TRUE)
+/mob/proc/put_in_inactive_hand(obj/item/I, force = FALSE, ignore_anim = TRUE, silent = FALSE)
if(hand)
- return put_in_r_hand(I, force, ignore_anim)
+ return put_in_r_hand(I, force, ignore_anim, silent)
else
- return put_in_l_hand(I, force, ignore_anim)
+ return put_in_l_hand(I, force, ignore_anim, silent)
/**
@@ -388,8 +388,9 @@
* * 'qdel_on_fail' qdels item if failed to pick in both hands.
* * 'merge_stacks' set to `TRUE` to allow stack auto-merging even when both hands are full.
* * 'ignore_anim' set to `TRUE` to prevent pick up animation.
+ * * 'silent' set to `TRUE` to stop pick up sounds.
*/
-/mob/proc/put_in_hands(obj/item/I, force = FALSE, qdel_on_fail = FALSE, merge_stacks = TRUE, ignore_anim = TRUE)
+/mob/proc/put_in_hands(obj/item/I, force = FALSE, qdel_on_fail = FALSE, merge_stacks = TRUE, ignore_anim = TRUE, silent = FALSE)
return FALSE
diff --git a/code/modules/mob/living/carbon/inventory.dm b/code/modules/mob/living/carbon/inventory.dm
index a64029fa247..c2fd9d708c0 100644
--- a/code/modules/mob/living/carbon/inventory.dm
+++ b/code/modules/mob/living/carbon/inventory.dm
@@ -368,8 +368,9 @@
* * 'qdel_on_fail' qdels item if failed to pick in both hands.
* * 'merge_stacks' set to `TRUE` to allow stack auto-merging even when both hands are full.
* * 'ignore_anim' set to `TRUE` to prevent pick up animation.
+ * * 'silent' set to `TRUE` to stop pick up sounds.
*/
-/mob/living/carbon/put_in_hands(obj/item/I, force = FALSE, qdel_on_fail = FALSE, merge_stacks = TRUE, ignore_anim = TRUE)
+/mob/living/carbon/put_in_hands(obj/item/I, force = FALSE, qdel_on_fail = FALSE, merge_stacks = TRUE, ignore_anim = TRUE, silent = FALSE)
// Its always TRUE if there is no item, since we are using this proc in 'if()' statements
if(!I)
@@ -384,7 +385,7 @@
I.pixel_y = initial(I.pixel_y)
I.layer = initial(I.layer)
I.plane = initial(I.plane)
- I.dropped(src)
+ I.dropped(src, silent)
return TRUE
// If the item is a stack and we're already holding a stack then merge
@@ -411,9 +412,9 @@
to_chat(src, span_notice("Your [inactive_stack.name] stack now contains [inactive_stack.get_amount()] [inactive_stack.singular_name]\s."))
return TRUE
- if(put_in_active_hand(I, force, ignore_anim))
+ if(put_in_active_hand(I, force, ignore_anim, silent))
return TRUE
- if(put_in_inactive_hand(I, force, ignore_anim))
+ if(put_in_inactive_hand(I, force, ignore_anim, silent))
return TRUE
if(qdel_on_fail)
@@ -423,7 +424,7 @@
I.forceMove(drop_location())
I.layer = initial(I.layer)
I.plane = initial(I.plane)
- I.dropped(src)
+ I.dropped(src, silent)
return FALSE
diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm
index 823837544df..eb89bf2f679 100644
--- a/code/modules/mob/living/living.dm
+++ b/code/modules/mob/living/living.dm
@@ -981,9 +981,9 @@
what.add_fingerprint(src)
if(do_mob(src, who, what.strip_delay))
if(what && what == who.get_item_by_slot(where) && Adjacent(who))
- who.drop_item_ground(what)
+ who.drop_item_ground(what, silent = silent)
if(silent)
- put_in_hands(what)
+ put_in_hands(what, silent = TRUE)
add_attack_logs(src, who, "Stripped of [what]")
// The src mob is trying to place an item on someone
@@ -1001,8 +1001,8 @@
visible_message("[src] tries to put [what] on [who].")
if(do_mob(src, who, what.put_on_delay))
if(what && Adjacent(who) && !(what.flags & NODROP))
- drop_item_ground(what)
- who.equip_to_slot_if_possible(what, where, disable_warning = TRUE)
+ drop_item_ground(what, silent = silent)
+ who.equip_to_slot_if_possible(what, where, disable_warning = TRUE, initial = silent)
add_attack_logs(src, who, "Equipped [what]")
/mob/living/singularity_act()
diff --git a/code/modules/mob/living/simple_animal/friendly/diona.dm b/code/modules/mob/living/simple_animal/friendly/diona.dm
index 7d20b768b46..e3bf7eac00f 100644
--- a/code/modules/mob/living/simple_animal/friendly/diona.dm
+++ b/code/modules/mob/living/simple_animal/friendly/diona.dm
@@ -271,7 +271,7 @@
to_chat(src, "The blood seeps into your small form, and you draw out the echoes of memories and personality from it, working them into your budding mind.")
-/mob/living/simple_animal/diona/put_in_hands(obj/item/I, force = FALSE, qdel_on_fail = FALSE, merge_stacks = TRUE, ignore_anim = TRUE)
+/mob/living/simple_animal/diona/put_in_hands(obj/item/I, force = FALSE, qdel_on_fail = FALSE, merge_stacks = TRUE, ignore_anim = TRUE, silent = FALSE)
I.forceMove(drop_location())
I.pixel_x = initial(I.pixel_x)
I.pixel_y = initial(I.pixel_y)