mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-26 05:27:01 +01:00
Adds saltpetre crystals, which grind into saltpetre (#25050)
* Added saltpeter crystal, a way to make them, and sprites. * comment changes * forgot to undef * actually undefing this time * raises saltpeter crystal yield when ground to 8 I did some play testing and it simply takes too many clicks to pump in the ammonia required to get the amount of saltpeter you need. * The compost bin being full of compost no longer hinders your saltpetre production * rebuild TGUI * Allows the compost bin to accept ammonia directly from plants that contain it * adding the K back to KNO3 * Minor ui adjustments * Compost bin can use ash now * I am made of stupid. * fixing a tiny little offset in the biomass bar * Icon update, new description for Saltpetre crystals, style fixes and recompile tgui * period * minor changes * rebuild TGUI * Apply suggestions from code review Signed-off-by: Matt <116982774+Burzah@users.noreply.github.com> --------- Signed-off-by: Matt <116982774+Burzah@users.noreply.github.com> Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com>
This commit is contained in:
co-authored by
Burzah
parent
ae10972946
commit
88d236d5c9
@@ -1,6 +1,10 @@
|
||||
#define SOIL_COST 25
|
||||
#define DECAY 0.2
|
||||
#define MIN_CONVERSION 10
|
||||
#define BIOMASS_POTASH_RATIO 6
|
||||
#define BIOMASS_POTASSIUM_RATIO 8
|
||||
#define POTASH_SALPETRE_MULT 2
|
||||
|
||||
/**
|
||||
* # compost bin
|
||||
* used to make soil from plants.
|
||||
@@ -20,10 +24,20 @@
|
||||
var/biomass = 0
|
||||
/// amount of compost in the compost bin
|
||||
var/compost = 0
|
||||
/// amount of potassium in the compost bin
|
||||
var/potassium = 0
|
||||
/// amount of potash in the compost bin
|
||||
var/potash = 0
|
||||
/// amount of saltpetre in the compost bin
|
||||
var/saltpetre = 0
|
||||
/// The maximum amount of biomass the compost bin can store.
|
||||
var/biomass_capacity = 1500
|
||||
/// The maximum amount of compost the compost bin can store.
|
||||
var/compost_capacity = 1500
|
||||
/// The maximum amount of potassium the compost bin can store.
|
||||
var/potassium_capacity = 200
|
||||
/// The maximum amount of potash the compost bin can store.
|
||||
var/potash_capacity = 500
|
||||
|
||||
/obj/machinery/compost_bin/on_deconstruction()
|
||||
// returns wood instead of the non-existent components
|
||||
@@ -39,11 +53,15 @@
|
||||
// no panel either
|
||||
return default_deconstruction_crowbar(user, I, ignore_panel = TRUE)
|
||||
|
||||
// Accepts inserted plants and converts them to biomass
|
||||
// Accepts inserted plants and converts them to biomass and potassium
|
||||
/obj/machinery/compost_bin/proc/make_biomass(obj/item/food/snacks/grown/O)
|
||||
// calculate biomass from plant nutriment and plant matter
|
||||
var/plant_biomass = O.reagents.get_reagent_amount("nutriment") + O.reagents.get_reagent_amount("plantmatter")
|
||||
biomass += clamp(plant_biomass * 10, 1, biomass_capacity - biomass)
|
||||
var/plant_potassium = O.reagents.get_reagent_amount("potassium")
|
||||
var/plant_potash = O.reagents.get_reagent_amount("ash")
|
||||
biomass += min(max(plant_biomass * 10, 1), biomass_capacity - biomass)
|
||||
potassium += min(potassium_capacity - potassium, plant_potassium)
|
||||
potash += min(potash_capacity - potash, plant_potash)
|
||||
//plant delenda est
|
||||
qdel(O)
|
||||
|
||||
@@ -53,30 +71,37 @@
|
||||
return ..()
|
||||
|
||||
if(istype(O, /obj/item/storage/bag/plants))
|
||||
if(biomass >= biomass_capacity)
|
||||
to_chat(user, "<span class='warning'>[src] can't hold any more biomass!</span>")
|
||||
if(biomass >= biomass_capacity && potassium >= potassium_capacity)
|
||||
to_chat(user, "<span class='warning'>[src] can't hold any more biomass, and it's contents are saturated with potassium!</span>")
|
||||
return
|
||||
|
||||
var/obj/item/storage/bag/plants/PB = O
|
||||
for(var/obj/item/food/snacks/grown/G in PB.contents)
|
||||
// if the plant contains either potassium, plantmatter and nutriment and the compost bin has space for any of those.
|
||||
if((G.reagents.get_reagent_amount("potassium") && potassium <= potassium_capacity) || ((G.reagents.get_reagent_amount("plantmatter") || G.reagents.get_reagent_amount("nutriment")) && biomass <= biomass_capacity))
|
||||
PB.remove_from_storage(G, src)
|
||||
make_biomass(G)
|
||||
|
||||
PB.remove_from_storage(G, src)
|
||||
make_biomass(G)
|
||||
|
||||
if(biomass >= biomass_capacity)
|
||||
to_chat(user, "<span class='info'>You fill [src] to its capacity.</span>")
|
||||
if(biomass >= biomass_capacity && potassium >= potassium_capacity)
|
||||
break
|
||||
|
||||
if(biomass < biomass_capacity)
|
||||
if(biomass >= biomass_capacity)
|
||||
to_chat(user, "<span class='info'>You fill [src] to its capacity.</span>")
|
||||
else
|
||||
to_chat(user, "<span class='info'>You empty [PB] into [src].</span>")
|
||||
|
||||
if(potassium == potassium_capacity)
|
||||
to_chat(user, "<span class='info'>You have saturated the contents of [src] with potassium.</span>")
|
||||
else if(potassium >= potassium_capacity * 0.95)
|
||||
to_chat(user, "<span class='info'>You have very nearly saturated the contents of [src] with potassium.</span>")
|
||||
|
||||
SStgui.update_uis(src)
|
||||
update_icon_state()
|
||||
return TRUE
|
||||
|
||||
if(istype(O, /obj/item/food/snacks/grown))
|
||||
if(biomass >= biomass_capacity)
|
||||
to_chat(user, "<span class='warning'>[src] can't hold any more plants!</span>")
|
||||
if(biomass >= biomass_capacity && potassium >= potassium_capacity)
|
||||
to_chat(user, "<span class='warning'>[src] can't hold any more biomass, and its contents are saturated with potassium!</span>")
|
||||
return
|
||||
if(!user.unEquip(O))
|
||||
return
|
||||
@@ -87,20 +112,92 @@
|
||||
SStgui.update_uis(src)
|
||||
update_icon_state()
|
||||
return TRUE
|
||||
if(istype(O, /obj/item/reagent_containers))
|
||||
var/proportion = 0
|
||||
var/obj/item/reagent_containers/B = O
|
||||
if(B.reagents.total_volume <= 0)
|
||||
to_chat(user, "<span class='warning'>[B] is empty!</span>")
|
||||
return
|
||||
if(potassium >= potassium_capacity && potash >= potash_capacity)
|
||||
to_chat(user, "<span class='warning'>The contents of [src] are saturated with potassium and it cannot hold more potash!</span>")
|
||||
return
|
||||
// Won't pour in more than the amount of potassium that can be accepted, even if the beaker is not filled with pure potassium.
|
||||
proportion = min(min(B.reagents.total_volume, B.amount_per_transfer_from_this), potassium_capacity - potassium) / B.reagents.total_volume
|
||||
|
||||
to_chat(user, "<span class='warning'>You cannot put this in [name]!</span>")
|
||||
// Since the character may not know what's in the beaker, I'm assuming it is assuming the beaker is full of pure potassium and pours according to that.
|
||||
for(var/E in B.reagents.reagent_list)
|
||||
var/datum/reagent/R = E
|
||||
switch(R.id)
|
||||
if("potassium")
|
||||
potassium += min(R.volume * proportion, potassium_capacity - potassium)
|
||||
if("ash")
|
||||
potash += min(R.volume * proportion, potash_capacity - potash)
|
||||
if("nutriment")
|
||||
biomass += min(R.volume * proportion, biomass_capacity - biomass)
|
||||
if("plantmatter")
|
||||
biomass += min(R.volume * proportion, biomass_capacity - biomass)
|
||||
|
||||
B.reagents.remove_reagent(R.id, R.volume * proportion)
|
||||
|
||||
if(proportion == 1)
|
||||
to_chat(user, "<span class='info'>You empty [B] into [src].</span>")
|
||||
else
|
||||
to_chat(user, "<span class='info'>You pour some of [B] into [src].</span>")
|
||||
if(potassium == potassium_capacity)
|
||||
to_chat(user, "<span class='info'>You have saturated the contents of [src] with potassium.</span>")
|
||||
else if(potassium >= potassium_capacity * 0.95)
|
||||
to_chat(user, "<span class='info'>You have very nearly saturated the contents of [src] with potassium.</span>")
|
||||
|
||||
if(potash == potash_capacity)
|
||||
to_chat(user, "<span class='info'>[src] has been filled with potash.</span>")
|
||||
else if(potash >= potash_capacity * 0.95)
|
||||
to_chat(user, "<span class='info'>[src] has been nearly filled with potash.</span>")
|
||||
|
||||
SStgui.update_uis(src)
|
||||
update_icon_state()
|
||||
|
||||
return TRUE
|
||||
|
||||
to_chat(user, "<span class='warning'>You cannot put this in [src]!</span>")
|
||||
|
||||
//Compost compostable material if there is any
|
||||
/obj/machinery/compost_bin/process()
|
||||
if(compost >= compost_capacity || biomass <= 0)
|
||||
if((compost >= compost_capacity && potassium <= 0) || biomass <= 0)
|
||||
return
|
||||
process_counter++
|
||||
if(process_counter < 5)
|
||||
return
|
||||
process_counter = 0
|
||||
//converts 20% of the biomass to compost each cycle, unless there isn't enough compost space or there is 10 or less biomass
|
||||
var/conversion_amount = clamp(DECAY * biomass, min(MIN_CONVERSION, biomass), compost_capacity - compost)
|
||||
biomass -= conversion_amount
|
||||
//Converts up to 20% of the biomass to compost each cycle, minimum of 10 converted.
|
||||
//In the presence of potassium will create saltpetre crystals instead. Using at most the amount of biomass that would've been used for compost
|
||||
//And making compost from whatever part of that amount it didn't use.
|
||||
var/conversion_amount = max(DECAY * biomass, min(MIN_CONVERSION, biomass))
|
||||
var/potash_saltpetre_conversion = 0
|
||||
var/potassium_saltpetre_conversion = 0
|
||||
var/used_potassium = 0
|
||||
var/used_potash = 0
|
||||
|
||||
if(potash > 0)
|
||||
potash_saltpetre_conversion = min(conversion_amount, potash * BIOMASS_POTASH_RATIO)
|
||||
used_potash = potash_saltpetre_conversion / BIOMASS_POTASH_RATIO
|
||||
saltpetre += used_potash * POTASH_SALPETRE_MULT
|
||||
conversion_amount -= potash_saltpetre_conversion
|
||||
potash -= used_potash
|
||||
|
||||
if(potassium > 0)
|
||||
potassium_saltpetre_conversion = min(conversion_amount, potassium * BIOMASS_POTASSIUM_RATIO)
|
||||
used_potassium = potassium_saltpetre_conversion / BIOMASS_POTASSIUM_RATIO
|
||||
saltpetre += used_potassium
|
||||
conversion_amount -= potassium_saltpetre_conversion
|
||||
potassium -= used_potassium
|
||||
|
||||
if(saltpetre / 4 >= 1)
|
||||
new /obj/item/stack/sheet/saltpetre_crystal(loc, round(saltpetre / 4))
|
||||
saltpetre -= round(saltpetre)
|
||||
|
||||
conversion_amount = min(conversion_amount, compost_capacity - compost)
|
||||
|
||||
biomass -= conversion_amount + potash_saltpetre_conversion + potassium_saltpetre_conversion
|
||||
compost += conversion_amount
|
||||
update_icon_state()
|
||||
SStgui.update_uis(src)
|
||||
@@ -134,6 +231,10 @@
|
||||
data["biomass_capacity"] = biomass_capacity
|
||||
data["compost"] = compost
|
||||
data["compost_capacity"] = compost_capacity
|
||||
data["potassium"] = potassium
|
||||
data["potassium_capacity"] = potassium_capacity
|
||||
data["potash"] = potash
|
||||
data["potash_capacity"] = potash_capacity
|
||||
return data
|
||||
|
||||
// calls functions according to ui interaction(just making compost for now)
|
||||
@@ -161,3 +262,6 @@
|
||||
#undef SOIL_COST
|
||||
#undef DECAY
|
||||
#undef MIN_CONVERSION
|
||||
#undef BIOMASS_POTASH_RATIO
|
||||
#undef BIOMASS_POTASSIUM_RATIO
|
||||
#undef POTASH_SALPETRE_MULT
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
/obj/item/stack/sheet/mineral/tranquillite = list("nothing" = 20),
|
||||
/obj/item/stack/sheet/mineral/silver = list("silver" = 20),
|
||||
/obj/item/stack/sheet/mineral/gold = list("gold" = 20),
|
||||
/obj/item/stack/sheet/saltpetre_crystal = list("saltpetre" = 8),
|
||||
|
||||
// Blender Stuff
|
||||
/obj/item/food/snacks/grown/tomato = list("ketchup" = 0),
|
||||
|
||||
Reference in New Issue
Block a user