From a190ec572543c16f563e9af1c29afa0ecf8e83a3 Mon Sep 17 00:00:00 2001 From: mistyLuminescence <32139558+mistyLuminescence@users.noreply.github.com> Date: Sat, 20 Jan 2018 02:11:28 +0000 Subject: [PATCH] Allows modkits to be created for any item. (#4450) * Adds modular modkits * Adds explorer suit functionality to voidsuit modkits. --- code/game/objects/items/paintkit.dm | 218 +++++++++++++------ code/modules/clothing/suits/miscellaneous.dm | 44 ++-- code/modules/clothing/suits/toggles.dm | 12 +- code/modules/customitems/item_spawning.dm | 23 +- 4 files changed, 191 insertions(+), 106 deletions(-) diff --git a/code/game/objects/items/paintkit.dm b/code/game/objects/items/paintkit.dm index 78e42f71a83..259a054c165 100644 --- a/code/game/objects/items/paintkit.dm +++ b/code/game/objects/items/paintkit.dm @@ -1,15 +1,18 @@ /obj/item/device/kit icon_state = "modkit" icon = 'icons/obj/device.dmi' - var/new_name = "mech" //What is the variant called? - var/new_desc = "A mech." //How is the new mech described? - var/new_icon = "ripley" //What base icon will the new mech use? + w_class = ITEMSIZE_SMALL + var/new_name = "custom item" + var/new_desc = "A custom item." + var/new_icon var/new_icon_file + var/new_icon_override_file var/uses = 1 // Uses before the kit deletes itself. + var/list/allowed_types = list() /obj/item/device/kit/examine() ..() - usr << "It has [uses] [uses>1?"uses":"use"] left." + to_chat(usr, "It has [uses] use\s left.") /obj/item/device/kit/proc/use(var/amt, var/mob/user) uses -= amt @@ -18,6 +21,42 @@ user.drop_item() qdel(src) +/obj/item/device/kit/proc/can_customize(var/obj/item/I) + return is_type_in_list(I, allowed_types) + +/obj/item/device/kit/proc/set_info(var/kit_name, var/kit_desc, var/kit_icon, var/kit_icon_file = CUSTOM_ITEM_OBJ, var/kit_icon_override_file = CUSTOM_ITEM_MOB, var/additional_data) + new_name = kit_name + new_desc = kit_desc + new_icon = kit_icon + new_icon_file = kit_icon_file + new_icon_override_file = kit_icon_override_file + + for(var/path in splittext(additional_data, ", ")) + allowed_types |= text2path(path) + +/obj/item/device/kit/proc/customize(var/obj/item/I, var/mob/user) + if(can_customize(I)) + I.name = new_name ? new_name : I.name + I.desc = new_desc ? new_desc : I.desc + I.icon = new_icon_file ? new_icon_file : I.icon + I.icon_override = new_icon_override_file ? new_icon_override_file : I.icon_override + if(new_icon) + I.icon_state = new_icon + var/obj/item/clothing/under/U = I + if(istype(U)) + U.worn_state = I.icon_state + U.update_rolldown_status() + use(1, user) + +// Generic use +/obj/item/attackby(obj/item/weapon/W as obj, mob/user as mob) + if(istype(W, /obj/item/device/kit)) + var/obj/item/device/kit/K = W + K.customize(src, user) + return + + ..() + // Root hardsuit kit defines. // Icons for modified hardsuits need to be in the proper .dmis because suit cyclers may cock them up. /obj/item/device/kit/suit @@ -25,88 +64,141 @@ desc = "A kit for modifying a voidsuit." uses = 2 var/new_light_overlay - var/new_mob_icon_file + +/obj/item/device/kit/suit/can_customize(var/obj/item/I) + return istype(I, /obj/item/clothing/head/helmet/space/void) || istype(I, /obj/item/clothing/suit/space/void) || istype(I, /obj/item/clothing/suit/storage/hooded/explorer) + +/obj/item/device/kit/suit/set_info(var/kit_name, var/kit_desc, var/kit_icon, var/kit_icon_file = CUSTOM_ITEM_OBJ, var/kit_icon_override_file = CUSTOM_ITEM_MOB, var/additional_data) + ..() + + new_light_overlay = additional_data + + +/obj/item/device/kit/suit/customize(var/obj/item/I, var/mob/user) + if(can_customize(I)) + if(istype(I, /obj/item/clothing/head/helmet/space/void)) + var/obj/item/clothing/head/helmet/space/void/helmet = I + helmet.name = "[new_name] suit helmet" + helmet.desc = new_desc + helmet.icon_state = "[new_icon]_helmet" + helmet.item_state = "[new_icon]_helmet" + if(new_icon_file) + helmet.icon = new_icon_file + if(new_icon_override_file) + helmet.icon_override = new_icon_override_file + if(new_light_overlay) + helmet.light_overlay = new_light_overlay + to_chat(user, "You set about modifying the helmet into [helmet].") + var/mob/living/carbon/human/H = user + if(istype(H)) + helmet.species_restricted = list(H.species.get_bodytype(H)) + else if(istype(I, /obj/item/clothing/suit/storage/hooded)) + var/obj/item/clothing/suit/storage/hooded/suit = I + suit.name = "[new_name] suit" + suit.desc = new_desc + suit.icon_state = "[new_icon]_suit" + suit.toggleicon = "[new_icon]_suit" + suit.item_state = "[new_icon]_suit" + var/obj/item/clothing/head/hood/S = suit.hood + S.icon_state = "[new_icon]_helmet" + S.item_state = "[new_icon]_helmet" + if(new_icon_file) + suit.icon = new_icon_file + S.icon = new_icon_file + if(new_icon_override_file) + suit.icon_override = new_icon_override_file + S.icon_override = new_icon_override_file + to_chat(user, "You set about modifying the suit into [suit].") + var/mob/living/carbon/human/H = user + if(istype(H)) + suit.species_restricted = list(H.species.get_bodytype(H)) + else + var/obj/item/clothing/suit/space/void/suit = I + suit.name = "[new_name] voidsuit" + suit.desc = new_desc + suit.icon_state = "[new_icon]_suit" + suit.item_state = "[new_icon]_suit" + if(new_icon_file) + suit.icon = new_icon_file + if(new_icon_override_file) + suit.icon_override = new_icon_override_file + to_chat(user, "You set about modifying the suit into [suit].") + var/mob/living/carbon/human/H = user + if(istype(H)) + suit.species_restricted = list(H.species.get_bodytype(H)) + use(1,user) /obj/item/clothing/head/helmet/space/void/attackby(var/obj/item/O, var/mob/user) if(istype(O,/obj/item/device/kit/suit)) var/obj/item/device/kit/suit/kit = O - name = "[kit.new_name] suit helmet" - desc = kit.new_desc - icon_state = "[kit.new_icon]_helmet" - item_state = "[kit.new_icon]_helmet" - if(kit.new_icon_file) - icon = kit.new_icon_file - if(kit.new_mob_icon_file) - icon_override = kit.new_mob_icon_file - if(kit.new_light_overlay) - light_overlay = kit.new_light_overlay - user << "You set about modifying the helmet into [src]." - var/mob/living/carbon/human/H = user - if(istype(H)) - species_restricted = list(H.species.get_bodytype()) - kit.use(1,user) - return 1 + kit.customize(src, user) + return return ..() /obj/item/clothing/suit/space/void/attackby(var/obj/item/O, var/mob/user) if(istype(O,/obj/item/device/kit/suit)) var/obj/item/device/kit/suit/kit = O - name = "[kit.new_name] voidsuit" - desc = kit.new_desc - icon_state = "[kit.new_icon]_suit" - item_state = "[kit.new_icon]_suit" - if(kit.new_icon_file) - icon = kit.new_icon_file - if(kit.new_mob_icon_file) - icon_override = kit.new_mob_icon_file - user << "You set about modifying the suit into [src]." - var/mob/living/carbon/human/H = user - if(istype(H)) - species_restricted = list(H.species.get_bodytype()) - kit.use(1,user) - return 1 + kit.customize(src, user) + return return ..() +/obj/item/clothing/suit/storage/hooded/attackby(var/obj/item/O, var/mob/user) + if(istype(O,/obj/item/device/kit/suit)) + var/obj/item/device/kit/suit/kit = O + kit.customize(src, user) + return + return ..() + + /obj/item/device/kit/paint name = "mecha customisation kit" desc = "A kit containing all the needed tools and parts to repaint a mech." var/removable = null - var/list/allowed_types = list() + +/obj/item/device/kit/paint/can_customize(var/obj/mecha/M) + if(!istype(M)) + return 0 + + for(var/type in allowed_types) + if(type == M.initial_icon) + return 1 + +/obj/item/device/kit/paint/set_info(var/kit_name, var/kit_desc, var/kit_icon, var/kit_icon_file = CUSTOM_ITEM_OBJ, var/kit_icon_override_file = CUSTOM_ITEM_MOB, var/additional_data) + ..() + + allowed_types = splittext(additional_data, ", ") + /obj/item/device/kit/paint/examine() ..() - usr << "This kit will convert an exosuit into: [new_name]." - usr << "This kit can be used on the following exosuit models:" + to_chat(usr, "This kit will convert an exosuit into: [new_name].") + to_chat(usr, "This kit can be used on the following exosuit models:") for(var/exotype in allowed_types) - usr << "- [capitalize(exotype)]" + to_chat(usr, "- [capitalize(exotype)]") + +/obj/item/device/kit/paint/customize(var/obj/mecha/M, var/mob/user) + if(!can_customize(M)) + to_chat(user, "That kit isn't meant for use on this class of exosuit.") + return + + if(M.occupant) + to_chat(user, "You can't customize a mech while someone is piloting it - that would be unsafe!") + return + + user.visible_message("[user] opens [src] and spends some quality time customising [M].") + M.name = new_name + M.desc = new_desc + M.initial_icon = new_icon + if(new_icon_file) + M.icon = new_icon_file + M.reset_icon() + use(1, user) /obj/mecha/attackby(var/obj/item/weapon/W, var/mob/user) if(istype(W, /obj/item/device/kit/paint)) - if(occupant) - user << "You can't customize a mech while someone is piloting it - that would be unsafe!" - return - var/obj/item/device/kit/paint/P = W - var/found = null - - for(var/type in P.allowed_types) - if(type==src.initial_icon) - found = 1 - break - - if(!found) - user << "That kit isn't meant for use on this class of exosuit." - return - - user.visible_message("[user] opens [P] and spends some quality time customising [src].") - src.name = P.new_name - src.desc = P.new_desc - src.initial_icon = P.new_icon - if(P.new_icon_file) - src.icon = P.new_icon_file - src.reset_icon() - P.use(1, user) - return 1 + P.customize(src, user) + return else return ..() diff --git a/code/modules/clothing/suits/miscellaneous.dm b/code/modules/clothing/suits/miscellaneous.dm index 4a6326a424e..9b884961193 100644 --- a/code/modules/clothing/suits/miscellaneous.dm +++ b/code/modules/clothing/suits/miscellaneous.dm @@ -665,10 +665,10 @@ obj/item/clothing/suit/storage/toggle/peacoat min_cold_protection_temperature = SPACE_SUIT_MIN_COLD_PROTECTION_TEMPERATURE armor = list(melee = 0, bullet = 0, laser = 0,energy = 0, bomb = 0, bio = 10, rad = 0) hooded = 1 - hoodtype = /obj/item/clothing/head/winterhood + hoodtype = /obj/item/clothing/head/hood/winter allowed = list (/obj/item/weapon/pen, /obj/item/weapon/paper, /obj/item/device/flashlight,/obj/item/weapon/tank/emergency/oxygen, /obj/item/weapon/storage/fancy/cigarettes, /obj/item/weapon/storage/box/matches, /obj/item/weapon/reagent_containers/food/drinks/flask) -/obj/item/clothing/head/winterhood +/obj/item/clothing/head/hood/winter name = "winter hood" desc = "A hood attached to a heavy winter jacket." icon_state = "generic_hood" @@ -682,9 +682,9 @@ obj/item/clothing/suit/storage/toggle/peacoat icon_state = "coatcaptain" item_state_slots = list(slot_r_hand_str = "coatcaptain", slot_l_hand_str = "coatcaptain") armor = list(melee = 20, bullet = 15, laser = 20, energy = 10, bomb = 15, bio = 0, rad = 0) - hoodtype = /obj/item/clothing/head/winterhood/captain + hoodtype = /obj/item/clothing/head/hood/winter/captain -/obj/item/clothing/head/winterhood/captain +/obj/item/clothing/head/hood/winter/captain name = "colony director's winter hood" armor = list(melee = 20, bullet = 15, laser = 20, energy = 10, bomb = 15, bio = 0, rad = 0) @@ -693,9 +693,9 @@ obj/item/clothing/suit/storage/toggle/peacoat icon_state = "coatsecurity" item_state_slots = list(slot_r_hand_str = "coatsecurity", slot_l_hand_str = "coatsecurity") armor = list(melee = 25, bullet = 20, laser = 20, energy = 15, bomb = 20, bio = 0, rad = 0) - hoodtype = /obj/item/clothing/head/winterhood/security + hoodtype = /obj/item/clothing/head/hood/winter/security -/obj/item/clothing/head/winterhood/security +/obj/item/clothing/head/hood/winter/security name = "security winter hood" armor = list(melee = 25, bullet = 20, laser = 20, energy = 15, bomb = 20, bio = 0, rad = 0) @@ -704,9 +704,9 @@ obj/item/clothing/suit/storage/toggle/peacoat icon_state = "coatmedical" item_state_slots = list(slot_r_hand_str = "coatmedical", slot_l_hand_str = "coatmedical") armor = list(melee = 0, bullet = 0, laser = 0,energy = 0, bomb = 0, bio = 50, rad = 0) - hoodtype = /obj/item/clothing/head/winterhood/medical + hoodtype = /obj/item/clothing/head/hood/winter/medical -/obj/item/clothing/head/winterhood/medical +/obj/item/clothing/head/hood/winter/medical name = "medical winter hood" armor = list(melee = 0, bullet = 0, laser = 0,energy = 0, bomb = 0, bio = 50, rad = 0) @@ -715,9 +715,9 @@ obj/item/clothing/suit/storage/toggle/peacoat icon_state = "coatscience" item_state_slots = list(slot_r_hand_str = "coatscience", slot_l_hand_str = "coatscience") armor = list(melee = 0, bullet = 0, laser = 0,energy = 0, bomb = 10, bio = 0, rad = 0) - hoodtype = /obj/item/clothing/head/winterhood/science + hoodtype = /obj/item/clothing/head/hood/winter/science -/obj/item/clothing/head/winterhood/science +/obj/item/clothing/head/hood/winter/science name = "science winter hood" armor = list(melee = 0, bullet = 0, laser = 0,energy = 0, bomb = 10, bio = 0, rad = 0) @@ -726,9 +726,9 @@ obj/item/clothing/suit/storage/toggle/peacoat icon_state = "coatengineer" item_state_slots = list(slot_r_hand_str = "coatengineer", slot_l_hand_str = "coatengineer") armor = list(melee = 0, bullet = 0, laser = 0, energy = 0, bomb = 0, bio = 0, rad = 20) - hoodtype = /obj/item/clothing/head/winterhood/engineering + hoodtype = /obj/item/clothing/head/hood/winter/engineering -/obj/item/clothing/head/winterhood/engineering +/obj/item/clothing/head/hood/winter/engineering name = "engineering winter hood" armor = list(melee = 0, bullet = 0, laser = 0, energy = 0, bomb = 0, bio = 0, rad = 20) @@ -736,27 +736,27 @@ obj/item/clothing/suit/storage/toggle/peacoat name = "atmospherics winter coat" icon_state = "coatatmos" item_state_slots = list(slot_r_hand_str = "coatatmos", slot_l_hand_str = "coatatmos") - hoodtype = /obj/item/clothing/head/winterhood/engineering/atmos + hoodtype = /obj/item/clothing/head/hood/winter/engineering/atmos -/obj/item/clothing/head/winterhood/engineering/atmos +/obj/item/clothing/head/hood/winter/engineering/atmos name = "atmospherics winter hood" /obj/item/clothing/suit/storage/hooded/wintercoat/hydro name = "hydroponics winter coat" icon_state = "coathydro" item_state_slots = list(slot_r_hand_str = "coathydro", slot_l_hand_str = "coathydro") - hoodtype = /obj/item/clothing/head/winterhood/hydro + hoodtype = /obj/item/clothing/head/hood/winter/hydro -/obj/item/clothing/head/winterhood/hydro +/obj/item/clothing/head/hood/winter/hydro name = "hydroponics winter hood" /obj/item/clothing/suit/storage/hooded/wintercoat/cargo name = "cargo winter coat" icon_state = "coatcargo" item_state_slots = list(slot_r_hand_str = "coatcargo", slot_l_hand_str = "coatcargo") - hoodtype = /obj/item/clothing/head/winterhood/cargo + hoodtype = /obj/item/clothing/head/hood/winter/cargo -/obj/item/clothing/head/winterhood/cargo +/obj/item/clothing/head/hood/winter/cargo name = "cargo winter hood" /obj/item/clothing/suit/storage/hooded/wintercoat/miner @@ -764,9 +764,9 @@ obj/item/clothing/suit/storage/toggle/peacoat icon_state = "coatminer" item_state_slots = list(slot_r_hand_str = "coatminer", slot_l_hand_str = "coatminer") armor = list(melee = 10, bullet = 0, laser = 0, energy = 0, bomb = 0, bio = 0, rad = 0) - hoodtype = /obj/item/clothing/head/winterhood/miner + hoodtype = /obj/item/clothing/head/hood/winter/miner -/obj/item/clothing/head/winterhood/miner +/obj/item/clothing/head/hood/winter/miner name = "mining winter hood" armor = list(melee = 10, bullet = 0, laser = 0, energy = 0, bomb = 0, bio = 0, rad = 0) @@ -780,7 +780,7 @@ obj/item/clothing/suit/storage/toggle/peacoat min_cold_protection_temperature = SPACE_SUIT_MIN_COLD_PROTECTION_TEMPERATURE cold_protection = UPPER_TORSO|LOWER_TORSO|LEGS|ARMS hooded = TRUE - hoodtype = /obj/item/clothing/head/explorer + hoodtype = /obj/item/clothing/head/hood/explorer siemens_coefficient = 0.9 armor = list(melee = 30, bullet = 20, laser = 20, energy = 20, bomb = 50, bio = 100, rad = 50) // Inferior to sec vests in bullet/laser but better for environmental protection. allowed = list( @@ -794,7 +794,7 @@ obj/item/clothing/suit/storage/toggle/peacoat /obj/item/weapon/pickaxe ) -/obj/item/clothing/head/explorer +/obj/item/clothing/head/hood/explorer name = "explorer hood" desc = "An armoured hood for exploring harsh environments." icon_state = "explorer" diff --git a/code/modules/clothing/suits/toggles.dm b/code/modules/clothing/suits/toggles.dm index 81b433fa27d..c3c9a790b67 100644 --- a/code/modules/clothing/suits/toggles.dm +++ b/code/modules/clothing/suits/toggles.dm @@ -5,9 +5,11 @@ var/hoodtype = null //so the chaplain hoodie or other hoodies can override this var/suittoggled = 0 var/hooded = 0 + var/toggleicon action_button_name = "Toggle Hood" /obj/item/clothing/suit/storage/hooded/New() + toggleicon = "[initial(icon_state)]" MakeHood() ..() @@ -17,7 +19,7 @@ /obj/item/clothing/suit/storage/hooded/proc/MakeHood() if(!hood) - var/obj/item/clothing/head/winterhood/W = new hoodtype(src) + var/obj/item/clothing/head/hood/winter/W = new hoodtype(src) hood = W /obj/item/clothing/suit/storage/hooded/ui_action_click() @@ -29,7 +31,7 @@ ..() /obj/item/clothing/suit/storage/hooded/proc/RemoveHood() - icon_state = "[initial(icon_state)]" + icon_state = toggleicon suittoggled = 0 hood.canremove = TRUE // This shouldn't matter anyways but just incase. if(ishuman(hood.loc)) @@ -46,16 +48,16 @@ if(ishuman(loc)) var/mob/living/carbon/human/H = src.loc if(H.wear_suit != src) - H << "You must be wearing [src] to put up the hood!" + to_chat(H, "You must be wearing [src] to put up the hood!") return if(H.head) - H << "You're already wearing something on your head!" + to_chat(H, "You're already wearing something on your head!") return else H.equip_to_slot_if_possible(hood,slot_head,0,0,1) suittoggled = 1 hood.canremove = FALSE - icon_state = "[initial(icon_state)]_t" + icon_state = "[toggleicon]_t" H.update_inv_wear_suit() else RemoveHood() \ No newline at end of file diff --git a/code/modules/customitems/item_spawning.dm b/code/modules/customitems/item_spawning.dm index ef2333a0af6..b87183c3856 100644 --- a/code/modules/customitems/item_spawning.dm +++ b/code/modules/customitems/item_spawning.dm @@ -9,11 +9,13 @@ // On-mob icons must be in CUSTOM_ITEM_MOB with state name [item_icon]. // Inhands must be in CUSTOM_ITEM_MOB as [icon_state]_l and [icon_state]_r. -// Kits must have mech icons in CUSTOM_ITEM_OBJ under [kit_icon]. +// Mech kits must have mech icons in CUSTOM_ITEM_OBJ under [kit_icon]. // Broken must be [kit_icon]-broken and open must be [kit_icon]-open. -// Kits must also have hardsuit icons in CUSTOM_ITEM_MOB as [kit_icon]_suit -// and [kit_icon]_helmet, and in CUSTOM_ITEM_OBJ as [kit_icon]. +// Voidsuits and hooded kits must also have hardsuit icons in CUSTOM_ITEM_MOB as [kit_icon]_suit +// and [kit_icon]_helmet, and in CUSTOM_ITEM_OBJ as [kit_icon]_suit. +// If hooded, have [kit_icon]_suit_t in both files for the hood-up version. +// If not using the default overlay, have [kit_icon]_light in both files for custom light overlays. /var/list/custom_items = list() @@ -30,7 +32,7 @@ var/kit_name var/kit_desc var/kit_icon - var/additional_data + var/additional_data //for modular modkits, item path; for mech modkits, allowed mechs; for voidsuit modkits, light overlays /datum/custom_item/proc/spawn_item(var/newloc) var/obj/item/citem = new item_path(newloc) @@ -69,18 +71,7 @@ // Kits are dumb so this is going to have to be hardcoded/snowflake. if(istype(item, /obj/item/device/kit)) var/obj/item/device/kit/K = item - K.new_name = kit_name - K.new_desc = kit_desc - K.new_icon = kit_icon - K.new_icon_file = CUSTOM_ITEM_OBJ - if(istype(item, /obj/item/device/kit/paint)) - var/obj/item/device/kit/paint/kit = item - kit.allowed_types = splittext(additional_data, ", ") - else if(istype(item, /obj/item/device/kit/suit)) - var/obj/item/device/kit/suit/kit = item - kit.new_light_overlay = additional_data - kit.new_mob_icon_file = CUSTOM_ITEM_MOB - + K.set_info(kit_name, kit_desc, kit_icon, additional_data = additional_data) return item /datum/custom_item/proc/apply_inherit_inhands(var/obj/item/item)