Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 95fdd6f

Browse files
Lohikarskull132
authored andcommittedJun 5, 2017
Kitchen tweaks (#2570)
changes: Reduced power usage of oven and fryer. Reduced warm up time of oven and fryer. Oven now heats up to exactly 200C instead of to 198.85C. Fixed some issues with cooking appliances' sanity checks. Recipe datums are now initialized once instead of per-appliance. Moved some cooking verbs to the Objects tab instead of a null category.
1 parent 68415f6 commit 95fdd6f

File tree

16 files changed

+158
-177
lines changed

16 files changed

+158
-177
lines changed
 

‎code/__defines/subsystem-defines.dm

+3
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,6 @@
6363

6464
// -- SSfalling --
6565
#define ADD_FALLING_ATOM(atom) if (!atom.multiz_falling) { atom.multiz_falling = 1; SSfalling.falling[atom] = 0; }
66+
67+
// -- SSmachinery --
68+
#define RECIPE_LIST(T) (SSmachinery.recipe_datums["[T]"])

‎code/_helpers/sorting/cmp.dm

+5
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,8 @@ var/cmp_field = "name"
7878

7979
/proc/cmp_surgery(datum/surgery_step/a, datum/surgery_step/b)
8080
return b.priority - a.priority
81+
82+
/proc/cmp_recipe_complexity_dsc(datum/recipe/A, datum/recipe/B)
83+
var/a_score = LAZYLEN(A.items) + LAZYLEN(A.reagents) + LAZYLEN(A.fruit)
84+
var/b_score = LAZYLEN(B.items) + LAZYLEN(B.reagents) + LAZYLEN(B.fruit)
85+
return b_score - a_score

‎code/_onclick/ai.dm

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
Topic(src, list("command"="open", "activate" = "0"))
134134
return 1
135135

136-
/atom/proc/AICtrlClick()
136+
/atom/proc/AICtrlClick(mob/user)
137137
return
138138

139139
/obj/machinery/door/airlock/AICtrlClick() // Bolts doors

‎code/controllers/subsystems/machinery.dm

+19
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020

2121
var/list/slept_in_process = list()
2222

23+
// Cooking stuff. Not substantial enough to get its own SS, so it's shoved in here.
24+
var/list/recipe_datums = list()
25+
2326
/datum/controller/subsystem/machinery/Recover()
2427
all_cameras = SSmachinery.all_cameras
2528

@@ -29,10 +32,26 @@
2932
/datum/controller/subsystem/machinery/New()
3033
NEW_SS_GLOBAL(SSmachinery)
3134

35+
#define ADD_TO_RDATUMS(i,t) if (R.appliance & i) { LAZYADD(recipe_datums["[i]"], t); added++; }
36+
3237
/datum/controller/subsystem/machinery/Initialize(timeofday)
38+
for (var/type in subtypesof(/datum/recipe))
39+
var/datum/recipe/R = new type
40+
var/added = 0
41+
ADD_TO_RDATUMS(MICROWAVE, R)
42+
ADD_TO_RDATUMS(FRYER, R)
43+
ADD_TO_RDATUMS(OVEN, R)
44+
ADD_TO_RDATUMS(CANDYMAKER, R)
45+
ADD_TO_RDATUMS(CEREALMAKER, R)
46+
if (!added)
47+
log_debug("SSmachinery: warning: type '[type]' does not have a valid machine type.")
48+
qdel(R)
49+
3350
fire(FALSE, TRUE) // Tick machinery once to pare down the list so we don't hammer the server on round-start.
3451
..(timeofday)
3552

53+
#undef ADD_TO_RDATUMS
54+
3655
/datum/controller/subsystem/machinery/fire(resumed = 0, no_mc_tick = FALSE)
3756
if (!resumed)
3857
src.processing_machinery = machines.Copy()

‎code/game/machinery/kitchen/cooking_machines/_appliance.dm

+36-73
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// This folder contains code that was originally ported from Apollo Station and then refactored/optimized/changed.
22

33
// Tracks precooked food to stop deep fried baked grilled grilled grilled diona nymph cereal.
4-
/obj/item/weapon/reagent_containers/food/snacks/var/list/cooked = list()
4+
/obj/item/weapon/reagent_containers/food/snacks
5+
var/tmp/list/cooked = list()
56

67
// Root type for cooking machines. See following files for specific implementations.
78
/obj/machinery/appliance
@@ -16,7 +17,6 @@
1617
idle_power_usage = 5 // Power used when turned on, but not processing anything
1718
active_power_usage = 1000 // Power used when turned on and actively cooking something
1819

19-
2020
var/cooking_power = 1
2121
var/max_contents = 1 // Maximum number of things this appliance can simultaneously cook
2222
var/on_icon // Icon state used when cooking.
@@ -34,7 +34,6 @@
3434
// If the machine has multiple output modes, define them here.
3535
var/selected_option
3636
var/list/output_options = list()
37-
var/list/datum/recipe/available_recipes // List of the recipes this appliance could possibly make
3837

3938
var/container_type = null
4039

@@ -45,16 +44,6 @@
4544
if(output_options.len)
4645
verbs += /obj/machinery/appliance/proc/choose_output
4746

48-
if (!available_recipes)
49-
available_recipes = new
50-
51-
for (var/type in subtypesof(/datum/recipe))
52-
var/datum/recipe/test = new type
53-
if ((appliancetype & test.appliance))
54-
available_recipes += test
55-
else
56-
qdel(test)
57-
5847
/obj/machinery/appliance/Destroy()
5948
for (var/a in cooking_objs)
6049
var/datum/cooking_item/CI = a
@@ -111,65 +100,62 @@
111100

112101
/obj/machinery/appliance/verb/toggle_power()
113102
set name = "Toggle Power"
114-
set category = null
115-
set src in view() //So that AI can operate it remotely
103+
set category = "Object"
104+
set src in view()
116105

117-
if (!isliving(usr))
118-
usr << "Ghosts aren't allowed to toggle power switches"
106+
attempt_toggle_power(usr)
107+
108+
/obj/machinery/appliance/proc/attempt_toggle_power(mob/user)
109+
if (!isliving(user))
119110
return
120111

121-
if (isanimal(usr))
122-
usr << "You lack the dexterity to do that!"
112+
if (!user.IsAdvancedToolUser())
113+
user << "You lack the dexterity to do that!"
123114
return
124115

125-
if (usr.stat || usr.restrained() || usr.incapacitated())
116+
if (user.stat || user.restrained() || user.incapacitated())
126117
return
127118

128-
if (!Adjacent(usr))
129-
if (!issilicon(usr))
130-
usr << "You can't reach the power switch from there, get closer!"
131-
return
119+
if (!Adjacent(user) && !issilicon(user))
120+
user << "You can't reach [src] from here."
121+
return
132122

133123
if (stat & POWEROFF)//Its turned off
134124
stat &= ~POWEROFF
135125
use_power = 1
136-
if (usr)
137-
usr.visible_message("[usr] turns the [src] on", "You turn on the [src]")
126+
user.visible_message("[user] turns [src] on.", "You turn on [src].")
127+
138128
else //Its on, turn it off
139129
stat |= POWEROFF
140130
use_power = 0
141-
if (usr)
142-
usr.visible_message("[usr] turns the [src] off", "You turn off the [src]")
131+
user.visible_message("[user] turns [src] off.", "You turn off [src].")
143132

144133
playsound(src, 'sound/machines/click.ogg', 40, 1)
145134
update_icon()
146135

147-
/obj/machinery/appliance/AICtrlClick()
148-
toggle_power()
136+
/obj/machinery/appliance/AICtrlClick(mob/user)
137+
attempt_toggle_power(user)
149138

150139
/obj/machinery/appliance/proc/choose_output()
151140
set src in view()
152141
set name = "Choose output"
153-
set category = null
142+
set category = "Object"
154143

155144
if (!isliving(usr))
156-
usr << "Ghosts aren't allowed to mess with cooking machines!"
157145
return
158146

159-
if (isanimal(usr))
147+
if (!usr.IsAdvancedToolUser())
160148
usr << "You lack the dexterity to do that!"
161149
return
162150

163151
if (usr.stat || usr.restrained() || usr.incapacitated())
164152
return
165153

166-
if (!Adjacent(usr))
167-
if (!issilicon(usr))
168-
usr << "You can't adjust the [src] from this distance, get closer!"
169-
return
154+
if (!Adjacent(usr) && !issilicon(usr))
155+
usr << "You can't adjust the [src] from this distance, get closer!"
156+
return
170157

171158
if(output_options.len)
172-
173159
var/choice = input("What specific food do you wish to make with \the [src]?") as null|anything in output_options+"Default"
174160
if(!choice)
175161
return
@@ -217,7 +203,7 @@
217203
user << "<span class='warning'>That would probably break [src].</span>"
218204
return 0
219205
else if(istype(check, /obj/item/weapon/disk/nuclear))
220-
user << "Central Command would kill you if you [cook_type] that."
206+
user << "<span class='warning'>You can't cook that.</span>"
221207
return 0
222208
else if(!istype(check) && !istype(check, /obj/item/weapon/holder))
223209
user << "<span class='warning'>That's not edible.</span>"
@@ -238,8 +224,6 @@
238224
user << "<span class='warning'>\The [src] is not working.</span>"
239225
return
240226

241-
242-
243227
var/result = can_insert(I, user)
244228
if (!result)
245229
return
@@ -250,18 +234,10 @@
250234
cook_mob(G.affecting, user)
251235
return
252236

253-
254237
//From here we can start cooking food
255238
add_content(I, user)
256-
257-
258239
update_icon()
259240

260-
261-
262-
263-
264-
265241
//Override for container mechanics
266242
/obj/machinery/appliance/proc/add_content(var/obj/item/I, var/mob/user)
267243
if(!user.unEquip(I))
@@ -286,7 +262,6 @@
286262
if (selected_option)
287263
CI.combine_target = selected_option
288264

289-
290265
// We can actually start cooking now.
291266
user.visible_message("<span class='notice'>\The [user] puts \the [I] into \the [src].</span>")
292267

@@ -348,7 +323,6 @@
348323

349324
CI.max_cookwork += work
350325

351-
352326
//Called every tick while we're cooking something
353327
/obj/machinery/appliance/proc/do_cooking_tick(var/datum/cooking_item/CI)
354328
if (!CI.max_cookwork)
@@ -381,7 +355,6 @@
381355
do_cooking_tick(i)
382356

383357

384-
385358
/obj/machinery/appliance/proc/finish_cooking(var/datum/cooking_item/CI)
386359

387360
src.visible_message("<span class='notice'>\The [src] pings!</span>")
@@ -394,7 +367,7 @@
394367
C = CI.container
395368
else
396369
C = src
397-
recipe = select_recipe(available_recipes,C)
370+
recipe = select_recipe(RECIPE_LIST(appliancetype), C)
398371

399372
if (recipe)
400373
CI.result_type = 4//Recipe type, a specific recipe will transform the ingredients into a new food
@@ -406,26 +379,25 @@
406379
AM.loc = temp
407380

408381
//making multiple copies of a recipe from one container. For example, tons of fries
409-
while (select_recipe(available_recipes,C) == recipe)
382+
while (select_recipe(RECIPE_LIST(appliancetype), C) == recipe)
410383
var/list/TR = list()
411-
TR.Add(recipe.make_food(C))
384+
TR += recipe.make_food(C)
412385
for (var/atom/movable/AM in TR) //Move results to buffer
413386
AM.loc = temp
414-
results.Add(TR)
387+
results += TR
415388

416389

417390
for (var/r in results)
418391
var/obj/item/weapon/reagent_containers/food/snacks/R = r
419392
R.loc = C //Move everything from the buffer back to the container
420-
R.cooked |= cook_type.
393+
R.cooked |= cook_type
421394

422-
qdel(temp) //delete buffer object
423-
temp = null
424-
.=1 //None of the rest of this function is relevant for recipe cooking
395+
QDEL_NULL(temp) //delete buffer object
396+
. = 1 //None of the rest of this function is relevant for recipe cooking
425397

426398
else if(CI.combine_target)
427399
CI.result_type = 3//Combination type. We're making something out of our ingredients
428-
.=combination_cook(CI)
400+
. = combination_cook(CI)
429401

430402

431403
else
@@ -461,8 +433,6 @@
461433
words |= dd_text2List(S.name," ")
462434
cooktypes |= S.cooked
463435

464-
465-
466436
if (S.reagents && S.reagents.total_volume > 0)
467437
if (S.filling_color)
468438
if (!totalcolour || !buffer.total_volume)
@@ -493,7 +463,7 @@
493463
result.filling_color = totalcolour
494464

495465
//Set the name.
496-
words.Remove(list("and", "the", "in", "is", "bar", "raw", "sticks", "boiled", "fried", "deep", "-o-", "warm", "two", "flavored"))
466+
words -= list("and", "the", "in", "is", "bar", "raw", "sticks", "boiled", "fried", "deep", "-o-", "warm", "two", "flavored")
497467
//Remove common connecting words and unsuitable ones from the list. Unsuitable words include those describing
498468
//the shape, cooked-ness/temperature or other state of an ingredient which doesn't apply to the finished product
499469
words.Remove(result.name)
@@ -524,7 +494,7 @@
524494
if (!result)
525495
return
526496

527-
result.cooked |= cook_type.
497+
result.cooked |= cook_type
528498

529499
// Set icon and appearance.
530500
change_product_appearance(result, CI)
@@ -600,17 +570,14 @@
600570

601571
/obj/machinery/appliance/proc/change_product_strings(var/obj/item/weapon/reagent_containers/food/snacks/product, var/datum/cooking_item/CI)
602572
product.name = "[cook_type] [product.name]"
603-
product.desc = "[product.desc] It has been [cook_type]."
573+
product.desc = "[product.desc]\nIt has been [cook_type]."
604574

605575

606576
/obj/machinery/appliance/proc/change_product_appearance(var/obj/item/weapon/reagent_containers/food/snacks/product, var/datum/cooking_item/CI)
607577
if (!product.coating) //Coatings change colour through a new sprite
608578
product.color = food_color
609579
product.filling_color = food_color
610580

611-
612-
613-
614581
//This function creates a food item which represents a dead mob
615582
/obj/machinery/appliance/proc/create_mob_food(var/obj/item/weapon/holder/H, var/datum/cooking_item/CI)
616583
if (!istype(H) || !H.contained)
@@ -649,9 +616,7 @@
649616

650617
return result
651618

652-
653619
/datum/cooking_item
654-
//var/obj/object
655620
var/max_cookwork
656621
var/cookwork
657622
var/overcook_mult = 3
@@ -674,10 +639,8 @@
674639
/datum/cooking_item/New(var/obj/item/I)
675640
container = I
676641

677-
678642
//This is called for containers whose contents are ejected without removing the container
679643
/datum/cooking_item/proc/reset()
680-
//object = null
681644
max_cookwork = 0
682645
cookwork = 0
683646
result_type = 0

‎code/game/machinery/kitchen/cooking_machines/_cooker.dm

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
/obj/machinery/appliance/cooker
22
var/temperature = T20C
3-
var/min_temp = 353//Minimum temperature to do any cooking
4-
var/optimal_temp = 472//Temperature at which we have 100% efficiency. efficiency is lowered on either side of this
3+
var/min_temp = 80 + T0C //Minimum temperature to do any cooking
4+
var/optimal_temp = 200 + T0C //Temperature at which we have 100% efficiency. efficiency is lowered on either side of this
55
var/optimal_power = 0.1//cooking power at 100%
66

7-
var/loss = 1//Temp lost per proc when equalising
8-
var/resistance = 320000//Resistance to heating. combines with active power usage to determine how long heating takes
7+
var/loss = 1 //Temp lost per proc when equalising
8+
var/resistance = 320000 //Resistance to heating. combines with active power usage to determine how long heating takes
99

1010
var/light_x = 0
1111
var/light_y = 0
1212
cooking_power = 0
1313

1414
/obj/machinery/appliance/cooker/examine(var/mob/user)
1515
. = ..()
16-
if (.)//no need to duplicate adjacency check
16+
if (.) //no need to duplicate adjacency check
1717
if (!stat)
1818
if (temperature < min_temp)
1919
user << span("warning", "The [src] is still heating up and is too cold to cook anything yet.")
@@ -37,8 +37,7 @@
3737
usr << span("notice","It is empty.")
3838

3939
/obj/machinery/appliance/cooker/proc/get_efficiency()
40-
. = cooking_power / optimal_power
41-
. *= 100
40+
. = (cooking_power / optimal_power) * 100
4241

4342
/obj/machinery/appliance/cooker/Initialize()
4443
. = ..()

0 commit comments

Comments
 (0)
Please sign in to comment.