mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-22 04:22:39 +01:00
Nutrition fixes and tweaks (#1265)
Fixes nutrition displays not updating. Adds code support for species-variable levels of max nutrition storage, and nutrition loss. No actual variations are yet implemented, awaiting input from lore team. Fixes all relevant static isntances of numeric literals with the max_nutrition variable And a feature tweak: Players will now spawn with randomised nutrition levels when they join
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/mob/living/carbon/alien/diona
|
||||
var/datum/reagents/vessel
|
||||
var/list/internal_organs_by_name = list() // so internal organs have less ickiness too
|
||||
var/max_nutrition = 6000
|
||||
max_nutrition = 6000
|
||||
language = null
|
||||
var/energy_duration = 144//The time in seconds that this diona can exist in total darkness before its energy runs out
|
||||
var/dark_consciousness = 144//How long this diona can stay on its feet and keep moving in darkness after energy is gone.
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
// nutrition decrease
|
||||
if (nutrition > 0 && stat != 2)
|
||||
nutrition = max (0, nutrition - HUNGER_FACTOR)
|
||||
nutrition = max (0, nutrition - nutrition_loss)
|
||||
|
||||
if (nutrition > max_nutrition)
|
||||
nutrition = max_nutrition
|
||||
|
||||
@@ -36,9 +36,9 @@
|
||||
. = ..()
|
||||
if(.)
|
||||
if(src.nutrition && src.stat != 2)
|
||||
src.nutrition -= HUNGER_FACTOR/10
|
||||
src.nutrition -= nutrition_loss*0.1//Multiplication is faster than division
|
||||
if(src.m_intent == "run")
|
||||
src.nutrition -= HUNGER_FACTOR/10
|
||||
src.nutrition -= nutrition_loss*0.1
|
||||
if((FAT in src.mutations) && src.m_intent == "run" && src.bodytemperature <= 360)
|
||||
src.bodytemperature += 2
|
||||
|
||||
|
||||
@@ -92,8 +92,8 @@ var/list/diona_banned_languages = list(
|
||||
if(DS.nutrient_organ.is_bruised())
|
||||
plus *= 0.5
|
||||
nutrition += plus
|
||||
if (nutrition > 400)
|
||||
nutrition = 400
|
||||
if (nutrition > max_nutrition)
|
||||
nutrition = max_nutrition
|
||||
|
||||
/mob/living/carbon/proc/diona_handle_temperature(var/datum/dionastats/DS)
|
||||
if (bodytemperature < TEMP_REGEN_STOP)
|
||||
|
||||
@@ -1159,7 +1159,12 @@
|
||||
sprint_speed_factor = species.sprint_speed_factor
|
||||
sprint_cost_factor = species.sprint_cost_factor
|
||||
stamina_recovery = species.stamina_recovery
|
||||
|
||||
exhaust_threshold = species.exhaust_threshold
|
||||
max_nutrition = BASE_MAX_NUTRITION * species.max_nutrition_factor
|
||||
nutrition = (rand(25,100)*0.01)*max_nutrition//Starting nutrition is randomised between 25-100% of max
|
||||
|
||||
nutrition_loss = HUNGER_FACTOR * species.nutrition_loss_factor
|
||||
if(species)
|
||||
return 1
|
||||
else
|
||||
|
||||
@@ -17,8 +17,12 @@
|
||||
if (!(species && (species.flags & NO_PAIN)))
|
||||
if(halloss >= 10) tally += (halloss / 10) //halloss shouldn't slow you down if you can't even feel it
|
||||
|
||||
var/hungry = (500 - nutrition)/5 // So overeat would be 100 and default level would be 80
|
||||
if (hungry >= 70) tally += hungry/50
|
||||
|
||||
//Simpler hunger slowdown calculations, this should be a little faster due to no division, and more scaleable
|
||||
if (nutrition < (max_nutrition * 0.4))
|
||||
tally++
|
||||
if (nutrition < (max_nutrition * 0.1))
|
||||
tally++
|
||||
|
||||
if(wear_suit)
|
||||
tally += wear_suit.slowdown
|
||||
|
||||
@@ -285,60 +285,47 @@
|
||||
|
||||
// #TODO-MERGE: Check vaurca and IPC radiation management
|
||||
if (radiation)
|
||||
var/obj/item/organ/diona/nutrients/rad_organ = locate() in internal_organs
|
||||
if(rad_organ && !rad_organ.is_broken())
|
||||
var/rads = radiation/25
|
||||
radiation -= rads
|
||||
nutrition += rads
|
||||
adjustBruteLoss(-(rads))
|
||||
adjustFireLoss(-(rads))
|
||||
adjustOxyLoss(-(rads))
|
||||
adjustToxLoss(-(rads))
|
||||
updatehealth()
|
||||
return
|
||||
//var/obj/item/organ/diona/nutrients/rad_organ = locate() in internal_organs
|
||||
if(src.is_diona())
|
||||
diona_handle_regeneration(get_dionastats())
|
||||
else
|
||||
var/damage = 0
|
||||
radiation -= 1 * RADIATION_SPEED_COEFFICIENT
|
||||
if(prob(25))
|
||||
damage = 1
|
||||
|
||||
if (radiation)
|
||||
//var/obj/item/organ/diona/nutrients/rad_organ = locate() in internal_organs
|
||||
if(src.is_diona())
|
||||
diona_handle_regeneration(get_dionastats())
|
||||
else
|
||||
var/damage = 0
|
||||
if (radiation > 50)
|
||||
damage = 1
|
||||
radiation -= 1 * RADIATION_SPEED_COEFFICIENT
|
||||
if(prob(25))
|
||||
damage = 1
|
||||
if(prob(5) && prob(100 * RADIATION_SPEED_COEFFICIENT))
|
||||
radiation -= 5 * RADIATION_SPEED_COEFFICIENT
|
||||
src << "<span class='warning'>You feel weak.</span>"
|
||||
Weaken(3)
|
||||
if(!lying)
|
||||
emote("collapse")
|
||||
if(prob(5) && prob(100 * RADIATION_SPEED_COEFFICIENT) && species.name == "Human") //apes go bald
|
||||
if((h_style != "Bald" || f_style != "Shaved" ))
|
||||
src << "<span class='warning'>Your hair falls out.</span>"
|
||||
h_style = "Bald"
|
||||
f_style = "Shaved"
|
||||
update_hair()
|
||||
|
||||
if (radiation > 50)
|
||||
damage = 1
|
||||
radiation -= 1 * RADIATION_SPEED_COEFFICIENT
|
||||
if(prob(5) && prob(100 * RADIATION_SPEED_COEFFICIENT))
|
||||
radiation -= 5 * RADIATION_SPEED_COEFFICIENT
|
||||
src << "<span class='warning'>You feel weak.</span>"
|
||||
Weaken(3)
|
||||
if(!lying)
|
||||
emote("collapse")
|
||||
if(prob(5) && prob(100 * RADIATION_SPEED_COEFFICIENT) && species.name == "Human") //apes go bald
|
||||
if((h_style != "Bald" || f_style != "Shaved" ))
|
||||
src << "<span class='warning'>Your hair falls out.</span>"
|
||||
h_style = "Bald"
|
||||
f_style = "Shaved"
|
||||
update_hair()
|
||||
if (radiation > 75)
|
||||
radiation -= 1 * RADIATION_SPEED_COEFFICIENT
|
||||
damage = 3
|
||||
if(prob(5))
|
||||
take_overall_damage(0, 5 * RADIATION_SPEED_COEFFICIENT, used_weapon = "Radiation Burns")
|
||||
if(prob(1))
|
||||
src << "<span class='warning'>You feel strange!</span>"
|
||||
adjustCloneLoss(5 * RADIATION_SPEED_COEFFICIENT)
|
||||
emote("gasp")
|
||||
|
||||
if (radiation > 75)
|
||||
radiation -= 1 * RADIATION_SPEED_COEFFICIENT
|
||||
damage = 3
|
||||
if(prob(5))
|
||||
take_overall_damage(0, 5 * RADIATION_SPEED_COEFFICIENT, used_weapon = "Radiation Burns")
|
||||
if(prob(1))
|
||||
src << "<span class='warning'>You feel strange!</span>"
|
||||
adjustCloneLoss(5 * RADIATION_SPEED_COEFFICIENT)
|
||||
emote("gasp")
|
||||
|
||||
if(damage)
|
||||
adjustToxLoss(damage * RADIATION_SPEED_COEFFICIENT)
|
||||
updatehealth()
|
||||
if(organs.len)
|
||||
var/obj/item/organ/external/O = pick(organs)
|
||||
if(istype(O)) O.add_autopsy_data("Radiation Poisoning", damage)
|
||||
if(damage)
|
||||
adjustToxLoss(damage * RADIATION_SPEED_COEFFICIENT)
|
||||
updatehealth()
|
||||
if(organs.len)
|
||||
var/obj/item/organ/external/O = pick(organs)
|
||||
if(istype(O)) O.add_autopsy_data("Radiation Poisoning", damage)
|
||||
|
||||
/** breathing **/
|
||||
|
||||
@@ -937,58 +924,18 @@
|
||||
|
||||
if(status_flags & GODMODE) return 0 //godmode
|
||||
|
||||
var/obj/item/organ/diona/node/light_organ = locate() in internal_organs
|
||||
if(light_organ && !light_organ.is_broken())
|
||||
var/light_amount = 0 //how much light there is in the place, affects receiving nutrition and healing
|
||||
if(isturf(loc)) //else, there's considered to be no light
|
||||
var/turf/T = loc
|
||||
var/atom/movable/lighting_overlay/L = locate(/atom/movable/lighting_overlay) in T
|
||||
if(L)
|
||||
light_amount = min(10,L.lum_r + L.lum_g + L.lum_b) - 5 //hardcapped so it's not abused by having a ton of flashlights
|
||||
else
|
||||
light_amount = 5
|
||||
nutrition += light_amount
|
||||
traumatic_shock -= light_amount
|
||||
|
||||
if(species.flags & IS_PLANT)
|
||||
if(nutrition > 450)
|
||||
nutrition = 450
|
||||
if(light_amount >= 3) //if there's enough light, heal
|
||||
adjustBruteLoss(-(round(light_amount/2)))
|
||||
adjustFireLoss(-(round(light_amount/2)))
|
||||
adjustToxLoss(-(light_amount))
|
||||
adjustOxyLoss(-(light_amount))
|
||||
//TODO: heal wounds, heal broken limbs.
|
||||
|
||||
if(species.light_dam)
|
||||
var/light_amount = 0
|
||||
if(isturf(loc))
|
||||
var/turf/T = loc
|
||||
var/atom/movable/lighting_overlay/L = locate(/atom/movable/lighting_overlay) in T
|
||||
if(L)
|
||||
light_amount = L.lum_r + L.lum_g + L.lum_b //hardcapped so it's not abused by having a ton of flashlights
|
||||
else
|
||||
light_amount = 10
|
||||
if(light_amount > species.light_dam) //if there's enough light, start dying
|
||||
take_overall_damage(1,1)
|
||||
else //heal in the dark
|
||||
heal_overall_damage(1,1)
|
||||
|
||||
// nutrition decrease
|
||||
if (nutrition > 0 && stat != 2)
|
||||
nutrition = max (0, nutrition - HUNGER_FACTOR)
|
||||
nutrition = max (0, nutrition - nutrition_loss)
|
||||
|
||||
if (nutrition > 450)
|
||||
if (nutrition > max_nutrition)
|
||||
if(overeatduration < 600) //capped so people don't take forever to unfat
|
||||
overeatduration++
|
||||
else
|
||||
if(overeatduration > 1)
|
||||
overeatduration -= 2 //doubled the unfat rate
|
||||
|
||||
if(species.flags & IS_PLANT && (!light_organ || light_organ.is_broken()))
|
||||
if(nutrition < 200)
|
||||
take_overall_damage(2,0)
|
||||
traumatic_shock++
|
||||
|
||||
// TODO: stomach and bloodstream organ.
|
||||
if(!isSynthetic())
|
||||
@@ -1162,7 +1109,6 @@
|
||||
handle_hud_list()
|
||||
|
||||
// now handle what we see on our screen
|
||||
|
||||
if(!..())
|
||||
return
|
||||
|
||||
@@ -1197,24 +1143,7 @@
|
||||
damageoverlay.overlays += I
|
||||
else
|
||||
//Oxygen damage overlay
|
||||
if(oxyloss)
|
||||
var/image/I
|
||||
switch(oxyloss)
|
||||
if(10 to 20)
|
||||
I = overlays_cache[11]
|
||||
if(20 to 25)
|
||||
I = overlays_cache[12]
|
||||
if(25 to 30)
|
||||
I = overlays_cache[13]
|
||||
if(30 to 35)
|
||||
I = overlays_cache[14]
|
||||
if(35 to 40)
|
||||
I = overlays_cache[15]
|
||||
if(40 to 45)
|
||||
I = overlays_cache[16]
|
||||
if(45 to INFINITY)
|
||||
I = overlays_cache[17]
|
||||
damageoverlay.overlays += I
|
||||
update_oxy_overlay()
|
||||
|
||||
// Vampire frenzy overlay.
|
||||
if (mind.vampire)
|
||||
@@ -1247,8 +1176,7 @@
|
||||
see_in_dark = 8
|
||||
if(!druggy) see_invisible = SEE_INVISIBLE_LEVEL_TWO
|
||||
if(healths) healths.icon_state = "health7" //DEAD healthmeter
|
||||
// #TODO-MERGE: Check the indentation of this file! It's awful!
|
||||
if(healths)
|
||||
// #TODO-MERGE: Check the indentation of this file! It's awful!
|
||||
if(client.view != world.view) // If mob dies while zoomed in with device, unzoom them.
|
||||
for(var/obj/item/item in contents)
|
||||
if(item.zoom)
|
||||
@@ -1299,13 +1227,14 @@
|
||||
|
||||
update_health_display()
|
||||
|
||||
|
||||
if(nutrition_icon)
|
||||
switch(nutrition)
|
||||
if(450 to INFINITY) nutrition_icon.icon_state = "nutrition0"
|
||||
if(350 to 450) nutrition_icon.icon_state = "nutrition1"
|
||||
if(250 to 350) nutrition_icon.icon_state = "nutrition2"
|
||||
if(150 to 250) nutrition_icon.icon_state = "nutrition3"
|
||||
//Update hunger UI less often, its not important
|
||||
if((life_tick % 3 == 0) && nutrition_icon)
|
||||
var/nut_factor = max(1,nutrition) / max_nutrition
|
||||
switch(nut_factor)
|
||||
if(1 to INFINITY) nutrition_icon.icon_state = "nutrition0"
|
||||
if(0.75 to 1) nutrition_icon.icon_state = "nutrition1"
|
||||
if(0.5 to 0.75) nutrition_icon.icon_state = "nutrition2"
|
||||
if(0.25 to 0.5) nutrition_icon.icon_state = "nutrition3"
|
||||
else nutrition_icon.icon_state = "nutrition4"
|
||||
|
||||
if(pressure)
|
||||
|
||||
@@ -122,7 +122,6 @@
|
||||
var/primitive_form // Lesser form, if any (ie. monkey for humans)
|
||||
var/greater_form // Greater form, if any, ie. human for monkeys.
|
||||
var/holder_type
|
||||
var/gluttonous // Can eat some mobs. Values can be GLUT_TINY, GLUT_SMALLER, GLUT_ANYTHING.
|
||||
var/rarity_value = 1 // Relative rarity/collector value for this species.
|
||||
var/ethanol_resistance = 1 // How well the mob resists alcohol, lower values get drunk faster, higher values need to drink more
|
||||
|
||||
@@ -132,6 +131,10 @@
|
||||
var/sprint_cost_factor = 0.9 // Multiplier on stamina cost for sprinting
|
||||
var/exhaust_threshold = 50 // When stamina runs out, the mob takes oxyloss up til this value. Then collapses and drops to walk
|
||||
|
||||
var/gluttonous // Can eat some mobs. Values can be GLUT_TINY, GLUT_SMALLER, GLUT_ANYTHING.
|
||||
var/max_nutrition_factor = 1 //Multiplier on maximum nutrition
|
||||
var/nutrition_loss_factor = 1 //Multiplier on passive nutrition losses
|
||||
|
||||
// Determines the organs that the species spawns with and
|
||||
var/list/has_organ = list( // which required-organ checks are conducted.
|
||||
"heart" = /obj/item/organ/heart,
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
|
||||
//Hunger/feeding vars
|
||||
var/hunger_enabled = 1//If set to 0, a creature ignores hunger
|
||||
var/max_nutrition = 50
|
||||
max_nutrition = 50
|
||||
var/metabolic_factor = 1//A multiplier on how fast nutrition is lost. used to tweak the rates on a per-animal basis
|
||||
var/nutrition_step = 0.2 //nutrition lost per tick and per step, calculated from mob_size, 0.2 is a fallback
|
||||
var/bite_factor = 0.4
|
||||
|
||||
@@ -108,6 +108,8 @@
|
||||
var/drowsyness = 0.0//Carbon
|
||||
var/charges = 0.0
|
||||
var/nutrition = 400.0//Carbon
|
||||
var/nutrition_loss = HUNGER_FACTOR//How much hunger is lost per tick. This is modified by species
|
||||
var/max_nutrition = 400
|
||||
|
||||
var/overeatduration = 0 // How long this guy is overeating //Carbon
|
||||
var/paralysis = 0.0
|
||||
|
||||
Reference in New Issue
Block a user