allows for deconstruction of kitchen appliances

should also hopefully allow for kitchen appliances to be upgraded
This commit is contained in:
MeepleMuncher
2022-09-14 15:14:44 +03:00
committed by GitHub
parent bc2886f4c5
commit dcc780f36e
7 changed files with 519 additions and 464 deletions

View File

@@ -42,3 +42,12 @@
/obj/machinery/appliance/mixer/candy/change_product_appearance(var/obj/item/weapon/reagent_containers/food/snacks/product) /obj/machinery/appliance/mixer/candy/change_product_appearance(var/obj/item/weapon/reagent_containers/food/snacks/product)
food_color = get_random_colour(1) food_color = get_random_colour(1)
. = ..() . = ..()
/obj/machinery/appliance/mixer/candy/attackby(var/obj/item/O as obj, var/mob/user as mob)
if(default_deconstruction_screwdriver(user, O)) //CHOMPedit - Allows for deconstruction
return
if(default_deconstruction_crowbar(user, O))
return
if(default_part_replacement(user, O))
return

View File

@@ -84,3 +84,12 @@
result.color = result.filling_color result.color = result.filling_color
for (var/i in images) for (var/i in images)
result.overlays += images[i] result.overlays += images[i]
/obj/machinery/appliance/mixer/cereal/attackby(var/obj/item/O as obj, var/mob/user as mob)
if(default_deconstruction_screwdriver(user, O)) //CHOMPedit - Allows for deconstruction
return
if(default_deconstruction_crowbar(user, O))
return
if(default_part_replacement(user, O))
return

View File

@@ -1,269 +1,275 @@
/obj/machinery/appliance/cooker/fryer /obj/machinery/appliance/cooker/fryer
name = "deep fryer" name = "deep fryer"
desc = "Deep fried <i>everything</i>." desc = "Deep fried <i>everything</i>."
icon_state = "fryer_off" icon_state = "fryer_off"
can_cook_mobs = 1 can_cook_mobs = 1
cook_type = "deep fried" cook_type = "deep fried"
on_icon = "fryer_on" on_icon = "fryer_on"
off_icon = "fryer_off" off_icon = "fryer_off"
food_color = "#FFAD33" food_color = "#FFAD33"
cooked_sound = 'sound/machines/ding.ogg' cooked_sound = 'sound/machines/ding.ogg'
var/datum/looping_sound/deep_fryer/fry_loop var/datum/looping_sound/deep_fryer/fry_loop
circuit = /obj/item/weapon/circuitboard/fryer circuit = /obj/item/weapon/circuitboard/fryer
appliancetype = FRYER appliancetype = FRYER
active_power_usage = 12 KILOWATTS active_power_usage = 12 KILOWATTS
heating_power = 12 KILOWATTS heating_power = 12 KILOWATTS
light_y = 15 light_y = 15
min_temp = 140 + T0C // Same as above, increasing this to just under 2x to make the % increase on efficiency not quite so painful as it would be at 80. min_temp = 140 + T0C // Same as above, increasing this to just under 2x to make the % increase on efficiency not quite so painful as it would be at 80.
optimal_temp = 400 + T0C // Increasing this to be 2x Oven to allow for a much higher/realistic frying temperatures. Doesn't really do anything but make heating the fryer take a bit longer. optimal_temp = 400 + T0C // Increasing this to be 2x Oven to allow for a much higher/realistic frying temperatures. Doesn't really do anything but make heating the fryer take a bit longer.
optimal_power = 0.95 // .35 higher than the default to give fryers faster cooking speed. optimal_power = 0.95 // .35 higher than the default to give fryers faster cooking speed.
idle_power_usage = 3.6 KILOWATTS idle_power_usage = 3.6 KILOWATTS
// Power used to maintain temperature once it's heated. // Power used to maintain temperature once it's heated.
// Going with 25% of the active power. This is a somewhat arbitrary value. // Going with 25% of the active power. This is a somewhat arbitrary value.
resistance = 10 KILOWATTS // Approx. 10 minutes to heat up. resistance = 10 KILOWATTS // Approx. 10 minutes to heat up.
max_contents = 2 max_contents = 2
container_type = /obj/item/weapon/reagent_containers/cooking_container/fryer container_type = /obj/item/weapon/reagent_containers/cooking_container/fryer
stat = POWEROFF // Starts turned off stat = POWEROFF // Starts turned off
var/datum/reagents/oil var/datum/reagents/oil
var/optimal_oil = 9000 //90 litres of cooking oil var/optimal_oil = 9000 //90 litres of cooking oil
/obj/machinery/appliance/cooker/fryer/Initialize() /obj/machinery/appliance/cooker/fryer/Initialize()
. = ..() . = ..()
fry_loop = new(list(src), FALSE) fry_loop = new(list(src), FALSE)
oil = new/datum/reagents(optimal_oil * 1.25, src) oil = new/datum/reagents(optimal_oil * 1.25, src)
var/variance = rand()*0.15 var/variance = rand()*0.15
// Fryer is always a little below full, but its usually negligible // Fryer is always a little below full, but its usually negligible
if(prob(20)) if(prob(20))
// Sometimes the fryer will start with much less than full oil, significantly impacting efficiency until filled // Sometimes the fryer will start with much less than full oil, significantly impacting efficiency until filled
variance = rand()*0.5 variance = rand()*0.5
oil.add_reagent("cookingoil", optimal_oil*(1 - variance)) oil.add_reagent("cookingoil", optimal_oil*(1 - variance))
/obj/machinery/appliance/cooker/fryer/Destroy() /obj/machinery/appliance/cooker/fryer/Destroy()
QDEL_NULL(fry_loop) QDEL_NULL(fry_loop)
QDEL_NULL(oil) QDEL_NULL(oil)
return ..() return ..()
/obj/machinery/appliance/cooker/fryer/examine(var/mob/user) /obj/machinery/appliance/cooker/fryer/examine(var/mob/user)
. = ..() . = ..()
if(Adjacent(user)) if(Adjacent(user))
to_chat(user, "Oil Level: [oil.total_volume]/[optimal_oil]") to_chat(user, "Oil Level: [oil.total_volume]/[optimal_oil]")
/obj/machinery/appliance/cooker/fryer/update_icon() // We add our own version of the proc to use the special fryer double-lights. /obj/machinery/appliance/cooker/fryer/update_icon() // We add our own version of the proc to use the special fryer double-lights.
cut_overlays() cut_overlays()
var/image/light var/image/light
if(use_power == 1 && !stat) if(use_power == 1 && !stat)
light = image(icon, "fryer_light_idle") light = image(icon, "fryer_light_idle")
else if(use_power == 2 && !stat) else if(use_power == 2 && !stat)
light = image(icon, "fryer_light_preheating") light = image(icon, "fryer_light_preheating")
else else
light = image(icon, "fryer_light_off") light = image(icon, "fryer_light_off")
light.pixel_x = light_x light.pixel_x = light_x
light.pixel_y = light_y light.pixel_y = light_y
add_overlay(light) add_overlay(light)
/obj/machinery/appliance/cooker/fryer/heat_up() /obj/machinery/appliance/cooker/fryer/heat_up()
if (..()) if (..())
//Set temperature of oil reagent //Set temperature of oil reagent
var/datum/reagent/nutriment/triglyceride/oil/OL = oil.get_master_reagent() var/datum/reagent/nutriment/triglyceride/oil/OL = oil.get_master_reagent()
if (OL && istype(OL)) if (OL && istype(OL))
OL.data["temperature"] = temperature OL.data["temperature"] = temperature
/obj/machinery/appliance/cooker/fryer/equalize_temperature() /obj/machinery/appliance/cooker/fryer/equalize_temperature()
if (..()) if (..())
//Set temperature of oil reagent //Set temperature of oil reagent
var/datum/reagent/nutriment/triglyceride/oil/OL = oil.get_master_reagent() var/datum/reagent/nutriment/triglyceride/oil/OL = oil.get_master_reagent()
if (OL && istype(OL)) if (OL && istype(OL))
OL.data["temperature"] = temperature OL.data["temperature"] = temperature
/obj/machinery/appliance/cooker/fryer/update_cooking_power() /obj/machinery/appliance/cooker/fryer/update_cooking_power()
..()//In addition to parent temperature calculation ..()//In addition to parent temperature calculation
//Fryer efficiency also drops when oil levels arent optimal //Fryer efficiency also drops when oil levels arent optimal
var/oil_level = 0 var/oil_level = 0
var/datum/reagent/nutriment/triglyceride/oil/OL = oil.get_master_reagent() var/datum/reagent/nutriment/triglyceride/oil/OL = oil.get_master_reagent()
if(OL && istype(OL)) if(OL && istype(OL))
oil_level = OL.volume oil_level = OL.volume
var/oil_efficiency = 0 var/oil_efficiency = 0
if(oil_level) if(oil_level)
oil_efficiency = oil_level / optimal_oil oil_efficiency = oil_level / optimal_oil
if(oil_efficiency > 1) if(oil_efficiency > 1)
//We're above optimal, efficiency goes down as we pass too much over it //We're above optimal, efficiency goes down as we pass too much over it
oil_efficiency = 1 - (oil_efficiency - 1) oil_efficiency = 1 - (oil_efficiency - 1)
cooking_power *= oil_efficiency cooking_power *= oil_efficiency
/obj/machinery/appliance/cooker/fryer/update_icon() /obj/machinery/appliance/cooker/fryer/update_icon()
if(!stat) if(!stat)
..() ..()
if(cooking == TRUE) if(cooking == TRUE)
icon_state = on_icon icon_state = on_icon
if(fry_loop) if(fry_loop)
fry_loop.start(src) fry_loop.start(src)
else else
icon_state = off_icon icon_state = off_icon
if(fry_loop) if(fry_loop)
fry_loop.stop(src) fry_loop.stop(src)
else else
icon_state = off_icon icon_state = off_icon
if(fry_loop) if(fry_loop)
fry_loop.stop(src) fry_loop.stop(src)
..() ..()
//Fryer gradually infuses any cooked food with oil. Moar calories //Fryer gradually infuses any cooked food with oil. Moar calories
//This causes a slow drop in oil levels, encouraging refill after extended use //This causes a slow drop in oil levels, encouraging refill after extended use
/obj/machinery/appliance/cooker/fryer/do_cooking_tick(var/datum/cooking_item/CI) /obj/machinery/appliance/cooker/fryer/do_cooking_tick(var/datum/cooking_item/CI)
if(..() && (CI.oil < CI.max_oil) && prob(20)) if(..() && (CI.oil < CI.max_oil) && prob(20))
var/datum/reagents/buffer = new /datum/reagents(2) var/datum/reagents/buffer = new /datum/reagents(2)
oil.trans_to_holder(buffer, min(0.5, CI.max_oil - CI.oil)) oil.trans_to_holder(buffer, min(0.5, CI.max_oil - CI.oil))
CI.oil += buffer.total_volume CI.oil += buffer.total_volume
CI.container.soak_reagent(buffer) CI.container.soak_reagent(buffer)
//To solve any odd logic problems with results having oil as part of their compiletime ingredients. //To solve any odd logic problems with results having oil as part of their compiletime ingredients.
//Upon finishing a recipe the fryer will analyse any oils in the result, and replace them with our oil //Upon finishing a recipe the fryer will analyse any oils in the result, and replace them with our oil
//As well as capping the total to the max oil //As well as capping the total to the max oil
/obj/machinery/appliance/cooker/fryer/finish_cooking(var/datum/cooking_item/CI) /obj/machinery/appliance/cooker/fryer/finish_cooking(var/datum/cooking_item/CI)
..() ..()
var/total_oil = 0 var/total_oil = 0
var/total_our_oil = 0 var/total_our_oil = 0
var/total_removed = 0 var/total_removed = 0
var/datum/reagent/our_oil = oil.get_master_reagent() var/datum/reagent/our_oil = oil.get_master_reagent()
for (var/obj/item/I in CI.container) for (var/obj/item/I in CI.container)
if (I.reagents && I.reagents.total_volume) if (I.reagents && I.reagents.total_volume)
for (var/datum/reagent/R in I.reagents.reagent_list) for (var/datum/reagent/R in I.reagents.reagent_list)
if (istype(R, /datum/reagent/nutriment/triglyceride/oil)) if (istype(R, /datum/reagent/nutriment/triglyceride/oil))
total_oil += R.volume total_oil += R.volume
if (R.id != our_oil.id) if (R.id != our_oil.id)
total_removed += R.volume total_removed += R.volume
I.reagents.remove_reagent(R.id, R.volume) I.reagents.remove_reagent(R.id, R.volume)
else else
total_our_oil += R.volume total_our_oil += R.volume
if (total_removed > 0 || total_oil != CI.max_oil) if (total_removed > 0 || total_oil != CI.max_oil)
total_oil = min(total_oil, CI.max_oil) total_oil = min(total_oil, CI.max_oil)
if (total_our_oil < total_oil) if (total_our_oil < total_oil)
//If we have less than the combined total, then top up from our reservoir //If we have less than the combined total, then top up from our reservoir
var/datum/reagents/buffer = new /datum/reagents(INFINITY) var/datum/reagents/buffer = new /datum/reagents(INFINITY)
oil.trans_to_holder(buffer, total_oil - total_our_oil) oil.trans_to_holder(buffer, total_oil - total_our_oil)
CI.container.soak_reagent(buffer) CI.container.soak_reagent(buffer)
else if (total_our_oil > total_oil) else if (total_our_oil > total_oil)
//If we have more than the maximum allowed then we delete some. //If we have more than the maximum allowed then we delete some.
//This could only happen if one of the objects spawns with the same type of oil as ours //This could only happen if one of the objects spawns with the same type of oil as ours
var/portion = 1 - (total_oil / total_our_oil) //find the percentage to remove var/portion = 1 - (total_oil / total_our_oil) //find the percentage to remove
for (var/obj/item/I in CI.container) for (var/obj/item/I in CI.container)
if (I.reagents && I.reagents.total_volume) if (I.reagents && I.reagents.total_volume)
for (var/datum/reagent/R in I.reagents.reagent_list) for (var/datum/reagent/R in I.reagents.reagent_list)
if (R.id == our_oil.id) if (R.id == our_oil.id)
I.reagents.remove_reagent(R.id, R.volume*portion) I.reagents.remove_reagent(R.id, R.volume*portion)
/obj/machinery/appliance/cooker/fryer/cook_mob(var/mob/living/victim, var/mob/user) /obj/machinery/appliance/cooker/fryer/cook_mob(var/mob/living/victim, var/mob/user)
if(!istype(victim)) if(!istype(victim))
return return
// user.visible_message("<span class='danger'>\The [user] starts pushing \the [victim] into \the [src]!</span>") // user.visible_message("<span class='danger'>\The [user] starts pushing \the [victim] into \the [src]!</span>")
//Removed delay on this action in favour of a cooldown after it //Removed delay on this action in favour of a cooldown after it
//If you can lure someone close to the fryer and grab them then you deserve success. //If you can lure someone close to the fryer and grab them then you deserve success.
//And a delay on this kind of niche action just ensures it never happens //And a delay on this kind of niche action just ensures it never happens
//Cooldown ensures it can't be spammed to instakill someone //Cooldown ensures it can't be spammed to instakill someone
user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN*3) user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN*3)
fry_loop.start(src) fry_loop.start(src)
if(!do_mob(user, victim, 20)) if(!do_mob(user, victim, 20))
cooking = FALSE cooking = FALSE
icon_state = off_icon icon_state = off_icon
fry_loop.stop(src) fry_loop.stop(src)
return return
if(!victim || !victim.Adjacent(user)) if(!victim || !victim.Adjacent(user))
to_chat(user, "<span class='danger'>Your victim slipped free!</span>") to_chat(user, "<span class='danger'>Your victim slipped free!</span>")
cooking = FALSE cooking = FALSE
icon_state = off_icon icon_state = off_icon
fry_loop.stop(src) fry_loop.stop(src)
return return
var/damage = rand(7,13) // Though this damage seems reduced, some hot oil is transferred to the victim and will burn them for a while after var/damage = rand(7,13) // Though this damage seems reduced, some hot oil is transferred to the victim and will burn them for a while after
var/datum/reagent/nutriment/triglyceride/oil/OL = oil.get_master_reagent() var/datum/reagent/nutriment/triglyceride/oil/OL = oil.get_master_reagent()
damage *= OL.heatdamage(victim) damage *= OL.heatdamage(victim)
var/obj/item/organ/external/E var/obj/item/organ/external/E
var/nopain var/nopain
if(ishuman(victim) && user.zone_sel.selecting != BP_GROIN && user.zone_sel.selecting != BP_TORSO) if(ishuman(victim) && user.zone_sel.selecting != BP_GROIN && user.zone_sel.selecting != BP_TORSO)
var/mob/living/carbon/human/H = victim var/mob/living/carbon/human/H = victim
E = H.get_organ(user.zone_sel.selecting) E = H.get_organ(user.zone_sel.selecting)
if(!E || E.species.flags & NO_PAIN) if(!E || E.species.flags & NO_PAIN)
nopain = 2 nopain = 2
else if(E.robotic >= ORGAN_ROBOT) else if(E.robotic >= ORGAN_ROBOT)
nopain = 1 nopain = 1
user.visible_message("<span class='danger'>\The [user] shoves \the [victim][E ? "'s [E.name]" : ""] into \the [src]!</span>") user.visible_message("<span class='danger'>\The [user] shoves \the [victim][E ? "'s [E.name]" : ""] into \the [src]!</span>")
if (damage > 0) if (damage > 0)
if(E) if(E)
if(E.children && E.children.len) if(E.children && E.children.len)
for(var/obj/item/organ/external/child in E.children) for(var/obj/item/organ/external/child in E.children)
if(nopain && nopain < 2 && !(child.robotic >= ORGAN_ROBOT)) if(nopain && nopain < 2 && !(child.robotic >= ORGAN_ROBOT))
nopain = 0 nopain = 0
child.take_damage(0, damage) child.take_damage(0, damage)
damage -= (damage*0.5)//IF someone's arm is plunged in, the hand should take most of it damage -= (damage*0.5)//IF someone's arm is plunged in, the hand should take most of it
E.take_damage(0, damage) E.take_damage(0, damage)
else else
victim.apply_damage(damage, BURN, user.zone_sel.selecting) victim.apply_damage(damage, BURN, user.zone_sel.selecting)
if(!nopain) if(!nopain)
to_chat(victim, "<span class='danger'>Agony consumes you as searing hot oil scorches your [E ? E.name : "flesh"] horribly!</span>") to_chat(victim, "<span class='danger'>Agony consumes you as searing hot oil scorches your [E ? E.name : "flesh"] horribly!</span>")
victim.emote("scream") victim.emote("scream")
else else
to_chat(victim, "<span class='danger'>Searing hot oil scorches your [E ? E.name : "flesh"]!</span>") to_chat(victim, "<span class='danger'>Searing hot oil scorches your [E ? E.name : "flesh"]!</span>")
user.attack_log += text("\[[time_stamp()]\] <font color='red'>Has [cook_type] \the [victim] ([victim.ckey]) in \a [src]</font>") user.attack_log += text("\[[time_stamp()]\] <font color='red'>Has [cook_type] \the [victim] ([victim.ckey]) in \a [src]</font>")
victim.attack_log += text("\[[time_stamp()]\] <font color='orange'>Has been [cook_type] in \a [src] by [user.name] ([user.ckey])</font>") victim.attack_log += text("\[[time_stamp()]\] <font color='orange'>Has been [cook_type] in \a [src] by [user.name] ([user.ckey])</font>")
msg_admin_attack("[key_name_admin(user)] [cook_type] \the [victim] ([victim.ckey]) in \a [src]. (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[user.x];Y=[user.y];Z=[user.z]'>JMP</a>)") msg_admin_attack("[key_name_admin(user)] [cook_type] \the [victim] ([victim.ckey]) in \a [src]. (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[user.x];Y=[user.y];Z=[user.z]'>JMP</a>)")
//Coat the victim in some oil //Coat the victim in some oil
oil.trans_to(victim, 40) oil.trans_to(victim, 40)
fry_loop.stop() fry_loop.stop()
/obj/machinery/appliance/cooker/fryer/attackby(var/obj/item/I, var/mob/user) /obj/machinery/appliance/cooker/fryer/attackby(var/obj/item/I, var/mob/user)
if(istype(I, /obj/item/weapon/reagent_containers/glass) && I.reagents) if(default_deconstruction_screwdriver(user, O)) //CHOMPedit - Allows for deconstruction
if (I.reagents.total_volume <= 0 && oil) return
//Its empty, handle scooping some hot oil out of the fryer if(default_deconstruction_crowbar(user, O))
oil.trans_to(I, I.reagents.maximum_volume) return
user.visible_message("[user] scoops some oil out of \the [src].", span("notice","You scoop some oil out of \the [src].")) if(default_part_replacement(user, O))
return 1 return
else if(istype(I, /obj/item/weapon/reagent_containers/glass) && I.reagents)
//It contains stuff, handle pouring any oil into the fryer if (I.reagents.total_volume <= 0 && oil)
//Possibly in future allow pouring non-oil reagents in, in order to sabotage it and poison food. //Its empty, handle scooping some hot oil out of the fryer
//That would really require coding some sort of filter or better replacement mechanism first oil.trans_to(I, I.reagents.maximum_volume)
//So for now, restrict to oil only user.visible_message("[user] scoops some oil out of \the [src].", span("notice","You scoop some oil out of \the [src]."))
var/amount = 0 return 1
for (var/datum/reagent/R in I.reagents.reagent_list) else
if (istype(R, /datum/reagent/nutriment/triglyceride/oil)) //It contains stuff, handle pouring any oil into the fryer
var/delta = oil.get_free_space() //Possibly in future allow pouring non-oil reagents in, in order to sabotage it and poison food.
delta = min(delta, R.volume) //That would really require coding some sort of filter or better replacement mechanism first
oil.add_reagent(R.id, delta) //So for now, restrict to oil only
I.reagents.remove_reagent(R.id, delta) var/amount = 0
amount += delta for (var/datum/reagent/R in I.reagents.reagent_list)
if (amount > 0) if (istype(R, /datum/reagent/nutriment/triglyceride/oil))
user.visible_message("[user] pours some oil into \the [src].", span("notice","You pour [amount]u of oil into \the [src]."), "<span class='notice'>You hear something viscous being poured into a metal container.</span>") var/delta = oil.get_free_space()
return 1 delta = min(delta, R.volume)
//If neither of the above returned, then call parent as normal oil.add_reagent(R.id, delta)
..() I.reagents.remove_reagent(R.id, delta)
amount += delta
if (amount > 0)
user.visible_message("[user] pours some oil into \the [src].", span("notice","You pour [amount]u of oil into \the [src]."), "<span class='notice'>You hear something viscous being poured into a metal container.</span>")
return 1
//If neither of the above returned, then call parent as normal
..()

View File

@@ -47,3 +47,11 @@
icon_state = off_icon icon_state = off_icon
if(grill_loop) if(grill_loop)
grill_loop.stop(src) grill_loop.stop(src)
/obj/machinery/appliance/cooker/grill/attackby(var/obj/item/O as obj, var/mob/user as mob)
if(default_deconstruction_screwdriver(user, O))
return
if(default_deconstruction_crowbar(user, O))
return
if(default_part_replacement(user, O))
return

View File

@@ -153,3 +153,13 @@
return return
else else
..() ..()
/obj/machinery/appliance/cooker/oven/attackby(var/obj/item/O as obj, var/mob/user as mob)
if(default_deconstruction_screwdriver(user, O)) //CHOMPedit - Allows for deconstruction
return
if(default_deconstruction_crowbar(user, O))
return
if(default_part_replacement(user, O))
return

View File

@@ -99,6 +99,13 @@
/obj/machinery/gibber/attackby(var/obj/item/W, var/mob/user) /obj/machinery/gibber/attackby(var/obj/item/W, var/mob/user)
var/obj/item/weapon/grab/G = W var/obj/item/weapon/grab/G = W
if(default_deconstruction_screwdriver(user, O)) //CHOMPedit - Allows for deconstruction
return
if(default_deconstruction_crowbar(user, O))
return
if(default_part_replacement(user, O))
return
if(default_unfasten_wrench(user, W, 40)) if(default_unfasten_wrench(user, W, 40))
return return

View File

@@ -1,195 +1,201 @@
#define ICECREAM_VANILLA 1 #define ICECREAM_VANILLA 1
#define ICECREAM_CHOCOLATE 2 #define ICECREAM_CHOCOLATE 2
#define ICECREAM_STRAWBERRY 3 #define ICECREAM_STRAWBERRY 3
#define ICECREAM_BLUE 4 #define ICECREAM_BLUE 4
#define CONE_WAFFLE 5 #define CONE_WAFFLE 5
#define CONE_CHOC 6 #define CONE_CHOC 6
// Ported wholesale from Apollo Station. // Ported wholesale from Apollo Station.
/obj/machinery/icecream_vat /obj/machinery/icecream_vat
name = "icecream vat" name = "icecream vat"
desc = "Ding-aling ding dong. Get your NanoTrasen-approved ice cream!" desc = "Ding-aling ding dong. Get your NanoTrasen-approved ice cream!"
icon = 'icons/obj/kitchen.dmi' icon = 'icons/obj/kitchen.dmi'
icon_state = "icecream_vat" icon_state = "icecream_vat"
density = TRUE density = TRUE
anchored = FALSE anchored = FALSE
use_power = USE_POWER_OFF use_power = USE_POWER_OFF
flags = OPENCONTAINER | NOREACT flags = OPENCONTAINER | NOREACT
var/list/product_types = list() var/list/product_types = list()
var/dispense_flavour = ICECREAM_VANILLA var/dispense_flavour = ICECREAM_VANILLA
var/flavour_name = "vanilla" var/flavour_name = "vanilla"
/obj/machinery/icecream_vat/proc/get_ingredient_list(var/type) /obj/machinery/icecream_vat/proc/get_ingredient_list(var/type)
switch(type) switch(type)
if(ICECREAM_CHOCOLATE) if(ICECREAM_CHOCOLATE)
return list("milk", "ice", "coco") return list("milk", "ice", "coco")
if(ICECREAM_STRAWBERRY) if(ICECREAM_STRAWBERRY)
return list("milk", "ice", "berryjuice") return list("milk", "ice", "berryjuice")
if(ICECREAM_BLUE) if(ICECREAM_BLUE)
return list("milk", "ice", "singulo") return list("milk", "ice", "singulo")
if(CONE_WAFFLE) if(CONE_WAFFLE)
return list("flour", "sugar") return list("flour", "sugar")
if(CONE_CHOC) if(CONE_CHOC)
return list("flour", "sugar", "coco") return list("flour", "sugar", "coco")
else else
return list("milk", "ice") return list("milk", "ice")
/obj/machinery/icecream_vat/proc/get_flavour_name(var/flavour_type) /obj/machinery/icecream_vat/proc/get_flavour_name(var/flavour_type)
switch(flavour_type) switch(flavour_type)
if(ICECREAM_CHOCOLATE) if(ICECREAM_CHOCOLATE)
return "chocolate" return "chocolate"
if(ICECREAM_STRAWBERRY) if(ICECREAM_STRAWBERRY)
return "strawberry" return "strawberry"
if(ICECREAM_BLUE) if(ICECREAM_BLUE)
return "blue" return "blue"
if(CONE_WAFFLE) if(CONE_WAFFLE)
return "waffle" return "waffle"
if(CONE_CHOC) if(CONE_CHOC)
return "chocolate" return "chocolate"
else else
return "vanilla" return "vanilla"
/obj/machinery/icecream_vat/Initialize() /obj/machinery/icecream_vat/Initialize()
. = ..() . = ..()
create_reagents(100) create_reagents(100)
while(product_types.len < 6) while(product_types.len < 6)
product_types.Add(5) product_types.Add(5)
reagents.add_reagent("milk", 5) reagents.add_reagent("milk", 5)
reagents.add_reagent("flour", 5) reagents.add_reagent("flour", 5)
reagents.add_reagent("sugar", 5) reagents.add_reagent("sugar", 5)
reagents.add_reagent("ice", 5) reagents.add_reagent("ice", 5)
/obj/machinery/icecream_vat/attack_hand(mob/user as mob) /obj/machinery/icecream_vat/attack_hand(mob/user as mob)
user.set_machine(src) user.set_machine(src)
interact(user) interact(user)
/obj/machinery/icecream_vat/interact(mob/user as mob) /obj/machinery/icecream_vat/interact(mob/user as mob)
var/dat var/dat
dat += "<b>ICECREAM</b><br><div class='statusDisplay'>" dat += "<b>ICECREAM</b><br><div class='statusDisplay'>"
dat += "<b>Dispensing: [flavour_name] icecream </b> <br><br>" dat += "<b>Dispensing: [flavour_name] icecream </b> <br><br>"
dat += "<b>Vanilla icecream:</b> <a href='?src=\ref[src];select=[ICECREAM_VANILLA]'><b>Select</b></a> <a href='?src=\ref[src];make=[ICECREAM_VANILLA];amount=1'><b>Make</b></a> <a href='?src=\ref[src];make=[ICECREAM_VANILLA];amount=5'><b>x5</b></a> [product_types[ICECREAM_VANILLA]] scoops left. (Ingredients: milk, ice)<br>" dat += "<b>Vanilla icecream:</b> <a href='?src=\ref[src];select=[ICECREAM_VANILLA]'><b>Select</b></a> <a href='?src=\ref[src];make=[ICECREAM_VANILLA];amount=1'><b>Make</b></a> <a href='?src=\ref[src];make=[ICECREAM_VANILLA];amount=5'><b>x5</b></a> [product_types[ICECREAM_VANILLA]] scoops left. (Ingredients: milk, ice)<br>"
dat += "<b>Strawberry icecream:</b> <a href='?src=\ref[src];select=[ICECREAM_STRAWBERRY]'><b>Select</b></a> <a href='?src=\ref[src];make=[ICECREAM_STRAWBERRY];amount=1'><b>Make</b></a> <a href='?src=\ref[src];make=[ICECREAM_STRAWBERRY];amount=5'><b>x5</b></a> [product_types[ICECREAM_STRAWBERRY]] dollops left. (Ingredients: milk, ice, berry juice)<br>" dat += "<b>Strawberry icecream:</b> <a href='?src=\ref[src];select=[ICECREAM_STRAWBERRY]'><b>Select</b></a> <a href='?src=\ref[src];make=[ICECREAM_STRAWBERRY];amount=1'><b>Make</b></a> <a href='?src=\ref[src];make=[ICECREAM_STRAWBERRY];amount=5'><b>x5</b></a> [product_types[ICECREAM_STRAWBERRY]] dollops left. (Ingredients: milk, ice, berry juice)<br>"
dat += "<b>Chocolate icecream:</b> <a href='?src=\ref[src];select=[ICECREAM_CHOCOLATE]'><b>Select</b></a> <a href='?src=\ref[src];make=[ICECREAM_CHOCOLATE];amount=1'><b>Make</b></a> <a href='?src=\ref[src];make=[ICECREAM_CHOCOLATE];amount=5'><b>x5</b></a> [product_types[ICECREAM_CHOCOLATE]] dollops left. (Ingredients: milk, ice, coco powder)<br>" dat += "<b>Chocolate icecream:</b> <a href='?src=\ref[src];select=[ICECREAM_CHOCOLATE]'><b>Select</b></a> <a href='?src=\ref[src];make=[ICECREAM_CHOCOLATE];amount=1'><b>Make</b></a> <a href='?src=\ref[src];make=[ICECREAM_CHOCOLATE];amount=5'><b>x5</b></a> [product_types[ICECREAM_CHOCOLATE]] dollops left. (Ingredients: milk, ice, coco powder)<br>"
dat += "<b>Blue icecream:</b> <a href='?src=\ref[src];select=[ICECREAM_BLUE]'><b>Select</b></a> <a href='?src=\ref[src];make=[ICECREAM_BLUE];amount=1'><b>Make</b></a> <a href='?src=\ref[src];make=[ICECREAM_BLUE];amount=5'><b>x5</b></a> [product_types[ICECREAM_BLUE]] dollops left. (Ingredients: milk, ice, singulo)<br></div>" dat += "<b>Blue icecream:</b> <a href='?src=\ref[src];select=[ICECREAM_BLUE]'><b>Select</b></a> <a href='?src=\ref[src];make=[ICECREAM_BLUE];amount=1'><b>Make</b></a> <a href='?src=\ref[src];make=[ICECREAM_BLUE];amount=5'><b>x5</b></a> [product_types[ICECREAM_BLUE]] dollops left. (Ingredients: milk, ice, singulo)<br></div>"
dat += "<br><b>CONES</b><br><div class='statusDisplay'>" dat += "<br><b>CONES</b><br><div class='statusDisplay'>"
dat += "<b>Waffle cones:</b> <a href='?src=\ref[src];cone=[CONE_WAFFLE]'><b>Dispense</b></a> <a href='?src=\ref[src];make=[CONE_WAFFLE];amount=1'><b>Make</b></a> <a href='?src=\ref[src];make=[CONE_WAFFLE];amount=5'><b>x5</b></a> [product_types[CONE_WAFFLE]] cones left. (Ingredients: flour, sugar)<br>" dat += "<b>Waffle cones:</b> <a href='?src=\ref[src];cone=[CONE_WAFFLE]'><b>Dispense</b></a> <a href='?src=\ref[src];make=[CONE_WAFFLE];amount=1'><b>Make</b></a> <a href='?src=\ref[src];make=[CONE_WAFFLE];amount=5'><b>x5</b></a> [product_types[CONE_WAFFLE]] cones left. (Ingredients: flour, sugar)<br>"
dat += "<b>Chocolate cones:</b> <a href='?src=\ref[src];cone=[CONE_CHOC]'><b>Dispense</b></a> <a href='?src=\ref[src];make=[CONE_CHOC];amount=1'><b>Make</b></a> <a href='?src=\ref[src];make=[CONE_CHOC];amount=5'><b>x5</b></a> [product_types[CONE_CHOC]] cones left. (Ingredients: flour, sugar, coco powder)<br></div>" dat += "<b>Chocolate cones:</b> <a href='?src=\ref[src];cone=[CONE_CHOC]'><b>Dispense</b></a> <a href='?src=\ref[src];make=[CONE_CHOC];amount=1'><b>Make</b></a> <a href='?src=\ref[src];make=[CONE_CHOC];amount=5'><b>x5</b></a> [product_types[CONE_CHOC]] cones left. (Ingredients: flour, sugar, coco powder)<br></div>"
dat += "<br>" dat += "<br>"
dat += "<b>VAT CONTENT</b><br>" dat += "<b>VAT CONTENT</b><br>"
for(var/datum/reagent/R in reagents.reagent_list) for(var/datum/reagent/R in reagents.reagent_list)
dat += "[R.name]: [R.volume]" dat += "[R.name]: [R.volume]"
dat += "<A href='?src=\ref[src];disposeI=[R.id]'>Purge</A><BR>" dat += "<A href='?src=\ref[src];disposeI=[R.id]'>Purge</A><BR>"
dat += "<a href='?src=\ref[src];refresh=1'>Refresh</a> <a href='?src=\ref[src];close=1'>Close</a>" dat += "<a href='?src=\ref[src];refresh=1'>Refresh</a> <a href='?src=\ref[src];close=1'>Close</a>"
var/datum/browser/popup = new(user, "icecreamvat","Icecream Vat", 700, 500, src) var/datum/browser/popup = new(user, "icecreamvat","Icecream Vat", 700, 500, src)
popup.set_content(dat) popup.set_content(dat)
popup.open() popup.open()
/obj/machinery/icecream_vat/attackby(var/obj/item/O as obj, var/mob/user as mob) /obj/machinery/icecream_vat/attackby(var/obj/item/O as obj, var/mob/user as mob)
if(istype(O, /obj/item/weapon/reagent_containers/food/snacks/icecream)) if(default_deconstruction_screwdriver(user, O)) //CHOMPedit - Allows for deconstruction
var/obj/item/weapon/reagent_containers/food/snacks/icecream/I = O return
if(!I.ice_creamed) if(default_deconstruction_crowbar(user, O))
if(product_types[dispense_flavour] > 0) return
src.visible_message("\icon[src][bicon(src)] <span class='info'>[user] scoops delicious [flavour_name] icecream into [I].</span>") if(default_part_replacement(user, O))
product_types[dispense_flavour] -= 1 return
I.add_ice_cream(flavour_name) if(istype(O, /obj/item/weapon/reagent_containers/food/snacks/icecream))
// if(beaker) var/obj/item/weapon/reagent_containers/food/snacks/icecream/I = O
// beaker.reagents.trans_to(I, 10) if(!I.ice_creamed)
if(I.reagents.total_volume < 10) if(product_types[dispense_flavour] > 0)
I.reagents.add_reagent("sugar", 10 - I.reagents.total_volume) src.visible_message("\icon[src][bicon(src)] <span class='info'>[user] scoops delicious [flavour_name] icecream into [I].</span>")
else product_types[dispense_flavour] -= 1
to_chat(user, "<span class='warning'>There is not enough icecream left!</span>") I.add_ice_cream(flavour_name)
else // if(beaker)
to_chat(user, "<span class='notice'>[O] already has icecream in it.</span>") // beaker.reagents.trans_to(I, 10)
return 1 if(I.reagents.total_volume < 10)
else if(O.is_open_container()) I.reagents.add_reagent("sugar", 10 - I.reagents.total_volume)
return else
else to_chat(user, "<span class='warning'>There is not enough icecream left!</span>")
..() else
to_chat(user, "<span class='notice'>[O] already has icecream in it.</span>")
/obj/machinery/icecream_vat/proc/make(var/mob/user, var/make_type, var/amount) return 1
for(var/R in get_ingredient_list(make_type)) else if(O.is_open_container())
if(reagents.has_reagent(R, amount)) return
continue else
amount = 0 ..()
break
if(amount) /obj/machinery/icecream_vat/proc/make(var/mob/user, var/make_type, var/amount)
for(var/R in get_ingredient_list(make_type)) for(var/R in get_ingredient_list(make_type))
reagents.remove_reagent(R, amount) if(reagents.has_reagent(R, amount))
product_types[make_type] += amount continue
var/flavour = get_flavour_name(make_type) amount = 0
if(make_type > 4) break
src.visible_message("<span class='info'>[user] cooks up some [flavour] cones.</span>") if(amount)
else for(var/R in get_ingredient_list(make_type))
src.visible_message("<span class='info'>[user] whips up some [flavour] icecream.</span>") reagents.remove_reagent(R, amount)
else product_types[make_type] += amount
to_chat(user, "<span class='warning'>You don't have the ingredients to make this.</span>") var/flavour = get_flavour_name(make_type)
if(make_type > 4)
/obj/machinery/icecream_vat/Topic(href, href_list) src.visible_message("<span class='info'>[user] cooks up some [flavour] cones.</span>")
else
if(..()) src.visible_message("<span class='info'>[user] whips up some [flavour] icecream.</span>")
return else
to_chat(user, "<span class='warning'>You don't have the ingredients to make this.</span>")
if(href_list["select"])
dispense_flavour = text2num(href_list["select"]) /obj/machinery/icecream_vat/Topic(href, href_list)
flavour_name = get_flavour_name(dispense_flavour)
src.visible_message("<span class='notice'>[usr] sets [src] to dispense [flavour_name] flavoured icecream.</span>") if(..())
return
if(href_list["cone"])
var/dispense_cone = text2num(href_list["cone"]) if(href_list["select"])
var/cone_name = get_flavour_name(dispense_cone) dispense_flavour = text2num(href_list["select"])
if(product_types[dispense_cone] >= 1) flavour_name = get_flavour_name(dispense_flavour)
product_types[dispense_cone] -= 1 src.visible_message("<span class='notice'>[usr] sets [src] to dispense [flavour_name] flavoured icecream.</span>")
var/obj/item/weapon/reagent_containers/food/snacks/icecream/I = new(src.loc)
I.cone_type = cone_name if(href_list["cone"])
I.icon_state = "icecream_cone_[cone_name]" var/dispense_cone = text2num(href_list["cone"])
I.desc = "Delicious [cone_name] cone, but no ice cream." var/cone_name = get_flavour_name(dispense_cone)
src.visible_message("<span class='info'>[usr] dispenses a crunchy [cone_name] cone from [src].</span>") if(product_types[dispense_cone] >= 1)
else product_types[dispense_cone] -= 1
to_chat(usr, "<span class='warning'>There are no [cone_name] cones left!</span>") var/obj/item/weapon/reagent_containers/food/snacks/icecream/I = new(src.loc)
I.cone_type = cone_name
if(href_list["make"]) I.icon_state = "icecream_cone_[cone_name]"
var/amount = (text2num(href_list["amount"])) I.desc = "Delicious [cone_name] cone, but no ice cream."
var/C = text2num(href_list["make"]) src.visible_message("<span class='info'>[usr] dispenses a crunchy [cone_name] cone from [src].</span>")
make(usr, C, amount) else
to_chat(usr, "<span class='warning'>There are no [cone_name] cones left!</span>")
if(href_list["disposeI"])
reagents.del_reagent(href_list["disposeI"]) if(href_list["make"])
var/amount = (text2num(href_list["amount"]))
updateDialog() var/C = text2num(href_list["make"])
make(usr, C, amount)
if(href_list["refresh"])
updateDialog() if(href_list["disposeI"])
reagents.del_reagent(href_list["disposeI"])
if(href_list["close"])
usr.unset_machine() updateDialog()
usr << browse(null,"window=icecreamvat")
return if(href_list["refresh"])
updateDialog()
/obj/item/weapon/reagent_containers/food/snacks/icecream
name = "ice cream cone" if(href_list["close"])
desc = "Delicious waffle cone, but no ice cream." usr.unset_machine()
icon_state = "icecream_cone_waffle" //default for admin-spawned cones, href_list["cone"] should overwrite this all the time usr << browse(null,"window=icecreamvat")
bitesize = 3 return
var/ice_creamed = 0 /obj/item/weapon/reagent_containers/food/snacks/icecream
var/cone_type name = "ice cream cone"
desc = "Delicious waffle cone, but no ice cream."
/obj/item/weapon/reagent_containers/food/snacks/icecream/New() icon_state = "icecream_cone_waffle" //default for admin-spawned cones, href_list["cone"] should overwrite this all the time
create_reagents(20) bitesize = 3
reagents.add_reagent("nutriment", 5)
var/ice_creamed = 0
/obj/item/weapon/reagent_containers/food/snacks/icecream/proc/add_ice_cream(var/flavour_name) var/cone_type
name = "[flavour_name] icecream"
add_overlay("icecream_[flavour_name]") /obj/item/weapon/reagent_containers/food/snacks/icecream/New()
desc = "Delicious [cone_type] cone with a dollop of [flavour_name] ice cream." create_reagents(20)
ice_creamed = 1 reagents.add_reagent("nutriment", 5)
#undef ICECREAM_VANILLA /obj/item/weapon/reagent_containers/food/snacks/icecream/proc/add_ice_cream(var/flavour_name)
#undef ICECREAM_CHOCOLATE name = "[flavour_name] icecream"
#undef ICECREAM_STRAWBERRY add_overlay("icecream_[flavour_name]")
#undef ICECREAM_BLUE desc = "Delicious [cone_type] cone with a dollop of [flavour_name] ice cream."
#undef CONE_WAFFLE ice_creamed = 1
#undef CONE_CHOC
#undef ICECREAM_VANILLA
#undef ICECREAM_CHOCOLATE
#undef ICECREAM_STRAWBERRY
#undef ICECREAM_BLUE
#undef CONE_WAFFLE
#undef CONE_CHOC