Merge pull request #13386 from neersighted/chem_love

Add remove buttons directly to Chem Dispenser
This commit is contained in:
Remie Richards
2015-12-03 21:59:12 +00:00
32 changed files with 2671 additions and 2570 deletions
File diff suppressed because it is too large Load Diff
@@ -1,24 +1,21 @@
/proc/mix_color_from_reagents(list/reagent_list)
if(!istype(reagent_list))
return
var/color
var/vol_counter = 0
var/vol_temp
for(var/datum/reagent/R in reagent_list)
vol_temp = R.volume
vol_counter += vol_temp
if(!color)
color = R.color
else if (length(color) >= length(R.color))
color = BlendRGB(color, R.color, vol_temp/vol_counter)
else
color = BlendRGB(R.color, color, vol_temp/vol_counter)
return color
/proc/mix_color_from_reagents(list/reagent_list)
if(!istype(reagent_list))
return
var/color
var/vol_counter = 0
var/vol_temp
for(var/datum/reagent/R in reagent_list)
vol_temp = R.volume
vol_counter += vol_temp
if(!color)
color = R.color
else if (length(color) >= length(R.color))
color = BlendRGB(color, R.color, vol_temp/vol_counter)
else
color = BlendRGB(R.color, color, vol_temp/vol_counter)
return color
@@ -0,0 +1,356 @@
/obj/machinery/chem_dispenser
name = "chem dispenser"
desc = "Creates and dispenses chemicals."
density = 1
anchored = 1
icon = 'icons/obj/chemical.dmi'
icon_state = "dispenser"
use_power = 1
idle_power_usage = 40
var/energy = 100
var/max_energy = 100
var/amount = 30
var/recharged = 0
var/recharge_delay = 5
var/image/icon_beaker = null
var/obj/item/weapon/reagent_containers/beaker = null
var/list/dispensable_reagents = list(
"hydrogen",
"lithium",
"carbon",
"nitrogen",
"oxygen",
"fluorine",
"sodium",
"aluminium",
"silicon",
"phosphorus",
"sulfur",
"chlorine",
"potassium",
"iron",
"copper",
"mercury",
"radium",
"water",
"ethanol",
"sugar",
"sacid",
"welding_fuel",
"silver",
"iodine",
"bromine",
"stable_plasma"
)
/obj/machinery/chem_dispenser/New()
..()
recharge()
dispensable_reagents = sortList(dispensable_reagents)
/obj/machinery/chem_dispenser/power_change()
if(powered())
stat &= ~NOPOWER
else
spawn(rand(0, 15))
stat |= NOPOWER
/obj/machinery/chem_dispenser/process()
if(recharged < 0)
recharge()
recharged = recharge_delay
else
recharged -= 1
/obj/machinery/chem_dispenser/proc/recharge()
if(stat & (BROKEN|NOPOWER)) return
var/addenergy = 1
var/oldenergy = energy
energy = min(energy + addenergy, max_energy)
if(energy != oldenergy)
use_power(2500)
/obj/machinery/chem_dispenser/ex_act(severity, target)
if(severity < 3)
..()
/obj/machinery/chem_dispenser/blob_act()
if(prob(50))
qdel(src)
/obj/machinery/chem_dispenser/interact(mob/user)
if(stat & BROKEN)
return
ui_interact(user)
/obj/machinery/chem_dispenser/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 0)
ui = SSnano.try_update_ui(user, src, ui_key, ui, force_open = force_open)
if (!ui)
ui = new(user, src, ui_key, "chem_dispenser.tmpl", name, 500, 650)
ui.open()
/obj/machinery/chem_dispenser/get_ui_data()
var/data = list()
data["amount"] = amount
data["energy"] = energy
data["maxEnergy"] = max_energy
data["isBeakerLoaded"] = beaker ? 1 : 0
var beakerContents[0]
var beakerCurrentVolume = 0
if(beaker && beaker.reagents && beaker.reagents.reagent_list.len)
for(var/datum/reagent/R in beaker.reagents.reagent_list)
beakerContents.Add(list(list("name" = R.name, "volume" = R.volume))) // list in a list because Byond merges the first list...
beakerCurrentVolume += R.volume
data["beakerContents"] = beakerContents
if (beaker)
data["beakerCurrentVolume"] = beakerCurrentVolume
data["beakerMaxVolume"] = beaker.volume
data["beakerTransferAmounts"] = beaker.possible_transfer_amounts
else
data["beakerCurrentVolume"] = null
data["beakerMaxVolume"] = null
data["beakerTransferAmounts"] = null
var chemicals[0]
for(var/re in dispensable_reagents)
var/datum/reagent/temp = chemical_reagents_list[re]
if(temp)
chemicals.Add(list(list("title" = temp.name, "id" = temp.id, "commands" = list("dispense" = temp.id)))) // list in a list because Byond merges the first list...
data["chemicals"] = chemicals
return data
/obj/machinery/chem_dispenser/Topic(href, href_list)
if(..())
return
if(href_list["amount"])
amount = round(text2num(href_list["amount"]), 5) // round to nearest 5
if (amount < 0) // Since the user can actually type the commands himself, some sanity checking
amount = 0
if (amount > 100)
amount = 100
if(href_list["dispense"])
if(beaker && dispensable_reagents.Find(href_list["dispense"]))
var/datum/reagents/R = beaker.reagents
var/space = R.maximum_volume - R.total_volume
R.add_reagent(href_list["dispense"], min(amount, energy * 10, space))
energy = max(energy - min(amount, energy * 10, space) / 10, 0)
if(href_list["remove"])
if(beaker)
var/amount = text2num(href_list["remove"])
if(isnum(amount) && (amount > 0) && (amount in beaker.possible_transfer_amounts))
beaker.reagents.remove_all(amount)
if(href_list["ejectBeaker"])
if(beaker)
beaker.loc = loc
beaker = null
overlays.Cut()
add_fingerprint(usr)
/obj/machinery/chem_dispenser/attackby(obj/item/I, mob/user, params)
if(default_unfasten_wrench(user, I))
return
if(isrobot(user))
return
var/obj/item/weapon/reagent_containers/B = I // Get a beaker from it?
if(!istype(B))
return // Not a beaker?
if(beaker)
user << "<span class='warning'>A beaker is already loaded into the machine!</span>"
return
if(!user.drop_item()) // Can't let go?
return
beaker = B
beaker.loc = src
user << "<span class='notice'>You add the beaker to the machine.</span>"
if(!icon_beaker)
icon_beaker = image('icons/obj/chemical.dmi', src, "disp_beaker") //randomize beaker overlay position.
icon_beaker.pixel_x = rand(-10,5)
overlays += icon_beaker
/obj/machinery/chem_dispenser/attack_hand(mob/user)
if (!user)
return
interact(user)
/obj/machinery/chem_dispenser/constructable
name = "portable chem dispenser"
icon = 'icons/obj/chemical.dmi'
icon_state = "minidispenser"
energy = 10
max_energy = 10
amount = 5
recharge_delay = 30
dispensable_reagents = list()
var/list/dispensable_reagent_tiers = list(
list(
"hydrogen",
"oxygen",
"silicon",
"phosphorus",
"sulfur",
"carbon",
"nitrogen",
"water"
),
list(
"lithium",
"sugar",
"sacid",
"copper",
"mercury",
"sodium",
"iodine",
"bromine"
),
list(
"ethanol",
"chlorine",
"potassium",
"aluminium",
"radium",
"fluorine",
"iron",
"welding_fuel",
"silver",
"stable_plasma"
),
list(
"oil",
"ash",
"acetone",
"saltpetre",
"ammonia",
"diethylamine"
)
)
/obj/machinery/chem_dispenser/constructable/New()
..()
component_parts = list()
component_parts += new /obj/item/weapon/circuitboard/chem_dispenser(null)
component_parts += new /obj/item/weapon/stock_parts/matter_bin(null)
component_parts += new /obj/item/weapon/stock_parts/matter_bin(null)
component_parts += new /obj/item/weapon/stock_parts/manipulator(null)
component_parts += new /obj/item/weapon/stock_parts/capacitor(null)
component_parts += new /obj/item/weapon/stock_parts/console_screen(null)
component_parts += new /obj/item/weapon/stock_parts/cell/high(null)
RefreshParts()
/obj/machinery/chem_dispenser/constructable/RefreshParts()
var/time = 0
var/temp_energy = 0
var/i
for(var/obj/item/weapon/stock_parts/matter_bin/M in component_parts)
temp_energy += M.rating
temp_energy--
max_energy = temp_energy * 5 //max energy = (bin1.rating + bin2.rating - 1) * 5, 5 on lowest 25 on highest
for(var/obj/item/weapon/stock_parts/capacitor/C in component_parts)
time += C.rating
for(var/obj/item/weapon/stock_parts/cell/P in component_parts)
time += round(P.maxcharge, 10000) / 10000
recharge_delay /= time/2 //delay between recharges, double the usual time on lowest 50% less than usual on highest
for(var/obj/item/weapon/stock_parts/manipulator/M in component_parts)
for(i=1, i<=M.rating, i++)
dispensable_reagents |= dispensable_reagent_tiers[i]
dispensable_reagents = sortList(dispensable_reagents)
/obj/machinery/chem_dispenser/constructable/attackby(var/obj/item/I, var/mob/user, params)
..()
if(default_deconstruction_screwdriver(user, "minidispenser-o", "minidispenser", I))
return
if(exchange_parts(user, I))
return
if(panel_open)
if(istype(I, /obj/item/weapon/crowbar))
if(beaker)
beaker.loc = loc
beaker = null
default_deconstruction_crowbar(I)
return 1
/obj/machinery/chem_dispenser/drinks
name = "soda dispenser"
anchored = 1
icon = 'icons/obj/chemical.dmi'
icon_state = "soda_dispenser"
amount = 10
dispensable_reagents = list(
"water",
"ice",
"coffee",
"cream",
"tea",
"icetea",
"cola",
"spacemountainwind",
"dr_gibb",
"space_up",
"tonic",
"sodawater",
"lemon_lime",
"sugar",
"orangejuice",
"limejuice",
"tomatojuice"
)
/obj/machinery/chem_dispenser/drinks/attackby(obj/item/I, mob/user)
if(default_unfasten_wrench(user, I))
return
if (istype(I, /obj/item/weapon/reagent_containers/glass) || \
istype(I, /obj/item/weapon/reagent_containers/food/drinks/drinkingglass) || \
istype(I, /obj/item/weapon/reagent_containers/food/drinks/shaker))
if (beaker)
return 1
else
if(!user.drop_item())
return 1
src.beaker = I
beaker.loc = src
update_icon()
return
/obj/machinery/chem_dispenser/drinks/beer
name = "booze dispenser"
anchored = 1
icon = 'icons/obj/chemical.dmi'
icon_state = "booze_dispenser"
dispensable_reagents = list(
"lemon_lime",
"sugar",
"orangejuice",
"limejuice",
"sodawater",
"tonic",
"beer",
"kahlua",
"whiskey",
"wine",
"vodka",
"gin",
"rum",
"tequila",
"vermouth",
"cognac",
"ale"
)
@@ -0,0 +1,134 @@
/obj/machinery/chem_heater
name = "chemical heater"
density = 1
anchored = 1
icon = 'icons/obj/chemical.dmi'
icon_state = "mixer0b"
use_power = 1
idle_power_usage = 40
var/obj/item/weapon/reagent_containers/beaker = null
var/desired_temp = 300
var/heater_coefficient = 0.10
var/on = FALSE
/obj/machinery/chem_heater/New()
..()
component_parts = list()
component_parts += new /obj/item/weapon/circuitboard/chem_heater(null)
component_parts += new /obj/item/weapon/stock_parts/micro_laser(null)
component_parts += new /obj/item/weapon/stock_parts/console_screen(null)
RefreshParts()
/obj/machinery/chem_heater/RefreshParts()
heater_coefficient = 0.10
for(var/obj/item/weapon/stock_parts/micro_laser/M in component_parts)
heater_coefficient *= M.rating
/obj/machinery/chem_heater/process()
..()
if(stat & NOPOWER)
return
if(on)
if(beaker)
if(beaker.reagents.chem_temp > desired_temp)
beaker.reagents.chem_temp += min(-1, (desired_temp - beaker.reagents.chem_temp) * heater_coefficient)
if(beaker.reagents.chem_temp < desired_temp)
beaker.reagents.chem_temp += max(1, (desired_temp - beaker.reagents.chem_temp) * heater_coefficient)
beaker.reagents.chem_temp = round(beaker.reagents.chem_temp) //stops stuff like 456.12312312302
beaker.reagents.handle_reactions()
/obj/machinery/chem_heater/power_change()
if(powered())
stat &= ~NOPOWER
else
spawn(rand(0, 15))
stat |= NOPOWER
/obj/machinery/chem_heater/attackby(obj/item/I, mob/user, params)
if(isrobot(user))
return
if(istype(I, /obj/item/weapon/reagent_containers/glass))
if(beaker)
user << "<span class='warning'>A beaker is already loaded into the machine!</span>"
return
if(user.drop_item())
beaker = I
I.loc = src
user << "<span class='notice'>You add the beaker to the machine.</span>"
icon_state = "mixer1b"
if(default_deconstruction_screwdriver(user, "mixer0b", "mixer0b", I))
return
if(exchange_parts(user, I))
return
if(panel_open)
if(istype(I, /obj/item/weapon/crowbar))
eject_beaker()
default_deconstruction_crowbar(I)
return 1
/obj/machinery/chem_heater/attack_hand(mob/user)
if (!user)
return
interact(user)
/obj/machinery/chem_heater/Topic(href, href_list)
if(..())
return
if(href_list["toggle_on"])
on = !on
if(href_list["adjust_temperature"])
var/val = href_list["adjust_temperature"]
if(isnum(val))
desired_temp = Clamp(desired_temp+val, 0, 1000)
else if(val == "input")
desired_temp = Clamp(input("Please input the target temperature", name) as num, 0, 1000)
else
return
if(href_list["eject_beaker"])
eject_beaker()
add_fingerprint(usr)
/obj/machinery/chem_heater/interact(mob/user)
if(stat & BROKEN)
return
ui_interact(user)
/obj/machinery/chem_heater/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 0)
ui = SSnano.try_update_ui(user, src, ui_key, ui, force_open = force_open)
if (!ui)
ui = new(user, src, ui_key, "chem_heater.tmpl", name, 350, 400)
ui.open()
/obj/machinery/chem_heater/get_ui_data()
var/data = list()
data["targetTemp"] = desired_temp
data["isActive"] = on
data["isBeakerLoaded"] = beaker ? 1 : 0
data["currentTemp"] = beaker ? beaker.reagents.chem_temp : null
data["beakerCurrentVolume"] = beaker ? beaker.reagents.total_volume : null
data["beakerMaxVolume"] = beaker ? beaker.volume : null
var beakerContents[0]
if(beaker)
for(var/datum/reagent/R in beaker.reagents.reagent_list)
beakerContents.Add(list(list("name" = R.name, "volume" = R.volume))) // list in a list because Byond merges the first list...
data["beakerContents"] = beakerContents
return data
/obj/machinery/chem_heater/proc/eject_beaker()
if(beaker)
beaker.loc = get_turf(src)
beaker.reagents.handle_reactions()
beaker = null
icon_state = "mixer0b"
@@ -0,0 +1,391 @@
/obj/machinery/chem_master
name = "ChemMaster 3000"
desc = "Used to bottle chemicals to create pills."
density = 1
anchored = 1
icon = 'icons/obj/chemical.dmi'
icon_state = "mixer0"
use_power = 1
idle_power_usage = 20
var/obj/item/weapon/reagent_containers/glass/beaker = null
var/obj/item/weapon/storage/pill_bottle/bottle = null
var/mode = 0
var/condi = 0
var/useramount = 30 // Last used amount
/obj/machinery/chem_master/New()
create_reagents(100)
overlays += "waitlight"
/obj/machinery/chem_master/ex_act(severity, target)
if(severity < 3)
..()
/obj/machinery/chem_master/blob_act()
if (prob(50))
qdel(src)
/obj/machinery/chem_master/power_change()
if(powered())
stat &= ~NOPOWER
else
spawn(rand(0, 15))
stat |= NOPOWER
/obj/machinery/chem_master/attackby(obj/item/I, mob/user, params)
if(default_unfasten_wrench(user, I))
return
if(istype(I, /obj/item/weapon/reagent_containers/glass))
if(isrobot(user))
return
if(beaker)
user << "<span class='warning'>A beaker is already loaded into the machine!</span>"
return
if(!user.drop_item())
return
beaker = I
beaker.loc = src
user << "<span class='notice'>You add the beaker to the machine.</span>"
src.updateUsrDialog()
icon_state = "mixer1"
else if(!condi && istype(I, /obj/item/weapon/storage/pill_bottle))
if(bottle)
user << "<span class='warning'>A pill bottle is already loaded into the machine!</span>"
return
if(!user.drop_item())
return
bottle = I
bottle.loc = src
user << "<span class='notice'>You add the pill bottle into the dispenser slot.</span>"
src.updateUsrDialog()
return
/obj/machinery/chem_master/Topic(href, href_list)
if(..())
return
usr.set_machine(src)
if(href_list["ejectp"])
if(bottle)
bottle.loc = src.loc
bottle = null
else if(href_list["close"])
usr << browse(null, "window=chem_master")
usr.unset_machine()
return
else if(href_list["toggle"])
mode = !mode
else if(href_list["createbottle"])
var/name = stripped_input(usr, "Name:","Name your bottle!", (reagents.total_volume ? reagents.get_master_reagent_name() : " "), MAX_NAME_LEN)
if(!name)
return
var/obj/item/weapon/reagent_containers/P
if(condi)
P = new/obj/item/weapon/reagent_containers/food/condiment(src.loc)
else
P = new/obj/item/weapon/reagent_containers/glass/bottle(src.loc)
P.pixel_x = rand(-7, 7) //random position
P.pixel_y = rand(-7, 7)
P.name = trim("[name] bottle")
reagents.trans_to(P, P.volume)
if(beaker)
if(href_list["analyze"])
if(locate(href_list["reagent"]))
var/datum/reagent/R = locate(href_list["reagent"])
if(R)
var/dat = ""
dat += "<H1>[condi ? "Condiment" : "Chemical"] information:</H1>"
dat += "<B>Name:</B> [initial(R.name)]<BR><BR>"
dat += "<B>State:</B> "
if(initial(R.reagent_state) == 1)
dat += "Solid"
else if(initial(R.reagent_state) == 2)
dat += "Liquid"
else if(initial(R.reagent_state) == 3)
dat += "Gas"
else
dat += "Unknown"
dat += "<BR>"
dat += "<B>Color:</B> <span style='color:[initial(R.color)];background-color:[initial(R.color)];font:Lucida Console'>[initial(R.color)]</span><BR><BR>"
dat += "<B>Description:</B> [initial(R.description)]<BR><BR>"
var/const/P = 3 //The number of seconds between life ticks
var/T = initial(R.metabolization_rate) * (60 / P)
dat += "<B>Metabolization Rate:</B> [T]u/minute<BR>"
dat += "<B>Overdose Threshold:</B> [initial(R.overdose_threshold) ? "[initial(R.overdose_threshold)]u" : "none"]<BR>"
dat += "<B>Addiction Threshold:</B> [initial(R.addiction_threshold) ? "[initial(R.addiction_threshold)]u" : "none"]<BR><BR>"
dat += "<BR><A href='?src=\ref[src];main=1'>Back</A>"
var/datum/browser/popup = new(usr, "chem_master", name)
popup.set_content(dat)
popup.set_title_image(usr.browse_rsc_icon(src.icon, src.icon_state))
popup.open(1)
return
else if(href_list["main"]) // Used to exit the analyze screen.
attack_hand(usr)
return
else if(href_list["add"])
if(href_list["amount"])
var/id = href_list["add"]
var/amount = text2num(href_list["amount"])
if (amount > 0)
beaker.reagents.trans_id_to(src, id, amount)
else if(href_list["addcustom"])
var/id = href_list["addcustom"]
var/amt_temp = isgoodnumber(input(usr, "Select the amount to transfer.", "Transfer how much?", useramount) as num|null)
if(!amt_temp)
return
useramount = amt_temp
src.Topic(null, list("amount" = "[useramount]", "add" = "[id]"))
else if(href_list["remove"])
if(href_list["amount"])
var/id = href_list["remove"]
var/amount = text2num(href_list["amount"])
if (amount > 0)
if(mode)
reagents.trans_id_to(beaker, id, amount)
else
reagents.remove_reagent(id, amount)
else if(href_list["removecustom"])
var/id = href_list["removecustom"]
var/amt_temp = isgoodnumber(input(usr, "Select the amount to transfer.", "Transfer how much?", useramount) as num|null)
if(!amt_temp)
return
useramount = amt_temp
src.Topic(null, list("amount" = "[useramount]", "remove" = "[id]"))
else if(href_list["eject"])
if(beaker)
beaker.loc = src.loc
beaker = null
reagents.clear_reagents()
icon_state = "mixer0"
else if(href_list["createpill"]) //Also used for condiment packs.
if(reagents.total_volume == 0) return
if(!condi)
var/amount = 1
var/vol_each = min(reagents.total_volume, 50)
if(text2num(href_list["many"]))
amount = min(max(round(input(usr, "Max 10. Buffer content will be split evenly.", "How many pills?", amount) as num|null), 0), 10)
if(!amount)
return
vol_each = min(reagents.total_volume / amount, 50)
var/name = stripped_input(usr,"Name:","Name your pill!", "[reagents.get_master_reagent_name()] ([vol_each]u)", MAX_NAME_LEN)
if(!name || !reagents.total_volume)
return
var/obj/item/weapon/reagent_containers/pill/P
for(var/i = 0; i < amount; i++)
if(bottle && bottle.contents.len < bottle.storage_slots)
P = new/obj/item/weapon/reagent_containers/pill(bottle)
else
P = new/obj/item/weapon/reagent_containers/pill(src.loc)
P.name = trim("[name] pill")
P.pixel_x = rand(-7, 7) //random position
P.pixel_y = rand(-7, 7)
reagents.trans_to(P,vol_each)
else
var/name = stripped_input(usr, "Name:", "Name your pack!", reagents.get_master_reagent_name(), MAX_NAME_LEN)
if(!name || !reagents.total_volume)
return
var/obj/item/weapon/reagent_containers/food/condiment/pack/P = new/obj/item/weapon/reagent_containers/food/condiment/pack(src.loc)
P.originalname = name
P.name = trim("[name] pack")
P.desc = "A small condiment pack. The label says it contains [name]."
reagents.trans_to(P,10)
else if(href_list["createpatch"])
if(reagents.total_volume == 0) return
var/amount = 1
var/vol_each = min(reagents.total_volume, 50)
if(text2num(href_list["many"]))
amount = min(max(round(input(usr, "Max 10. Buffer content will be split evenly.", "How many patches?", amount) as num|null), 0), 10)
if(!amount)
return
vol_each = min(reagents.total_volume / amount, 50)
var/name = stripped_input(usr,"Name:","Name your patch!", "[reagents.get_master_reagent_name()] ([vol_each]u)", MAX_NAME_LEN)
if(!name || !reagents.total_volume)
return
var/obj/item/weapon/reagent_containers/pill/P
for(var/i = 0; i < amount; i++)
P = new/obj/item/weapon/reagent_containers/pill/patch(src.loc)
P.name = trim("[name] patch")
P.pixel_x = rand(-7, 7) //random position
P.pixel_y = rand(-7, 7)
reagents.trans_to(P,vol_each)
src.updateUsrDialog()
return
/obj/machinery/chem_master/attack_hand(mob/user)
if(stat & BROKEN)
return
user.set_machine(src)
var/dat = ""
if(beaker)
dat += "Beaker \[[beaker.reagents.total_volume]/[beaker.volume]\] <A href='?src=\ref[src];eject=1'>Eject and Clear Buffer</A><BR>"
else
dat = "Please insert beaker.<BR>"
dat += "<HR><B>Add to buffer:</B><UL>"
if(beaker)
if(beaker.reagents.total_volume)
for(var/datum/reagent/G in beaker.reagents.reagent_list)
dat += "<LI>[G.name], [G.volume] Units - "
dat += "<A href='?src=\ref[src];analyze=1;reagent=\ref[G]'>Analyze</A> "
dat += "<A href='?src=\ref[src];add=[G.id];amount=1'>1</A> "
dat += "<A href='?src=\ref[src];add=[G.id];amount=5'>5</A> "
dat += "<A href='?src=\ref[src];add=[G.id];amount=10'>10</A> "
dat += "<A href='?src=\ref[src];add=[G.id];amount=[G.volume]'>All</A> "
dat += "<A href='?src=\ref[src];addcustom=[G.id]'>Custom</A>"
else
dat += "<LI>Beaker is empty."
else
dat += "<LI>No beaker."
dat += "</UL><HR><B>Transfer to <A href='?src=\ref[src];toggle=1'>[(!mode ? "disposal" : "beaker")]</A>:</B><UL>"
if(reagents.total_volume)
for(var/datum/reagent/N in reagents.reagent_list)
dat += "<LI>[N.name], [N.volume] Units - "
dat += "<A href='?src=\ref[src];analyze=1;reagent=\ref[N]'>Analyze</A> "
dat += "<A href='?src=\ref[src];remove=[N.id];amount=1'>1</A> "
dat += "<A href='?src=\ref[src];remove=[N.id];amount=5'>5</A> "
dat += "<A href='?src=\ref[src];remove=[N.id];amount=10'>10</A> "
dat += "<A href='?src=\ref[src];remove=[N.id];amount=[N.volume]'>All</A> "
dat += "<A href='?src=\ref[src];removecustom=[N.id]'>Custom</A>"
else
dat += "<LI>Buffer is empty."
dat += "</UL><HR>"
if(!condi)
if(bottle)
dat += "Pill Bottle \[[bottle.contents.len]/[bottle.storage_slots]\] <A href='?src=\ref[src];ejectp=1'>Eject</A>"
else
dat += "No pill bottle inserted."
else
dat += "<BR>"
dat += "<UL>"
if(!condi)
if(beaker && reagents.total_volume)
dat += "<LI><A href='?src=\ref[src];createpill=1;many=0'>Create pill</A> (50 units max)"
dat += "<LI><A href='?src=\ref[src];createpill=1;many=1'>Create multiple pills</A><BR>"
dat += "<LI><A href='?src=\ref[src];createpatch=1;many=0'>Create patch</A> (50 units max)"
dat += "<LI><A href='?src=\ref[src];createpatch=1;many=1'>Create multiple patches</A><BR>"
else
dat += "<LI><span class='linkOff'>Create pill</span> (50 units max)"
dat += "<LI><span class='linkOff'>Create multiple pills</span><BR>"
dat += "<LI><span class='linkOff'>Create patch</span> (50 units max)"
dat += "<LI><span class='linkOff'>Create multiple patches</span><BR>"
else
if(beaker && reagents.total_volume)
dat += "<LI><A href='?src=\ref[src];createpill=1'>Create pack</A> (10 units max)<BR>"
else
dat += "<LI><span class='linkOff'>Create pack</span> (10 units max)<BR>"
dat += "<LI><A href='?src=\ref[src];createbottle=1'>Create bottle</A> ([condi ? "50" : "30"] units max)"
dat += "</UL>"
dat += "<BR><A href='?src=\ref[src];close=1'>Close</A>"
var/datum/browser/popup = new(user, "chem_master", name, 470, 500)
popup.set_content(dat)
popup.set_title_image(user.browse_rsc_icon(src.icon, src.icon_state))
popup.open(1)
return
/obj/machinery/chem_master/proc/isgoodnumber(num)
if(isnum(num))
if(num > 200)
num = 200
else if(num < 0)
num = 0
else
num = round(num)
return num
else
return 0
/obj/machinery/chem_master/condimaster
name = "CondiMaster 3000"
desc = "Used to create condiments and other cooking supplies."
condi = 1
/obj/machinery/chem_master/constructable
name = "ChemMaster 2999"
desc = "Used to seperate chemicals and distribute them in a variety of forms."
/obj/machinery/chem_master/constructable/New()
..()
component_parts = list()
component_parts += new /obj/item/weapon/circuitboard/chem_master(null)
component_parts += new /obj/item/weapon/stock_parts/manipulator(null)
component_parts += new /obj/item/weapon/stock_parts/console_screen(null)
component_parts += new /obj/item/weapon/reagent_containers/glass/beaker(null)
component_parts += new /obj/item/weapon/reagent_containers/glass/beaker(null)
/obj/machinery/chem_master/constructable/attackby(obj/item/B, mob/user, params)
if(default_deconstruction_screwdriver(user, "mixer0_nopower", "mixer0", B))
if(beaker)
beaker.loc = src.loc
beaker = null
reagents.clear_reagents()
if(bottle)
bottle.loc = src.loc
bottle = null
return
if(exchange_parts(user, B))
return
if(panel_open)
if(istype(B, /obj/item/weapon/crowbar))
default_deconstruction_crowbar(B)
return 1
else
user << "<span class='warning'>You can't use the [src.name] while it's panel is opened!</span>"
return 1
if(istype(B, /obj/item/weapon/reagent_containers/glass))
if(beaker)
user << "<span class='warning'>A beaker is already loaded into the machine!</span>"
return
if(!user.drop_item())
return
beaker = B
beaker.loc = src
user << "<span class='notice'>You add the beaker to the machine.</span>"
src.updateUsrDialog()
icon_state = "mixer1"
else if(!condi && istype(B, /obj/item/weapon/storage/pill_bottle))
if(bottle)
user << "<span class='warning'>A pill bottle is already loaded into the machine!</span>"
return
if(!user.drop_item())
return
src.bottle = B
B.loc = src
user << "<span class='notice'>You add the pill bottle into the dispenser slot.</span>"
src.updateUsrDialog()
return
@@ -0,0 +1,295 @@
/obj/machinery/computer/pandemic
name = "PanD.E.M.I.C 2200"
desc = "Used to work with viruses."
density = 1
anchored = 1
icon = 'icons/obj/chemical.dmi'
icon_state = "mixer0"
circuit = /obj/item/weapon/circuitboard/pandemic
use_power = 1
idle_power_usage = 20
var/temp_html = ""
var/wait = null
var/obj/item/weapon/reagent_containers/glass/beaker = null
/obj/machinery/computer/pandemic/New()
..()
update_icon()
/obj/machinery/computer/pandemic/set_broken()
icon_state = (beaker ? "mixer1_b" : "mixer0_b")
overlays.Cut()
stat |= BROKEN
/obj/machinery/computer/pandemic/proc/GetVirusByIndex(index)
if(beaker && beaker.reagents)
if(beaker.reagents.reagent_list.len)
var/datum/reagent/blood/BL = locate() in beaker.reagents.reagent_list
if(BL)
if(BL.data && BL.data["viruses"])
var/list/viruses = BL.data["viruses"]
return viruses[index]
return null
/obj/machinery/computer/pandemic/proc/GetResistancesByIndex(index)
if(beaker && beaker.reagents)
if(beaker.reagents.reagent_list.len)
var/datum/reagent/blood/BL = locate() in beaker.reagents.reagent_list
if(BL)
if(BL.data && BL.data["resistances"])
var/list/resistances = BL.data["resistances"]
return resistances[index]
return null
/obj/machinery/computer/pandemic/proc/GetVirusTypeByIndex(index)
var/datum/disease/D = GetVirusByIndex(index)
if(D)
return D.GetDiseaseID()
return null
/obj/machinery/computer/pandemic/proc/replicator_cooldown(waittime)
wait = 1
update_icon()
spawn(waittime)
src.wait = null
update_icon()
playsound(src.loc, 'sound/machines/ping.ogg', 30, 1)
/obj/machinery/computer/pandemic/update_icon()
if(stat & BROKEN)
icon_state = (beaker ? "mixer1_b" : "mixer0_b")
return
icon_state = "mixer[(beaker)?"1":"0"][(powered()) ? "" : "_nopower"]"
if(wait)
overlays.Cut()
else
overlays += "waitlight"
/obj/machinery/computer/pandemic/Topic(href, href_list)
if(..())
return
usr.set_machine(src)
if(!beaker) return
if (href_list["create_vaccine"])
if(!src.wait)
var/obj/item/weapon/reagent_containers/glass/bottle/B = new/obj/item/weapon/reagent_containers/glass/bottle(src.loc)
if(B)
B.pixel_x = rand(-3, 3)
B.pixel_y = rand(-3, 3)
var/path = GetResistancesByIndex(text2num(href_list["create_vaccine"]))
var/vaccine_type = path
var/vaccine_name = "Unknown"
if(!ispath(vaccine_type))
if(archive_diseases[path])
var/datum/disease/D = archive_diseases[path]
if(D)
vaccine_name = D.name
vaccine_type = path
else if(vaccine_type)
var/datum/disease/D = new vaccine_type(0, null)
if(D)
vaccine_name = D.name
if(vaccine_type)
B.name = "[vaccine_name] vaccine bottle"
B.reagents.add_reagent("vaccine", 15, list(vaccine_type))
replicator_cooldown(200)
else
src.temp_html = "The replicator is not ready yet."
src.updateUsrDialog()
return
else if (href_list["create_virus_culture"])
if(!wait)
var/type = GetVirusTypeByIndex(text2num(href_list["create_virus_culture"]))//the path is received as string - converting
var/datum/disease/D = null
if(!ispath(type))
D = GetVirusByIndex(text2num(href_list["create_virus_culture"]))
var/datum/disease/advance/A = archive_diseases[D.GetDiseaseID()]
if(A)
D = new A.type(0, A)
else if(type)
if(type in diseases) // Make sure this is a disease
D = new type(0, null)
if(!D)
return
var/name = stripped_input(usr,"Name:","Name the culture",D.name,MAX_NAME_LEN)
if(name == null || wait)
return
var/obj/item/weapon/reagent_containers/glass/bottle/B = new/obj/item/weapon/reagent_containers/glass/bottle(src.loc)
B.icon_state = "bottle3"
B.pixel_x = rand(-3, 3)
B.pixel_y = rand(-3, 3)
replicator_cooldown(50)
var/list/data = list("viruses"=list(D))
B.name = "[name] culture bottle"
B.desc = "A small bottle. Contains [D.agent] culture in synthblood medium."
B.reagents.add_reagent("blood",20,data)
src.updateUsrDialog()
else
src.temp_html = "The replicator is not ready yet."
src.updateUsrDialog()
return
else if (href_list["empty_beaker"])
beaker.reagents.clear_reagents()
src.updateUsrDialog()
return
else if (href_list["eject"])
beaker:loc = src.loc
beaker = null
icon_state = "mixer0"
src.updateUsrDialog()
return
else if(href_list["clear"])
src.temp_html = ""
src.updateUsrDialog()
return
else if(href_list["name_disease"])
var/new_name = stripped_input(usr, "Name the Disease", "New Name", "", MAX_NAME_LEN)
if(!new_name)
return
if(..())
return
var/id = GetVirusTypeByIndex(text2num(href_list["name_disease"]))
if(archive_diseases[id])
var/datum/disease/advance/A = archive_diseases[id]
A.AssignName(new_name)
for(var/datum/disease/advance/AD in SSdisease.processing)
AD.Refresh()
src.updateUsrDialog()
else
usr << browse(null, "window=pandemic")
src.updateUsrDialog()
return
src.add_fingerprint(usr)
return
/obj/machinery/computer/pandemic/attack_hand(mob/user)
if(..())
return
user.set_machine(src)
var/dat = ""
if(src.temp_html)
dat = "[src.temp_html]<BR><BR><A href='?src=\ref[src];clear=1'>Main Menu</A>"
else if(!beaker)
dat += "Please insert beaker.<BR>"
dat += "<A href='?src=\ref[user];mach_close=pandemic'>Close</A>"
else
var/datum/reagents/R = beaker.reagents
var/datum/reagent/blood/Blood = null
for(var/datum/reagent/blood/B in R.reagent_list)
if(B)
Blood = B
break
if(!R.total_volume||!R.reagent_list.len)
dat += "The beaker is empty<BR>"
else if(!Blood)
dat += "No blood sample found in beaker."
else if(!Blood.data)
dat += "No blood data found in beaker."
else
dat += "<h3>Blood sample data:</h3>"
dat += "<b>Blood DNA:</b> [(Blood.data["blood_DNA"]||"none")]<BR>"
dat += "<b>Blood Type:</b> [(Blood.data["blood_type"]||"none")]<BR>"
if(Blood.data["viruses"])
var/list/vir = Blood.data["viruses"]
if(vir.len)
var/i = 0
for(var/datum/disease/D in Blood.data["viruses"])
i++
if(!(D.visibility_flags & HIDDEN_PANDEMIC))
if(istype(D, /datum/disease/advance))
var/datum/disease/advance/A = D
D = archive_diseases[A.GetDiseaseID()]
if(D && D.name == "Unknown")
dat += "<b><a href='?src=\ref[src];name_disease=[i]'>Name Disease</a></b><BR>"
if(!D)
CRASH("We weren't able to get the advance disease from the archive.")
dat += "<b>Disease Agent:</b> [D?"[D.agent] - <A href='?src=\ref[src];create_virus_culture=[i]'>Create virus culture bottle</A>":"none"]<BR>"
dat += "<b>Common name:</b> [(D.name||"none")]<BR>"
dat += "<b>Description: </b> [(D.desc||"none")]<BR>"
dat += "<b>Spread:</b> [(D.spread_text||"none")]<BR>"
dat += "<b>Possible cure:</b> [(D.cure_text||"none")]<BR><BR>"
if(istype(D, /datum/disease/advance))
var/datum/disease/advance/A = D
dat += "<b>Symptoms:</b> "
var/english_symptoms = list()
for(var/datum/symptom/S in A.symptoms)
english_symptoms += S.name
dat += english_list(english_symptoms)
else
dat += "No detectable virus in the sample."
else
dat += "No detectable virus in the sample."
dat += "<BR><b>Contains antibodies to:</b> "
if(Blood.data["resistances"])
var/list/res = Blood.data["resistances"]
if(res.len)
dat += "<ul>"
var/i = 0
for(var/type in Blood.data["resistances"])
i++
var/disease_name = "Unknown"
if(!ispath(type))
var/datum/disease/advance/A = archive_diseases[type]
if(A)
disease_name = A.name
else
var/datum/disease/D = new type(0, null)
disease_name = D.name
dat += "<li>[disease_name] - <A href='?src=\ref[src];create_vaccine=[i]'>Create vaccine bottle</A></li>"
dat += "</ul><BR>"
else
dat += "nothing<BR>"
else
dat += "nothing<BR>"
dat += "<BR><A href='?src=\ref[src];eject=1'>Eject beaker</A>[((R.total_volume&&R.reagent_list.len) ? "-- <A href='?src=\ref[src];empty_beaker=1'>Empty beaker</A>":"")]<BR>"
dat += "<A href='?src=\ref[user];mach_close=pandemic'>Close</A>"
user << browse("<TITLE>[src.name]</TITLE><BR>[dat]", "window=pandemic;size=575x400")
onclose(user, "pandemic")
return
/obj/machinery/computer/pandemic/attackby(obj/item/I, mob/user, params)
if(istype(I, /obj/item/weapon/reagent_containers/glass))
if(stat & (NOPOWER|BROKEN)) return
if(beaker)
user << "<span class='warning'>A beaker is already loaded into the machine!</span>"
return
if(!user.drop_item())
return
beaker = I
beaker.loc = src
user << "<span class='notice'>You add the beaker to the machine.</span>"
src.updateUsrDialog()
icon_state = "mixer1"
else if(istype(I, /obj/item/weapon/screwdriver))
if(src.beaker)
beaker.loc = get_turf(src)
..()
return
else
..()
return
@@ -0,0 +1,441 @@
/obj/machinery/reagentgrinder
name = "All-In-One Grinder"
desc = "Used to grind things up into raw materials."
icon = 'icons/obj/kitchen.dmi'
icon_state = "juicer1"
layer = 2.9
anchored = 1
use_power = 1
idle_power_usage = 5
active_power_usage = 100
pass_flags = PASSTABLE
var/operating = 0
var/obj/item/weapon/reagent_containers/beaker = null
var/limit = 10
var/list/blend_items = list (
//Sheets
/obj/item/stack/sheet/mineral/plasma = list("plasma" = 20),
/obj/item/stack/sheet/metal = list("iron" = 20),
/obj/item/stack/sheet/plasteel = list("iron" = 20, "plasma" = 20),
/obj/item/stack/sheet/mineral/wood = list("carbon" = 20),
/obj/item/stack/sheet/glass = list("silicon" = 20),
/obj/item/stack/sheet/rglass = list("silicon" = 20, "iron" = 20),
/obj/item/stack/sheet/mineral/uranium = list("uranium" = 20),
/obj/item/stack/sheet/mineral/bananium = list("banana" = 20),
/obj/item/stack/sheet/mineral/silver = list("silver" = 20),
/obj/item/stack/sheet/mineral/gold = list("gold" = 20),
/obj/item/weapon/grown/nettle/basic = list("sacid" = 0),
/obj/item/weapon/grown/nettle/death = list("facid" = 0),
/obj/item/weapon/grown/novaflower = list("capsaicin" = 0, "condensedcapsaicin" = 0),
//Crayons (for overriding colours)
/obj/item/toy/crayon/red = list("redcrayonpowder" = 10),
/obj/item/toy/crayon/orange = list("orangecrayonpowder" = 10),
/obj/item/toy/crayon/yellow = list("yellowcrayonpowder" = 10),
/obj/item/toy/crayon/green = list("greencrayonpowder" = 10),
/obj/item/toy/crayon/blue = list("bluecrayonpowder" = 10),
/obj/item/toy/crayon/purple = list("purplecrayonpowder" = 10),
/obj/item/toy/crayon/mime = list("invisiblecrayonpowder" = 50),
//Blender Stuff
/obj/item/weapon/reagent_containers/food/snacks/grown/soybeans = list("soymilk" = 0),
/obj/item/weapon/reagent_containers/food/snacks/grown/tomato = list("ketchup" = 0),
/obj/item/weapon/reagent_containers/food/snacks/grown/corn = list("cornoil" = 0),
/obj/item/weapon/reagent_containers/food/snacks/grown/wheat = list("flour" = -5),
/obj/item/weapon/reagent_containers/food/snacks/grown/oat = list("flour" = -5),
/obj/item/weapon/reagent_containers/food/snacks/grown/cherries = list("cherryjelly" = 0),
/obj/item/weapon/reagent_containers/food/snacks/grown/bluecherries = list("bluecherryjelly" = 0),
/obj/item/weapon/reagent_containers/food/snacks/egg = list("eggyolk" = -5),
//Grinder stuff, but only if dry
/obj/item/weapon/reagent_containers/food/snacks/grown/coffee/arabica = list("coffeepowder" = 0),
/obj/item/weapon/reagent_containers/food/snacks/grown/coffee/robusta = list("coffeepowder" = 0, "morphine" = 0),
/obj/item/weapon/reagent_containers/food/snacks/grown/tea/aspera = list("teapowder" = 0),
/obj/item/weapon/reagent_containers/food/snacks/grown/tea/astra = list("teapowder" = 0, "salglu_solution" = 0),
//All types that you can put into the grinder to transfer the reagents to the beaker. !Put all recipes above this.!
/obj/item/weapon/reagent_containers/pill = list(),
/obj/item/weapon/reagent_containers/food = list()
)
var/list/juice_items = list (
//Juicer Stuff
/obj/item/weapon/reagent_containers/food/snacks/grown/corn = list("corn_starch" = 0),
/obj/item/weapon/reagent_containers/food/snacks/grown/tomato = list("tomatojuice" = 0),
/obj/item/weapon/reagent_containers/food/snacks/grown/carrot = list("carrotjuice" = 0),
/obj/item/weapon/reagent_containers/food/snacks/grown/berries = list("berryjuice" = 0),
/obj/item/weapon/reagent_containers/food/snacks/grown/banana = list("banana" = 0),
/obj/item/weapon/reagent_containers/food/snacks/grown/potato = list("potato" = 0),
/obj/item/weapon/reagent_containers/food/snacks/grown/citrus/lemon = list("lemonjuice" = 0),
/obj/item/weapon/reagent_containers/food/snacks/grown/citrus/orange = list("orangejuice" = 0),
/obj/item/weapon/reagent_containers/food/snacks/grown/citrus/lime = list("limejuice" = 0),
/obj/item/weapon/reagent_containers/food/snacks/grown/watermelon = list("watermelonjuice" = 0),
/obj/item/weapon/reagent_containers/food/snacks/watermelonslice = list("watermelonjuice" = 0),
/obj/item/weapon/reagent_containers/food/snacks/grown/berries/poison = list("poisonberryjuice" = 0),
/obj/item/weapon/reagent_containers/food/snacks/grown/pumpkin = list("pumpkinjuice" = 0),
/obj/item/weapon/reagent_containers/food/snacks/grown/blumpkin = list("blumpkinjuice" = 0),
)
var/list/dried_items = list(
//Grinder stuff, but only if dry
/obj/item/weapon/reagent_containers/food/snacks/grown/coffee/arabica = list("coffeepowder" = 0),
/obj/item/weapon/reagent_containers/food/snacks/grown/coffee/robusta = list("coffeepowder" = 0, "morphine" = 0),
/obj/item/weapon/reagent_containers/food/snacks/grown/tea/aspera = list("teapowder" = 0),
/obj/item/weapon/reagent_containers/food/snacks/grown/tea/astra = list("teapowder" = 0, "salglu_solution" = 0),
)
var/list/holdingitems = list()
/obj/machinery/reagentgrinder/New()
..()
beaker = new /obj/item/weapon/reagent_containers/glass/beaker/large(src)
return
/obj/machinery/reagentgrinder/update_icon()
icon_state = "juicer"+num2text(!isnull(beaker))
return
/obj/machinery/reagentgrinder/attackby(obj/item/I, mob/user, params)
if(default_unfasten_wrench(user, I))
return
if (istype(I, /obj/item/weapon/reagent_containers/glass) || \
istype(I, /obj/item/weapon/reagent_containers/food/drinks/drinkingglass) || \
istype(I, /obj/item/weapon/reagent_containers/food/drinks/shaker))
if (beaker)
return 1
else
if(!user.drop_item())
return 1
beaker = I
beaker.loc = src
update_icon()
src.updateUsrDialog()
return 0
if(is_type_in_list(I, dried_items))
if(istype(I, /obj/item/weapon/reagent_containers/food/snacks/grown))
var/obj/item/weapon/reagent_containers/food/snacks/grown/G = I
if(!G.dry)
user << "<span class='warning'>You must dry that first!</span>"
return 1
if(holdingitems && holdingitems.len >= limit)
usr << "The machine cannot hold anymore items."
return 1
//Fill machine with a bag!
if(istype(I, /obj/item/weapon/storage/bag))
var/obj/item/weapon/storage/bag/B = I
for (var/obj/item/weapon/reagent_containers/food/snacks/grown/G in B.contents)
B.remove_from_storage(G, src)
holdingitems += G
if(holdingitems && holdingitems.len >= limit) //Sanity checking so the blender doesn't overfill
user << "<span class='notice'>You fill the All-In-One grinder to the brim.</span>"
break
if(!I.contents.len)
user << "<span class='notice'>You empty the plant bag into the All-In-One grinder.</span>"
src.updateUsrDialog()
return 0
if (!is_type_in_list(I, blend_items) && !is_type_in_list(I, juice_items))
user << "<span class='warning'>Cannot refine into a reagent!</span>"
return 1
user.unEquip(I)
I.loc = src
holdingitems += I
src.updateUsrDialog()
return 0
/obj/machinery/reagentgrinder/attack_paw(mob/user)
return src.attack_hand(user)
/obj/machinery/reagentgrinder/attack_ai(mob/user)
return 0
/obj/machinery/reagentgrinder/attack_hand(mob/user)
user.set_machine(src)
interact(user)
/obj/machinery/reagentgrinder/interact(mob/user) // The microwave Menu
var/is_chamber_empty = 0
var/is_beaker_ready = 0
var/processing_chamber = ""
var/beaker_contents = ""
var/dat = ""
if(!operating)
for (var/obj/item/O in holdingitems)
processing_chamber += "\A [O.name]<BR>"
if (!processing_chamber)
is_chamber_empty = 1
processing_chamber = "Nothing."
if (!beaker)
beaker_contents = "<B>No beaker attached.</B><br>"
else
is_beaker_ready = 1
beaker_contents = "<B>The beaker contains:</B><br>"
var/anything = 0
for(var/datum/reagent/R in beaker.reagents.reagent_list)
anything = 1
beaker_contents += "[R.volume] - [R.name]<br>"
if(!anything)
beaker_contents += "Nothing<br>"
dat = {"
<b>Processing chamber contains:</b><br>
[processing_chamber]<br>
[beaker_contents]<hr>
"}
if (is_beaker_ready && !is_chamber_empty && !(stat & (NOPOWER|BROKEN)))
dat += "<A href='?src=\ref[src];action=grind'>Grind the reagents</a><BR>"
dat += "<A href='?src=\ref[src];action=juice'>Juice the reagents</a><BR><BR>"
if(holdingitems && holdingitems.len > 0)
dat += "<A href='?src=\ref[src];action=eject'>Eject the reagents</a><BR>"
if (beaker)
dat += "<A href='?src=\ref[src];action=detach'>Detach the beaker</a><BR>"
else
dat += "Please wait..."
var/datum/browser/popup = new(user, "reagentgrinder", "All-In-One Grinder")
popup.set_content(dat)
popup.set_title_image(user.browse_rsc_icon(src.icon, src.icon_state))
popup.open(1)
return
/obj/machinery/reagentgrinder/Topic(href, href_list)
if(..())
return
usr.set_machine(src)
if(operating)
updateUsrDialog()
return
switch(href_list["action"])
if ("grind")
grind()
if("juice")
juice()
if("eject")
eject()
if ("detach")
detach()
/obj/machinery/reagentgrinder/proc/detach()
if (usr.stat != 0)
return
if (!beaker)
return
beaker.loc = src.loc
beaker = null
update_icon()
updateUsrDialog()
/obj/machinery/reagentgrinder/proc/eject()
if (usr.stat != 0)
return
if (holdingitems && holdingitems.len == 0)
return
for(var/obj/item/O in holdingitems)
O.loc = src.loc
holdingitems -= O
holdingitems = list()
updateUsrDialog()
/obj/machinery/reagentgrinder/proc/is_allowed(obj/item/weapon/reagent_containers/O)
for (var/i in blend_items)
if(istype(O, i))
return 1
return 0
/obj/machinery/reagentgrinder/proc/get_allowed_by_id(obj/item/O)
for (var/i in blend_items)
if (istype(O, i))
return blend_items[i]
/obj/machinery/reagentgrinder/proc/get_allowed_snack_by_id(obj/item/weapon/reagent_containers/food/snacks/O)
for(var/i in blend_items)
if(istype(O, i))
return blend_items[i]
/obj/machinery/reagentgrinder/proc/get_allowed_juice_by_id(obj/item/weapon/reagent_containers/food/snacks/O)
for(var/i in juice_items)
if(istype(O, i))
return juice_items[i]
/obj/machinery/reagentgrinder/proc/get_grownweapon_amount(obj/item/weapon/grown/O)
if (!istype(O))
return 5
else if (O.potency == -1)
return 5
else
return round(O.potency)
/obj/machinery/reagentgrinder/proc/get_juice_amount(obj/item/weapon/reagent_containers/food/snacks/grown/O)
if (!istype(O))
return 5
else if (O.potency == -1)
return 5
else
return round(5*sqrt(O.potency))
/obj/machinery/reagentgrinder/proc/remove_object(obj/item/O)
holdingitems -= O
qdel(O)
/obj/machinery/reagentgrinder/proc/juice()
power_change()
if(stat & (NOPOWER|BROKEN))
return
if (!beaker || (beaker && beaker.reagents.total_volume >= beaker.reagents.maximum_volume))
return
playsound(src.loc, 'sound/machines/juicer.ogg', 20, 1)
var/offset = prob(50) ? -2 : 2
animate(src, pixel_x = pixel_x + offset, time = 0.2, loop = 250) //start shaking
operating = 1
updateUsrDialog()
spawn(50)
pixel_x = initial(pixel_x) //return to its spot after shaking
operating = 0
updateUsrDialog()
//Snacks
for (var/obj/item/weapon/reagent_containers/food/snacks/O in holdingitems)
if (beaker.reagents.total_volume >= beaker.reagents.maximum_volume)
break
var/allowed = get_allowed_juice_by_id(O)
if(isnull(allowed))
break
for (var/r_id in allowed)
var/space = beaker.reagents.maximum_volume - beaker.reagents.total_volume
var/amount = get_juice_amount(O)
beaker.reagents.add_reagent(r_id, min(amount, space))
if (beaker.reagents.total_volume >= beaker.reagents.maximum_volume)
break
remove_object(O)
/obj/machinery/reagentgrinder/proc/grind()
power_change()
if(stat & (NOPOWER|BROKEN))
return
if (!beaker || (beaker && beaker.reagents.total_volume >= beaker.reagents.maximum_volume))
return
playsound(src.loc, 'sound/machines/blender.ogg', 50, 1)
var/offset = prob(50) ? -2 : 2
animate(src, pixel_x = pixel_x + offset, time = 0.2, loop = 250) //start shaking
operating = 1
updateUsrDialog()
spawn(60)
pixel_x = initial(pixel_x) //return to its spot after shaking
operating = 0
updateUsrDialog()
//Snacks and Plants
for (var/obj/item/weapon/reagent_containers/food/snacks/O in holdingitems)
if (beaker.reagents.total_volume >= beaker.reagents.maximum_volume)
break
var/allowed = get_allowed_snack_by_id(O)
if(isnull(allowed))
break
for (var/r_id in allowed)
var/space = beaker.reagents.maximum_volume - beaker.reagents.total_volume
var/amount = allowed[r_id]
if(amount <= 0)
if(amount == 0)
if (O.reagents != null && O.reagents.has_reagent("nutriment"))
beaker.reagents.add_reagent(r_id, min(O.reagents.get_reagent_amount("nutriment"), space))
O.reagents.remove_reagent("nutriment", min(O.reagents.get_reagent_amount("nutriment"), space))
else
if (O.reagents != null && O.reagents.has_reagent("nutriment"))
beaker.reagents.add_reagent(r_id, min(round(O.reagents.get_reagent_amount("nutriment")*abs(amount)), space))
O.reagents.remove_reagent("nutriment", min(O.reagents.get_reagent_amount("nutriment"), space))
else
O.reagents.trans_id_to(beaker, r_id, min(amount, space))
if (beaker.reagents.total_volume >= beaker.reagents.maximum_volume)
break
if(O.reagents.reagent_list.len == 0)
remove_object(O)
//Sheets
for (var/obj/item/stack/sheet/O in holdingitems)
var/allowed = get_allowed_by_id(O)
if (beaker.reagents.total_volume >= beaker.reagents.maximum_volume)
break
for(var/i = 1; i <= round(O.amount, 1); i++)
for (var/r_id in allowed)
var/space = beaker.reagents.maximum_volume - beaker.reagents.total_volume
var/amount = allowed[r_id]
beaker.reagents.add_reagent(r_id,min(amount, space))
if (space < amount)
break
if (i == round(O.amount, 1))
remove_object(O)
break
//Plants
for (var/obj/item/weapon/grown/O in holdingitems)
if (beaker.reagents.total_volume >= beaker.reagents.maximum_volume)
break
var/allowed = get_allowed_by_id(O)
for (var/r_id in allowed)
var/space = beaker.reagents.maximum_volume - beaker.reagents.total_volume
var/amount = allowed[r_id]
if (amount == 0)
if (O.reagents != null && O.reagents.has_reagent(r_id))
beaker.reagents.add_reagent(r_id,min(O.reagents.get_reagent_amount(r_id), space))
else
beaker.reagents.add_reagent(r_id,min(amount, space))
if (beaker.reagents.total_volume >= beaker.reagents.maximum_volume)
break
remove_object(O)
//Crayons
//With some input from aranclanos, now 30% less shoddily copypasta
for (var/obj/item/toy/crayon/O in holdingitems)
if (beaker.reagents.total_volume >= beaker.reagents.maximum_volume)
break
var/allowed = get_allowed_by_id(O)
for (var/r_id in allowed)
var/space = beaker.reagents.maximum_volume - beaker.reagents.total_volume
var/amount = allowed[r_id]
beaker.reagents.add_reagent(r_id,min(amount, space))
if (space < amount)
break
remove_object(O)
//Everything else - Transfers reagents from it into beaker
for (var/obj/item/weapon/reagent_containers/O in holdingitems)
if (beaker.reagents.total_volume >= beaker.reagents.maximum_volume)
break
var/amount = O.reagents.total_volume
O.reagents.trans_to(beaker, amount)
if(!O.reagents.total_volume)
remove_object(O)
@@ -1,267 +1,270 @@
/*
NOTE: IF YOU UPDATE THE REAGENT-SYSTEM, ALSO UPDATE THIS README.
Structure: /////////////////// //////////////////////////
// Mob or object // -------> // Reagents var (datum) // Is a reference to the datum that holds the reagents.
/////////////////// //////////////////////////
| |
The object that holds everything. V
reagent_list var (list) A List of datums, each datum is a reagent.
| | |
V V V
reagents (datums) Reagents. I.e. Water , cryoxadone or mercury.
Random important notes:
An objects on_reagent_change will be called every time the objects reagents change.
Useful if you want to update the objects icon etc.
About the Holder:
The holder (reagents datum) is the datum that holds a list of all reagents
currently in the object.It also has all the procs needed to manipulate reagents
remove_any(var/amount)
This proc removes reagents from the holder until the passed amount
is matched. It'll try to remove some of ALL reagents contained.
trans_to(var/obj/target, var/amount)
This proc equally transfers the contents of the holder to another
objects holder. You need to pass it the object (not the holder) you want
to transfer to and the amount you want to transfer. Its return value is the
actual amount transfered (if one of the objects is full/empty)
trans_id_to(var/obj/target, var/reagent, var/amount)
Same as above but only for a specific reagent in the reagent list.
If the specified amount is greater than what is available, it will use
the amount of the reagent that is available. If no reagent exists, returns null.
metabolize(var/mob/M)
This proc is called by the mobs life proc. It simply calls on_mob_life for
all contained reagents. You shouldnt have to use this one directly.
handle_reactions()
This proc check all recipes and, on a match, uses them.
It will also call the recipe's on_reaction proc (for explosions or w/e).
Currently, this proc is automatically called by trans_to.
isolate_reagent(var/reagent)
Pass it a reagent id and it will remove all reagents but that one.
It's that simple.
del_reagent(var/reagent)
Completely remove the reagent with the matching id.
reaction_fire(exposed_temp)
Simply calls the reaction_fire procs of all contained reagents.
update_total()
This one simply updates the total volume of the holder.
(the volume of all reagents added together)
clear_reagents()
This proc removes ALL reagents from the holder.
reaction(var/atom/A, var/method=TOUCH, var/volume_modifier=0)
This proc calls the appropriate reaction procs of the reagents.
I.e. if A is an object, it will call the reagents reaction_obj
proc. The method var is used for reaction on mobs. It simply tells
us if the mob TOUCHed the reagent, if it INGESTed the reagent, if the reagent
was VAPORIZEd on them, if the reagent was INJECTed, or transfered via a PATCH to them.
Since the volume can be checked in a reagents proc, you might want to
use the volume_modifier var to modifiy the passed value without actually
changing the volume of the reagents.
If you're not sure if you need to use this the answer is very most likely 'No'.
You'll want to use this proc whenever an atom first comes in
contact with the reagents of a holder. (in the 'splash' part of a beaker i.e.)
More on the reaction in the reagent part of this readme.
add_reagent(var/reagent, var/amount, var/data)
Attempts to add X of the matching reagent to the holder.
You wont use this much. Mostly in new procs for pre-filled
objects.
remove_reagent(var/reagent, var/amount)
The exact opposite of the add_reagent proc.
has_reagent(var/reagent, var/amount)
Returns 1 if the holder contains this reagent.
Or 0 if not.
If you pass it an amount it will additionally check
if the amount is matched. This is optional.
get_reagent_amount(var/reagent)
Returns the amount of the matching reagent inside the
holder. Returns 0 if the reagent is missing.
Important variables:
total_volume
This variable contains the total volume of all reagents in this holder.
reagent_list
This is a list of all contained reagents. More specifically, references
to the reagent datums.
maximum_volume
This is the maximum volume of the holder.
my_atom
This is the atom the holder is 'in'. Useful if you need to find the location.
(i.e. for explosions)
About Reagents:
Reagents are all the things you can mix and fille in bottles etc. This can be anything from
rejuvs over water to ... iron. Each reagent also has a few procs - i'll explain those below.
reaction_mob(var/mob/M, var/method=TOUCH)
This is called by the holder's reation proc.
This version is only called when the reagent
reacts with a mob. The method var can be either
TOUCH or INGEST. You'll want to put stuff like
acid-facemelting in here.
reaction_obj(var/obj/O)
This is called by the holder's reation proc.
This version is called when the reagents reacts
with an object. You'll want to put stuff like
object melting in here ... or something. i dunno.
reaction_turf(var/turf/T)
This is called by the holder's reation proc.
This version is called when the reagents reacts
with a turf. You'll want to put stuff like extra
slippery floors for lube or something in here.
on_mob_life(var/mob/M)
This proc is called everytime the mobs life proc executes.
This is the place where you put damage for toxins ,
drowsyness for sleep toxins etc etc.
You'll want to call the parents proc by using ..() .
If you dont, the chemical will stay in the mob forever -
unless you write your own piece of code to slowly remove it.
(Should be pretty easy, 1 line of code)
Important variables:
holder
This variable contains a reference to the holder the chemical is 'in'
volume
This is the volume of the reagent.
id
The id of the reagent
name
The name of the reagent.
data
This var can be used for whatever the fuck you want. I used it for the sleep
toxins to make them work slowly instead of instantly. You could also use this
for DNA in a blood reagent or ... well whatever you want.
color
This is a hexadecimal color that represents the reagent outside of containers,
you define it as "#RRGGBB", or, red green blue. You can also define it using the
rgb() proc, which returns a hexadecimal value too. The color is black by default.
A good website for color calculations: http://www.psyclops.com/tools/rgb/
About Recipes:
Recipes are simple datums that contain a list of required reagents and a result.
They also have a proc that is called when the recipe is matched.
on_reaction(var/datum/reagents/holder, var/created_volume)
This proc is called when the recipe is matched.
You'll want to add explosions etc here.
To find the location you'll have to do something
like get_turf(holder.my_atom)
name & id
Should be pretty obvious.
result
This var contains the id of the resulting reagent.
required_reagents
This is a list of ids of the required reagents.
Each id also needs an associated value that gives us the minimum required amount
of that reagent. The handle_reaction proc can detect mutiples of the same recipes
so for most cases you want to set the required amount to 1.
required_catalysts
This is a list of the ids of the required catalysts.
Functionally similar to required_reagents, it is a list of reagents that are required
for the reaction. However, unlike required_reagents, catalysts are NOT consumed.
They mearly have to be present in the container.
result_amount
This is the amount of the resulting reagent this recipe will produce.
I recommend you set this to the total volume of all required reagent.
required_container
The container the recipe has to take place in in order to happen. Leave this blank/null
if you want the reaction to happen anywhere.
required_other
Basically like a reagent's data variable. You can set extra requirements for a
reaction with this.
required_temp
This is the required temperature.
About the Tools:
By default, all atom have a reagents var - but its empty. if you want to use an object for the chem.
system you'll need to add something like this in its new proc:
var/datum/reagents/R = new/datum/reagents(100) <<<<< create a new datum , 100 is the maximum_volume of the new holder datum.
reagents = R <<<<< assign the new datum to the objects reagents var
R.my_atom = src <<<<< set the holders my_atom to src so that we know where we are.
This can also be done by calling a convenience proc:
atom/proc/create_reagents(var/max_volume)
Other important stuff:
amount_per_transfer_from_this var
This var is mostly used by beakers and bottles.
It simply tells us how much to transfer when
'pouring' our reagents into something else.
atom/proc/is_open_container()
Checks atom/var/flags & OPENCONTAINER.
If this returns 1 , you can use syringes, beakers etc
to manipulate the contents of this object.
If it's 0, you'll need to write your own custom reagent
transfer code since you will not be able to use the standard
tools to manipulate it.
*/
/* GOON CHEMS README:
Credit goes to Cogwerks, and all the other goonstation coders
for the original idea and implementation of this over at goonstation.
THE REQUESTED DON'T PORT LIST: IF YOU PORT THESE THE GOONS WILL MURDER US IN OUR SLEEP SO PLEASE DON'T KTHX - Iamgoofball
Any of the Secret Chems
Goon in-joke chems (Eg. Cat Drugs, Hairgrownium)
Liquid Electricity
Rajajajah
/*
NOTE: IF YOU UPDATE THE REAGENT-SYSTEM, ALSO UPDATE THIS README.
Structure: /////////////////// //////////////////////////
// Mob or object // -------> // Reagents var (datum) // Is a reference to the datum that holds the reagents.
/////////////////// //////////////////////////
| |
The object that holds everything. V
reagent_list var (list) A List of datums, each datum is a reagent.
| | |
V V V
reagents (datums) Reagents. I.e. Water , cryoxadone or mercury.
Random important notes:
An objects on_reagent_change will be called every time the objects reagents change.
Useful if you want to update the objects icon etc.
About the Holder:
The holder (reagents datum) is the datum that holds a list of all reagents
currently in the object.It also has all the procs needed to manipulate reagents
remove_any(var/amount)
This proc removes reagents from the holder until the passed amount
is matched. It'll try to remove some of ALL reagents contained.
remove_all(var/amount)
This proc removes reagents from the holder equally.
trans_to(var/obj/target, var/amount)
This proc equally transfers the contents of the holder to another
objects holder. You need to pass it the object (not the holder) you want
to transfer to and the amount you want to transfer. Its return value is the
actual amount transfered (if one of the objects is full/empty)
trans_id_to(var/obj/target, var/reagent, var/amount)
Same as above but only for a specific reagent in the reagent list.
If the specified amount is greater than what is available, it will use
the amount of the reagent that is available. If no reagent exists, returns null.
metabolize(var/mob/M)
This proc is called by the mobs life proc. It simply calls on_mob_life for
all contained reagents. You shouldnt have to use this one directly.
handle_reactions()
This proc check all recipes and, on a match, uses them.
It will also call the recipe's on_reaction proc (for explosions or w/e).
Currently, this proc is automatically called by trans_to.
isolate_reagent(var/reagent)
Pass it a reagent id and it will remove all reagents but that one.
It's that simple.
del_reagent(var/reagent)
Completely remove the reagent with the matching id.
reaction_fire(exposed_temp)
Simply calls the reaction_fire procs of all contained reagents.
update_total()
This one simply updates the total volume of the holder.
(the volume of all reagents added together)
clear_reagents()
This proc removes ALL reagents from the holder.
reaction(var/atom/A, var/method=TOUCH, var/volume_modifier=0)
This proc calls the appropriate reaction procs of the reagents.
I.e. if A is an object, it will call the reagents reaction_obj
proc. The method var is used for reaction on mobs. It simply tells
us if the mob TOUCHed the reagent, if it INGESTed the reagent, if the reagent
was VAPORIZEd on them, if the reagent was INJECTed, or transfered via a PATCH to them.
Since the volume can be checked in a reagents proc, you might want to
use the volume_modifier var to modifiy the passed value without actually
changing the volume of the reagents.
If you're not sure if you need to use this the answer is very most likely 'No'.
You'll want to use this proc whenever an atom first comes in
contact with the reagents of a holder. (in the 'splash' part of a beaker i.e.)
More on the reaction in the reagent part of this readme.
add_reagent(var/reagent, var/amount, var/data)
Attempts to add X of the matching reagent to the holder.
You wont use this much. Mostly in new procs for pre-filled
objects.
remove_reagent(var/reagent, var/amount)
The exact opposite of the add_reagent proc.
has_reagent(var/reagent, var/amount)
Returns 1 if the holder contains this reagent.
Or 0 if not.
If you pass it an amount it will additionally check
if the amount is matched. This is optional.
get_reagent_amount(var/reagent)
Returns the amount of the matching reagent inside the
holder. Returns 0 if the reagent is missing.
Important variables:
total_volume
This variable contains the total volume of all reagents in this holder.
reagent_list
This is a list of all contained reagents. More specifically, references
to the reagent datums.
maximum_volume
This is the maximum volume of the holder.
my_atom
This is the atom the holder is 'in'. Useful if you need to find the location.
(i.e. for explosions)
About Reagents:
Reagents are all the things you can mix and fille in bottles etc. This can be anything from
rejuvs over water to ... iron. Each reagent also has a few procs - i'll explain those below.
reaction_mob(var/mob/M, var/method=TOUCH)
This is called by the holder's reation proc.
This version is only called when the reagent
reacts with a mob. The method var can be either
TOUCH or INGEST. You'll want to put stuff like
acid-facemelting in here.
reaction_obj(var/obj/O)
This is called by the holder's reation proc.
This version is called when the reagents reacts
with an object. You'll want to put stuff like
object melting in here ... or something. i dunno.
reaction_turf(var/turf/T)
This is called by the holder's reation proc.
This version is called when the reagents reacts
with a turf. You'll want to put stuff like extra
slippery floors for lube or something in here.
on_mob_life(var/mob/M)
This proc is called everytime the mobs life proc executes.
This is the place where you put damage for toxins ,
drowsyness for sleep toxins etc etc.
You'll want to call the parents proc by using ..() .
If you dont, the chemical will stay in the mob forever -
unless you write your own piece of code to slowly remove it.
(Should be pretty easy, 1 line of code)
Important variables:
holder
This variable contains a reference to the holder the chemical is 'in'
volume
This is the volume of the reagent.
id
The id of the reagent
name
The name of the reagent.
data
This var can be used for whatever the fuck you want. I used it for the sleep
toxins to make them work slowly instead of instantly. You could also use this
for DNA in a blood reagent or ... well whatever you want.
color
This is a hexadecimal color that represents the reagent outside of containers,
you define it as "#RRGGBB", or, red green blue. You can also define it using the
rgb() proc, which returns a hexadecimal value too. The color is black by default.
A good website for color calculations: http://www.psyclops.com/tools/rgb/
About Recipes:
Recipes are simple datums that contain a list of required reagents and a result.
They also have a proc that is called when the recipe is matched.
on_reaction(var/datum/reagents/holder, var/created_volume)
This proc is called when the recipe is matched.
You'll want to add explosions etc here.
To find the location you'll have to do something
like get_turf(holder.my_atom)
name & id
Should be pretty obvious.
result
This var contains the id of the resulting reagent.
required_reagents
This is a list of ids of the required reagents.
Each id also needs an associated value that gives us the minimum required amount
of that reagent. The handle_reaction proc can detect mutiples of the same recipes
so for most cases you want to set the required amount to 1.
required_catalysts
This is a list of the ids of the required catalysts.
Functionally similar to required_reagents, it is a list of reagents that are required
for the reaction. However, unlike required_reagents, catalysts are NOT consumed.
They mearly have to be present in the container.
result_amount
This is the amount of the resulting reagent this recipe will produce.
I recommend you set this to the total volume of all required reagent.
required_container
The container the recipe has to take place in in order to happen. Leave this blank/null
if you want the reaction to happen anywhere.
required_other
Basically like a reagent's data variable. You can set extra requirements for a
reaction with this.
required_temp
This is the required temperature.
About the Tools:
By default, all atom have a reagents var - but its empty. if you want to use an object for the chem.
system you'll need to add something like this in its new proc:
var/datum/reagents/R = new/datum/reagents(100) <<<<< create a new datum , 100 is the maximum_volume of the new holder datum.
reagents = R <<<<< assign the new datum to the objects reagents var
R.my_atom = src <<<<< set the holders my_atom to src so that we know where we are.
This can also be done by calling a convenience proc:
atom/proc/create_reagents(var/max_volume)
Other important stuff:
amount_per_transfer_from_this var
This var is mostly used by beakers and bottles.
It simply tells us how much to transfer when
'pouring' our reagents into something else.
atom/proc/is_open_container()
Checks atom/var/flags & OPENCONTAINER.
If this returns 1 , you can use syringes, beakers etc
to manipulate the contents of this object.
If it's 0, you'll need to write your own custom reagent
transfer code since you will not be able to use the standard
tools to manipulate it.
*/
/* GOON CHEMS README:
Credit goes to Cogwerks, and all the other goonstation coders
for the original idea and implementation of this over at goonstation.
THE REQUESTED DON'T PORT LIST: IF YOU PORT THESE THE GOONS WILL MURDER US IN OUR SLEEP SO PLEASE DON'T KTHX - Iamgoofball
Any of the Secret Chems
Goon in-joke chems (Eg. Cat Drugs, Hairgrownium)
Liquid Electricity
Rajajajah
*/
@@ -267,7 +267,7 @@
return
/datum/reagent/consumable/spacemountainwind
name = "Space Mountain Wind"
name = "SM Wind"
id = "spacemountainwind"
description = "Blows right through you like a space wind."
color = "#102000" // rgb: 16, 32, 0
@@ -1,91 +1,90 @@
///////////////////////////////////////////////////////////////////////////////////
/datum/chemical_reaction
var/name = null
var/id = null
var/result = null
var/list/required_reagents = new/list()
var/list/required_catalysts = new/list()
// Both of these variables are mostly going to be used with slime cores - but if you want to, you can use them for other things
var/atom/required_container = null // the container required for the reaction to happen
var/required_other = 0 // an integer required for the reaction to happen
var/result_amount = 0
var/secondary = 0 // set to nonzero if secondary reaction
var/mob_react = 0 //Determines if a chemical reaction can occur inside a mob
var/required_temp = 0
var/mix_message = "The solution begins to bubble."
/datum/chemical_reaction/proc/on_reaction(datum/reagents/holder, created_volume)
return
//I recommend you set the result amount to the total volume of all components.
var/list/chemical_mob_spawn_meancritters = list() // list of possible hostile mobs
var/list/chemical_mob_spawn_nicecritters = list() // and possible friendly mobs
/datum/chemical_reaction/proc/chemical_mob_spawn(datum/reagents/holder, amount_to_spawn, reaction_name, mob_faction = "chemicalsummon")
if(holder && holder.my_atom)
if (chemical_mob_spawn_meancritters.len <= 0 || chemical_mob_spawn_nicecritters.len <= 0)
for (var/T in typesof(/mob/living/simple_animal))
var/mob/living/simple_animal/SA = T
switch(initial(SA.gold_core_spawnable))
if(1)
chemical_mob_spawn_meancritters += T
if(2)
chemical_mob_spawn_nicecritters += T
var/atom/A = holder.my_atom
var/turf/T = get_turf(A)
var/area/my_area = get_area(T)
var/message = "A [reaction_name] reaction has occured in [my_area.name]. (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[T.x];Y=[T.y];Z=[T.z]'>JMP</A>)"
message += " (<A HREF='?_src_=vars;Vars=\ref[A]'>VV</A>)"
var/mob/M = get(A, /mob)
if(M)
message += " - Carried By: [key_name_admin(M)](<A HREF='?_src_=holder;adminmoreinfo=\ref[M]'>?</A>) (<A HREF='?_src_=holder;adminplayerobservefollow=\ref[M]'>FLW</A>)"
else
message += " - Last Fingerprint: [(A.fingerprintslast ? A.fingerprintslast : "N/A")]"
message_admins(message, 0, 1)
playsound(get_turf(holder.my_atom), 'sound/effects/phasein.ogg', 100, 1)
for(var/mob/living/carbon/C in viewers(get_turf(holder.my_atom), null))
C.flash_eyes()
for(var/i = 1, i <= amount_to_spawn, i++)
var/chosen
if (reaction_name == "Friendly Gold Slime")
chosen = pick(chemical_mob_spawn_nicecritters)
else
chosen = pick(chemical_mob_spawn_meancritters)
var/mob/living/simple_animal/C = new chosen
C.faction |= mob_faction
C.loc = get_turf(holder.my_atom)
if(prob(50))
for(var/j = 1, j <= rand(1, 3), j++)
step(C, pick(NORTH,SOUTH,EAST,WEST))
/datum/chemical_reaction/proc/goonchem_vortex(turf/simulated/T, setting_type, range)
for(var/atom/movable/X in orange(range, T))
if(istype(X, /obj/effect))
continue
if(!X.anchored)
var/distance = get_dist(X, T)
var/moving_power = max(range - distance, 1)
spawn(0) //so everything moves at the same time.
if(moving_power > 2) //if the vortex is powerful and we're close, we get thrown
if(setting_type)
var/atom/throw_target = get_edge_target_turf(X, get_dir(X, get_step_away(X, T)))
X.throw_at(throw_target, moving_power, 1)
else
X.throw_at(T, moving_power, 1)
else
if(setting_type)
for(var/i = 0, i < moving_power, i++)
sleep(2)
if(!step_away(X, T))
break
else
for(var/i = 0, i < moving_power, i++)
sleep(2)
if(!step_towards(X, T))
break
/datum/chemical_reaction
var/name = null
var/id = null
var/result = null
var/list/required_reagents = new/list()
var/list/required_catalysts = new/list()
// Both of these variables are mostly going to be used with slime cores - but if you want to, you can use them for other things
var/atom/required_container = null // the container required for the reaction to happen
var/required_other = 0 // an integer required for the reaction to happen
var/result_amount = 0
var/secondary = 0 // set to nonzero if secondary reaction
var/mob_react = 0 //Determines if a chemical reaction can occur inside a mob
var/required_temp = 0
var/mix_message = "The solution begins to bubble."
/datum/chemical_reaction/proc/on_reaction(datum/reagents/holder, created_volume)
return
//I recommend you set the result amount to the total volume of all components.
var/list/chemical_mob_spawn_meancritters = list() // list of possible hostile mobs
var/list/chemical_mob_spawn_nicecritters = list() // and possible friendly mobs
/datum/chemical_reaction/proc/chemical_mob_spawn(datum/reagents/holder, amount_to_spawn, reaction_name, mob_faction = "chemicalsummon")
if(holder && holder.my_atom)
if (chemical_mob_spawn_meancritters.len <= 0 || chemical_mob_spawn_nicecritters.len <= 0)
for (var/T in typesof(/mob/living/simple_animal))
var/mob/living/simple_animal/SA = T
switch(initial(SA.gold_core_spawnable))
if(1)
chemical_mob_spawn_meancritters += T
if(2)
chemical_mob_spawn_nicecritters += T
var/atom/A = holder.my_atom
var/turf/T = get_turf(A)
var/area/my_area = get_area(T)
var/message = "A [reaction_name] reaction has occured in [my_area.name]. (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[T.x];Y=[T.y];Z=[T.z]'>JMP</A>)"
message += " (<A HREF='?_src_=vars;Vars=\ref[A]'>VV</A>)"
var/mob/M = get(A, /mob)
if(M)
message += " - Carried By: [key_name_admin(M)](<A HREF='?_src_=holder;adminmoreinfo=\ref[M]'>?</A>) (<A HREF='?_src_=holder;adminplayerobservefollow=\ref[M]'>FLW</A>)"
else
message += " - Last Fingerprint: [(A.fingerprintslast ? A.fingerprintslast : "N/A")]"
message_admins(message, 0, 1)
playsound(get_turf(holder.my_atom), 'sound/effects/phasein.ogg', 100, 1)
for(var/mob/living/carbon/C in viewers(get_turf(holder.my_atom), null))
C.flash_eyes()
for(var/i = 1, i <= amount_to_spawn, i++)
var/chosen
if (reaction_name == "Friendly Gold Slime")
chosen = pick(chemical_mob_spawn_nicecritters)
else
chosen = pick(chemical_mob_spawn_meancritters)
var/mob/living/simple_animal/C = new chosen
C.faction |= mob_faction
C.loc = get_turf(holder.my_atom)
if(prob(50))
for(var/j = 1, j <= rand(1, 3), j++)
step(C, pick(NORTH,SOUTH,EAST,WEST))
/datum/chemical_reaction/proc/goonchem_vortex(turf/simulated/T, setting_type, range)
for(var/atom/movable/X in orange(range, T))
if(istype(X, /obj/effect))
continue
if(!X.anchored)
var/distance = get_dist(X, T)
var/moving_power = max(range - distance, 1)
spawn(0) //so everything moves at the same time.
if(moving_power > 2) //if the vortex is powerful and we're close, we get thrown
if(setting_type)
var/atom/throw_target = get_edge_target_turf(X, get_dir(X, get_step_away(X, T)))
X.throw_at(throw_target, moving_power, 1)
else
X.throw_at(T, moving_power, 1)
else
if(setting_type)
for(var/i = 0, i < moving_power, i++)
sleep(2)
if(!step_away(X, T))
break
else
for(var/i = 0, i < moving_power, i++)
sleep(2)
if(!step_towards(X, T))
break