Skip to content

Commit

Permalink
Merge branch 'master' into blastdoors
Browse files Browse the repository at this point in the history
  • Loading branch information
Gristlebee authored May 19, 2024
2 parents ae8097c + 3b2b6da commit 16772d5
Show file tree
Hide file tree
Showing 10 changed files with 128 additions and 46 deletions.
65 changes: 65 additions & 0 deletions code/modules/autowiki/pages/reactions.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
Templates:
Autowiki/Reaction
{{{chems|ERROR}}} {{#if: {{{temperature|}}} | <br />Temperature {{{temperature}}} | }} {{#if: {{{container|}}} | <br />Needs container "{{{container}}}" | }} <br/>Makes {{{volume|1}}}u
Autowiki/Reagent
{{#if: {{{tooltip|}}} | {{Tooltip|{{{volume}}} part [[#{{{name}}}|{{{name}}}]]|{{{tooltip}}}|FEF6E7}} | {{{volume}}} part {{{name}}} }}
*/

/datum/autowiki/reactions
page = "Template:Autowiki/Content/Reactions"

/datum/autowiki/reactions/generate()
var/list/output = list()

var/list/mixable_reagents = list()
var/list/all_reactions = list()
for(var/type in subtypesof(/datum/chemical_reaction))
var/datum/chemical_reaction/reaction = new type
all_reactions += reaction
mixable_reagents |= reaction.results

for(var/datum/chemical_reaction/reaction as anything in all_reactions)
var/required_chems = ""
for(var/datum/reagent/required_chem_type as anything in reaction.required_reagents)
var/has_tooltip = (required_chem_type in mixable_reagents) && !(required_chem_type in reaction.results) && !(required_chem_type in GLOB.base_reagents)
required_chems += format_required_reagent(required_chem_type, reaction.required_reagents[required_chem_type], has_tooltip)

for(var/datum/reagent/required_catalyst_type as anything in reaction.required_catalysts)
var/has_tooltip = (required_catalyst_type in mixable_reagents) && !(required_catalyst_type in reaction.results) && !(required_catalyst_type in GLOB.base_reagents)
required_chems += format_required_reagent(required_catalyst_type, reaction.required_catalysts[required_catalyst_type], has_tooltip, "Catalyst")

for(var/datum/reagent/result_chem_type as anything in reaction.results)
var/result_name = escape_value(initial(result_chem_type.name))
var/list/details = list("volume" = reaction.results[result_chem_type], "chems" = required_chems, "name" = result_name)

if(reaction.required_temp > 0)
details["temperature"] = "[reaction.is_cold_recipe ? "below" : "above"] [reaction.required_temp]K"

if(reaction.required_container)
details["container"] = "[escape_value(initial(reaction.required_container.name))]"

var/description = include_template("Autowiki/Reaction", details)
if(result_name in output)
output[result_name] += "<br />OR<br />[description]"
else
output[result_name] = description

return output

/datum/autowiki/reactions/proc/format_required_reagent(datum/reagent/required_reagent_type, volume, has_tooltip = FALSE, type)
var/list/details = list(
"volume" = volume,
"name" = escape_value(initial(required_reagent_type.name))
)

if(has_tooltip)
details["tooltip"] = include_template("Autowiki/Content/Reactions/[initial(required_reagent_type.name)]")

if(type)
details["type"] = type

return include_template("Autowiki/Reagent", details)
79 changes: 33 additions & 46 deletions code/modules/autowiki/pages/reagents.dm
Original file line number Diff line number Diff line change
@@ -1,65 +1,52 @@
/*
Templates:
Autowiki/Reaction
{{{chems|ERROR}}} {{#if: {{{temperature|}}} | <br />Temperature {{{temperature}}} | }} {{#if: {{{container|}}} | <br />Needs container "{{{container}}}" | }} <br/>Makes {{{volume|1}}}u
Autowiki/Reagent
{{#if: {{{tooltip|}}} | {{Tooltip|{{{volume}}} part [[#{{{name}}}|{{{name}}}]]|{{{tooltip}}}|FEF6E7}} | {{{volume}}} part {{{name}}} }}
*/

/datum/autowiki/reagents
page = "Template:Autowiki/Content/Reactions"
page = "Template:Autowiki/Content/Reagents"

/datum/autowiki/reagents/generate()
var/list/output = list()
var/output = ""

var/list/mixable_reagents = list()
var/list/all_reactions = list()
for(var/type in subtypesof(/datum/chemical_reaction))
var/datum/chemical_reaction/reaction = new type
all_reactions += reaction
mixable_reagents |= reaction.results
qdel(reaction)

for(var/datum/chemical_reaction/reaction as anything in all_reactions)
var/required_chems = ""
for(var/datum/reagent/required_chem_type as anything in reaction.required_reagents)
var/has_tooltip = (required_chem_type in mixable_reagents) && !(required_chem_type in reaction.results) && !(required_chem_type in GLOB.base_reagents)
required_chems += format_required_reagent(required_chem_type, reaction.required_reagents[required_chem_type], has_tooltip)
var/list/categories = list()

for(var/datum/reagent/required_catalyst_type as anything in reaction.required_catalysts)
var/has_tooltip = (required_catalyst_type in mixable_reagents) && !(required_catalyst_type in reaction.results) && !(required_catalyst_type in GLOB.base_reagents)
required_chems += format_required_reagent(required_catalyst_type, reaction.required_catalysts[required_catalyst_type], has_tooltip, "Catalyst")
for(var/reagent in mixable_reagents)
var/datum/reagent/chem = new reagent

for(var/datum/reagent/result_chem_type as anything in reaction.results)
var/result_name = escape_value(initial(result_chem_type.name))
var/list/details = list("volume" = reaction.results[result_chem_type], "chems" = required_chems, "name" = result_name)
LAZYINITLIST(categories[chem.category])
categories[chem.category] += list(chem)

if(reaction.required_temp > 0)
details["temperature"] = "[reaction.is_cold_recipe ? "below" : "above"] [reaction.required_temp]K"
for(var/category in sortList(categories))
output += "\n"
output += generate_category(category, categories[category])

if(reaction.required_container)
details["container"] = "[escape_value(initial(reaction.required_container.name))]"
return output

var/description = include_template("Autowiki/Reaction", details)
if(result_name in output)
output[result_name] += "<br />OR<br />[description]"
else
output[result_name] = description
/datum/autowiki/reagents/proc/generate_category(name, list/datum/reagent/reagents)
var/output = "== [escape_value(name)] ==\n"

return output
output += "{| class='wikitable sortable' style=width:100%; text-align:left; border: 3px solid #FFDD66; cellspacing=0; cellpadding=2; background-color:white;'\n"
output += "! scope='col' style='width:150px; background-color:#FFDD66;' |Name\n"
output += "! class='unsortable' scope='col' style='width:150px; background-color:#FFDD66;' |Recipe\n"
output += "! class='unsortable' scope='col' style='background-color:#FFDD66;' |Description\n"
output += "! scope='col' | Metabolization Rate\n"
output += "! scope='col' | Overdose Threshold\n"
output += "! scope='col' | Addiction Threshold\n"
output += "|-\n"

/datum/autowiki/reagents/proc/format_required_reagent(datum/reagent/required_reagent_type, volume, has_tooltip = FALSE, type)
var/list/details = list(
"volume" = volume,
"name" = escape_value(initial(required_reagent_type.name))
)
reagents = sortList(reagents, /proc/cmp_typepaths_asc)

if(has_tooltip)
details["tooltip"] = include_template("Autowiki/Content/Reactions/[initial(required_reagent_type.name)]")
for(var/datum/reagent/reagent as anything in reagents)
output += "! style='background-color: #FFEE88;' | [include_template("anchor", list("1" = escape_value(reagent.name)))][escape_value(reagent.name)] <span style='color:[escape_value(reagent.color)];background-color:[escape_value(reagent.color)]'>_</span>\n"
output += "|[include_template("Autowiki/Content/Reactions/[escape_value(reagent.name)]")]\n"
output += "|[escape_value(reagent.description)]\n"
output += "|data-sort-value=[reagent.metabolization_rate]|[reagent.metabolization_rate] units per tick\n"
output += "|[reagent.overdose_threshold || "data-sort-value=0|N/A"]\n"
output += "|[reagent.addiction_threshold || "data-sort-value=0|N/A"]\n"
output += "|-\n"

if(type)
details["type"] = type
output += "|}\n"

return include_template("Autowiki/Reagent", details)
return output
3 changes: 3 additions & 0 deletions code/modules/reagents/chemistry/reagents.dm
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ GLOBAL_LIST_INIT(name2reagent, build_name2reagent())
///How good of an accelerant is this reagent
var/accelerant_quality = 0

///The section of the autowiki chem table this reagent will be under
var/category = "Misc"

/datum/reagent/New()
. = ..()

Expand Down
1 change: 1 addition & 0 deletions code/modules/reagents/chemistry/reagents/drug_reagents.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "Drug"
metabolization_rate = 0.5 * REAGENTS_METABOLISM
taste_description = "bitterness"
category = "Drug"
var/trippy = TRUE //Does this drug make you trip?

/datum/reagent/drug/on_mob_end_metabolize(mob/living/M)
Expand Down
1 change: 1 addition & 0 deletions code/modules/reagents/chemistry/reagents/food_reagents.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
name = "Consumable"
taste_description = "generic food"
taste_mult = 4
category = "Food and Drink"
var/nutriment_factor = 1 * REAGENTS_METABOLISM
var/quality = 0 //affects mood, typically higher for mixed drinks with more complex recipes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/datum/reagent/medicine
name = "Medicine"
taste_description = "bitterness"
category = "Medicine"

/datum/reagent/medicine/on_mob_life(mob/living/carbon/M)
current_cycle++
Expand Down
18 changes: 18 additions & 0 deletions code/modules/reagents/chemistry/reagents/pyrotechnic_reagents.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/datum/reagent/thermite
name = "Thermite"
description = "Thermite produces an aluminothermic reaction known as a thermite reaction. Can be used to melt walls."
category = "Pyrotechnics"
reagent_state = SOLID
color = "#550000"
taste_description = "sweet tasting metal"
Expand All @@ -19,6 +20,7 @@
/datum/reagent/nitroglycerin
name = "Nitroglycerin"
description = "Nitroglycerin is a heavy, colorless, oily, explosive liquid obtained by nitrating glycerol."
category = "Pyrotechnics"
color = "#808080" // rgb: 128, 128, 128
taste_description = "oil"

Expand All @@ -37,6 +39,7 @@
/datum/reagent/clf3
name = "Chlorine Trifluoride"
description = "Makes a temporary 3x3 fireball when it comes into existence, so be careful when mixing. ClF3 applied to a surface burns things that wouldn't otherwise burn, including typically-robust flooring, potentially exposing it to the vacuum of space."
category = "Pyrotechnics"
reagent_state = LIQUID
color = "#FFC8C8"
metabolization_rate = 4
Expand Down Expand Up @@ -82,20 +85,23 @@
/datum/reagent/sorium
name = "Sorium"
description = "Sends everything flying from the detonation point."
category = "Pyrotechnics"
reagent_state = LIQUID
color = "#5A64C8"
taste_description = "air and bitterness"

/datum/reagent/liquid_dark_matter
name = "Liquid Dark Matter"
description = "Sucks everything into the detonation point."
category = "Pyrotechnics"
reagent_state = LIQUID
color = "#210021"
taste_description = "compressed bitterness"

/datum/reagent/gunpowder
name = "Gunpowder"
description = "Explodes. Violently."
category = "Pyrotechnics"
reagent_state = LIQUID
color = "#000000"
metabolization_rate = 0.05
Expand All @@ -120,41 +126,47 @@
/datum/reagent/rdx
name = "RDX"
description = "Military grade explosive"
category = "Pyrotechnics"
reagent_state = SOLID
color = "#FFFFFF"
taste_description = "salt"

/datum/reagent/tatp
name = "TaTP"
description = "Suicide grade explosive"
category = "Pyrotechnics"
reagent_state = SOLID
color = "#FFFFFF"
taste_description = "death"

/datum/reagent/flash_powder
name = "Flash Powder"
description = "Makes a very bright flash."
category = "Pyrotechnics"
reagent_state = LIQUID
color = "#C8C8C8"
taste_description = "salt"

/datum/reagent/smoke_powder
name = "Smoke Powder"
description = "Makes a large cloud of smoke that can carry reagents."
category = "Pyrotechnics"
reagent_state = LIQUID
color = "#C8C8C8"
taste_description = "smoke"

/datum/reagent/sonic_powder
name = "Sonic Powder"
description = "Makes a deafening noise."
category = "Pyrotechnics"
reagent_state = LIQUID
color = "#C8C8C8"
taste_description = "loud noises"

/datum/reagent/phlogiston
name = "Phlogiston"
description = "Catches you on fire and makes you ignite."
category = "Pyrotechnics"
reagent_state = LIQUID
color = "#FA00AF"
taste_description = "burning"
Expand All @@ -179,6 +191,7 @@
/datum/reagent/napalm
name = "Napalm"
description = "Very flammable."
category = "Pyrotechnics"
reagent_state = LIQUID
color = "#FA00AF"
taste_description = "burning"
Expand Down Expand Up @@ -206,6 +219,7 @@
/datum/reagent/cryostylane
name = "Cryostylane"
description = "Comes into existence at 20K. As long as there is sufficient oxygen for it to react with, Cryostylane slowly cools all other reagents in the container 0K."
category = "Pyrotechnics"
color = "#0000DC"
metabolization_rate = 0.5 * REAGENTS_METABOLISM
taste_description = "bitterness"
Expand All @@ -227,6 +241,7 @@
/datum/reagent/pyrosium
name = "Pyrosium"
description = "Comes into existence at 20K. As long as there is sufficient oxygen for it to react with, Pyrosium slowly heats all other reagents in the container."
category = "Pyrotechnics"
color = "#64FAC8"
metabolization_rate = 0.5 * REAGENTS_METABOLISM
taste_description = "bitterness"
Expand All @@ -242,6 +257,7 @@
/datum/reagent/teslium //Teslium. Causes periodic shocks, and makes shocks against the target much more effective.
name = "Teslium"
description = "An unstable, electrically-charged metallic slurry. Periodically electrocutes its victim, and makes electrocutions against them more deadly. Excessively heating teslium results in dangerous destabilization. Do not allow to come into contact with water."
category = "Pyrotechnics"
reagent_state = LIQUID
color = "#20324D" //RGB: 32, 50, 77
metabolization_rate = 0.5 * REAGENTS_METABOLISM
Expand Down Expand Up @@ -273,6 +289,7 @@
/datum/reagent/teslium/energized_jelly
name = "Energized Jelly"
description = "Electrically-charged jelly. Boosts jellypeople's nervous system, but only shocks other lifeforms."
category = "Pyrotechnics"
reagent_state = LIQUID
color = "#CAFF43"
taste_description = "jelly"
Expand All @@ -291,6 +308,7 @@
/datum/reagent/firefighting_foam
name = "Firefighting Foam"
description = "A historical fire suppressant. Originally believed to simply displace oxygen to starve fires, it actually interferes with the combustion reaction itself. Vastly superior to the cheap water-based extinguishers found on NT vessels."
category = "Pyrotechnics"
reagent_state = LIQUID
color = "#A6FAFF55"
taste_description = "the inside of a fire extinguisher"
Expand Down
1 change: 1 addition & 0 deletions code/modules/reagents/chemistry/reagents/toxin_reagents.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
color = "#CF3600" // rgb: 207, 54, 0
taste_description = "bitterness"
taste_mult = 1.2
category = "Toxin"
var/toxpwr = 1.5
var/silent_toxin = FALSE //won't produce a pain message when processed by liver/life() if there isn't another non-silent toxin present.

Expand Down
4 changes: 4 additions & 0 deletions html/changelogs/AutoChangeLog-pr-2928.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
author: MarkSuckerberg
changes:
- {rscadd: Autowiki generated reagents list page}
delete-after: true
1 change: 1 addition & 0 deletions shiptest.dme
Original file line number Diff line number Diff line change
Expand Up @@ -1813,6 +1813,7 @@
#include "code\modules\atmospherics\machinery\portable\scrubber.dm"
#include "code\modules\autowiki\autowiki.dm"
#include "code\modules\autowiki\pages\base.dm"
#include "code\modules\autowiki\pages\reactions.dm"
#include "code\modules\autowiki\pages\reagents.dm"
#include "code\modules\autowiki\pages\ships.dm"
#include "code\modules\autowiki\pages\techweb.dm"
Expand Down

0 comments on commit 16772d5

Please sign in to comment.