Merge pull request #1150 from FalseIncarnate/master

Botany Atmospheric Interactions
This commit is contained in:
ZomgPonies
2015-05-24 10:19:01 -04:00
7 changed files with 110 additions and 24 deletions
+60 -21
View File
@@ -243,39 +243,49 @@
origin_turf.visible_message("<span class='danger'>The [thrown.name] splatters against [target]!</span>")
del(thrown)
/datum/seed/proc/handle_environment(var/turf/current_turf, var/datum/gas_mixture/environment, var/light_supplied, var/check_only)
/datum/seed/proc/handle_environment(var/turf/current_turf, var/datum/gas_mixture/environment, var/light_supplied, var/obj/item/weapon/tank/holding, var/check_only)
var/health_change = 0
/*
// Handle gas consumption.
if(consume_gasses && consume_gasses.len)
var/missing_gas = 0
for(var/gas in consume_gasses)
if(environment && environment.gas && environment.gas[gas] && \
environment.gas[gas] >= consume_gasses[gas])
if(!check_only)
environment.adjust_gas(gas,-consume_gasses[gas],1)
else
missing_gas++
if(missing_gas > 0)
health_change += missing_gas * HYDRO_SPEED_MULTIPLIER
*/
if(!environment) //Someone called this without passing an environment. Punish their plant.
return -100
// Process it.
var/pressure = environment.return_pressure()
var/pressure
if(holding) //Check if we are running from an internal source (portable tank)
//Use the tank's distribution pressure or it's internal pressure (whichever is lower) for pressure checks
pressure = min(environment.return_pressure(), holding.distribute_pressure)
else //Not using an internal source
pressure = environment.return_pressure()
if(pressure < get_trait(TRAIT_LOWKPA_TOLERANCE)|| pressure > get_trait(TRAIT_HIGHKPA_TOLERANCE))
health_change += rand(1,3) * HYDRO_SPEED_MULTIPLIER
if(abs(environment.temperature - get_trait(TRAIT_IDEAL_HEAT)) > get_trait(TRAIT_HEAT_TOLERANCE))
health_change += rand(1,3) * HYDRO_SPEED_MULTIPLIER
/*
// Handle gas consumption.
if(consume_gasses && consume_gasses.len)
var/missing_gas = 0
for(var/gas in consume_gasses)
if(environment && environment.vars[gas] && environment.vars[gas] >= consume_gasses[gas])
if(!check_only)
environment = adjust_gas(environment, gas,-consume_gasses[gas])
else
missing_gas++
if(missing_gas > 0)
health_change += missing_gas * HYDRO_SPEED_MULTIPLIER
// Handle gas production.
if(exude_gasses && exude_gasses.len && !check_only)
for(var/gas in exude_gasses)
environment.adjust_gas(gas, max(1,round((exude_gasses[gas]*(get_trait(TRAIT_POTENCY)/5))/exude_gasses.len)))
*/
environment = adjust_gas(environment, gas, max(1,round((exude_gasses[gas]*(get_trait(TRAIT_POTENCY)/5))/exude_gasses.len)))
//Handle heat adjustment
if(get_trait(TRAIT_ALTER_TEMP))
environment.temperature += get_trait(TRAIT_ALTER_TEMP)
if(environment.temperature < 0) //Make sure we didn't drop below absolute zero
environment.temperature = 0 //Set temperature back to zero if we did
// Handle light requirements.
if(!light_supplied)
@@ -291,6 +301,35 @@
return health_change
//Screw it, making a new proc for this for the sake of readability or something. --FalseIncarnate
/datum/seed/proc/adjust_gas(var/datum/gas_mixture/environment, var/gas, var/amount = 0)
if(!environment || !gas) //no gas_mixture or gas defined to adjust
return
var/transfer_moles = environment.total_moles()
var/datum/gas_mixture/temp_holding
if(transfer_moles <= 0) //Check if the transfer_moles is an unacceptable value for the remove proc
//The environment is empty (or somehow has negative moles), create a new gas_mixture for temp_holding
temp_holding = new /datum/gas_mixture()
temp_holding.temperature = T20C
else
//The environment is acceptable, transfer it's contents into temp_holding
temp_holding = environment.remove(transfer_moles)
if(!temp_holding) return //Just in case temp_holding has somehow avoided being set
switch(gas)
if("oxygen")
temp_holding.oxygen += amount
if("nitrogen")
temp_holding.nitrogen += amount
if("carbon_dioxide")
temp_holding.carbon_dioxide += amount
if("toxins")
temp_holding.toxins += amount
return environment.merge(temp_holding)
/datum/seed/proc/apply_special_effect(var/mob/living/target,var/obj/item/thrown)
var/impact = 1
@@ -361,12 +400,12 @@
if(prob(5))
consume_gasses = list()
var/gas = pick("oxygen","nitrogen","plasma","carbon_dioxide")
var/gas = pick("oxygen","nitrogen","toxins","carbon_dioxide")
consume_gasses[gas] = rand(3,9)
if(prob(5))
exude_gasses = list()
var/gas = pick("oxygen","nitrogen","plasma","carbon_dioxide")
var/gas = pick("oxygen","nitrogen","toxins","carbon_dioxide")
exude_gasses[gas] = rand(3,9)
chems = list()
+18
View File
@@ -1236,6 +1236,7 @@
seed_name = "test"
display_name = "test trees"
chems = list("omnizine" = list(1,20))
consume_gasses = list("oxygen" = 5)
/datum/seed/test/New()
..()
@@ -1249,3 +1250,20 @@
set_trait(TRAIT_PRODUCT_COLOUR,"#BB6AC4")
set_trait(TRAIT_PLANT_ICON,"tree")
set_trait(TRAIT_EXPLOSIVE, 1)
/datum/seed/test2
name = "test2"
seed_name = "test2"
display_name = "test2 trees"
exude_gasses = list("toxins" = 5)
/datum/seed/test2/New()
..()
set_trait(TRAIT_HARVEST_REPEAT,1)
set_trait(TRAIT_MATURATION,1)
set_trait(TRAIT_PRODUCTION,1)
set_trait(TRAIT_YIELD,4)
set_trait(TRAIT_POTENCY,15)
set_trait(TRAIT_PRODUCT_ICON,"treefruit")
set_trait(TRAIT_PRODUCT_COLOUR,"#BB6AC4")
set_trait(TRAIT_PLANT_ICON,"tree")
+3
View File
@@ -287,6 +287,9 @@ var/global/list/plant_seed_sprites = list()
/obj/item/seeds/test
seed_type = "test"
/obj/item/seeds/test2
seed_type = "test2"
/obj/item/seeds/stobaccoseed
seed_type = "stobacco"
@@ -45,7 +45,7 @@
// Handle life.
var/turf/simulated/T = get_turf(src)
if(istype(T))
health -= seed.handle_environment(T,T.return_air(),null,1)
health -= seed.handle_environment(T,T.return_air(),null,null,1)
if(health < max_health)
health += rand(3,5)
refresh_icon()
+10
View File
@@ -740,6 +740,16 @@
A.icon_state = src.icon_state
A.hydrotray_type = src.type
del(src)
else if ((istype(O, /obj/item/weapon/tank) && !( src.destroyed )))
if (src.holding)
user << "\blue There is alreadu a tank loaded into the [src]."
return
var/obj/item/weapon/tank/T = O
user.drop_item()
T.loc = src
src.holding = T
update_icon()
return
else if(O && O.force && seed)
user.visible_message("<span class='danger'>\The [seed.display_name] has been attacked by [user] with \the [O]!</span>")
if(!dead)
@@ -62,6 +62,8 @@
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()
@@ -69,10 +71,12 @@
// Seed datum handles gasses, light and pressure.
if(mechanical && closed_system)
health -= seed.handle_environment(T,environment,tray_light)
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()
+13 -1
View File
@@ -166,6 +166,18 @@
dat += "It thrives in a temperature of [grown_seed.get_trait(TRAIT_IDEAL_HEAT)] Kelvin."
if(grown_seed.consume_gasses && grown_seed.consume_gasses.len)
for(var/gas in grown_seed.consume_gasses)
if(gas == "carbon_dioxide") gas = "carbon dioxide"
if(gas == "toxins") gas = "plasma"
dat += "<br>It requires an environment rich in [gas] gas to thrive."
if(grown_seed.exude_gasses && grown_seed.exude_gasses.len)
for(var/gas in grown_seed.exude_gasses)
if(gas == "carbon_dioxide") gas = "carbon dioxide"
if(gas == "toxins") gas = "plasma"
dat += "<br>It releases [gas] gas as a byproduct of it's growth."
if(grown_seed.get_trait(TRAIT_LOWKPA_TOLERANCE) < 20)
dat += "<br>It is well adapted to low pressure levels."
if(grown_seed.get_trait(TRAIT_HIGHKPA_TOLERANCE) > 220)
@@ -213,7 +225,7 @@
if(grown_seed.get_trait(TRAIT_PARASITE))
dat += "<br>It is capable of parisitizing and gaining sustenance from tray weeds."
if(grown_seed.get_trait(TRAIT_ALTER_TEMP))
dat += "<br>It will periodically alter the local temperature by [grown_seed.get_trait(TRAIT_ALTER_TEMP)] degrees Kelvin."
dat += "<br>It will periodically alter the local temperature by [grown_seed.get_trait(TRAIT_ALTER_TEMP)] Kelvin."
if(grown_seed.get_trait(TRAIT_BIOLUM))
dat += "<br>It is [grown_seed.get_trait(TRAIT_BIOLUM_COLOUR) ? "<font color='[grown_seed.get_trait(TRAIT_BIOLUM_COLOUR)]'>bio-luminescent</font>" : "bio-luminescent"]."