diff --git a/code/__DEFINES/reagents.dm b/code/__DEFINES/reagents.dm index 711992eb831..04834baf587 100644 --- a/code/__DEFINES/reagents.dm +++ b/code/__DEFINES/reagents.dm @@ -171,3 +171,8 @@ /// For the pH meter flashing method #define ENABLE_FLASHING -1 #define DISABLE_FLASHING 14 + +#define GOLDSCHLAGER_VODKA (10) +#define GOLDSCHLAGER_GOLD (1) + +#define GOLDSCHLAGER_GOLD_RATIO (GOLDSCHLAGER_GOLD/(GOLDSCHLAGER_VODKA+GOLDSCHLAGER_GOLD)) diff --git a/code/__HELPERS/reagents.dm b/code/__HELPERS/reagents.dm index e959b9734ff..39d5b1ea37b 100644 --- a/code/__HELPERS/reagents.dm +++ b/code/__HELPERS/reagents.dm @@ -51,32 +51,32 @@ //there is at least one unique catalyst for the short reaction, so there is no conflict return FALSE - //if we got this far, the longer reaction will be impossible to create if the shorter one is earlier in GLOB.chemical_reactions_list, and will require the reagents to be added in a particular order otherwise + //if we got this far, the longer reaction will be impossible to create if the shorter one is earlier in GLOB.chemical_reactions_list_reactant_index, and will require the reagents to be added in a particular order otherwise return TRUE /proc/get_chemical_reaction(id) - if(!GLOB.chemical_reactions_list) + if(!GLOB.chemical_reactions_list_reactant_index) return - for(var/reagent in GLOB.chemical_reactions_list) - for(var/R in GLOB.chemical_reactions_list[reagent]) + for(var/reagent in GLOB.chemical_reactions_list_reactant_index) + for(var/R in GLOB.chemical_reactions_list_reactant_index[reagent]) var/datum/reac = R if(reac.type == id) return R /proc/remove_chemical_reaction(datum/chemical_reaction/R) - if(!GLOB.chemical_reactions_list || !R) + if(!GLOB.chemical_reactions_list_reactant_index || !R) return for(var/rid in R.required_reagents) - GLOB.chemical_reactions_list[rid] -= R + GLOB.chemical_reactions_list_reactant_index[rid] -= R //see build_chemical_reactions_list in holder.dm for explanations /proc/add_chemical_reaction(datum/chemical_reaction/R) - if(!GLOB.chemical_reactions_list || !R.required_reagents || !R.required_reagents.len) + if(!GLOB.chemical_reactions_list_reactant_index || !R.required_reagents || !R.required_reagents.len) return var/primary_reagent = R.required_reagents[1] - if(!GLOB.chemical_reactions_list[primary_reagent]) - GLOB.chemical_reactions_list[primary_reagent] = list() - GLOB.chemical_reactions_list[primary_reagent] += R + if(!GLOB.chemical_reactions_list_reactant_index[primary_reagent]) + GLOB.chemical_reactions_list_reactant_index[primary_reagent] = list() + GLOB.chemical_reactions_list_reactant_index[primary_reagent] += R //Creates foam from the reagent. Metaltype is for metal foam, notification is what to show people in textbox /datum/reagents/proc/create_foam(foamtype,foam_volume,metaltype = 0,notification = null) diff --git a/code/_globalvars/lists/objects.dm b/code/_globalvars/lists/objects.dm index cce1743a2f9..271f448d95a 100644 --- a/code/_globalvars/lists/objects.dm +++ b/code/_globalvars/lists/objects.dm @@ -17,7 +17,8 @@ GLOBAL_LIST_EMPTY(alarmdisplay) //list of all machines or programs that GLOBAL_LIST_EMPTY_TYPED(singularities, /datum/component/singularity) //list of all singularities on the station GLOBAL_LIST_EMPTY(mechpad_list) //list of all /obj/machinery/mechpad -GLOBAL_LIST(chemical_reactions_list) //list of all /datum/chemical_reaction datums. Used during chemical reactions. Indexed by REACTANT types +GLOBAL_LIST(chemical_reactions_list) //list of all /datum/chemical_reaction datums indexed by their typepath. Use this for general lookup stuff +GLOBAL_LIST(chemical_reactions_list_reactant_index) //list of all /datum/chemical_reaction datums. Used during chemical reactions. Indexed by REACTANT types GLOBAL_LIST(chemical_reactions_list_product_index) //list of all /datum/chemical_reaction datums. Used for the reaction lookup UI. Indexed by PRODUCT type GLOBAL_LIST(chemical_reagents_list) //list of all /datum/reagent datums indexed by reagent id. Used by chemistry stuff GLOBAL_LIST(chemical_reactions_results_lookup_list) //List of all reactions with their associated product and result ids. Used for reaction lookups diff --git a/code/modules/food_and_drinks/recipes/drinks_recipes.dm b/code/modules/food_and_drinks/recipes/drinks_recipes.dm index c606617a891..82644005d64 100644 --- a/code/modules/food_and_drinks/recipes/drinks_recipes.dm +++ b/code/modules/food_and_drinks/recipes/drinks_recipes.dm @@ -16,7 +16,7 @@ /datum/chemical_reaction/drink/goldschlager results = list(/datum/reagent/consumable/ethanol/goldschlager = 10) - required_reagents = list(/datum/reagent/consumable/ethanol/vodka = 10, /datum/reagent/gold = 1) + required_reagents = list(/datum/reagent/consumable/ethanol/vodka = GOLDSCHLAGER_VODKA, /datum/reagent/gold = GOLDSCHLAGER_GOLD) reaction_tags = REACTION_TAG_DRINK | REACTION_TAG_EASY /datum/chemical_reaction/drink/patron diff --git a/code/modules/mob/living/simple_animal/hostile/regalrat.dm b/code/modules/mob/living/simple_animal/hostile/regalrat.dm index 6d8e9e128b5..62a41b55557 100644 --- a/code/modules/mob/living/simple_animal/hostile/regalrat.dm +++ b/code/modules/mob/living/simple_animal/hostile/regalrat.dm @@ -41,6 +41,11 @@ ADD_TRAIT(src, TRAIT_VENTCRAWLER_ALWAYS, INNATE_TRAIT) +/mob/living/simple_animal/hostile/regalrat/Destroy() + . = ..() + QDEL_NULL(domain) + QDEL_NULL(riot) + /mob/living/simple_animal/hostile/regalrat/proc/get_player() var/list/mob/dead/observer/candidates = pollGhostCandidates("Do you want to play as the Royal Rat, cheesey be his crown?", ROLE_SENTIENCE, null, FALSE, 100, POLL_IGNORE_SENTIENCE_POTION) if(LAZYLEN(candidates) && !mind) diff --git a/code/modules/reagents/chemistry/holder.dm b/code/modules/reagents/chemistry/holder.dm index bc9c84420e4..0c66dc025f9 100644 --- a/code/modules/reagents/chemistry/holder.dm +++ b/code/modules/reagents/chemistry/holder.dm @@ -23,19 +23,20 @@ //Chemical Reactions - Initialises all /datum/chemical_reaction into a list // It is filtered into multiple lists within a list. // For example: - // chemical_reaction_list[/datum/reagent/toxin/plasma] is a list of all reactions relating to plasma + // chemical_reactions_list_reactant_index[/datum/reagent/toxin/plasma] is a list of all reactions relating to plasma //For chemical reaction list product index - indexes reactions based off the product reagent type - see get_recipe_from_reagent_product() in helpers //For chemical reactions list lookup list - creates a bit list of info passed to the UI. This is saved to reduce lag from new windows opening, since it's a lot of data. //Prevent these reactions from appearing in lookup tables (UI code) var/list/blacklist = (/datum/chemical_reaction/randomized) - if(GLOB.chemical_reactions_list) + if(GLOB.chemical_reactions_list_reactant_index) return //Randomized need to go last since they need to check against conflicts with normal recipes var/paths = subtypesof(/datum/chemical_reaction) - typesof(/datum/chemical_reaction/randomized) + subtypesof(/datum/chemical_reaction/randomized) - GLOB.chemical_reactions_list = list() //reagents to reaction list + GLOB.chemical_reactions_list = list() //typepath to reaction list + GLOB.chemical_reactions_list_reactant_index = list() //reagents to reaction list GLOB.chemical_reactions_results_lookup_list = list() //UI glob GLOB.chemical_reactions_list_product_index = list() //product to reaction list @@ -50,6 +51,8 @@ if(!D.required_reagents || !D.required_reagents.len) //Skip impossible reactions continue + GLOB.chemical_reactions_list[path] = D + for(var/reaction in D.required_reagents) reaction_ids += reaction var/datum/reagent/reagent = find_reagent_object_from_type(reaction) @@ -81,9 +84,9 @@ // Create filters based on each reagent id in the required reagents list - this is used to speed up handle_reactions() for(var/id in reaction_ids) - if(!GLOB.chemical_reactions_list[id]) - GLOB.chemical_reactions_list[id] = list() - GLOB.chemical_reactions_list[id] += D + if(!GLOB.chemical_reactions_list_reactant_index[id]) + GLOB.chemical_reactions_list_reactant_index[id] = list() + GLOB.chemical_reactions_list_reactant_index[id] += D break // Don't bother adding ourselves to other reagent ids, it is redundant ///////////////////////////////Main reagents code///////////////////////////////////////////// @@ -842,7 +845,7 @@ return FALSE var/list/cached_reagents = reagent_list - var/list/cached_reactions = GLOB.chemical_reactions_list + var/list/cached_reactions = GLOB.chemical_reactions_list_reactant_index var/datum/cached_my_atom = my_atom LAZYNULL(failed_but_capable_reactions) @@ -1506,7 +1509,7 @@ var/list/possible_reactions = list() if(!length(cached_reagents)) return null - cached_reactions = GLOB.chemical_reactions_list + cached_reactions = GLOB.chemical_reactions_list_reactant_index for(var/_reagent in cached_reagents) var/datum/reagent/reagent = _reagent for(var/_reaction in cached_reactions[reagent.type]) // Was a big list but now it should be smaller since we filtered it with our reagent id diff --git a/code/modules/reagents/chemistry/machinery/chem_recipe_debug.dm b/code/modules/reagents/chemistry/machinery/chem_recipe_debug.dm index 8e5b4d7759e..996ba4bae34 100644 --- a/code/modules/reagents/chemistry/machinery/chem_recipe_debug.dm +++ b/code/modules/reagents/chemistry/machinery/chem_recipe_debug.dm @@ -77,10 +77,10 @@ /obj/machinery/chem_recipe_debug/proc/setup_reactions() cached_reactions = list() if(process_all) - for(var/reaction in GLOB.chemical_reactions_list) - if(is_type_in_list(GLOB.chemical_reactions_list[reaction], cached_reactions)) + for(var/reaction in GLOB.chemical_reactions_list_reactant_index) + if(is_type_in_list(GLOB.chemical_reactions_list_reactant_index[reaction], cached_reactions)) continue - cached_reactions += GLOB.chemical_reactions_list[reaction] + cached_reactions += GLOB.chemical_reactions_list_reactant_index[reaction] else cached_reactions = reaction_names reagents.clear_reagents() diff --git a/code/modules/reagents/chemistry/reagents/alcohol_reagents.dm b/code/modules/reagents/chemistry/reagents/alcohol_reagents.dm index c19d448d0e3..c2cc9c32f9d 100644 --- a/code/modules/reagents/chemistry/reagents/alcohol_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/alcohol_reagents.dm @@ -517,22 +517,9 @@ All effects don't start immediately, but rather get worse over time; the rate is shot_glass_icon_state = "shotglassgold" chemical_flags = REAGENT_CAN_BE_SYNTHESIZED - /// Ratio of gold that the goldschlager recipe contains - var/static/gold_ratio - // This drink is really popular with a certain demographic. var/teenage_girl_quality = DRINK_VERYGOOD -/datum/reagent/consumable/ethanol/goldschlager/New() - . = ..() - if(!gold_ratio) - // Calculate the amount of gold that goldschlager is made from - var/datum/chemical_reaction/drink/goldschlager/goldschlager_reaction = new - var/vodka_amount = goldschlager_reaction.required_reagents[/datum/reagent/consumable/ethanol/vodka] - var/gold_amount = goldschlager_reaction.required_reagents[/datum/reagent/gold] - gold_ratio = gold_amount / (gold_amount + vodka_amount) - qdel(goldschlager_reaction) - /datum/reagent/consumable/ethanol/goldschlager/expose_mob(mob/living/exposed_mob, methods=TOUCH, reac_volume) // Reset quality each time, since the bottle can be shared quality = initial(quality) @@ -549,7 +536,7 @@ All effects don't start immediately, but rather get worse over time; the rate is if(!(methods & INGEST)) return ..() - var/convert_amount = trans_volume * gold_ratio + var/convert_amount = trans_volume * min(GOLDSCHLAGER_GOLD_RATIO, 1) A.reagents.remove_reagent(/datum/reagent/consumable/ethanol/goldschlager, convert_amount) A.reagents.add_reagent(/datum/reagent/gold, convert_amount) return ..() diff --git a/code/modules/reagents/chemistry/recipes/special.dm b/code/modules/reagents/chemistry/recipes/special.dm index b0db782ac48..10384c267d1 100644 --- a/code/modules/reagents/chemistry/recipes/special.dm +++ b/code/modules/reagents/chemistry/recipes/special.dm @@ -35,7 +35,7 @@ GLOBAL_LIST_INIT(medicine_reagents, build_medicine_reagents()) /datum/chemical_reaction/randomized //Increase default leniency because these are already hard enough - optimal_ph_min = 1 + optimal_ph_min = 1 optimal_ph_max = 13 temp_exponent_factor = 0 ph_exponent_factor = 1 @@ -92,28 +92,28 @@ GLOBAL_LIST_INIT(medicine_reagents, build_medicine_reagents()) if(randomize_req_temperature) is_cold_recipe = pick(TRUE,FALSE) if(is_cold_recipe) - required_temp = rand(min_temp+50, max_temp) - optimal_temp = rand(min_temp+25, required_temp-10) + required_temp = rand(min_temp+50, max_temp) + optimal_temp = rand(min_temp+25, required_temp-10) overheat_temp = rand(min_temp, optimal_temp-10) if(overheat_temp >= 200) //Otherwise it can disappear when you're mixing and I don't want this to happen here overheat_temp = 200 if(exo_or_endothermic) thermic_constant = (rand(-200, 200)) else - required_temp = rand(min_temp, max_temp-50) - optimal_temp = rand(required_temp+10, max_temp-25) + required_temp = rand(min_temp, max_temp-50) + optimal_temp = rand(required_temp+10, max_temp-25) overheat_temp = rand(optimal_temp, max_temp+50) if(overheat_temp <= 400) overheat_temp = 400 if(exo_or_endothermic) thermic_constant = (rand(-200, 200)) - + if(randomize_req_ph) optimal_ph_min = min_ph + rand(0, inoptimal_range_ph) optimal_ph_max = max((max_ph + rand(0, inoptimal_range_ph)), (min_ph + 1)) //Always ensure we've a window of 1 determin_ph_range = inoptimal_range_ph H_ion_release = (rand(0, 25)/100)// 0 - 0.25 - + if(randomize_impurity_minimum) purity_min = (rand(0, 4)/10) @@ -169,7 +169,7 @@ GLOBAL_LIST_INIT(medicine_reagents, build_medicine_reagents()) /datum/chemical_reaction/randomized/proc/HasConflicts() for(var/x in required_reagents) - for(var/datum/chemical_reaction/R in GLOB.chemical_reactions_list[x]) + for(var/datum/chemical_reaction/R in GLOB.chemical_reactions_list_reactant_index[x]) if(chem_recipes_do_conflict(R,src)) return TRUE return FALSE diff --git a/code/modules/unit_tests/reagent_id_typos.dm b/code/modules/unit_tests/reagent_id_typos.dm index 4b82245c39e..60da167f645 100644 --- a/code/modules/unit_tests/reagent_id_typos.dm +++ b/code/modules/unit_tests/reagent_id_typos.dm @@ -6,8 +6,8 @@ build_chemical_reactions_lists() build_chemical_reagent_list() - for(var/I in GLOB.chemical_reactions_list) - for(var/V in GLOB.chemical_reactions_list[I]) + for(var/I in GLOB.chemical_reactions_list_reactant_index) + for(var/V in GLOB.chemical_reactions_list_reactant_index[I]) var/datum/chemical_reaction/R = V for(var/id in (R.required_reagents + R.required_catalysts)) if(!GLOB.chemical_reagents_list[id]) diff --git a/code/modules/unit_tests/reagent_recipe_collisions.dm b/code/modules/unit_tests/reagent_recipe_collisions.dm index 0eaefce3f42..d7db7255eed 100644 --- a/code/modules/unit_tests/reagent_recipe_collisions.dm +++ b/code/modules/unit_tests/reagent_recipe_collisions.dm @@ -5,8 +5,8 @@ /datum/unit_test/reagent_recipe_collisions/Run() build_chemical_reactions_lists() var/list/reactions = list() - for(var/V in GLOB.chemical_reactions_list) - reactions += GLOB.chemical_reactions_list[V] + for(var/V in GLOB.chemical_reactions_list_reactant_index) + reactions += GLOB.chemical_reactions_list_reactant_index[V] for(var/i in 1 to (reactions.len-1)) for(var/i2 in (i+1) to reactions.len) var/datum/chemical_reaction/r1 = reactions[i]