merge fixes

This commit is contained in:
Seris02
2020-02-02 11:51:26 +08:00
427 changed files with 10673 additions and 4240 deletions
+15 -5
View File
@@ -171,7 +171,7 @@
return master
/datum/reagents/proc/trans_to(obj/target, amount=1, multiplier=1, preserve_data=1, no_react = 0)//if preserve_data=0, the reagents data will be lost. Usefull if you use data for some strange stuff and don't want it to be transferred.
/datum/reagents/proc/trans_to(obj/target, amount = 1, multiplier = 1, preserve_data = 1, no_react = 0, log = FALSE)//if preserve_data=0, the reagents data will be lost. Usefull if you use data for some strange stuff and don't want it to be transferred.
var/list/cached_reagents = reagent_list
if(!target || !total_volume)
return
@@ -188,17 +188,23 @@
amount = min(min(amount, src.total_volume), R.maximum_volume-R.total_volume)
var/part = amount / src.total_volume
var/trans_data = null
var/list/transferred = list()
for(var/reagent in cached_reagents)
var/datum/reagent/T = reagent
var/transfer_amount = T.volume * part
if(preserve_data)
trans_data = copy_data(T)
transferred += "[T] - [transfer_amount]"
R.add_reagent(T.type, transfer_amount * multiplier, trans_data, chem_temp, T.purity, pH, no_react = TRUE, ignore_pH = TRUE) //we only handle reaction after every reagent has been transfered.
remove_reagent(T.type, transfer_amount, ignore_pH = TRUE)
if(log && amount > 0)
var/atom/us = my_atom
var/atom/them = R.my_atom
var/location_string = "FROM [(us && "[us] ([REF(us)]) [COORD(us)]") || "NULL"] TO [(them && "[them] ([REF(them)]) [COORD(them)]") || "NULL"]"
log_reagent_transfer("[location_string] - [key_name(usr)][istext(log) ? " - [log]" : ""]: trans_to with arguments [target] [amount] [multiplier] [preserve_data] [no_react] and reagents [english_list(transferred)]")
update_total()
R.update_total()
if(!no_react)
@@ -237,7 +243,7 @@
src.handle_reactions()
return amount
/datum/reagents/proc/trans_id_to(obj/target, reagent, amount=1, preserve_data=1)//Not sure why this proc didn't exist before. It does now! /N
/datum/reagents/proc/trans_id_to(obj/target, reagent, amount = 1, preserve_data = TRUE, log = FALSE)//Not sure why this proc didn't exist before. It does now! /N
var/list/cached_reagents = reagent_list
if (!target)
return
@@ -257,8 +263,12 @@
if(preserve_data)
trans_data = current_reagent.data
R.add_reagent(current_reagent.type, amount, trans_data, chem_temp, current_reagent.purity, pH, no_react = TRUE)
remove_reagent(current_reagent.type, amount, 1)
if(log && amount > 0)
var/atom/us = my_atom
var/atom/them = R.my_atom
var/location_string = "FROM [(us && "[us] ([REF(us)]) [COORD(us)]") || "NULL"] TO [(them && "[them] ([REF(them)]) [COORD(them)]") || "NULL"]"
log_reagent_transfer("[location_string] - [key_name(usr)][istext(log) ? " - [log]" : ""]: trans_id_to with arguments [target] [reagent] [amount] [preserve_data]")
break
src.update_total()
@@ -31,8 +31,8 @@
var/working_state = "dispenser_working"
var/nopower_state = "dispenser_nopower"
var/has_panel_overlay = TRUE
var/macrotier = 1
var/obj/item/reagent_containers/beaker = null
//dispensable_reagents is copypasted in plumbing synthesizers. Please update accordingly. (I didn't make it global because that would limit custom chem dispensers)
var/list/dispensable_reagents = list(
/datum/reagent/hydrogen,
/datum/reagent/lithium,
@@ -61,7 +61,7 @@
/datum/reagent/bromine,
/datum/reagent/stable_plasma
)
//these become available once upgraded.
//These become available once upgraded.
var/list/upgrade_reagents = list(
/datum/reagent/oil,
/datum/reagent/ammonia,
@@ -87,11 +87,13 @@
/datum/reagent/toxin/histamine,
/datum/reagent/medicine/morphine
)
var/list/recording_recipe
var/list/saved_recipes = list()
/obj/machinery/chem_dispenser/Initialize()
. = ..()
dispensable_reagents = sortList(dispensable_reagents, /proc/cmp_reagents_asc)
if(emagged_reagents)
emagged_reagents = sortList(emagged_reagents, /proc/cmp_reagents_asc)
if(upgrade_reagents)
@@ -116,15 +118,6 @@
. += "<span class='notice'>The status display reads:\n\
Recharging <b>[recharge_amount]</b> power units per interval.\n\
Power efficiency increased by <b>[round((powerefficiency*1000)-100, 1)]%</b>.</span>"
switch(macrotier)
if(1)
. += "<span class='notice'>Macro granularity at <b>5u</b>.<span>"
if(2)
. += "<span class='notice'>Macro granularity at <b>3u</b>.<span>"
if(3)
. += "<span class='notice'>Macro granularity at <b>2u</b>.<span>"
if(4)
. += "<span class='notice'>Macro granularity at <b>1u</b>.<span>"
/obj/machinery/chem_dispenser/process()
if (recharge_counter >= 4)
@@ -160,7 +153,6 @@
beaker_overlay = display_beaker()
add_overlay(beaker_overlay)
/obj/machinery/chem_dispenser/emag_act(mob/user)
. = ..()
if(obj_flags & EMAGGED)
@@ -225,8 +217,7 @@
data["beakerTransferAmounts"] = null
data["beakerCurrentpH"] = null
var/chemicals[0]
var/recipes[0]
var/list/chemicals = list()
var/is_hallucinating = FALSE
if(user.hallucinating())
is_hallucinating = TRUE
@@ -237,10 +228,10 @@
if(is_hallucinating && prob(5))
chemname = "[pick_list_replacements("hallucination.json", "chemicals")]"
chemicals.Add(list(list("title" = chemname, "id" = ckey(temp.name))))
for(var/recipe in saved_recipes)
recipes.Add(list(recipe))
data["chemicals"] = chemicals
data["recipes"] = recipes
data["recipes"] = saved_recipes
data["recordingRecipe"] = recording_recipe
return data
/obj/machinery/chem_dispenser/ui_act(action, params)
@@ -258,24 +249,28 @@
if("dispense")
if(!is_operational() || QDELETED(cell))
return
var/reagent = GLOB.name2reagent[params["reagent"]]
if(beaker && dispensable_reagents.Find(reagent))
var/datum/reagents/R = beaker.reagents
var/free = R.maximum_volume - R.total_volume
var/actual = min(amount, (cell.charge * powerefficiency)*10, free)
var/reagent_name = params["reagent"]
if(!recording_recipe)
var/reagent = GLOB.name2reagent[reagent_name]
if(beaker && dispensable_reagents.Find(reagent))
var/datum/reagents/R = beaker.reagents
var/free = R.maximum_volume - R.total_volume
var/actual = min(amount, (cell.charge * powerefficiency)*10, free)
if(!cell.use(actual / powerefficiency))
say("Not enough energy to complete operation!")
return
R.add_reagent(reagent, actual)
if(!cell.use(actual / powerefficiency))
say("Not enough energy to complete operation!")
return
R.add_reagent(reagent, actual)
work_animation()
. = TRUE
work_animation()
else
recording_recipe[reagent_name] += amount
. = TRUE
if("remove")
if(!is_operational())
if(!is_operational() || recording_recipe)
return
var/amount = text2num(params["amount"])
if(beaker && (amount in beaker.possible_transfer_amounts))
if(beaker && amount in beaker.possible_transfer_amounts)
beaker.reagents.remove_all(amount)
work_animation()
. = TRUE
@@ -285,57 +280,65 @@
if("dispense_recipe")
if(!is_operational() || QDELETED(cell))
return
var/recipe_to_use = params["recipe"]
var/list/chemicals_to_dispense = process_recipe_list(recipe_to_use)
var/res = get_macro_resolution()
for(var/key in chemicals_to_dispense) // i suppose you could edit the list locally before passing it
var/list/keysplit = splittext(key," ")
var/r_id = GLOB.name2reagent[translate_legacy_chem_id(keysplit[1])]
if(beaker && dispensable_reagents.Find(r_id)) // but since we verify we have the reagent, it'll be fine
var/list/chemicals_to_dispense = saved_recipes[params["recipe"]]
if(!LAZYLEN(chemicals_to_dispense))
return
for(var/key in chemicals_to_dispense)
var/reagent = GLOB.name2reagent[translate_legacy_chem_id(key)]
var/dispense_amount = chemicals_to_dispense[key]
if(!dispensable_reagents.Find(reagent))
return
if(!recording_recipe)
if(!beaker)
return
var/datum/reagents/R = beaker.reagents
var/free = R.maximum_volume - R.total_volume
var/actual = min(max(chemicals_to_dispense[key], res), (cell.charge * powerefficiency)*10, free)
var/actual = min(dispense_amount, (cell.charge * powerefficiency)*10, free)
if(actual)
if(!cell.use(actual / powerefficiency))
say("Not enough energy to complete operation!")
return
R.add_reagent(r_id, actual)
R.add_reagent(reagent, actual)
work_animation()
else
recording_recipe[key] += dispense_amount
. = TRUE
if("clear_recipes")
if(!is_operational())
return
var/yesno = alert("Clear all recipes?",, "Yes","No")
if(yesno == "Yes")
saved_recipes = list()
if("add_recipe")
. = TRUE
if("record_recipe")
if(!is_operational())
return
recording_recipe = list()
. = TRUE
if("save_recording")
if(!is_operational())
return
var/name = stripped_input(usr,"Name","What do you want to name this recipe?", "Recipe", MAX_NAME_LEN)
var/recipe = stripped_input(usr,"Recipe","Insert recipe with chem IDs")
if(!usr.canUseTopic(src, !hasSiliconAccessInArea(usr)))
return
if(name && recipe)
var/list/first_process = splittext(recipe, ";")
if(!LAZYLEN(first_process))
return
var/res = get_macro_resolution()
var/resmismatch = FALSE
for(var/reagents in first_process)
var/list/reagent = splittext(reagents, "=")
var/reagent_id = GLOB.name2reagent[translate_legacy_chem_id(reagent[1])]
if(dispensable_reagents.Find(reagent_id))
if (!resmismatch && !check_macro_part(reagents, res))
resmismatch = TRUE
continue
else
var/chemid = reagent[1]
if(saved_recipes[name] && alert("\"[name]\" already exists, do you want to overwrite it?",, "Yes", "No") == "No")
return
if(name && recording_recipe)
for(var/reagent in recording_recipe)
var/reagent_id = GLOB.name2reagent[translate_legacy_chem_id(reagent)]
if(!dispensable_reagents.Find(reagent_id))
visible_message("<span class='warning'>[src] buzzes.</span>", "<span class='italics'>You hear a faint buzz.</span>")
to_chat(usr, "<span class ='danger'>[src] cannot find Chemical ID: <b>[chemid]</b>!</span>")
to_chat(usr, "<span class ='danger'>[src] cannot find <b>[reagent]</b>!</span>")
playsound(src, 'sound/machines/buzz-two.ogg', 50, 1)
return
if (resmismatch && alert("[src] is not yet capable of replicating this recipe with the precision it needs, do you want to save it anyway?",, "Yes","No") == "No")
return
saved_recipes += list(list("recipe_name" = name, "contents" = recipe))
saved_recipes[name] = recording_recipe
recording_recipe = null
. = TRUE
if("cancel_recording")
if(!is_operational())
return
recording_recipe = null
. = TRUE
/obj/machinery/chem_dispenser/attackby(obj/item/I, mob/user, params)
if(default_unfasten_wrench(user, I))
@@ -343,7 +346,6 @@
if(default_deconstruction_screwdriver(user, icon_state, icon_state, I))
update_icon()
return
if(default_deconstruction_crowbar(I))
return
if(istype(I, /obj/item/reagent_containers) && !(I.item_flags & ABSTRACT) && I.is_open_container())
@@ -384,7 +386,6 @@
work_animation()
visible_message("<span class='danger'>[src] malfunctions, spraying chemicals everywhere!</span>")
/obj/machinery/chem_dispenser/RefreshParts()
recharge_amount = initial(recharge_amount)
var/newpowereff = 0.0666666
@@ -395,13 +396,11 @@
for(var/obj/item/stock_parts/capacitor/C in component_parts)
recharge_amount *= C.rating
for(var/obj/item/stock_parts/manipulator/M in component_parts)
if (M.rating > macrotier)
macrotier = M.rating
if (M.rating > 1)
if(M.rating > 1)
dispensable_reagents |= upgrade_reagents
if (M.rating > 2)
if(M.rating > 2)
dispensable_reagents |= upgrade_reagents2
if (M.rating > 3)
if(M.rating > 3)
dispensable_reagents |= upgrade_reagents3
powerefficiency = round(newpowereff, 0.01)
@@ -422,41 +421,14 @@
cell = null
if(beaker)
beaker.forceMove(drop_location())
beaker = null
return ..()
/obj/machinery/chem_dispenser/proc/get_macro_resolution()
. = 5
if (macrotier > 1)
. -= macrotier // 5 for tier1, 3 for 2, 2 for 3, 1 for 4.
/obj/machinery/chem_dispenser/proc/check_macro(macro)
var/res = get_macro_resolution()
for (var/reagent in splittext(trim(macro), ";"))
if (!check_macro_part(reagent, res))
return FALSE
return TRUE
/obj/machinery/chem_dispenser/proc/check_macro_part(var/part, var/res = get_macro_resolution())
var/detail = splittext(part, "=")
if (round(text2num(detail[2]), res) != text2num(detail[2]))
return FALSE
return TRUE
/obj/machinery/chem_dispenser/proc/process_recipe_list(var/fucking_hell)
var/list/key_list = list()
var/list/final_list = list()
var/list/first_process = splittext(fucking_hell, ";")
for(var/reagents in first_process)
var/list/fuck = splittext(reagents, "=")
final_list += list(avoid_assoc_duplicate_keys(fuck[1],key_list) = text2num(fuck[2]))
return final_list
/obj/machinery/chem_dispenser/AltClick(mob/living/user)
. = ..()
if(!istype(user) || !user.canUseTopic(src, BE_CLOSE, FALSE, NO_TK))
return
replace_beaker(user)
return TRUE
if(istype(user) && user.canUseTopic(src, BE_CLOSE, FALSE, NO_TK))
replace_beaker(user)
return TRUE
/obj/machinery/chem_dispenser/drinks/Initialize()
. = ..()
@@ -540,7 +512,6 @@
/datum/reagent/toxin/staminatoxin
)
/obj/machinery/chem_dispenser/drinks/fullupgrade //fully ugpraded stock parts, emagged
desc = "Contains a large reservoir of soft drinks. This model has had its safeties shorted out."
obj_flags = CAN_BE_HIT | EMAGGED
@@ -646,7 +617,7 @@
/datum/reagent/ammonia,
/datum/reagent/ash,
/datum/reagent/diethylamine)
//same as above.
//same as above.
upgrade_reagents = null
upgrade_reagents2 = null
upgrade_reagents3 = null
@@ -153,20 +153,37 @@
color = "#669900" // rgb: 102, 153, 0
toxpwr = 0.5
taste_description = "death"
var/fakedeath_active = FALSE
pH = 13
/datum/reagent/toxin/zombiepowder/on_mob_metabolize(mob/living/L)
..()
L.fakedeath(type)
ADD_TRAIT(L, TRAIT_FAKEDEATH, type)
/datum/reagent/toxin/zombiepowder/on_mob_end_metabolize(mob/living/L)
L.cure_fakedeath(type)
..()
/datum/reagent/toxin/zombiepowder/on_mob_life(mob/living/carbon/M)
M.adjustOxyLoss(0.5*REM, 0)
/datum/reagent/toxin/zombiepowder/reaction_mob(mob/living/L, method=TOUCH, reac_volume)
L.adjustOxyLoss(0.5*REM, 0)
if(method == INGEST)
fakedeath_active = TRUE
L.fakedeath(type)
/datum/reagent/toxin/zombiepowder/on_mob_life(mob/living/M)
..()
. = 1
if(fakedeath_active)
return TRUE
switch(current_cycle)
if(1 to 5)
M.confused += 1
M.drowsyness += 1
M.slurring += 3
if(5 to 8)
M.adjustStaminaLoss(40, 0)
if(9 to INFINITY)
fakedeath_active = TRUE
M.fakedeath(type)
/datum/reagent/toxin/ghoulpowder
name = "Ghoul Powder"
@@ -70,6 +70,14 @@
required_other = TRUE
required_container = /obj/item/slime_extract/green
/datum/chemical_reaction/slime/slimemammal
name = "Mammal Mutation Toxin"
id = /datum/reagent/mutationtoxin/mammal
results = list(/datum/reagent/mutationtoxin/mammal = 1)
required_reagents = list(/datum/reagent/water = 1)
required_other = TRUE
required_container = /obj/item/slime_extract/green
//Metal
/datum/chemical_reaction/slime/slimemetal
name = "Slime Metal"