From 7886e4830c4bcebcb01cc108395935a75c4717e5 Mon Sep 17 00:00:00 2001 From: Geeves Date: Sun, 29 Jan 2023 13:46:27 +0200 Subject: [PATCH] Helmet Storage Framework (#15615) --- code/__defines/obj.dm | 2 + .../items/weapons/material/material_armor.dm | 5 +- .../objects/items/weapons/storage/internal.dm | 33 +++++++++++ .../objects/items/weapons/storage/storage.dm | 4 +- code/modules/clothing/head/helmet.dm | 54 ++++++++++++++++++ code/modules/clothing/head/pilot_helmet.dm | 6 +- code/modules/clothing/head/xenos/tajara.dm | 5 +- .../modules/clothing/spacesuits/spacesuits.dm | 2 + html/changelogs/geeves-helmet_storage.yml | 6 ++ icons/clothing/kit/helmet_garb.dmi | Bin 0 -> 746 bytes 10 files changed, 112 insertions(+), 5 deletions(-) create mode 100644 html/changelogs/geeves-helmet_storage.yml create mode 100644 icons/clothing/kit/helmet_garb.dmi diff --git a/code/__defines/obj.dm b/code/__defines/obj.dm index fbd3da5097c..8128c6ad2e5 100644 --- a/code/__defines/obj.dm +++ b/code/__defines/obj.dm @@ -83,3 +83,5 @@ if(tool.iswirecutter() && (!requires_surgery_compatibility || tool.issurgerycompatible())) return return_value return null + +#define HELMET_GARB_PASS_ICON "pass_icon" diff --git a/code/game/objects/items/weapons/material/material_armor.dm b/code/game/objects/items/weapons/material/material_armor.dm index f07465c629b..928375fa105 100644 --- a/code/game/objects/items/weapons/material/material_armor.dm +++ b/code/game/objects/items/weapons/material/material_armor.dm @@ -103,6 +103,8 @@ Protectiveness | Armor % ) contained_sprite = 1 + has_storage = FALSE + /obj/item/clothing/head/helmet/bucket/wood name = "wooden bucket helmet" icon = 'icons/obj/clothing/material_armor.dmi' @@ -129,6 +131,7 @@ Protectiveness | Armor % name = "helmet" flags_inv = HIDEEARS|HIDEEYES|BLOCKHAIR default_material = DEFAULT_WALL_MATERIAL + has_storage = FALSE /obj/item/clothing/head/helmet/material/makeshift name = "bucket helmet" @@ -159,4 +162,4 @@ Protectiveness | Armor % qdel(src) qdel(kelly) else - ..() \ No newline at end of file + ..() diff --git a/code/game/objects/items/weapons/storage/internal.dm b/code/game/objects/items/weapons/storage/internal.dm index 50b933e1b8d..2a4e19e25ba 100644 --- a/code/game/objects/items/weapons/storage/internal.dm +++ b/code/game/objects/items/weapons/storage/internal.dm @@ -97,3 +97,36 @@ /obj/item/storage/internal/skrell/Initialize() . = ..() name = initial(name) + +// Helmet Slots +/obj/item/storage/internal/helmet + var/list/helmet_storage_types = list( + /obj/item/storage/box/fancy/cigarettes = HELMET_GARB_PASS_ICON, + /obj/item/storage/box/fancy/cigarettes/acmeco = HELMET_GARB_PASS_ICON, + /obj/item/storage/box/fancy/cigarettes/blank = HELMET_GARB_PASS_ICON, + /obj/item/storage/box/fancy/cigarettes/dromedaryco = HELMET_GARB_PASS_ICON, + /obj/item/storage/box/fancy/cigarettes/nicotine = HELMET_GARB_PASS_ICON, + /obj/item/storage/box/fancy/cigarettes/rugged = HELMET_GARB_PASS_ICON, + /obj/item/storage/box/fancy/cigarettes/pra = HELMET_GARB_PASS_ICON, + /obj/item/storage/box/fancy/cigarettes/dpra = HELMET_GARB_PASS_ICON, + /obj/item/storage/box/fancy/cigarettes/nka = HELMET_GARB_PASS_ICON + ) + can_hold_strict = TRUE + +/obj/item/storage/internal/helmet/Initialize(mapload, defer_shrinkwrap) + . = ..() + can_hold = list() + for(var/thing_type in helmet_storage_types) + can_hold += thing_type + +/obj/item/storage/internal/helmet/handle_item_insertion(obj/item/W, prevent_messages) + . = ..() + if(. && istype(loc, /obj/item/clothing/head/helmet)) + var/obj/item/clothing/head/helmet/helmet = loc + helmet.update_clothing_icon() + +/obj/item/storage/internal/helmet/remove_from_storage(obj/item/W, atom/new_location) + . = ..() + if(. && istype(loc, /obj/item/clothing/head/helmet)) + var/obj/item/clothing/head/helmet/helmet = loc + helmet.update_clothing_icon() diff --git a/code/game/objects/items/weapons/storage/storage.dm b/code/game/objects/items/weapons/storage/storage.dm index f9c2ebfab22..c960f577828 100644 --- a/code/game/objects/items/weapons/storage/storage.dm +++ b/code/game/objects/items/weapons/storage/storage.dm @@ -17,6 +17,7 @@ icon = 'icons/obj/storage.dmi' w_class = ITEMSIZE_NORMAL var/list/can_hold //List of objects which this item can store (if set, it can't store anything else) + var/can_hold_strict = FALSE // if strict, the exact path has to be matched var/list/cant_hold //List of objects which this item can't store (in effect only if can_hold isn't set) var/list/is_seeing //List of mobs which are currently seeing the contents of this item's storage var/max_w_class = ITEMSIZE_NORMAL //Max size of objects that this object can store (in effect only if can_hold isn't set) @@ -354,7 +355,8 @@ return 0 if(LAZYLEN(can_hold)) - if(!is_type_in_list(W, can_hold)) + var/can_hold_item = can_hold_strict ? (W.type in can_hold) : is_type_in_list(W, can_hold) + if(!can_hold_item) if(!stop_messages && ! istype(W, /obj/item/device/hand_labeler)) to_chat(usr, "[src] cannot hold \the [W].") return 0 diff --git a/code/modules/clothing/head/helmet.dm b/code/modules/clothing/head/helmet.dm index 81200cc6c33..49831d6f728 100644 --- a/code/modules/clothing/head/helmet.dm +++ b/code/modules/clothing/head/helmet.dm @@ -25,10 +25,59 @@ drop_sound = 'sound/items/drop/helm.ogg' pickup_sound = 'sound/items/pickup/helm.ogg' + var/has_storage = TRUE + var/obj/item/storage/internal/helmet/hold + var/slots = 1 + /obj/item/clothing/head/helmet/Initialize() . = ..() if(camera) verbs += /obj/item/clothing/head/helmet/proc/toggle_camera + if(has_storage) + hold = new /obj/item/storage/internal/helmet(src) + hold.storage_slots = slots + hold.max_storage_space = slots * ITEMSIZE_SMALL + hold.max_w_class = ITEMSIZE_SMALL + +/obj/item/clothing/head/helmet/get_mob_overlay(var/mob/living/carbon/human/H, var/mob_icon, var/mob_state, var/slot) + var/image/I = ..() + if(has_storage && slot == slot_head_str && length(hold.contents)) + for(var/obj/item/thing in hold.contents) + var/icon_type = hold.helmet_storage_types[thing.type] + var/thing_state = icon_type == HELMET_GARB_PASS_ICON ? initial(thing.icon_state) : icon_type + I.add_overlay(image('icons/clothing/kit/helmet_garb.dmi', null, thing_state)) + I.add_overlay(image('icons/clothing/kit/helmet_garb.dmi', null, "helmet_band")) + return I + +/obj/item/clothing/head/helmet/attack_hand(mob/user) + if(has_storage && !hold.handle_attack_hand(user)) + return + return ..(user) + +/obj/item/clothing/head/helmet/MouseDrop(obj/over_object) + if(has_storage && !hold.handle_mousedrop(usr, over_object)) + return + return ..(over_object) + +/obj/item/clothing/head/helmet/handle_middle_mouse_click(mob/user) + if(has_storage && Adjacent(user)) + hold.open(user) + return TRUE + return FALSE + +/obj/item/clothing/head/helmet/attackby(obj/item/W, mob/user) + . = ..() + if(!has_storage || istype(W, /obj/item/clothing/accessory)) + return + hold.attackby(W, user) + +/obj/item/clothing/head/helmet/emp_act(severity) + if(has_storage) hold.emp_act(severity) + return ..() + +/obj/item/clothing/head/helmet/hear_talk(mob/M, var/msg, verb, datum/language/speaking) + if(has_storage) hold.hear_talk(M, msg, verb, speaking) + return ..() /obj/item/clothing/head/helmet/proc/toggle_camera() set name = "Toggle Helmet Camera" @@ -64,18 +113,21 @@ name = "dermal armor patch" desc = "You're not quite sure how you manage to take it on and off, but it implants nicely in your head." icon_state = "dermal" + has_storage = FALSE allow_hair_covering = FALSE /obj/item/clothing/head/helmet/hop name = "crew resource's hat" desc = "A stylish hat that both protects you from enraged former-crewmembers and gives you a false sense of authority." icon_state = "hopcap" + has_storage = FALSE flags_inv = 0 /obj/item/clothing/head/helmet/formalcaptain name = "parade hat" desc = "No one in a commanding position should be without a perfect, white hat of ultimate authority." icon_state = "officercap" + has_storage = FALSE flags_inv = 0 /obj/item/clothing/head/helmet/riot @@ -229,6 +281,7 @@ flags_inv = HIDEMASK|HIDEEARS|HIDEEYES|BLOCKHAIR body_parts_covered = HEAD|FACE siemens_coefficient = 1 + has_storage = FALSE /obj/item/clothing/head/helmet/tactical name = "tactical helmet" @@ -337,6 +390,7 @@ melee = ARMOR_MELEE_KNIVES ) siemens_coefficient = 0.75 + has_storage = FALSE /obj/item/clothing/head/helmet/tank/olive color = "#727c58" diff --git a/code/modules/clothing/head/pilot_helmet.dm b/code/modules/clothing/head/pilot_helmet.dm index 6079dd904e2..0584fe875c7 100644 --- a/code/modules/clothing/head/pilot_helmet.dm +++ b/code/modules/clothing/head/pilot_helmet.dm @@ -29,6 +29,8 @@ var/obj/pilot_overlay_holder/hud_overlay var/obj/pilot_overlay_holder/ship_hud/ship_overlay + has_storage = FALSE + /obj/item/clothing/head/helmet/pilot/Initialize() . = ..() hud_overlay = new(src) @@ -48,7 +50,7 @@ if(linked_helm) linked_helm.linked_helmets -= src linked_helm = null - + if(!isnull(C)) if(istype(C, /obj/machinery/computer/shuttle_control)) linked_console = C @@ -155,4 +157,4 @@ maptext_width = 192 /obj/pilot_overlay_holder/ship_hud - screen_loc = "CENTER:90,NORTH:-10" \ No newline at end of file + screen_loc = "CENTER:90,NORTH:-10" diff --git a/code/modules/clothing/head/xenos/tajara.dm b/code/modules/clothing/head/xenos/tajara.dm index f691c952105..db2bb2d40b9 100644 --- a/code/modules/clothing/head/xenos/tajara.dm +++ b/code/modules/clothing/head/xenos/tajara.dm @@ -156,6 +156,8 @@ and the People's Republic of Adhomai looms over the southern end of the island..." siemens_coefficient = 0.35 + has_storage = FALSE + /obj/item/clothing/head/helmet/kettle name = "kettle helmet" desc = "A kettle helmet used by the forces of the new Kingdom of Adhomai." @@ -170,6 +172,7 @@ energy = ARMOR_ENERGY_MINOR, bomb = ARMOR_BOMB_MINOR ) + has_storage = FALSE /obj/item/clothing/head/tajaran/nka_merchant_navy name = "her majesty's mercantile flotilla cap" @@ -196,4 +199,4 @@ item_state = "ala-grunt-wraps-hood" flags_inv = HIDEMASK|HIDEEARS|HIDEEYES|HIDEFACE|BLOCKHAIR body_parts_covered = HEAD|FACE|EYES - species_restricted = list(BODYTYPE_TAJARA) \ No newline at end of file + species_restricted = list(BODYTYPE_TAJARA) diff --git a/code/modules/clothing/spacesuits/spacesuits.dm b/code/modules/clothing/spacesuits/spacesuits.dm index 520778de1b3..bfe65bb3e8a 100644 --- a/code/modules/clothing/spacesuits/spacesuits.dm +++ b/code/modules/clothing/spacesuits/spacesuits.dm @@ -26,6 +26,8 @@ flash_protection = FLASH_PROTECTION_MAJOR allow_hair_covering = FALSE + has_storage = FALSE + action_button_name = "Toggle Helmet Light" light_overlay = "helmet_light" brightness_on = 4 diff --git a/html/changelogs/geeves-helmet_storage.yml b/html/changelogs/geeves-helmet_storage.yml new file mode 100644 index 00000000000..65c3c6ccc4d --- /dev/null +++ b/html/changelogs/geeves-helmet_storage.yml @@ -0,0 +1,6 @@ +author: Geeves + +delete-after: True + +changes: + - rscadd: "You can now store cigarette packets in helmets." diff --git a/icons/clothing/kit/helmet_garb.dmi b/icons/clothing/kit/helmet_garb.dmi new file mode 100644 index 0000000000000000000000000000000000000000..280686c34a455dd6a2c7759686b3620e38cb0f46 GIT binary patch literal 746 zcmVxT<1_lsr#00D+cL_t(|obBD)ZrVT;1<-Jbu^~W8 zT4R#Z2=f2`SXEV}RAkJtV`E2J>j`PLx94H}bTs1b4mvWK27}W{x??h}X_?LcnzdZN z7Pzu}pWa#P$-vvHizxI6JW*_`&vOWgc{URTF4@p@E$!xJGy4VW<00000 zFudg|7+fvW9m`d;!(=i?o3#V3pDWR~aaw(sv^eh2^n0001t zOa1-3dYf%9xZR{XHrr^+g`)M;Bj~Y*WE11Pc6Lic-@nVg_5A+N+`k+8{@k z006+S*6Hy;QLI}};fB6{_)b3qo}up_^2bxY`#$9RR}bNXUMD?id)n=Ov~3-Feh2^n z0001tOSumQ_hq`H+(%n3REJ>jP^CMnL%QWTyp?#eiI*OdG*$f!AGBT^e;w0*j@ZQ! zDa+T^-{7%>WbHQy000000DLK@b1-;5r8`dNXv^)r^^oMNIaT3L1Z~y=R literal 0 HcmV?d00001