mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-06-28 00:34:22 +01:00
4ad00d93a5
Re-enables botany's interactions with atmospheric conditions and gases. Seeds can now consume and exude gases as part of their growth process. Most seeds do not have this functionality, however it can be found on random seeds. Random seeds will occasionally require a gas to grow, or will produce a gas while planted. Possible gases are Oxygen (O2), Nitrogen (N2), Carbon Dioxide (CO2), or Plasma gas. If a plant that affects a gas is planted, it will attempt to interact with the environment differently depending on conditions as detailed below: - Tray lid down: Will always utilize the air of it's tile for atmos interaction. - Tray lid up, nothing connected/inserted: Will utilize the air of it's tile for atmos interaction. - Tray lid up, tray connected to a connector port pipe: Will attempt to utilize the air of the pipe network the connector is part of, allowing you to utilize canisters or direct feeds into the station's piping. If there are no gases at all (0 total moles) in the network, it will create an empty gas_mixture at 20C (standard room temp) in the network before attempting atmos interactions. - Tray lid up, tank inserted into tray: Will attempt to utilize the contents of the inserted tank for atmos interaction. If the tank is completely empty (0 total moles), it will create a new empty gas_mixture at 20C before attempting atmos interactions. - Tray lid up, tank inserted AND connector port: Will attempt to utilize the contents of the inserted tank for atmos interaction. If the tank is completely empty (0 total moles), it will create a new empty gas_mixture at 20C before attempting atmos interactions. (Pretty much just ignores the connector port) In case it wasn't apparent from the above mentions, you can now insert any portable tank (emergency oxygen, plasma tank, pretty much any tank that could be hooked up to internals) into a hydroponics tray. You can remove them with the previously added eject internal tank verb. There is currently no visual indication of whether or not there is a tank inserted (the tray icons are already cluttered with the sheer number of overlays, and I didn't want to sprite another monstrosity like my past spriting attempts yielded) When utilizing an inserted tank for the plant's atmos interactions, it will attempt to use distribution pressure set on the tank for the atmospheric pressure inside the closed lid. If the tank's internal pressure drops lower than the distribution pressure, it will use the tank's internal pressure instead. The alter temperature trait is now functional, and will heat/cool the air used for the plant's atmos interactions. This means it can heat/cool the surrounding air, inserted tanks, or the contents of a connected pipe network. Plant analyzers have had their readouts updated to report what (if any) gases the plant consumes or produces during it's life. Also edited the alter temperature trait's message on the plant analyzer to not incorrectly refer to the change in "degrees Kelvin". There may be a bit of wonkiness with open-air atmos interaction and gas redistribution, which would be an issue with LINDA's processing and not the changes in this PR. Also, a major reminder that atmos grief is a bannable offense, and releasing plasma-producing vines into the halls will be considered equal to causing an atmos flood from atmospherics and dealt with accordingly.
129 lines
4.7 KiB
Plaintext
129 lines
4.7 KiB
Plaintext
/obj/machinery/portable_atmospherics/hydroponics/process()
|
|
|
|
/* MOVED INTO code\game\objects\effects\effect_system.dm
|
|
// Handle nearby smoke if any.
|
|
for(var/obj/effect/effect/smoke/chem/smoke in view(1, src))
|
|
if(smoke.reagents.total_volume)
|
|
smoke.reagents.copy_to(src, 5)
|
|
*/
|
|
|
|
//Do this even if we're not ready for a plant cycle.
|
|
process_reagents()
|
|
|
|
// Update values every cycle rather than every process() tick.
|
|
if(force_update)
|
|
force_update = 0
|
|
else if(world.time < (lastcycle + cycledelay))
|
|
return
|
|
lastcycle = world.time
|
|
|
|
// Weeds like water and nutrients, there's a chance the weed population will increase.
|
|
// Bonus chance if the tray is unoccupied.
|
|
if(waterlevel > 10 && nutrilevel > 2 && prob(isnull(seed) ? 5 : 1))
|
|
weedlevel += 1 * HYDRO_SPEED_MULTIPLIER
|
|
|
|
// There's a chance for a weed explosion to happen if the weeds take over.
|
|
// Plants that are themselves weeds (weed_tolerance > 10) are unaffected.
|
|
if (weedlevel >= 10 && prob(10))
|
|
if(!seed || weedlevel >= seed.get_trait(TRAIT_WEED_TOLERANCE))
|
|
weed_invasion()
|
|
|
|
// If there is no seed data (and hence nothing planted),
|
|
// or the plant is dead, process nothing further.
|
|
if(!seed || dead)
|
|
if(mechanical) update_icon() //Harvesting would fail to set alert icons properly.
|
|
return
|
|
|
|
// Advance plant age.
|
|
if(prob(30)) age += 1 * HYDRO_SPEED_MULTIPLIER
|
|
|
|
//Highly mutable plants have a chance of mutating every tick.
|
|
if(seed.get_trait(TRAIT_IMMUTABLE) == -1)
|
|
var/mut_prob = rand(1,100)
|
|
if(mut_prob <= 5) mutate(mut_prob == 1 ? 2 : 1)
|
|
|
|
// Maintain tray nutrient and water levels.
|
|
if(seed.get_trait(TRAIT_NUTRIENT_CONSUMPTION) > 0 && nutrilevel > 0 && prob(25))
|
|
nutrilevel -= max(0,seed.get_trait(TRAIT_NUTRIENT_CONSUMPTION) * HYDRO_SPEED_MULTIPLIER)
|
|
if(seed.get_trait(TRAIT_WATER_CONSUMPTION) > 0 && waterlevel > 0 && prob(25))
|
|
waterlevel -= max(0,seed.get_trait(TRAIT_WATER_CONSUMPTION) * HYDRO_SPEED_MULTIPLIER)
|
|
|
|
// Make sure the plant is not starving or thirsty. Adequate
|
|
// water and nutrients will cause a plant to become healthier.
|
|
var/healthmod = rand(1,3) * HYDRO_SPEED_MULTIPLIER
|
|
if(seed.get_trait(TRAIT_REQUIRES_NUTRIENTS) && prob(35))
|
|
health += (nutrilevel < 2 ? -healthmod : healthmod)
|
|
if(seed.get_trait(TRAIT_REQUIRES_WATER) && prob(35))
|
|
health += (waterlevel < 10 ? -healthmod : healthmod)
|
|
|
|
// Check that pressure, heat and light are all within bounds.
|
|
// First, handle an open system or an unconnected closed system.
|
|
var/turf/T = loc
|
|
var/datum/gas_mixture/environment
|
|
// If we're closed, take from our internal sources.
|
|
if(closed_system && (connected_port || holding))
|
|
if(holding)
|
|
air_contents = holding.air_contents
|
|
environment = air_contents
|
|
// If atmos input is not there, grab from turf.
|
|
if(!environment && istype(T)) environment = T.return_air()
|
|
if(!environment) return
|
|
|
|
// Seed datum handles gasses, light and pressure.
|
|
if(mechanical && closed_system)
|
|
health -= seed.handle_environment(T,environment,tray_light, holding)
|
|
else
|
|
health -= seed.handle_environment(T,environment)
|
|
|
|
T.air_update_turf()
|
|
|
|
// If we're attached to a pipenet, then we should let the pipenet know we might have modified some gasses
|
|
if (closed_system && connected_port)
|
|
update_connected_network()
|
|
|
|
// Toxin levels beyond the plant's tolerance cause damage, but
|
|
// toxins are sucked up each tick and slowly reduce over time.
|
|
if(toxins > 0)
|
|
var/toxin_uptake = max(1,round(toxins/10))
|
|
if(toxins > seed.get_trait(TRAIT_TOXINS_TOLERANCE))
|
|
health -= toxin_uptake
|
|
toxins -= toxin_uptake
|
|
|
|
// Check for pests and weeds.
|
|
// Some carnivorous plants happily eat pests.
|
|
if(pestlevel > 0)
|
|
if(seed.get_trait(TRAIT_CARNIVOROUS))
|
|
health += HYDRO_SPEED_MULTIPLIER
|
|
pestlevel -= HYDRO_SPEED_MULTIPLIER
|
|
else if (pestlevel >= seed.get_trait(TRAIT_PEST_TOLERANCE))
|
|
health -= HYDRO_SPEED_MULTIPLIER
|
|
|
|
// Some plants thrive and live off of weeds.
|
|
if(weedlevel > 0)
|
|
if(seed.get_trait(TRAIT_PARASITE))
|
|
health += HYDRO_SPEED_MULTIPLIER
|
|
weedlevel -= HYDRO_SPEED_MULTIPLIER
|
|
else if (weedlevel >= seed.get_trait(TRAIT_WEED_TOLERANCE))
|
|
health -= HYDRO_SPEED_MULTIPLIER
|
|
|
|
// Handle life and death.
|
|
// When the plant dies, weeds thrive and pests die off.
|
|
check_health()
|
|
|
|
// If enough time (in cycles, not ticks) has passed since the plant was harvested, we're ready to harvest again.
|
|
if((age > seed.get_trait(TRAIT_MATURATION)) && \
|
|
((age - lastproduce) > seed.get_trait(TRAIT_PRODUCTION)) && \
|
|
(!harvest && !dead))
|
|
harvest = 1
|
|
lastproduce = age
|
|
|
|
if(prob(3)) // On each tick, there's a chance the pest population will increase
|
|
pestlevel += 0.1 * HYDRO_SPEED_MULTIPLIER
|
|
|
|
// Some seeds will self-harvest if you don't keep a lid on them.
|
|
if(seed && seed.can_self_harvest && harvest && !closed_system && prob(5))
|
|
harvest()
|
|
|
|
check_health()
|
|
return
|