Skip to content

Commit

Permalink
bugfix: Hardsuit Fixes (#4496)
Browse files Browse the repository at this point in the history
Hardsuit Fixes
  • Loading branch information
Gottfrei authored Feb 28, 2024
1 parent d256454 commit 960cd9d
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 100 deletions.
4 changes: 2 additions & 2 deletions code/datums/outfits/outfit.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/clockwork/clockwork_items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@
to_chat(carbon, "<span class='danger'>Robe tightens, as it frees you to be flexible around!</span>")
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
76 changes: 34 additions & 42 deletions code/modules/clothing/spacesuits/hardsuit.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand Down Expand Up @@ -150,8 +147,7 @@


/obj/item/clothing/suit/space/hardsuit/Destroy()
if(helmet)
QDEL_NULL(helmet)
QDEL_NULL(helmet)
QDEL_NULL(jetpack)
return ..()

Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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)
Expand Down
55 changes: 26 additions & 29 deletions code/modules/clothing/suits/hood.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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!"))
Expand All @@ -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()
Expand All @@ -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)

Loading

0 comments on commit 960cd9d

Please sign in to comment.