Microwave Overhaul, or: death to user << browse (#7180)

This commit is contained in:
JohnWildkins
2019-11-15 23:05:51 +01:00
committed by Werner
parent 92c2614582
commit 129cf25763
6 changed files with 448 additions and 261 deletions
+333 -259
View File
@@ -1,6 +1,6 @@
/obj/machinery/microwave
name = "Microwave"
name = "microwave"
desc = "A Getmore-brand microwave. It's seen better days. Below the oven door, a faded label warns to keep non-food items out, and to beware of choking."
icon = 'icons/obj/kitchen.dmi'
icon_state = "mw"
layer = 2.9
@@ -10,22 +10,39 @@
idle_power_usage = 5
active_power_usage = 2000
flags = OPENCONTAINER | NOREACT
var/operating = 0 // Is it on?
var/operating = FALSE // Is it on?
var/dirty = 0 // = {0..100} Does it need cleaning?
var/broken = 0 // ={0,1,2} How broken is it???
var/global/list/acceptable_items // List of the items you can put in
var/global/list/acceptable_reagents // List of the reagents you can put in
var/global/max_n_of_items = 20
var/list/acceptable_containers = list(
/obj/item/weapon/reagent_containers/glass,
/obj/item/weapon/reagent_containers/food/drinks,
/obj/item/weapon/reagent_containers/food/condiment
)
var/appliancetype = MICROWAVE
var/datum/looping_sound/microwave/soundloop
var/datum/recipe/recipe
// These determine if the current cooking process failed, the vars above determine if the microwave is broken
var/cook_break = FALSE
var/cook_dirty = FALSE
var/abort = FALSE
var/failed = FALSE // pretty much exclusively for sending the fail state across to the UI, using recipe elsewhere is preferred
component_types = list(
/obj/item/weapon/circuitboard/microwave,
/obj/item/weapon/circuitboard/microwave = 1,
/obj/item/weapon/stock_parts/capacitor = 3,
/obj/item/weapon/stock_parts/scanning_module,
/obj/item/weapon/stock_parts/micro_laser = 1,
/obj/item/weapon/stock_parts/matter_bin = 2
)
var/cook_time = 400
var/start_time = 0
var/end_time = 0
var/cooking_power = 1
// see code/modules/food/recipes_microwave.dm for recipes
/*******************
@@ -42,6 +59,20 @@
else
setup_recipes()
if(component_parts)
component_parts.Cut()
else
component_parts = list()
for (var/type in component_types)
var/count = component_types[type]
for (var/i in 1 to count)
var/obj/t = new type
component_parts += t
t.forceMove(null)
RefreshParts()
/obj/machinery/microwave/proc/setup_recipes()
if (!LAZYLEN(acceptable_items))
acceptable_items = list()
@@ -63,9 +94,16 @@
* Item Adding
********************/
/obj/machinery/microwave/proc/add_item(var/obj/item/I as obj, var/mob/user as mob)
user.drop_from_inventory(I, src)
user.visible_message( \
"<span class='notice'>\The [user] has added one of [I] to \the [src].</span>", \
"<span class='notice'>You add one of [I] to \the [src].</span>")
SSvueui.check_uis_for_change(src)
/obj/machinery/microwave/attackby(var/obj/item/O as obj, var/mob/user as mob)
if(src.broken > 0)
if(src.broken == 2 && O.isscrewdriver()) // If it's broken and they're using a screwdriver
if(broken > 0)
if(broken == 2 && O.isscrewdriver()) // If it's broken and they're using a screwdriver
user.visible_message( \
"<span class='notice'>\The [user] starts to fix part of the microwave.</span>", \
"<span class='notice'>You start to fix part of the microwave.</span>" \
@@ -75,8 +113,8 @@
"<span class='notice'>\The [user] fixes part of the microwave.</span>", \
"<span class='notice'>You have fixed part of the microwave.</span>" \
)
src.broken = 1 // Fix it a bit
else if(src.broken == 1 && O.iswrench()) // If it's broken and they're doing the wrench
broken = 1 // Fix it a bit
else if(broken == 1 && O.iswrench()) // If it's broken and they're doing the wrench
user.visible_message( \
"<span class='notice'>\The [user] starts to fix part of the microwave.</span>", \
"<span class='notice'>You start to fix part of the microwave.</span>" \
@@ -86,15 +124,15 @@
"<span class='notice'>\The [user] fixes the microwave.</span>", \
"<span class='notice'>You have fixed the microwave.</span>" \
)
src.icon_state = "mw"
src.broken = 0 // Fix it!
src.dirty = 0 // just to be sure
src.flags = OPENCONTAINER | NOREACT
icon_state = "mw"
broken = 0 // Fix it!
dirty = 0 // just to be sure
flags = OPENCONTAINER | NOREACT
else
to_chat(user, "<span class='warning'>It's broken!</span>")
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
else if(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) || istype(O, /obj/item/weapon/reagent_containers/glass/rag)) // If they're trying to clean it then let them
user.visible_message( \
"<span class='notice'>\The [user] starts to clean the microwave.</span>", \
"<span class='notice'>You start to clean the microwave.</span>" \
@@ -104,43 +142,21 @@
"<span class='notice'>\The [user] has cleaned the microwave.</span>", \
"<span class='notice'>You have cleaned the microwave.</span>" \
)
src.dirty = 0 // It's clean!
src.broken = 0 // just to be sure
src.icon_state = "mw"
src.flags = OPENCONTAINER | NOREACT
dirty = 0 // It's clean!
broken = 0 // just to be sure
icon_state = "mw"
flags = OPENCONTAINER | NOREACT
else //Otherwise bad luck!!
to_chat(user, "<span class='warning'>It's dirty!</span>")
return 1
else if(is_type_in_list(O,acceptable_items))
if (contents.len>=max_n_of_items)
to_chat(user, "<span class='warning'>This [src] is full of ingredients, you cannot put more.</span>")
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( \
"<span class='notice'>\The [user] has added one of [O] to \the [src].</span>", \
"<span class='notice'>You add one of [O] to \the [src].</span>")
return
else
// user.remove_from_mob(O) //This just causes problems so far as I can tell. -Pete
user.drop_from_inventory(O,src)
user.visible_message( \
"<span class='notice'>\The [user] has added \the [O] to \the [src].</span>", \
"<span class='notice'>You add \the [O] to \the [src].</span>")
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) \
)
else if(is_type_in_list(O, acceptable_containers))
if (!O.reagents)
return 1
for (var/datum/reagent/R in O.reagents.reagent_list)
if (!(R.id in acceptable_reagents))
to_chat(user, "<span class='warning'>Your [O] contains components unsuitable for cookery.</span>")
return 1
return
return // Note to the future: reagents are added after this in the container's afterattack().
else if(istype(O,/obj/item/weapon/grab))
var/obj/item/weapon/grab/G = O
to_chat(user, "<span class='warning'>This is ridiculous. You can not fit \the [G.affecting] in this [src].</span>")
@@ -167,10 +183,30 @@
else if(default_part_replacement(user, O))
return
else
to_chat(user, "<span class='warning'>You have no idea what you can cook with this [O].</span>")
if (contents.len>=max_n_of_items)
to_chat(user, "<span class='warning'>This [src] is full of ingredients, you can't fit any more!</span>")
return 1
if(istype(O, /obj/item/stack))
var/obj/item/stack/S = O
if(S.get_amount() > 1)
new O.type (src)
S.use(1)
user.visible_message( \
"<span class='notice'>\The [user] has added one of [O] to \the [src].</span>", \
"<span class='notice'>You add one of [O] to \the [src].</span>")
SSvueui.check_uis_for_change(src)
return
else
add_item(O, user)
else
add_item(O, user)
return
SSvueui.check_uis_for_change(src)
..()
src.updateUsrDialog()
/obj/machinery/microwave/AltClick()
if(!operating)
cook()
/obj/machinery/microwave/attack_ai(mob/user as mob)
if(istype(user, /mob/living/silicon/robot) && Adjacent(user))
@@ -178,75 +214,67 @@
/obj/machinery/microwave/attack_hand(mob/user as mob)
user.set_machine(src)
interact(user)
if(broken > 0)
to_chat(user, "<span class='warning'>\The [name] is broken! You'll need to fix it before using it.</span>")
else if(dirty >= 100)
to_chat(user, "<span class='warning'>\The [name] is dirty! You'll need to clean it before using it.</span>")
else
ui_interact(user)
/obj/machinery/microwave/examine(var/mob/user)
..()
if(broken > 0)
to_chat(user, "It's broken!")
else if(dirty >= 100)
to_chat(user, "The insides are completely filthy!")
else if(dirty > 75)
to_chat(user, "It's covered in stains.")
else if(dirty > 50)
to_chat(user, "It's pretty messy.")
else if(dirty > 25)
to_chat(user, "It's a bit dirty.")
/*******************
* Microwave Menu
********************/
/obj/machinery/microwave/interact(mob/user as mob) // The microwave Menu
var/dat = ""
if(src.broken > 0)
dat = {"<TT>Bzzzzttttt</TT>"}
else if(src.operating)
dat = {"<TT>Microwaving in progress!<BR>Please wait...!</TT>"}
else if(src.dirty==100)
dat = {"<TT>This microwave is dirty!<BR>Please clean it before use!</TT>"}
else
var/list/items_counts = new
var/list/items_measures = new
var/list/items_measures_p = new
VUEUI_MONITOR_VARS(/obj/machinery/microwave, microwavemonitor)
watch_var("operating", "on", CALLBACK(null, .proc/transform_to_boolean, FALSE))
watch_var("failed", "failed")
watch_var("cook_time", "cook_time")
watch_var("start_time", "start_time")
/obj/machinery/microwave/vueui_data_change(var/list/data, var/mob/user, var/datum/vueui/ui)
var/monitordata = ..()
if(monitordata)
. = data = monitordata
// init data objects if they aren't already
LAZYINITLIST(data["cookingobjs"])
LAZYINITLIST(data["cookingreas"])
// if BYOND lists are smaller than UI, then something (or everything) was removed - wipe the list
if(LAZYLEN(contents) < LAZYLEN(data["cookingobjs"]))
VUEUI_SET_CHECK(data["cookingobjs"], list(), ., data)
if(LAZYLEN(reagents.reagent_list) < LAZYLEN(data["cookingreas"]))
VUEUI_SET_CHECK(data["cookingreas"], list(), ., data)
// build the list of objs and reagents
if (LAZYLEN(contents))
var/list/cook_count = list()
for (var/obj/O in contents)
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 += {"<B>[capitalize(O)]:</B> [N] [lowertext(O)]\s<BR>"}
else
if (N==1)
dat += {"<B>[capitalize(O)]:</B> [N] [items_measures[O]]<BR>"}
else
dat += {"<B>[capitalize(O)]:</B> [N] [items_measures_p[O]]<BR>"}
cook_count[O.name]++
for (var/C in cook_count)
VUEUI_SET_CHECK(data["cookingobjs"][C], cook_count[C], ., data)
if (LAZYLEN(reagents.reagent_list))
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 += {"<B>[display_name]:</B> [R.volume] unit\s<BR>"}
if (items_counts.len==0 && reagents.reagent_list.len==0)
dat = {"<B>The microwave is empty</B><BR>"}
else
dat = {"<b>Ingredients:</b><br>[dat]"}
dat += {"<HR><BR>\
<A href='?src=\ref[src];action=cook'>Turn on!<BR>\
<A href='?src=\ref[src];action=dispose'>Eject ingredients!<BR>\
"}
user << browse("<HEAD><TITLE>Microwave Controls</TITLE></HEAD><TT>[dat]</TT>", "window=microwave")
onclose(user, "microwave")
return
VUEUI_SET_CHECK(data["cookingreas"][R], R.volume, ., data)
/obj/machinery/microwave/ui_interact(mob/user)
var/datum/vueui/ui = SSvueui.get_open_ui(user, src)
if (!ui)
ui = new(user, src, "cooking-microwave", 300, 300, capitalize(name))
ui.open()
/***********************************
* Microwave Menu Handling/Cooking
@@ -255,102 +283,91 @@
/obj/machinery/microwave/proc/cook()
if(stat & (NOPOWER|BROKEN))
return
start()
if (reagents.total_volume==0 && !(locate(/obj) in contents)) //dry run
if (!wzhzhzh(16))
abort()
return
stop()
if (!reagents.reagent_list.len && !(locate(/obj) in contents)) //dry run
start()
return
var/datum/recipe/recipe = select_recipe(RECIPE_LIST(appliancetype),src)
var/obj/cooked
recipe = select_recipe(RECIPE_LIST(appliancetype),src)
if (reagents.reagent_list.len && prob(50)) // 50% chance a liquid recipe gets messy
dirty += Ceiling(reagents.total_volume / 10)
if (!recipe)
dirty += 1
if (prob(max(10,dirty*5)))
if (!wzhzhzh(16))
abort()
return
muck_start()
wzhzhzh(16)
muck_finish()
cooked = fail()
cooked.forceMove(src.loc)
return
failed = TRUE
cook_time = update_cook_time()
dirty += 5
if (prob(max(10, dirty*5)))
// It's dirty enough to mess up the microwave
cook_dirty = TRUE
else if (has_extra_item())
if (!wzhzhzh(16))
abort()
return
broke()
cooked = fail()
cooked.forceMove(src.loc)
return
else
if (!wzhzhzh(40))
abort()
return
stop()
cooked = fail()
cooked.forceMove(src.loc)
return
// Something's in the microwave that shouldn't be! Time to break!
cook_break = TRUE
else
var/halftime = round((recipe.time*4)/10/2)
if (!wzhzhzh(halftime))
abort()
return
if (!wzhzhzh(halftime))
abort()
cooked = fail()
cooked.forceMove(src.loc)
return
failed = FALSE
cook_time = update_cook_time(round(recipe.time * 2))
start()
//Making multiple copies of a recipe
var/result = recipe.result
var/valid = 1
var/list/cooked_items = list()
var/obj/temp = new /obj(src) //To prevent infinite loops, all results will be moved into a temporary location so they're not considered as inputs for other recipes
while(valid)
var/list/things = list()
things.Add(recipe.make_food(src))
cooked_items += things
//Move cooked things to the buffer so they're not considered as ingredients
for (var/atom/movable/AM in things)
AM.forceMove(temp)
/obj/machinery/microwave/proc/update_cook_time(var/ct = 200)
RefreshParts()
return (ct / cooking_power)
valid = 0
recipe = select_recipe(RECIPE_LIST(appliancetype),src)
if (recipe && recipe.result == result)
sleep(2)
valid = 1
/obj/machinery/microwave/proc/finish_cooking()
var/result = recipe.result
var/valid = TRUE
var/list/cooked_items = list()
var/obj/temp = new /obj(src) //To prevent infinite loops, all results will be moved into a temporary location so they're not considered as inputs for other recipes
while(valid)
var/list/things = list()
things.Add(recipe.make_food(src))
cooked_items += things
//Move cooked things to the buffer so they're not considered as ingredients
for (var/atom/movable/AM in things)
AM.forceMove(temp)
for (var/r in cooked_items)
var/atom/movable/R = r
R.forceMove(src) //Move everything from the buffer back to the container
valid = FALSE
recipe = select_recipe(RECIPE_LIST(appliancetype),src)
if (recipe && recipe.result == result)
sleep(2)
valid = TRUE
qdel(temp)//Delete buffer object
temp = null
for (var/r in cooked_items)
var/atom/movable/R = r
R.forceMove(src) //Move everything from the buffer back to the container
//Any leftover reagents are divided amongst the foods
var/total = reagents.total_volume
for (var/obj/item/weapon/reagent_containers/food/snacks/S in cooked_items)
reagents.trans_to_holder(S.reagents, total/cooked_items.len)
QDEL_NULL(temp)//Delete buffer object
for (var/obj/item/weapon/reagent_containers/food/snacks/S in contents)
S.cook()
//Any leftover reagents are divided amongst the foods
var/total = reagents.total_volume
for (var/obj/item/weapon/reagent_containers/food/snacks/S in cooked_items)
reagents.trans_to_holder(S.reagents, total/cooked_items.len)
dispose(0) //clear out anything left
for (var/obj/item/weapon/reagent_containers/food/snacks/S in contents)
S.cook()
eject(0) //clear out anything left
return
/obj/machinery/microwave/process() // What you see here are the remains of proc/wzhzhzh, 2010 - 2019. RIP.
if (stat & (NOPOWER|BROKEN))
stop()
return
/obj/machinery/microwave/proc/wzhzhzh(var/seconds as num) // Whoever named this proc is fucking literally Satan. ~ Z
for (var/i=1 to seconds)
if (stat & (NOPOWER|BROKEN))
return 0
use_power(active_power_usage)
sleep(10)
return 1
use_power(active_power_usage)
if(world.time > end_time)
stop()
/obj/machinery/microwave/proc/half_time_process()
if (stat & (NOPOWER|BROKEN))
return
playsound(src, 'sound/machines/click.ogg', 20, 1)
if(failed)
visible_message(span("warning", "\The [src] begins to leak an acrid smoke..."))
/obj/machinery/microwave/proc/has_extra_item()
for (var/obj/O in contents)
@@ -358,64 +375,57 @@
!istype(O,/obj/item/weapon/reagent_containers/food) && \
!istype(O, /obj/item/weapon/grown) \
)
return 1
return 0
return TRUE
return FALSE
/obj/machinery/microwave/proc/start()
src.visible_message("<span class='notice'>The microwave turns on.</span>", "<span class='notice'>You hear a microwave.</span>")
src.operating = 1
src.icon_state = "mw1"
src.updateUsrDialog()
start_time = world.time
end_time = cook_time + start_time
operating = TRUE
START_PROCESSING(SSprocessing, src)
addtimer(CALLBACK(src, .proc/half_time_process), cook_time / 2)
visible_message("<span class='notice'>The microwave turns on.</span>", "<span class='notice'>You hear a microwave.</span>")
if(cook_dirty)
playsound(loc, 'sound/effects/splat.ogg', 50, 1) // Play a splat sound
icon_state = "mwbloody1" // Make it look dirty!!
else
icon_state = "mw1"
set_light(1.5)
soundloop.start()
/obj/machinery/microwave/proc/abort()
after_finish_loop()
src.operating = 0 // Turn it off again aferwards
src.icon_state = "mw"
src.updateUsrDialog()
SSvueui.check_uis_for_change(src)
/obj/machinery/microwave/proc/stop()
STOP_PROCESSING(SSprocessing, src)
after_finish_loop()
src.operating = 0 // Turn it off again aferwards
src.icon_state = "mw"
src.updateUsrDialog()
/obj/machinery/microwave/proc/dispose(var/message = 1)
for (var/atom/movable/A in contents)
A.forceMove(loc)
if (src.reagents.total_volume)
src.dirty++
src.reagents.clear_reagents()
if (message)
to_chat(usr, "<span class='notice'>You dispose of the microwave contents.</span>")
src.updateUsrDialog()
operating = FALSE // Turn it off again aferwards
if(cook_dirty || cook_break)
flags = null //So you can't add condiments
if(cook_dirty)
visible_message(span("warning", "The insides of the microwave get covered in muck!"))
dirty = 100 // Make it dirty so it can't be used util cleaned
icon_state = "mwbloody" // Make it look dirty too
else if(cook_break)
spark(src, 2, alldirs)
icon_state = "mwb" // Make it look all busted up and shit
visible_message(span("warning", "The microwave sprays out a shower of sparks - it's broken!")) //Let them know they're stupid
broken = 2 // Make it broken so it can't be used util
else
icon_state = "mw"
/obj/machinery/microwave/proc/muck_start()
playsound(src.loc, 'sound/effects/splat.ogg', 50, 1) // Play a splat sound
src.icon_state = "mwbloody1" // Make it look dirty!!
if(failed)
fail()
failed = FALSE
else if(!failed && !abort)
finish_cooking()
/obj/machinery/microwave/proc/muck_finish()
after_finish_loop()
src.visible_message("<span class='warning'>The microwave gets covered in muck!</span>")
src.dirty = 100 // Make it dirty so it can't be used util cleaned
src.flags = null //So you can't add condiments
src.icon_state = "mwbloody" // Make it look dirty too
src.operating = 0 // Turn it off again aferwards
src.updateUsrDialog()
/obj/machinery/microwave/proc/broke()
after_finish_loop()
spark(src, 2, alldirs)
src.icon_state = "mwb" // Make it look all busted up and shit
src.visible_message("<span class='warning'>The microwave breaks!</span>") //Let them know they're stupid
src.broken = 2 // Make it broken so it can't be used util fixed
src.flags = null //So you can't add condiments
src.operating = 0 // Turn it off again aferwards
src.updateUsrDialog()
abort = FALSE
SSvueui.check_uis_for_change(src)
/obj/machinery/microwave/proc/fail()
after_finish_loop()
var/obj/item/weapon/reagent_containers/food/snacks/badrecipe/ffuu = new(src)
var/amount = 0
for (var/obj/O in contents-ffuu)
@@ -425,45 +435,90 @@
if (id)
amount+=O.reagents.get_reagent_amount(id)
qdel(O)
src.reagents.clear_reagents()
reagents.clear_reagents()
SSvueui.check_uis_for_change(src)
ffuu.reagents.add_reagent("carbon", amount)
ffuu.reagents.add_reagent("toxin", amount/10)
if(!abort)
visible_message("<span class='danger'>\The [src] belches out foul-smelling smoke!</span>")
var/datum/effect/effect/system/smoke_spread/bad/smoke = new /datum/effect/effect/system/smoke_spread/bad
smoke.attach(src)
smoke.set_up(10, 0, get_turf(src), 300)
smoke.start()
ffuu.forceMove(loc)
return ffuu
/obj/machinery/microwave/Topic(href, href_list)
SSvueui.check_uis_for_change(src)
if(..())
return
usr.set_machine(src)
if(src.operating)
src.updateUsrDialog()
if(dirty >= 100)
to_chat(usr, "<span class='warning'>\The [name] is dirty! You'll need to clean it before using it.</span>")
return
switch(href_list["action"])
if ("cook")
cook()
if(broken > 0)
to_chat(usr, "<span class='warning'>\The [name] is broken! You'll need to fix it before using it.</span>")
return
usr.set_machine(src)
if(operating)
if(href_list["abort"])
abort = TRUE
stop()
SSvueui.check_uis_for_change(src)
return
if(href_list["cook"])
cook()
SSvueui.check_uis_for_change(src)
else if(href_list["eject_all"])
eject()
else if(href_list["eject"])
for (var/datum/reagent/R in reagents.reagent_list)
if(R.name == href_list["eject"])
eject_reagent(R, usr)
break
for (var/obj/O in contents)
if(O.name == href_list["eject"])
eject(0, O)
break
if ("dispose")
dispose()
return
/obj/machinery/microwave/verb/Eject()
set src in oview(1)
set category = "Object"
set name = "Eject content"
usr.visible_message(
"<span class='notice'>[usr] is trying to open [src] to take out its content.</span>" ,
"<span class='notice'>You are trying to open [src] to take out its content</span>"
)
/obj/machinery/microwave/proc/eject_reagent(datum/reagent/R, mob/user)
if(istype(user.l_hand, /obj/item/weapon/reagent_containers) || istype(user.r_hand, /obj/item/weapon/reagent_containers))
var/obj/item/weapon/reagent_containers/RC = user.l_hand || user.r_hand
var/free_space = RC.reagents.get_free_space()
if(free_space > R.volume)
to_chat(user, "<span class='notice'>You empty [R.volume] units of [R.name] into your [RC.name].</span>")
RC.reagents.add_reagent(R.id, R.volume)
reagents.remove_reagent(R.id, R.volume)
else if(free_space <= 0)
to_chat(user, "<span class='warning'>[RC.name] is full!</span>")
else
to_chat(user, "<span class='notice'>You empty [free_space] units of [R.name] into your [RC.name].</span>")
RC.reagents.add_reagent(R.id, free_space)
reagents.remove_reagent(R.id, free_space)
SSvueui.check_uis_for_change(src)
else
to_chat(user, "<span class='warning'>You need to be holding a valid container to empty [R.name]!</span>")
if (!do_after(usr, 1 SECONDS, act_target = src))
return
usr.visible_message(
"<span class='notice'>[usr] opened [src] and has taken out [english_list(contents)].</span>" ,
"<span class='notice'>You have opened [src] and taken out [english_list(contents)].</span>"
)
dispose()
/obj/machinery/microwave/proc/eject(var/message = 1, var/obj/EJ = null)
if (EJ)
EJ.forceMove(loc)
else
for (var/atom/movable/A in contents)
A.forceMove(loc)
if (reagents.total_volume)
dirty += round(reagents.total_volume / 10)
reagents.clear_reagents()
if (message)
to_chat(usr, "<span class='notice'>You dispose of the microwave contents.</span>")
SSvueui.check_uis_for_change(src)
/obj/machinery/microwave/CanPass(atom/movable/mover, turf/target, height=0, air_group=0)
if (!mover)
@@ -476,4 +531,23 @@
/obj/machinery/microwave/proc/after_finish_loop()
set_light(0)
soundloop.stop()
update_icon()
update_icon()
/obj/machinery/microwave/RefreshParts()
..()
var/bin_rating = 0 // 2
var/cap_rating = 0 // 3
var/las_rating = 0 // 1
for (var/obj/item/weapon/stock_parts/P in component_parts)
if(ismatterbin(P))
bin_rating += (P.rating - 1)
else if(iscapacitor(P))
cap_rating += (P.rating - 1)
else if(ismicrolaser(P))
las_rating += (P.rating - 1)
active_power_usage = initial(active_power_usage) - (cap_rating * 25)
max_n_of_items = initial(max_n_of_items) + Floor(bin_rating)
cooking_power = initial(cooking_power) + (las_rating / 3)
@@ -117,7 +117,7 @@
board_type = "machine"
req_components = list(
"/obj/item/weapon/stock_parts/capacitor" = 3,
"/obj/item/weapon/stock_parts/scanning_module" = 1,
"/obj/item/weapon/stock_parts/micro_laser" = 1,
"/obj/item/weapon/stock_parts/matter_bin" = 2)
/obj/item/weapon/circuitboard/oven
@@ -70,6 +70,7 @@
if(standard_splash_mob(user, target))
return
if(standard_pour_into(user, target))
SSvueui.check_uis_for_change(target)
return
if(standard_splash_obj(user, target))
return
+49
View File
@@ -0,0 +1,49 @@
################################
# Example Changelog File
#
# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb.
#
# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.)
# When it is, any changes listed below will disappear.
#
# Valid Prefixes:
# bugfix
# wip (For works in progress)
# tweak
# soundadd
# sounddel
# rscadd (general adding of nice things)
# rscdel (general deleting of nice things)
# imageadd
# imagedel
# maptweak
# spellcheck (typo fixes)
# experiment
# balance
# admin
# backend
# security
# refactor
#################################
# Your name.
author: JohnWildkins
# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again.
delete-after: True
# Any changes you've made. See valid prefix list above.
# INDENT WITH TWO SPACES. NOT TABS. SPACES.
# SCREW THIS UP AND IT WON'T WORK.
# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries.
# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog.
changes:
- refactor: "Microwaves have been reworked from the ground up on the back-end. Microwaves have been moved to a process-based system for cooking, and behave more similarly to other cooking devices."
- rscadd: "Microwaves have had their UI rebuilt from scratch in Vue."
- rscadd: "You can now eject individual ingredients and reagents from a microwave. To perform the latter, you must be holding a reagent container with enough space in your hands."
- rscadd: "You can now start microwaves by alt-clicking on them."
- rscadd: "Microwaves can now be upgraded, with matter bins, capacitors, and the micro laser affecting maximum cookable items, power usage, and cook time respectively."
- tweak: "Microwaves now display their cook time as a progress bar in the UI. Cook time has been reduced across the board."
- tweak: "Eject verb for microwaves removed. All interfacing should now be done via the UI."
- bugfix: "Bugs both known and unknown relating to the old UI and general instability of the microwave have been solved, including food duplication."
- backend: "Vue UI progress bar element now caps width at 100%."
@@ -0,0 +1,63 @@
<template>
<div>
<template v-if="on">
<template v-if="pastHalfTime">
<p v-if="!ingredientsPresent">There's nothing inside. Microwave's working, though!</p>
<p v-else-if="failed">Something doesn't look right...</p>
<p v-else>It's cooking nicely!</p>
</template>
<p v-else>It's starting to cook...</p>
<vui-progress :value="$root.$data.wtime" :min="start_time" :max="start_time + cook_time"/>
<vui-button class="danger danger-control" icon="exclamation-triangle" :params="{abort: 1}">Abort!</vui-button>
</template>
<template v-else>
<h4>Ingredients</h4>
<ul>
<li v-if="!ingredientsPresent">The microwave is empty!</li>
<li v-for="(amt, name) in cookingobjs" :key="name">
<vui-button :params="{ eject: name }"> {{ name }} {{ amt }}
</vui-button>
</li>
<li v-for="(amt, name) in cookingreas" :key="name">
<vui-button :params="{ eject: name }"> {{ name }} {{ amt }} units
</vui-button>
</li>
</ul>
<vui-button class="danger danger-control" icon="trash" :params="{eject_all: 1}">Eject All</vui-button>
<vui-button class="control" :params="{cook: 1}">Cook!</vui-button>
</template>
</div>
</template>
<script>
export default {
data() {
return this.$root.$data.state; // Make data more easily accessible
},
computed: {
ingredientsPresent() {
return (Object.keys(this.cookingobjs).length > 0 || Object.keys(this.cookingreas).length > 0);
},
pastHalfTime() {
return this.$root.$data.wtime > (this.start_time + (this.cook_time / 2))
}
}
};
</script>
<style lang="scss" scoped>
// I am so sorry.
ul {
padding: 4px 4px 10px 10px;
}
.danger-control {
position: fixed;
right: 20px;
bottom: 20px;
}
.control {
position: fixed;
left: 20px;
bottom: 20px;
}
</style>
+1 -1
View File
@@ -23,7 +23,7 @@ export default {
},
computed: {
percentage() {
return (this.value - this.min) / (this.max - this.min) * 100
return (Math.min(this.max, Math.max(this.value, this.min)) - this.min) / (this.max - this.min) * 100;
}
}
}