diff --git a/code/modules/clothing/suits/ablativecoat.dm b/code/modules/clothing/suits/ablativecoat.dm index 32366d06193..527cded1ef8 100644 --- a/code/modules/clothing/suits/ablativecoat.dm +++ b/code/modules/clothing/suits/ablativecoat.dm @@ -39,14 +39,14 @@ return TRUE /obj/item/clothing/suit/hooded/ablative/ToggleHood() - if (hood_up) - return ..() + . = ..() + if (!hood_up) + return var/mob/living/carbon/user = loc var/datum/atom_hud/hud = GLOB.huds[DATA_HUD_SECURITY_ADVANCED] ADD_TRAIT(user, TRAIT_SECURITY_HUD, HELMET_TRAIT) hud.show_to(user) balloon_alert(user, "you put on the hood, and enable the hud") - return ..() /obj/item/clothing/suit/hooded/ablative/RemoveHood() if (!hood_up) diff --git a/code/modules/unit_tests/_unit_tests.dm b/code/modules/unit_tests/_unit_tests.dm index da4370b3b12..615e2609c2b 100644 --- a/code/modules/unit_tests/_unit_tests.dm +++ b/code/modules/unit_tests/_unit_tests.dm @@ -75,6 +75,7 @@ #include "~skyrat/opposing_force.dm" #include "~skyrat/automapper.dm" //SKYRAT EDIT END +#include "ablative_hud.dm" #include "achievements.dm" #include "anchored_mobs.dm" #include "anonymous_themes.dm" diff --git a/code/modules/unit_tests/ablative_hud.dm b/code/modules/unit_tests/ablative_hud.dm new file mode 100644 index 00000000000..b8b2efc188c --- /dev/null +++ b/code/modules/unit_tests/ablative_hud.dm @@ -0,0 +1,25 @@ +/// Check that player gains and loses sec hud when toggling the ablative hood +/datum/unit_test/ablative_hood_hud + +/datum/unit_test/ablative_hood_hud/Run() + var/mob/living/carbon/human/person = allocate(/mob/living/carbon/human) + var/obj/item/clothing/suit/hooded/ablative/coat = allocate(/obj/item/clothing/suit/hooded/ablative) + person.equip_to_slot(coat, ITEM_SLOT_OCLOTHING) + TEST_ASSERT(!HAS_TRAIT(person, TRAIT_SECURITY_HUD), "Person already had a sechud before trying to equip the ablative hood.") + coat.ToggleHood() + TEST_ASSERT(HAS_TRAIT(person, TRAIT_SECURITY_HUD), "Person toggled the ablative hood but didn't gain a sechud.") + coat.ToggleHood() + TEST_ASSERT(!HAS_TRAIT(person, TRAIT_SECURITY_HUD), "Person lowered their ablative hood but still has a sechud.") + +// Check that player doesn't gain sec hud if the hood is toggled when already wearing a helmet +/datum/unit_test/ablative_hood_hud_with_helmet + +/datum/unit_test/ablative_hood_hud_with_helmet/Run() + var/mob/living/carbon/human/person = allocate(/mob/living/carbon/human) + var/obj/item/clothing/suit/hooded/ablative/coat = allocate(/obj/item/clothing/suit/hooded/ablative) + var/obj/item/clothing/head/helmet/hat = allocate(/obj/item/clothing/head/helmet) + person.equip_to_slot(coat, ITEM_SLOT_OCLOTHING) + person.equip_to_slot(hat, ITEM_SLOT_HEAD) + TEST_ASSERT(!HAS_TRAIT(person, TRAIT_SECURITY_HUD), "Person already had a sechud before trying to equip the ablative hood.") + coat.ToggleHood() + TEST_ASSERT(!HAS_TRAIT(person, TRAIT_SECURITY_HUD), "Person has gained a sechud from toggling the ablative hood despite already wearing a helmet.")