anchor.diff:  	var/emergency_issued = FALSE
   
   	var/explosion_power = 12
  +	var/temp_factor = 30
   
   	var/lastwarning = 0				// Time in 1/10th of seconds since the last sent warning
   	var/power = 0
  
positive.code: 
  	//Ok, get the air from the turf
  	var/datum/gas_mixture/env = T.return_air()
  	var/datum/gas_mixture/removed
  	if(produces_gas)
  		//Remove gas from surrounding area
  		removed = env.remove(gasefficency * env.total_moles())
  
negative.code: 		// Pass all the gas related code an empty gas container
  		removed = new()
  
  	if(!removed || !removed.total_moles() || isspaceturf(T)) //we're in space or there is no gas to process
  		if(takes_damage)
  			damage += max((power-1600)/10, 0)
  		return 1
  
  	damage_archived = damage
  	if(takes_damage)
  		//causing damage
  		damage = max(damage + (max(removed.temperature - ((T0C + HEAT_PENALTY_THRESHOLD)*dynamic_heat_resistance), 0) * mole_heat_penalty / 150 ) * DAMAGE_INCREASE_MULTIPLIER, 0)
  		damage = max(damage + (max(power - POWER_PENALTY_THRESHOLD, 0)/500) * DAMAGE_INCREASE_MULTIPLIER, 0)
  		damage = max(damage + (max(combined_gas - MOLE_PENALTY_THRESHOLD, 0)/80) * DAMAGE_INCREASE_MULTIPLIER, 0)
  
  		//healing damage
  		if(combined_gas < MOLE_PENALTY_THRESHOLD)
  			damage = max(damage + (min(removed.temperature - (T0C + HEAT_PENALTY_THRESHOLD), 0) / 150 ), 0)
  
  		//capping damage
  		damage = min(damage_archived + (DAMAGE_HARDCAP * explosion_point),damage)
  		if(damage > damage_archived && prob(10))
  			playsound(get_turf(src), 'sound/effects/empulse.ogg', 50, 1)
  
  	removed.assert_gases("o2", "plasma", "co2", "n2o", "n2", "freon")
  	//calculating gas related values
  	combined_gas = max(removed.total_moles(), 0)
  
  	plasmacomp = max(removed.gases["plasma"][MOLES]/combined_gas, 0)
  	o2comp = max(removed.gases["o2"][MOLES]/combined_gas, 0)
  	co2comp = max(removed.gases["co2"][MOLES]/combined_gas, 0)
  
  	n2ocomp = max(removed.gases["n2o"][MOLES]/combined_gas, 0)
  	n2comp = max(removed.gases["n2"][MOLES]/combined_gas, 0)
  	freoncomp = max(removed.gases["freon"][MOLES]/combined_gas, 0)
  
  	gasmix_power_ratio = min(max(plasmacomp + o2comp + co2comp - n2comp - freoncomp, 0), 1)
  
  	dynamic_heat_modifier = max((plasmacomp * PLASMA_HEAT_PENALTY)+(o2comp * OXYGEN_HEAT_PENALTY)+(co2comp * CO2_HEAT_PENALTY)+(n2comp * NITROGEN_HEAT_MODIFIER), 0.5)
  	dynamic_heat_resistance = max(n2ocomp * N2O_HEAT_RESISTANCE, 1)
  
  	power_transmission_bonus = max((plasmacomp * PLASMA_TRANSMIT_MODIFIER) + (o2comp * OXYGEN_TRANSMIT_MODIFIER), 0)
  
  	freon_transmit_modifier = max(1-(freoncomp * FREON_TRANSMIT_PENALTY), 0)
  
  	//more moles of gases are harder to heat than fewer, so let's scale heat damage around them
  	mole_heat_penalty = max(combined_gas / MOLE_HEAT_PENALTY, 0.25)
  
  	if (combined_gas > POWERLOSS_INHIBITION_MOLE_THRESHOLD && co2comp > POWERLOSS_INHIBITION_GAS_THRESHOLD)
  		powerloss_dynamic_scaling = Clamp(powerloss_dynamic_scaling + Clamp(co2comp - powerloss_dynamic_scaling, -0.02, 0.02), 0, 1)
  	else
  		powerloss_dynamic_scaling = Clamp(powerloss_dynamic_scaling - 0.05,0, 1)
  	powerloss_inhibitor = Clamp(1-(powerloss_dynamic_scaling * Clamp(combined_gas/POWERLOSS_INHIBITION_MOLE_BOOST_THRESHOLD,1 ,1.5)),0 ,1)
  
  	if(matter_power)
  		var/removed_matter = max(matter_power/MATTER_POWER_CONVERSION, 40)
  		power = max(power + removed_matter, 0)
  		matter_power = max(matter_power - removed_matter, 0)
  
  	var/temp_factor = 50
  
  	if(gasmix_power_ratio > 0.8)
  		// with a perfect gas mix, make the power less based on heat
  		icon_state = "[base_icon_state]_glow"
  	else
  		// in normal mode, base the produced energy around the heat
  		temp_factor = 30
  		icon_state = base_icon_state
  
  	power = max( (removed.temperature * temp_factor / T0C) * gasmix_power_ratio + power, 0) //Total laser power plus an overload
  
  	//We've generated power, now let's transfer it to the collectors for storing/usage
  	transfer_energy()
  
  	var/device_energy = power * REACTION_POWER_MODIFIER
  
  	//To figure out how much temperature to add each tick, consider that at one atmosphere's worth
  	//of pure oxygen, with all four lasers firing at standard energy and no N2 present, at room temperature
  	//that the device energy is around 2140. At that stage, we don't want too much heat to be put out
  	//Since the core is effectively "cold"
  
  	//Also keep in mind we are only adding this temperature to (efficiency)% of the one tile the rock
  	//is on. An increase of 4*C @ 25% efficiency here results in an increase of 1*C / (#tilesincore) overall.
  	removed.temperature += ((device_energy * dynamic_heat_modifier) / THERMAL_RELEASE_MODIFIER)
  
  	removed.temperature = max(0, min(removed.temperature, 2500 * dynamic_heat_modifier))
  
  	//Calculate how much gas to release
  	removed.gases["plasma"][MOLES] += max((device_energy * dynamic_heat_modifier) / PLASMA_RELEASE_MODIFIER, 0)
  
  	removed.gases["o2"][MOLES] += max(((device_energy + removed.temperature * dynamic_heat_modifier) - T0C) / OXYGEN_RELEASE_MODIFIER, 0)
  
  	if(combined_gas < 50)
  		removed.gases["freon"][MOLES] = max((removed.gases["freon"][MOLES] + device_energy) * freoncomp / FREON_BREEDING_MODIFIER, 0)
  
  	if(produces_gas)
  		env.merge(removed)
  		air_update_turf()
  
  	for(var/mob/living/carbon/human/l in view(src, HALLUCINATION_RANGE(power))) // If they can see it without mesons on.  Bad on them.
  		if(!istype(l.glasses, /obj/item/clothing/glasses/meson))
  			var/D = sqrt(1 / max(1, get_dist(l, src)))
  			l.hallucination += power * config_hallucination_power * D
  			l.hallucination = Clamp(0, 200, l.hallucination)
  
  	for(var/mob/living/l in range(src, round((power / 100) ** 0.25)))
  		var/rads = (power / 10) * sqrt( 1 / max(get_dist(l, src),1) )
  		l.rad_act(rads)
  
  	if(power > POWER_PENALTY_THRESHOLD || damage > damage_penalty_point)
  
  		if(power > POWER_PENALTY_THRESHOLD)
  			playsound(src.loc, 'sound/weapons/emitter2.ogg', 100, 1, extrarange = 10)
  			supermatter_zap(src, 5, min(power*2, 20000))
  			supermatter_zap(src, 5, min(power*2, 20000))
  			if(power > SEVERE_POWER_PENALTY_THRESHOLD)
  				supermatter_zap(src, 5, min(power*2, 20000))
  				if(power > CRITICAL_POWER_PENALTY_THRESHOLD)
  					supermatter_zap(src, 5, min(power*2, 20000))
  		else if (damage > damage_penalty_point && prob(20))
  			playsound(src.loc, 'sound/weapons/emitter2.ogg', 100, 1, extrarange = 10)
  			supermatter_zap(src, 5, Clamp(power*2, 4000, 20000))
  
  		if(prob(15) && power > POWER_PENALTY_THRESHOLD)
  			supermatter_pull(src, power/750)
  		if(prob(5))
  			supermatter_anomaly_gen(src, FLUX_ANOMALY, rand(5, 10))
  		if(power > SEVERE_POWER_PENALTY_THRESHOLD && prob(5) || prob(1))
  			supermatter_anomaly_gen(src, GRAVITATIONAL_ANOMALY, rand(5, 10))
  		if(power > SEVERE_POWER_PENALTY_THRESHOLD && prob(2) || prob(0.3) && power > POWER_PENALTY_THRESHOLD)
  			supermatter_anomaly_gen(src, PYRO_ANOMALY, rand(5, 10))
  
  
  
  	if(damage > warning_point) // while the core is still damaged and it's still worth noting its status
  		if((REALTIMEOFDAY - lastwarning) / 10 >= WARNING_DELAY)
  			alarm()
  
  			if(damage > emergency_point)
  				radio.talk_into(src, "[emergency_alert] Integrity: [get_integrity()]%", common_channel, get_spans(), get_default_language())
  				lastwarning = REALTIMEOFDAY
  