Skip to content

Commit

Permalink
CWJ Oven overhaul (#5515)
Browse files Browse the repository at this point in the history
* Cooking fix

Prevents containers placed in an oven from storing time infinitely, leading to a feedback loop where it caused later recipes to be low quality.

* Further Oven Updates

Measuring Cooking time should be improved
Food is burned if left to cook in an oven for too long
Oven is set fire if the oven is left on way too long - will trigger nearby fire alarms and require an extinguisher to put out.
CtrlClick option menu now has the "start oven" option

* Ensuring code compilation

* oven overhauls

Improved oven open/close interactions
Grill cooking time fixed
Stove Cooking time fixed
Added CWJ recipes for making and kneading up high quality dough, and making dough batches
Small bug removed from use_tool step type

* being thorough with the code

Laid chicken eggs have  more food quality
Improved Reagent quality calculation
  • Loading branch information
hex37 authored Jul 9, 2024
1 parent cf20cb5 commit 8034ded
Show file tree
Hide file tree
Showing 14 changed files with 265 additions and 91 deletions.
6 changes: 3 additions & 3 deletions code/__DEFINES/cooking_with_jane.dm
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@

//Ignite times for reagents interacting with a stove.
//The stove will catch fire if left on too long with flammable reagents in any of its holders.
#define CWJ_IGNITE_TIME_LOW 1 HOUR
#define CWJ_IGNITE_TIME_MEDIUM 30 MINUTES
#define CWJ_IGNITE_TIME_HIGH 15 MINUTES
#define CWJ_IGNITE_TIME_LOW 20 MINUTES
#define CWJ_IGNITE_TIME_MEDIUM 12 MINUTES
#define CWJ_IGNITE_TIME_HIGH 10 MINUTES

//Determines how much quality is taken from a food each tick when a 'no recipe' response is made.
#define CWJ_BASE_QUAL_REDUCTION 5
Expand Down
19 changes: 15 additions & 4 deletions code/modules/cooking_with_jane/cooking.dm
Original file line number Diff line number Diff line change
Expand Up @@ -619,9 +619,15 @@ Food quality is calculated based on the steps taken.
//-----------------------------------------------------------------------------------
//default function for creating a product
/datum/cooking_with_jane/recipe/proc/create_product(var/datum/cooking_with_jane/recipe_pointer/pointer)
#ifdef CWJ_DEBUG
log_debug("/recipe/proc/create_product: Called Function.")
#endif
var/datum/cooking_with_jane/recipe_tracker/parent = pointer.parent_ref.resolve()
var/obj/item/container = parent.holder_ref.resolve()
if(container)
//Calculate quality for reagents before we mess around with the datum
var/reagent_quality = calculate_reagent_quality(pointer)

//Build up a list of reagents that went into this.
var/datum/reagents/slurry = new /datum/reagents(max=1000000, A=container)

Expand Down Expand Up @@ -699,9 +705,6 @@ Food quality is calculated based on the steps taken.
QDEL_LIST(container.contents)
container.contents = list()

var/reagent_quality = calculate_reagent_quality(pointer)


//Produce Item descriptions based on the steps taken
var/cooking_description_modifier = ""
for(var/id in pointer.steps_taken)
Expand Down Expand Up @@ -736,7 +739,7 @@ Food quality is calculated based on the steps taken.

if(reagent_id) //Make a reagent
//quality handling
var/total_quality = pointer.tracked_quality + calculate_reagent_quality(pointer)
var/total_quality = pointer.tracked_quality + reagent_quality

//Create our Reagent
container.reagents.add_reagent(reagent_id, reagent_amount, data=list("FOOD_QUALITY" = total_quality))
Expand All @@ -746,6 +749,9 @@ Food quality is calculated based on the steps taken.
//Extra Reagents in a recipe take away recipe quality for every extra unit added to the concoction.
//Reagents are calculated in two areas. Here and /datum/cooking_with_jane/recipe_step/add_reagent/calculate_quality
/datum/cooking_with_jane/recipe/proc/calculate_reagent_quality(var/datum/cooking_with_jane/recipe_pointer/pointer)
#ifdef CWJ_DEBUG
log_debug("/recipe/proc/calculate_reagent_quality: Calculating product")
#endif
if(!GLOB.cwj_step_dictionary_ordered["[CWJ_ADD_REAGENT]"])
return 0
var/datum/cooking_with_jane/recipe_tracker/parent = pointer.parent_ref.resolve()
Expand All @@ -762,6 +768,11 @@ Food quality is calculated based on the steps taken.
calculated_volume += active_step.required_reagent_amount

calculated_quality += active_step.base_quality_award
#ifdef CWJ_DEBUG
log_debug("/recipe/proc/calculate_reagent_quality: Calculated quality - [calculated_quality]")
log_debug("/recipe/proc/calculate_reagent_quality: Calculated volume - [calculated_volume]")
log_debug("/recipe/proc/calculate_reagent_quality: Total volume - [total_volume]")
#endif

return calculated_quality - (total_volume - calculated_volume)

Expand Down
62 changes: 49 additions & 13 deletions code/modules/cooking_with_jane/cooking_appliances/grill.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
var/list/cooking_timestamp = list(0, 0) //Timestamp of when cooking initialized so we know if the prep was disturbed at any point.
var/list/items[2]

var/datum/effect/effect/system/smoke_spread/bad/bsmoke = new /datum/effect/effect/system/smoke_spread/bad

use_power = 0
interact_offline = TRUE

Expand All @@ -33,15 +35,24 @@
var/obj/effect/flicker_overlay/hopper_insert
scan_types = list("scan_1")

/obj/machinery/cooking_with_jane/grill/New()
..()
bsmoke.attach(src)
bsmoke.set_up(7, 0, src.loc)

/obj/machinery/cooking_with_jane/grill/Initialize()
. = ..()
hopper_insert = new(src)

//Did not want to use this...
/obj/machinery/cooking_with_jane/grill/Process()

//if(on_fire)
//Do bad things if it is on fire.
if(on_fire)
if(stored_wood)
emit_fire()
else
on_fire = FALSE


for(var/i=1, i<=2, i++)
if(switches[i])
Expand Down Expand Up @@ -133,12 +144,21 @@
container.handle_burning()

/obj/machinery/cooking_with_jane/grill/proc/handle_ignition(input)
if(!(items[input] && istype(items[input], /obj/item/reagent_containers/cooking_with_jane/cooking_container)))
if(!(items && istype(items, /obj/item/reagent_containers/cooking_with_jane/cooking_container)))
return

var/obj/item/reagent_containers/cooking_with_jane/cooking_container/container = items[input]
if(container.handle_ignition())
on_fire = TRUE
//Initial burst of smoke so it matches the fire alarm
bsmoke.start()

//Trigger fire alarms
var/area/area = get_area(src)
for(var/obj/machinery/firealarm/FA in area)
fire_alarm.triggerAlarm(loc, FA, 0)

on_fire = TRUE

/obj/machinery/cooking_with_jane/grill/proc/emit_fire()
bsmoke.start()

//Retrieve which quadrant of the baking pan is being used.
/obj/machinery/cooking_with_jane/grill/proc/getInput(params)
Expand All @@ -158,6 +178,26 @@
if(default_deconstruction(used_item, user))
return

if(on_fire && istype(used_item, /obj/item/extinguisher))
var/obj/item/extinguisher/exting = used_item
if(!exting.safety)
if (exting.reagents.total_volume < 1)
to_chat(usr, SPAN_NOTICE("\The [exting] is empty."))
return

if (world.time < exting.last_use + 20)
return

exting.last_use = world.time

playsound(exting.loc, 'sound/effects/extinguish.ogg', 75, 1, -3)

exting.reagents.remove_any(20)

on_fire = FALSE

return

if(istype(used_item, /obj/item/stack/material/wood))
var/obj/item/stack/material/wood/stack = used_item
var/used_sheets = min(stack.get_amount(), (wood_maximum - stored_wood))
Expand Down Expand Up @@ -336,17 +376,13 @@
log_debug(" grill_data: [container.grill_data]")
#endif


if(container.grill_data[temperature[input]])
container.grill_data[temperature[input]] += reference_time
else
container.grill_data[temperature[input]] = reference_time
container.grill_data[temperature[input]] = reference_time


if(user && user.Adjacent(src))
container.process_item(src, user, lower_quality_on_fail=CWJ_BASE_QUAL_REDUCTION, send_message=TRUE)
container.process_item(src, user, lower_quality_on_fail=0, send_message=TRUE)
else
container.process_item(src, user, lower_quality_on_fail=CWJ_BASE_QUAL_REDUCTION)
container.process_item(src, user, lower_quality_on_fail=0)



Expand Down
96 changes: 62 additions & 34 deletions code/modules/cooking_with_jane/cooking_appliances/oven.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,22 @@

var/on_fire = FALSE //if the oven has caught fire or not.

var/datum/effect/effect/system/smoke_spread/bad/bsmoke = new /datum/effect/effect/system/smoke_spread/bad

circuit = /obj/item/circuitboard/cooking_with_jane/oven

scan_types = list("smile", "peep")

/obj/machinery/cooking_with_jane/oven/New()
..()
bsmoke.attach(src)
bsmoke.set_up(7, 0, src.loc)

//Did not want to use this...
/obj/machinery/cooking_with_jane/oven/Process()

//if(on_fire)
//Do bad things if it is on fire.
if(on_fire)
emit_fire()

if(switches)
handle_cooking(null, FALSE)
Expand Down Expand Up @@ -103,48 +109,74 @@
if(!(items && istype(items, /obj/item/reagent_containers/cooking_with_jane/cooking_container)))
return

var/obj/item/reagent_containers/cooking_with_jane/cooking_container/container = items
if(container.handle_ignition())
on_fire = TRUE
//Initial burst of smoke so it matches the fire alarm
bsmoke.start()

//Trigger fire alarms
var/area/area = get_area(src)
for(var/obj/machinery/firealarm/FA in area)
fire_alarm.triggerAlarm(loc, FA, 0)

on_fire = TRUE

/obj/machinery/cooking_with_jane/oven/proc/emit_fire()
bsmoke.start()

/obj/machinery/cooking_with_jane/oven/attackby(var/obj/item/used_item, var/mob/user, params)
if(default_deconstruction(used_item, user))
return

var/center_selected = getInput(params)
if(on_fire && istype(used_item, /obj/item/extinguisher))
var/obj/item/extinguisher/exting = used_item
if(!exting.safety)
if (exting.reagents.total_volume < 1)
to_chat(usr, SPAN_NOTICE("\The [exting] is empty."))
return

if(opened && center_selected)
if (world.time < exting.last_use + 20)
return

exting.last_use = world.time

playsound(exting.loc, 'sound/effects/extinguish.ogg', 75, 1, -3)

exting.reagents.remove_any(20)

on_fire = FALSE

if(istype(used_item, /obj/item/gripper))
var/obj/item/gripper/gripper = used_item
if(!gripper.wrapped && items)
var/obj/item/reagent_containers/cooking_with_jane/cooking_container/container = items
var/turf/T = get_turf(src)
container.forceMove(T)
items = null
update_icon()
return

if(items != null)
if(istype(used_item, /obj/item/gripper))
var/obj/item/gripper/gripper = used_item
if(!gripper.wrapped && items)
var/obj/item/reagent_containers/cooking_with_jane/cooking_container/container = items
var/turf/T = get_turf(src)
container.forceMove(T)
items = null
update_icon()
return

if(istype(used_item, /obj/item/spatula))
container.do_empty(user, target=src, reagent_clear = FALSE)
else
container.process_item(used_item, params)
if(items != null && opened)
var/obj/item/reagent_containers/cooking_with_jane/cooking_container/container = items

if(istype(used_item, /obj/item/spatula))
container.do_empty(user, target=src, reagent_clear = FALSE)
else
container.process_item(used_item, params)

else if(istype(used_item, /obj/item/reagent_containers/cooking_with_jane/cooking_container))
to_chat(usr, SPAN_NOTICE("You put a [used_item] on the oven."))
else if(istype(used_item, /obj/item/reagent_containers/cooking_with_jane/cooking_container))
if(opened)
to_chat(usr, SPAN_NOTICE("You put a [used_item] in the oven."))
if(usr.canUnEquip(used_item))
usr.unEquip(used_item, src)
else
used_item.forceMove(src)
items = used_item
if(switches == 1)
cooking_timestamp = world.time
else
handle_open()

else
handle_open(user)
update_icon()

//Retrieve whether or not the oven door has been clicked.
Expand Down Expand Up @@ -188,7 +220,7 @@
burn_victim.adjustFireLoss(5)
if("Medium")
burn_victim.adjustFireLoss(2)
to_chat(burn_victim, SPAN_DANGER("You burn your hand a little taking the [items] off of the oven."))
to_chat(burn_victim, SPAN_DANGER("You burn your hand a little taking the [items] out of the oven."))
user.put_in_hands(items)
items = null
else
Expand All @@ -213,6 +245,7 @@
if("Set timer")
handle_timer(user)


//Switch the cooking device on or off
/obj/machinery/cooking_with_jane/oven/CtrlShiftClick(var/mob/user, params)

Expand Down Expand Up @@ -262,7 +295,7 @@
#endif
var/old_timerstamp = timerstamp
spawn(timer)
log_debug("Comparimg timerstamp() of [timerstamp] to old_timerstamp [old_timerstamp]")
log_debug("Comparing timerstamp() of [timerstamp] to old_timerstamp [old_timerstamp]")
if(old_timerstamp == timerstamp)
playsound(src, 'sound/items/lighter.ogg', 100, 1, 0)

Expand Down Expand Up @@ -319,17 +352,12 @@
log_debug(" oven_data: [container.oven_data]")
#endif


if(container.oven_data[temperature])
container.oven_data[temperature] += reference_time
else
container.oven_data[temperature] = reference_time

container.oven_data[temperature] = reference_time

if(user && user.Adjacent(src))
container.process_item(src, user, lower_quality_on_fail=CWJ_BASE_QUAL_REDUCTION, send_message=TRUE)
container.process_item(src, user, lower_quality_on_fail=0, send_message=TRUE)
else
container.process_item(src, user, lower_quality_on_fail=CWJ_BASE_QUAL_REDUCTION)
container.process_item(src, user, lower_quality_on_fail=0)



Expand Down
Loading

0 comments on commit 8034ded

Please sign in to comment.