diff --git a/code/datums/components/mood.dm b/code/datums/components/mood.dm index 88ad75f345..90fea9ec8a 100644 --- a/code/datums/components/mood.dm +++ b/code/datums/components/mood.dm @@ -25,7 +25,7 @@ var/mob/living/owner = parent if(owner.stat != DEAD) - START_PROCESSING(SSdcs, src) + START_PROCESSING(SSobj, src) RegisterSignal(parent, COMSIG_ADD_MOOD_EVENT, .proc/add_event) RegisterSignal(parent, COMSIG_CLEAR_MOOD_EVENT, .proc/clear_event) @@ -40,12 +40,12 @@ hud.show_hud(hud.hud_version) /datum/component/mood/Destroy() - STOP_PROCESSING(SSdcs, src) + STOP_PROCESSING(SSobj, src) unmodify_hud() return ..() /datum/component/mood/proc/stop_processing() - STOP_PROCESSING(SSdcs, src) + STOP_PROCESSING(SSobj, src) /datum/component/mood/proc/print_mood(mob/user) var/msg = "*---------*\nYour current mood\n" @@ -138,7 +138,7 @@ else screen_obj.icon_state = "mood[mood_level]" -/datum/component/mood/process() //Called on SSdcs process +/datum/component/mood/process() //Called on SSobj process if(QDELETED(parent)) // workaround to an obnoxious sneaky periodical runtime. qdel(src) return @@ -345,7 +345,7 @@ ///Called when parent is revived. /datum/component/mood/proc/on_revive(datum/source, full_heal) - START_PROCESSING(SSdcs, src) + START_PROCESSING(SSobj, src) if(!full_heal) return remove_temp_moods() diff --git a/code/datums/elements/earhealing.dm b/code/datums/elements/earhealing.dm index 7477742673..91c2120fc2 100644 --- a/code/datums/elements/earhealing.dm +++ b/code/datums/elements/earhealing.dm @@ -4,7 +4,7 @@ var/list/user_by_item = list() /datum/element/earhealing/New() - START_PROCESSING(SSdcs, src) + START_PROCESSING(SSobj, src) /datum/element/earhealing/Attach(datum/target) . = ..() diff --git a/code/datums/elements/photosynthesis.dm b/code/datums/elements/photosynthesis.dm new file mode 100644 index 0000000000..049506a138 --- /dev/null +++ b/code/datums/elements/photosynthesis.dm @@ -0,0 +1,81 @@ +/datum/element/photosynthesis + element_flags = ELEMENT_BESPOKE|ELEMENT_DETACH + id_arg_index = 2 + ///how much brute damage (or integrity, for objects) is healed (taken if positive) at maximum luminosity. (if lum_minus were 0) + var/light_bruteheal = -1 + ///how much burn damage is restored/taken at maximum luminosity. Mobs only. + var/light_burnheal = -1 + ///how much tox damage is restored/taken at maximum luminosity. Mobs only. + var/light_toxheal = -1 + ///how much oxy damage is restored/taken at maximum luminosity. Mobs only. + var/light_oxyheal = -1 + ///how nutrition recovery/expenses factor, not affected by bonus_lum and malus_lum. Mobs only. + var/light_nutrition_gain = 4 + ///A value subtracted to the lum count, which allows targets to wilt or heal in the darkness. + var/lum_minus = 0.5 + ///the minimum lum count over which where the target damage is adjusted. + var/bonus_lum = 0.2 + ///the maximum lum count under which the target damage is inversely adjusted. + var/malus_lum = 0 + ///List of atoms this element is attached to. Doubles as a multiplier if the same element is attached multiple times to a target multiple times. + var/list/attached_atoms + +/datum/element/photosynthesis/Attach(datum/target, brute = -1, burn = -1, tox = -1, oxy = -1, nutri = 4, minus = 0.5, bonus = 0.2, malus = 0) + . = ..() + if(. == ELEMENT_INCOMPATIBLE || !(isliving(target) || (isobj(target) && light_bruteheal))) + return ELEMENT_INCOMPATIBLE + light_bruteheal = brute + light_burnheal = burn + light_toxheal = tox + light_oxyheal = oxy + light_nutrition_gain = nutri + lum_minus = minus + bonus_lum = bonus + malus_lum = malus + + if(!attached_atoms) + attached_atoms = list() + START_PROCESSING(SSobj, src) + attached_atoms[target]++ + +/datum/element/photosynthesis/Detach(datum/target) + attached_atoms[target]-- + if(!attached_atoms[target]) + attached_atoms -= target + if(!length(attached_atoms)) + STOP_PROCESSING(SSobj, src) + attached_atoms = null + return ..() + +/datum/element/photosynthesis/process() + for(var/A in attached_atoms) + var/atom/movable/AM = A + var/light_amount = 0 //how much light there is in the place, affects receiving nutrition and healing + if(isturf(AM.loc)) //else, there's considered to be no light + var/turf/T = AM.loc + light_amount = (T.get_lumcount() - lum_minus) + + if(isliving(AM)) + var/mob/living/L = AM + if(L.stat == DEAD) + continue + if(light_nutrition_gain) + L.adjust_nutrition(light_amount * light_nutrition_gain * attached_atoms[AM], NUTRITION_LEVEL_FULL) + if(light_amount > bonus_lum || light_amount < malus_lum) + var/mult = ((light_amount > bonus_lum) ? 1 : -1) * attached_atoms[AM] + if(light_bruteheal) + L.adjustBruteLoss(light_bruteheal * mult) + if(light_burnheal) + L.adjustFireLoss(light_burnheal * mult) + if(light_toxheal) + L.adjustToxLoss(light_toxheal * mult) + if(light_oxyheal) + L.adjustOxyLoss(light_oxyheal * mult) + + else if(light_amount > bonus_lum || light_amount < malus_lum) + var/obj/O = AM + var/damage = light_bruteheal * ((light_amount > bonus_lum) ? 1 : -1) * attached_atoms[AM] + if(damage < 0 && O.obj_integrity < O.max_integrity) + O.obj_integrity = min(O.obj_integrity + damage, O.max_integrity) //Till we get a obj heal proc... + else + O.take_damage(damage, BRUTE, FALSE, FALSE, null, 100) diff --git a/code/modules/mob/living/carbon/human/species_types/golems.dm b/code/modules/mob/living/carbon/human/species_types/golems.dm index 2b9d28a5f7..958e58a8ad 100644 --- a/code/modules/mob/living/carbon/human/species_types/golems.dm +++ b/code/modules/mob/living/carbon/human/species_types/golems.dm @@ -280,25 +280,15 @@ . = ..() C.faction |= "plants" C.faction |= "vines" + C.AddElement(/datum/element/photosynthesis) /datum/species/golem/wood/on_species_loss(mob/living/carbon/C) . = ..() C.faction -= "plants" C.faction -= "vines" + C.RemoveElement(/datum/element/photosynthesis) /datum/species/golem/wood/spec_life(mob/living/carbon/human/H) - if(H.stat == DEAD) - return - var/light_amount = 0 //how much light there is in the place, affects receiving nutrition and healing - if(isturf(H.loc)) //else, there's considered to be no light - var/turf/T = H.loc - light_amount = min(1,T.get_lumcount()) - 0.5 - H.adjust_nutrition(light_amount * 4, NUTRITION_LEVEL_FULL) - if(light_amount > 0.2) //if there's enough light, heal - H.heal_overall_damage(1,1) - H.adjustToxLoss(-1) - H.adjustOxyLoss(-1) - if(H.nutrition < NUTRITION_LEVEL_STARVING + 50) H.take_overall_damage(2,0) diff --git a/code/modules/mob/living/carbon/human/species_types/podpeople.dm b/code/modules/mob/living/carbon/human/species_types/podpeople.dm index 817498e417..e79160da06 100644 --- a/code/modules/mob/living/carbon/human/species_types/podpeople.dm +++ b/code/modules/mob/living/carbon/human/species_types/podpeople.dm @@ -14,34 +14,24 @@ liked_food = VEGETABLES | FRUIT | GRAIN species_language_holder = /datum/language_holder/sylvan var/light_nutrition_gain_factor = 4 - var/light_toxheal = 1 - var/light_oxyheal = 1 - var/light_burnheal = 1 - var/light_bruteheal = 1 + var/light_toxheal = -1 + var/light_oxyheal = -1 + var/light_burnheal = -1 + var/light_bruteheal = -1 /datum/species/pod/on_species_gain(mob/living/carbon/C, datum/species/old_species) . = ..() C.faction |= "plants" C.faction |= "vines" + C.AddElement(/datum/element/photosynthesis, light_bruteheal, light_burnheal, light_toxheal, light_oxyheal, light_nutrition_gain_factor) /datum/species/pod/on_species_loss(mob/living/carbon/C) . = ..() C.faction -= "plants" C.faction -= "vines" + C.RemoveElement(/datum/element/photosynthesis, light_bruteheal, light_burnheal, light_toxheal, light_oxyheal, light_nutrition_gain_factor) /datum/species/pod/spec_life(mob/living/carbon/human/H) - if(H.stat == DEAD) - return - var/light_amount = 0 //how much light there is in the place, affects receiving nutrition and healing - if(isturf(H.loc)) //else, there's considered to be no light - var/turf/T = H.loc - light_amount = min(1,T.get_lumcount()) - 0.5 - H.adjust_nutrition(light_amount * light_nutrition_gain_factor, NUTRITION_LEVEL_FULL) - if(light_amount > 0.2) //if there's enough light, heal - H.heal_overall_damage(light_bruteheal, light_burnheal) - H.adjustToxLoss(-light_toxheal) - H.adjustOxyLoss(-light_oxyheal) - if(H.nutrition < NUTRITION_LEVEL_STARVING + 50) H.take_overall_damage(2,0) @@ -77,9 +67,9 @@ mutant_bodyparts = list("mcolor" = "FFF","mcolor2" = "FFF","mcolor3" = "FFF", "mam_snouts" = "Husky", "mam_tail" = "Husky", "mam_ears" = "Husky", "mam_body_markings" = "Husky", "taur" = "None", "legs" = "Normal Legs") limbs_id = "pod" light_nutrition_gain_factor = 3 - light_bruteheal = 0.2 - light_burnheal = 0.2 - light_toxheal = 0.7 + light_bruteheal = -0.2 + light_burnheal = -0.2 + light_toxheal = -0.7 /datum/species/pod/pseudo_weak/spec_death(gibbed, mob/living/carbon/human/H) if(H) diff --git a/code/modules/mob/living/carbon/human/species_types/shadowpeople.dm b/code/modules/mob/living/carbon/human/species_types/shadowpeople.dm index e229860cf7..fede67b47a 100644 --- a/code/modules/mob/living/carbon/human/species_types/shadowpeople.dm +++ b/code/modules/mob/living/carbon/human/species_types/shadowpeople.dm @@ -15,16 +15,13 @@ dangerous_existence = 1 mutanteyes = /obj/item/organ/eyes/night_vision +/datum/species/shadow/on_species_gain(mob/living/carbon/C, datum/species/old_species) + . = ..() + C.AddElement(/datum/element/photosynthesis, 1, 1, 0, 0, 0, 0, SHADOW_SPECIES_LIGHT_THRESHOLD, SHADOW_SPECIES_LIGHT_THRESHOLD) -/datum/species/shadow/spec_life(mob/living/carbon/human/H) - var/turf/T = H.loc - if(istype(T)) - var/light_amount = T.get_lumcount() - - if(light_amount > SHADOW_SPECIES_LIGHT_THRESHOLD) //if there's enough light, start dying - H.take_overall_damage(1,1) - else if (light_amount < SHADOW_SPECIES_LIGHT_THRESHOLD) //heal in the dark - H.heal_overall_damage(1,1) +/datum/species/shadow/on_species_loss(mob/living/carbon/C) + . = ..() + C.RemoveElement(/datum/element/photosynthesis, 1, 1, 0, 0, 0, 0, SHADOW_SPECIES_LIGHT_THRESHOLD, SHADOW_SPECIES_LIGHT_THRESHOLD) /datum/species/shadow/check_roundstart_eligible() if(SSevents.holidays && SSevents.holidays[HALLOWEEN]) diff --git a/tgstation.dme b/tgstation.dme index d9769d4426..abccd15625 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -537,6 +537,7 @@ #include "code\datums\elements\forced_gravity.dm" #include "code\datums\elements\ghost_role_eligibility.dm" #include "code\datums\elements\mob_holder.dm" +#include "code\datums\elements\photosynthesis.dm" #include "code\datums\elements\polychromic.dm" #include "code\datums\elements\scavenging.dm" #include "code\datums\elements\snail_crawl.dm"