diff --git a/code/game/objects/structures/crates_lockers/closets/secure/security.dm b/code/game/objects/structures/crates_lockers/closets/secure/security.dm index 8f7f34164c0..9700a3e80fa 100755 --- a/code/game/objects/structures/crates_lockers/closets/secure/security.dm +++ b/code/game/objects/structures/crates_lockers/closets/secure/security.dm @@ -183,6 +183,7 @@ new /obj/item/pinpointer/crew(src) new /obj/item/binoculars(src) new /obj/item/storage/box/rxglasses/spyglasskit(src) + new /obj/item/clothing/head/fedora/inspector_hat(src) /obj/structure/closet/secure_closet/injection name = "lethal injections" diff --git a/code/modules/clothing/head/jobs.dm b/code/modules/clothing/head/jobs.dm index fd30bdd742f..4022e259505 100644 --- a/code/modules/clothing/head/jobs.dm +++ b/code/modules/clothing/head/jobs.dm @@ -206,6 +206,116 @@ /obj/item/clothing/head/fedora/det_hat/minor flask_path = /obj/item/reagent_containers/cup/glass/flask/det/minor +///Detectives Fedora, but like Inspector Gadget. Not a subtype to not inherit candy corn stuff +/obj/item/clothing/head/fedora/inspector_hat + name = "inspector's fedora" + desc = "There's only one man can try to stop an evil villian." + armor_type = /datum/armor/fedora_det_hat + icon_state = "detective" + inhand_icon_state = "det_hat" + dog_fashion = /datum/dog_fashion/head/detective + ///prefix our phrases must begin with + var/prefix = "go go gadget" + ///an assoc list of phrase = item (like gun = revolver) + var/list/items_by_phrase = list() + ///how many gadgets can we hold + var/max_items = 4 + ///items above this weight cannot be put in the hat + var/max_weight = WEIGHT_CLASS_NORMAL + +/obj/item/clothing/head/fedora/inspector_hat/Initialize(mapload) + . = ..() + become_hearing_sensitive(ROUNDSTART_TRAIT) + QDEL_NULL(atom_storage) + +/obj/item/clothing/head/fedora/inspector_hat/examine(mob/user) + . = ..() + . += span_notice("You can put items inside, and get them out by saying a phrase, or using it in-hand!") + . += span_notice("The prefix is [prefix], and you can change it with alt-click!\n") + for(var/phrase in items_by_phrase) + var/obj/item/item = items_by_phrase[phrase] + . += span_notice("[icon2html(item, user)] You can remove [item] by saying \"[prefix] [phrase]\"!") + +/obj/item/clothing/head/fedora/inspector_hat/Hear(message, atom/movable/speaker, message_language, raw_message, radio_freq, list/spans, list/message_mods = list(), message_range) + . = ..() + var/mob/living/carbon/wearer = loc + if(!istype(wearer) || speaker != wearer) //if we are worn + return FALSE + + raw_message = htmlrendertext(raw_message) + var/prefix_index = findtext(raw_message, prefix) + if(prefix_index != 1) + return FALSE + + var/the_phrase = trim_left(replacetext(raw_message, prefix, "")) + var/obj/item/result = items_by_phrase[the_phrase] + if(!result) + return FALSE + + if(wearer.put_in_active_hand(result)) + wearer.visible_message(span_warning("[src] drops [result] into the hands of [wearer]!")) + else + balloon_alert(wearer, "cant put in hands!") + + return TRUE + +/obj/item/clothing/head/fedora/inspector_hat/attackby(obj/item/item, mob/user, params) + . = ..() + + if(LAZYLEN(contents) >= max_items) + balloon_alert(user, "full!") + return + if(item.w_class > max_weight) + balloon_alert(user, "too big!") + return + + var/input = tgui_input_text(user, "What is the activation phrase?", "Activation phrase", "gadget", max_length = 26) + if(!input) + return + if(input in items_by_phrase) + balloon_alert(user, "already used!") + return + + if(item.loc != user || !user.transferItemToLoc(item, src)) + return + + to_chat(user, span_notice("You install [item] into the [thtotext(contents.len)] slot in [src].")) + playsound(src, 'sound/machines/click.ogg', 30, TRUE) + items_by_phrase[input] = item + +/obj/item/clothing/head/fedora/inspector_hat/attack_self(mob/user) + . = ..() + var/phrase = tgui_input_list(user, "What item do you want to remove by phrase?", "Item Removal", items_by_phrase) + if(!phrase) + return + user.put_in_inactive_hand(items_by_phrase[phrase]) + +/obj/item/clothing/head/fedora/inspector_hat/AltClick(mob/user) + . = ..() + var/new_prefix = tgui_input_text(user, "What should be the new prefix?", "Activation prefix", prefix, max_length = 24) + if(!new_prefix) + return + prefix = new_prefix + +/obj/item/clothing/head/fedora/inspector_hat/Exited(atom/movable/gone, direction) + . = ..() + for(var/phrase in items_by_phrase) + var/obj/item/result = items_by_phrase[phrase] + if(gone == result) + items_by_phrase -= phrase + return + +/obj/item/clothing/head/fedora/inspector_hat/atom_destruction(damage_flag) + for(var/phrase in items_by_phrase) + var/obj/item/result = items_by_phrase[phrase] + result.forceMove(drop_location()) + items_by_phrase = null + return ..() + +/obj/item/clothing/head/fedora/inspector_hat/Destroy() + QDEL_LIST_ASSOC(items_by_phrase) + return ..() + //Mime /obj/item/clothing/head/beret name = "beret"