From 30dde5cff39746499d1d1eca0c9262b55fc4937e Mon Sep 17 00:00:00 2001 From: NanakoAC Date: Wed, 28 Sep 2016 22:35:34 +0100 Subject: [PATCH] Diona Light Fixes (#1018) Fixes #1018 Fixes diona not recieving any light in space - initialises light amount to the max light value, so that is used in tiles where there is no lighting overlay. ie, space Fixes dionastats organ references not updating when organs are lost or regrown Fixes some spamming from lightmessages when a diona recovers after almost dying in the dark. Adds a new light sensing message to the check light verb, if the response node is damaged or missing --- code/modules/mob/living/carbon/diona_base.dm | 17 ++++++++++---- .../mob/living/carbon/human/diona_gestalt.dm | 16 +++++++++++++ code/modules/organs/organ_alien.dm | 23 ++++++++++++++++--- 3 files changed, 48 insertions(+), 8 deletions(-) diff --git a/code/modules/mob/living/carbon/diona_base.dm b/code/modules/mob/living/carbon/diona_base.dm index 07b0b951304..f9984497239 100644 --- a/code/modules/mob/living/carbon/diona_base.dm +++ b/code/modules/mob/living/carbon/diona_base.dm @@ -32,6 +32,7 @@ var/list/diona_banned_languages = list( if (life_tick % 2 == 0)//Only fetch the lightlevel every other proc to save performance if (DS.last_location != loc || life_tick % 4 == 0)//Fetch it even less often if we haven't moved since last check light_amount = get_lightlevel_diona(DS) + DS.last_lightlevel = light_amount DS.stored_energy += light_amount @@ -306,6 +307,7 @@ var/list/diona_banned_languages = list( B.touch_turf(get_turf(src)) H.regenerate_icons() DS.LMS = min(2, DS.LMS)//Prevents a message about darkness in light areas + H.update_dionastats()//Re-find the organs in case they were lost or regained updatehealth() return @@ -328,9 +330,11 @@ var/list/diona_banned_languages = list( if (path) if (DS.stored_energy < REGROW_ENERGY_REQ) src << "You try to regrow a lost organ, but you lack the energy. Find more light!" + return if (H.nutrition < REGROW_FOOD_REQ) src << "You try to regrow a lost organ, but you lack the biomass. Find some food!" + return DS.stored_energy -= REGROW_ENERGY_REQ H.nutrition -= REGROW_FOOD_REQ @@ -340,6 +344,7 @@ var/list/diona_banned_languages = list( src << "You feel a shifting sensation inside you as your nymphs move apart to make space, forming a new [O.name]" H.regenerate_icons() DS.LMS = max(2, DS.LMS)//Prevents a message about darkness in light areas + H.update_dionastats()//Re-find the organs in case they were lost or regained updatehealth() return @@ -386,7 +391,7 @@ var/list/diona_banned_languages = list( DS.EP = DS.stored_energy / DS.max_energy if (DS.LMS == 1)//If we're full - if (DS.EP <= 0.8)//But at <=80% energy + if (DS.EP <= 0.8 && DS.last_lightlevel <= 0)//But at <=80% energy DS.LMS = 2 src << "The darkness makes you uncomfortable" @@ -394,7 +399,7 @@ var/list/diona_banned_languages = list( if (DS.EP >= 0.99) DS.LMS = 1 src << "You bask in the light" - else if (DS.EP <= 0.4) + else if (DS.EP <= 0.4 && DS.last_lightlevel <= 0) DS.LMS = 3 src << "You feel lethargic as your energy drains away. Find some light soon!" @@ -402,7 +407,7 @@ var/list/diona_banned_languages = list( if (DS.EP >= 0.5) DS.LMS = 2 src << "You feel a little more energised as you return to the light. Stay awhile" - else if (DS.EP <= 0.0) + else if (DS.EP <= 0.0 && DS.last_lightlevel <= 0) DS.LMS = 4 src << " You feel sensory distress as your tendrils start to wither in the darkness. You will die soon without light" //From here down, we immediately return to state 3 if we get any light @@ -410,7 +415,7 @@ var/list/diona_banned_languages = list( if (DS.EP > 0.0)//If there's any light at all, we can be saved src << "At long last, light! Treasure it, savour it, hold onto it" DS.LMS = 3 - else + else if(DS.last_lightlevel <= 0) var/HP = diona_get_health(DS) / DS.max_health//HP = health-percentage if (DS.LMS == 4) if (HP < 0.6) @@ -440,7 +445,7 @@ if (flashlight_active) //GETTER FUNCTIONS /mob/living/carbon/proc/get_lightlevel_diona(var/datum/dionastats/DS) - var/light_amount = 1.5 //how much light there is in the place, affects receiving nutrition and healing + var/light_amount = DIONA_MAX_LIGHT //how much light there is in the place, affects receiving nutrition and healing var/light_factor = 1//used for if a gestalt's response node is damaged. it will feed more slowly if (DS.light_organ) @@ -448,6 +453,8 @@ if (flashlight_active) light_factor = 0.55 else if (DS.light_organ.is_bruised()) light_factor = 0.8 + else if (DS.dionatype == 2) + light_factor = 0.55 var/turf/T = get_turf(src) var/atom/movable/lighting_overlay/L = locate(/atom/movable/lighting_overlay) in T diff --git a/code/modules/mob/living/carbon/human/diona_gestalt.dm b/code/modules/mob/living/carbon/human/diona_gestalt.dm index c05aeaaa1f4..9fbded9679a 100644 --- a/code/modules/mob/living/carbon/human/diona_gestalt.dm +++ b/code/modules/mob/living/carbon/human/diona_gestalt.dm @@ -119,6 +119,9 @@ set category = "Abilities" set name = "Check light level" + if (!DS.light_organ || DS.light_organ.is_broken() || DS.light_organ.is_bruised()) + usr << span("danger", "Our response node is damaged or missing, without it we can't tell light from darkness. We can only hope this area is bright enough to let us regenerate it!") + return var/light = get_lightlevel_diona(DS) if (light <= -0.75) @@ -142,6 +145,8 @@ var/dark_consciousness = 120//How long this diona can stay on its feet and keep moving in darkness after energy is gone. var/dark_survival = 180//How long this diona can survive in darkness after energy is gone, before it dies + + var/MLS = (1.5 / 2.1)//Maximum (energy) lost per second, in total darkness DS = new/datum/dionastats() DS.max_energy = energy_duration * MLS @@ -157,6 +162,17 @@ if (istype(organ, /obj/item/organ/diona/nutrients)) DS.nutrient_organ = organ +//This proc can be called if some dionastats information needs to be refreshed or re-found +//Currently only used for refreshing organs +/mob/living/carbon/human/proc/update_dionastats() + DS.light_organ = null + DS.nutrient_organ = null + + for (var/organ in internal_organs) + if (istype(organ, /obj/item/organ/diona/node)) + DS.light_organ = organ + if (istype(organ, /obj/item/organ/diona/nutrients)) + DS.nutrient_organ = organ //Splitting functions //==================== diff --git a/code/modules/organs/organ_alien.dm b/code/modules/organs/organ_alien.dm index 4e15573124a..a92f4aa66bf 100644 --- a/code/modules/organs/organ_alien.dm +++ b/code/modules/organs/organ_alien.dm @@ -24,6 +24,8 @@ dislocated = -1 status = ORGAN_PLANT + + /obj/item/organ/external/diona/chest name = "core trunk" limb_name = "chest" @@ -136,7 +138,11 @@ var/mob/living/carbon/human/H = owner ..() if(!istype(H) || !H.organs || !H.organs.len) - H.death() + H.death()//if you somehow remove all of a gestalt's organs, it will dissolve into nymphs + + if (H.is_diona()) + spawn(1) + H.update_dionastats()//This ensures that the dionastats registers the removal of an organ /obj/item/organ/diona/process() @@ -183,6 +189,17 @@ if(!istype(H) || !H.organs || !H.organs.len) H.death() +/obj/item/organ/diona/removed() + var/mob/living/carbon/human/H = owner + ..() + if(!istype(H) || !H.organs || !H.organs.len) + H.death()//if you somehow remove all of a gestalt's organs, it will dissolve into nymphs + + if (H.is_diona()) + spawn(1) + H.update_dionastats()//This ensures that the dionastats registers the removal of an organ + + // These are different to the standard diona organs as they have a purpose in other // species (absorbing radiation and light respectively) /obj/item/organ/diona/nutrients @@ -412,7 +429,7 @@ icon_state = "tracheae" /obj/item/organ/vaurca/tracheae/removed() return */ - + // Skeleton limbs. /obj/item/organ/external/chest/skeleton name = "rib cage" @@ -420,7 +437,7 @@ /obj/item/organ/external/groin/skeleton name = "pelvis" vital = 0 - + /obj/item/organ/external/arm/skeleton dislocated = -1