/obj/machinery/microwave
name = "Microwave"
desc = "Studies are inconclusive on whether pressing your face against the glass is harmful."
icon = 'icons/obj/kitchen.dmi'
icon_state = "mw"
layer = 2.9
density = 1
anchored = 1
use_power = USE_POWER_IDLE
idle_power_usage = 5
active_power_usage = 2000
clicksound = "button"
clickvol = "30"
flags = OPENCONTAINER | NOREACT
circuit = /obj/item/weapon/circuitboard/microwave
var/operating = 0 // Is it on?
var/dirty = 0 // = {0..100} Does it need cleaning?
var/broken = 0 // ={0,1,2} How broken is it???
var/circuit_item_capacity = 1 //how many items does the circuit add to max number of items
var/item_level = 0 // items microwave can handle, 0 foodstuff, 1 materials
var/global/list/acceptable_items // List of the items you can put in
var/global/list/available_recipes // List of the recipes you can use
var/global/list/acceptable_reagents // List of the reagents you can put in
var/global/max_n_of_items = 20
var/appliancetype = MICROWAVE
var/datum/looping_sound/microwave/soundloop
// see code/modules/food/recipes_microwave.dm for recipes
/*******************
* Initialising
********************/
/obj/machinery/microwave/Initialize()
. = ..()
reagents = new/datum/reagents(100)
reagents.my_atom = src
default_apply_parts()
if(!available_recipes)
available_recipes = new
for(var/T in (typesof(/datum/recipe)-/datum/recipe))
var/datum/recipe/type = T
if((initial(type.appliance) & appliancetype))
available_recipes += new type
acceptable_items = new
acceptable_reagents = new
for (var/datum/recipe/recipe in available_recipes)
for (var/item in recipe.items)
acceptable_items |= item
for (var/reagent in recipe.reagents)
acceptable_reagents |= reagent
// This will do until I can think of a fun recipe to use dionaea in -
// will also allow anything using the holder item to be microwaved into
// impure carbon. ~Z
acceptable_items |= /obj/item/weapon/holder
acceptable_items |= /obj/item/weapon/reagent_containers/food/snacks/grown
acceptable_items |= /obj/item/device/soulstone
acceptable_items |= /obj/item/weapon/fuel_assembly/supermatter
soundloop = new(list(src), FALSE)
/obj/machinery/microwave/Destroy()
QDEL_NULL(soundloop)
return ..()
/*******************
* Item Adding
********************/
/obj/machinery/microwave/attackby(var/obj/item/O as obj, var/mob/user as mob)
if(src.broken > 0)
if(src.broken == 2 && O.is_screwdriver()) // If it's broken and they're using a screwdriver
user.visible_message( \
"\The [user] starts to fix part of the microwave.", \
"You start to fix part of the microwave." \
)
playsound(src, O.usesound, 50, 1)
if (do_after(user,20 * O.toolspeed))
user.visible_message( \
"\The [user] fixes part of the microwave.", \
"You have fixed part of the microwave." \
)
src.broken = 1 // Fix it a bit
else if(src.broken == 1 && O.is_wrench()) // If it's broken and they're doing the wrench
user.visible_message( \
"\The [user] starts to fix part of the microwave.", \
"You start to fix part of the microwave." \
)
if (do_after(user,20 * O.toolspeed))
user.visible_message( \
"\The [user] fixes the microwave.", \
"You have fixed the microwave." \
)
src.icon_state = "mw"
src.broken = 0 // Fix it!
src.dirty = 0 // just to be sure
src.flags = OPENCONTAINER
else
to_chat(user, "It's broken!")
return 1
else if(src.dirty==100) // The microwave is all dirty so can't be used!
if(istype(O, /obj/item/weapon/reagent_containers/spray/cleaner) || istype(O, /obj/item/weapon/soap)) // If they're trying to clean it then let them
user.visible_message( \
"\The [user] starts to clean the microwave.", \
"You start to clean the microwave." \
)
if (do_after(user,20))
user.visible_message( \
"\The [user] has cleaned the microwave.", \
"You have cleaned the microwave." \
)
src.dirty = 0 // It's clean!
src.broken = 0 // just to be sure
src.icon_state = "mw"
src.flags = OPENCONTAINER
else //Otherwise bad luck!!
to_chat(user, "It's dirty!")
return 1
else if(is_type_in_list(O,acceptable_items))
if(contents.len>=(max_n_of_items + component_parts.len + circuit_item_capacity)) //Adds component_parts to the maximum number of items. changed 1 to actually just be the circuit item capacity var.
to_chat(user, "This [src] is full of ingredients, you cannot put more.")
return 1
if(istype(O, /obj/item/stack) && O:get_amount() > 1) // This is bad, but I can't think of how to change it
var/obj/item/stack/S = O
new O.type (src)
S.use(1)
user.visible_message( \
"\The [user] has added one of [O] to \the [src].", \
"You add one of [O] to \the [src].")
return
else
// user.remove_from_mob(O) //This just causes problems so far as I can tell. -Pete - Man whoever you are, it's been years. o7
user.drop_from_inventory(O,src)
user.visible_message( \
"\The [user] has added \the [O] to \the [src].", \
"You add \the [O] to \the [src].")
return
else if(istype(O,/obj/item/weapon/reagent_containers/glass) || \
istype(O,/obj/item/weapon/reagent_containers/food/drinks) || \
istype(O,/obj/item/weapon/reagent_containers/food/condiment) \
)
if (!O.reagents)
return 1
for (var/datum/reagent/R in O.reagents.reagent_list)
if (!(R.id in acceptable_reagents))
to_chat(user, "Your [O] contains components unsuitable for cookery.")
return 1
return
else if(istype(O,/obj/item/weapon/grab))
var/obj/item/weapon/grab/G = O
to_chat(user, "This is ridiculous. You can not fit \the [G.affecting] in this [src].")
return 1
else if(O.is_crowbar())
user.visible_message( \
"\The [user] begins [src.anchored ? "unsecuring" : "securing"] the microwave.", \
"You attempt to [src.anchored ? "unsecure" : "secure"] the microwave."
)
if (do_after(user,20))
user.visible_message( \
"\The [user] [src.anchored ? "unsecures" : "secures"] the microwave.", \
"You [src.anchored ? "unsecure" : "secure"] the microwave."
)
src.anchored = !src.anchored
else
to_chat(user, "You decide not to do that.")
else
to_chat(user, "You have no idea what you can cook with this [O].")
..()
src.updateUsrDialog()
/obj/machinery/microwave/attack_ai(mob/user as mob)
if(istype(user, /mob/living/silicon/robot) && Adjacent(user))
attack_hand(user)
/obj/machinery/microwave/attack_hand(mob/user as mob)
user.set_machine(src)
interact(user)
/*******************
* Microwave Menu
********************/
/obj/machinery/microwave/interact(mob/user as mob) // The microwave Menu
var/dat = ""
if(src.broken > 0)
dat = {"Bzzzzttttt"}
else if(src.operating)
dat = {"Microwaving in progress!
Please wait...!"}
else if(src.dirty==100)
dat = {"This microwave is dirty!
Please clean it before use!"}
else
var/list/items_counts = new
var/list/items_measures = new
var/list/items_measures_p = new
for (var/obj/O in ((contents - component_parts) - circuit))
var/display_name = O.name
if (istype(O,/obj/item/weapon/reagent_containers/food/snacks/egg))
items_measures[display_name] = "egg"
items_measures_p[display_name] = "eggs"
if (istype(O,/obj/item/weapon/reagent_containers/food/snacks/tofu))
items_measures[display_name] = "tofu chunk"
items_measures_p[display_name] = "tofu chunks"
if (istype(O,/obj/item/weapon/reagent_containers/food/snacks/meat)) //any meat
items_measures[display_name] = "slab of meat"
items_measures_p[display_name] = "slabs of meat"
if (istype(O,/obj/item/weapon/reagent_containers/food/snacks/donkpocket))
display_name = "Turnovers"
items_measures[display_name] = "turnover"
items_measures_p[display_name] = "turnovers"
if (istype(O,/obj/item/weapon/reagent_containers/food/snacks/carpmeat))
items_measures[display_name] = "fillet of meat"
items_measures_p[display_name] = "fillets of meat"
items_counts[display_name]++
for (var/O in items_counts)
var/N = items_counts[O]
if (!(O in items_measures))
dat += {"[capitalize(O)]: [N] [lowertext(O)]\s
"}
else
if (N==1)
dat += {"[capitalize(O)]: [N] [items_measures[O]]
"}
else
dat += {"[capitalize(O)]: [N] [items_measures_p[O]]
"}
for (var/datum/reagent/R in reagents.reagent_list)
var/display_name = R.name
if (R.id == "capsaicin")
display_name = "Hotsauce"
if (R.id == "frostoil")
display_name = "Coldsauce"
dat += {"[display_name]: [R.volume] unit\s
"}
if (items_counts.len==0 && reagents.reagent_list.len==0)
dat = {"The microwave is empty
"}
else
dat = {"Ingredients:
[dat]"}
dat += {"