Skip to content

Commit

Permalink
spent_chemical
Browse files Browse the repository at this point in the history
  • Loading branch information
CM Dev committed Jun 2, 2020
1 parent 7504a35 commit a902533
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions code/datums/_ndatabase/code/entity/entity.dm
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
if(CB)
CB.Invoke(src)

/datum/entity/proc/assign_values(var/list/values)
/datum/entity/proc/assign_values(var/list/values, var/list/ignore = list())
for(var/F in metadata.field_types)
if(values[F])
if(!(ignore.Find(F)))
vars[F] = values[F]
4 changes: 3 additions & 1 deletion code/datums/entities/chemical_information.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
var/burncolor
var/burncolormod
var/properties_text
var/spent_chemical

var/list/properties

Expand All @@ -35,7 +36,8 @@
"radiusmod" = DB_FIELDTYPE_DECIMAL,
"burncolor" = DB_FIELDTYPE_STRING_SMALL,
"burncolormod" = DB_FIELDTYPE_INT,
"properties_text" = DB_FIELDTYPE_STRING_MAX)
"properties_text" = DB_FIELDTYPE_STRING_MAX,
"spent_chemical" = DB_FIELDTYPE_INT)

/datum/entity_meta/chemical_information/map(var/datum/entity/chemical_information/ET, var/list/values)
..()
Expand Down
4 changes: 2 additions & 2 deletions code/modules/reagents/Chemistry-Generator.dm
Original file line number Diff line number Diff line change
Expand Up @@ -527,9 +527,9 @@
else if(neutral_properties.Find(P))
value += round(-1 * potency / 2)
else if(positive_properties.Find(P))
value += potency
value += potency * 2
else if(special_properties.Find(P))
value += potency * 5
value += potency * 6
else if(admin_properties.Find(P))
value += potency * 1000 //shouldn't ever be possible
return max(value, 3)
Expand Down
1 change: 0 additions & 1 deletion code/modules/reagents/Chemistry-Reagents.dm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
var/gen_tier = 0 //Decides the chance of the chem being good during generation
var/objective_value // How valuable it is to identify the chemical. (Only works on chemclass SPECIAL or ULTRA)
var/list/properties = list() //Decides properties
var/properties_text //bandaid fix for runtime in assign_values(), this var isn't really used for anything
var/original_type //For tracing back

/datum/reagent/proc/reaction_mob(var/mob/M, var/method=TOUCH, var/volume) //By default we have a chance to transfer some
Expand Down
10 changes: 6 additions & 4 deletions code/modules/reagents/chemical_research/Chemical-Research.dm
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ var/global/datum/chemical_research_data/chemical_research_data = new /datum/chem

var/datum/entity/chemical_information/CI = DB_ENTITY(/datum/entity/chemical_information)

CI.assign_values(R.vars)
CI.assign_values(R.vars, list("properties_text", "spent_chemical"))
CI.properties = R.properties
CI.spent_chemical = FALSE

CI.save()

Expand All @@ -49,7 +50,7 @@ var/global/datum/chemical_research_data/chemical_research_data = new /datum/chem
set waitfor = 0
while(!SSentity_manager.ready)
stoplag()
SSentity_manager.filter_then(/datum/entity/chemical_information, null, CALLBACK(GLOBAL_PROC, /proc/initialize_saved_chem_data_callback), TRUE)
DB_FILTER(/datum/entity/chemical_information, DB_COMP("spent_chemical", DB_EQUALS, 0), CALLBACK(GLOBAL_PROC, /proc/initialize_saved_chem_data_callback), TRUE)

/proc/initialize_saved_chem_data_callback(var/list/datum/entity/chemical_information/chemicals)
var/i = 0
Expand All @@ -58,7 +59,7 @@ var/global/datum/chemical_research_data/chemical_research_data = new /datum/chem

//Make the reagent
for(var/V in data.metadata.field_types)
if(V != "properties_text")
if(V != "properties_text" && V != "spent_chemical")
R.vars[V] = data.vars[V]
R.properties = data.properties
//I hate doing this, but until the DB converts stuff into proper types we have to do this ourselves
Expand Down Expand Up @@ -88,5 +89,6 @@ var/global/datum/chemical_research_data/chemical_research_data = new /datum/chem
//Make a new recipe
R.generate_assoc_recipe()

data.delete() // and delete it so it doesn't appear next round
data.spent_chemical = TRUE //so it doesn't appear next round
data.save()
i++

0 comments on commit a902533

Please sign in to comment.