diff --git a/code/__defines/chemistry.dm b/code/__defines/chemistry.dm index cc212c82cce..51e84a65106 100644 --- a/code/__defines/chemistry.dm +++ b/code/__defines/chemistry.dm @@ -1,4 +1,4 @@ -#define HUNGER_FACTOR 0.05 // Factor of how fast mob nutrition decreases + #define REM 0.2 // Means 'Reagent Effect Multiplier'. This is how many units of reagent are consumed per tick diff --git a/code/__defines/mobs.dm b/code/__defines/mobs.dm index 0859792370c..4ec106d56fa 100644 --- a/code/__defines/mobs.dm +++ b/code/__defines/mobs.dm @@ -126,6 +126,9 @@ #define GLUT_SMALLER 2 // Eat anything smaller than we are #define GLUT_ANYTHING 3 // Eat anything, ever +#define BASE_MAX_NUTRITION 400 +#define HUNGER_FACTOR 0.05 // Factor of how fast mob nutrition decreases. Moved here from chemistry define + #define TINT_NONE 0 #define TINT_MODERATE 1 #define TINT_HEAVY 2 diff --git a/code/datums/diseases/advance/symptoms/weight.dm b/code/datums/diseases/advance/symptoms/weight.dm index 4abf89240b5..1d5dabb8429 100644 --- a/code/datums/diseases/advance/symptoms/weight.dm +++ b/code/datums/diseases/advance/symptoms/weight.dm @@ -33,7 +33,7 @@ Bonus M << "[pick("You feel blubbery.", "You feel full.")]" else M.overeatduration = min(M.overeatduration + 100, 600) - M.nutrition = min(M.nutrition + 100, 500) + M.nutrition = min(M.nutrition + 100, M.max_nutrition * 1.25) return @@ -114,6 +114,6 @@ Bonus switch(A.stage) if(4, 5) M.overeatduration = 0 - M.nutrition = 400 + M.nutrition = M.max_nutrition return \ No newline at end of file diff --git a/code/game/gamemodes/changeling/changeling_powers.dm b/code/game/gamemodes/changeling/changeling_powers.dm index 366c5085147..1704d81d764 100644 --- a/code/game/gamemodes/changeling/changeling_powers.dm +++ b/code/game/gamemodes/changeling/changeling_powers.dm @@ -236,7 +236,7 @@ var/global/list/possible_changeling_IDs = list("Alpha","Beta","Gamma","Delta","E T.dna.real_name = T.real_name //Set this again, just to be sure that it's properly set. changeling.absorbed_dna |= T.dna - if(src.nutrition < 400) src.nutrition = min((src.nutrition + T.nutrition), 400) + if(src.nutrition < max_nutrition) src.nutrition = min((nutrition + T.nutrition), max_nutrition) changeling.chem_charges += 10 changeling.geneticpoints += 2 diff --git a/code/game/machinery/rechargestation.dm b/code/game/machinery/rechargestation.dm index 47d0b1008d7..0ee35951d9b 100644 --- a/code/game/machinery/rechargestation.dm +++ b/code/game/machinery/rechargestation.dm @@ -105,9 +105,9 @@ R.adjustFireLoss(-wire_rate) else if(ishuman(occupant)) var/mob/living/carbon/human/H = occupant - if(!isnull(H.internal_organs_by_name["cell"]) && H.nutrition < 450) - H.nutrition = min(H.nutrition+10, 450) - cell.use(7000/450*10) + if(!isnull(H.internal_organs_by_name["cell"]) && H.nutrition < H.max_nutrition) + H.nutrition = min(H.nutrition+10, H.max_nutrition) + cell.use(7000/H.max_nutrition*10) /obj/machinery/recharge_station/examine(mob/user) diff --git a/code/modules/mob/living/carbon/alien/diona/diona_nymph.dm b/code/modules/mob/living/carbon/alien/diona/diona_nymph.dm index e02926b06dc..1328d118c9e 100644 --- a/code/modules/mob/living/carbon/alien/diona/diona_nymph.dm +++ b/code/modules/mob/living/carbon/alien/diona/diona_nymph.dm @@ -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. diff --git a/code/modules/mob/living/carbon/alien/diona/life.dm b/code/modules/mob/living/carbon/alien/diona/life.dm index f8e44039944..b88b1dbb66d 100644 --- a/code/modules/mob/living/carbon/alien/diona/life.dm +++ b/code/modules/mob/living/carbon/alien/diona/life.dm @@ -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 diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index 692a7b1194c..16ed79de598 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -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 diff --git a/code/modules/mob/living/carbon/diona_base.dm b/code/modules/mob/living/carbon/diona_base.dm index b2f8dac1be7..51203359426 100644 --- a/code/modules/mob/living/carbon/diona_base.dm +++ b/code/modules/mob/living/carbon/diona_base.dm @@ -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) diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index 79c3a22db60..622ba8ffd78 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -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 diff --git a/code/modules/mob/living/carbon/human/human_movement.dm b/code/modules/mob/living/carbon/human/human_movement.dm index 08ae2b8022d..fb16cea1a6b 100644 --- a/code/modules/mob/living/carbon/human/human_movement.dm +++ b/code/modules/mob/living/carbon/human/human_movement.dm @@ -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 diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index 6514c219323..25903c49024 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -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 << "You feel weak." + 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 << "Your hair falls out." + 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 << "You feel weak." - 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 << "Your hair falls out." - 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 << "You feel strange!" + 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 << "You feel strange!" - 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) diff --git a/code/modules/mob/living/carbon/human/species/species.dm b/code/modules/mob/living/carbon/human/species/species.dm index 21fa847af3c..bfd54d1e784 100644 --- a/code/modules/mob/living/carbon/human/species/species.dm +++ b/code/modules/mob/living/carbon/human/species/species.dm @@ -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, diff --git a/code/modules/mob/living/simple_animal/simple_animal.dm b/code/modules/mob/living/simple_animal/simple_animal.dm index ac5544560c5..2bedb4f7a4a 100644 --- a/code/modules/mob/living/simple_animal/simple_animal.dm +++ b/code/modules/mob/living/simple_animal/simple_animal.dm @@ -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 diff --git a/code/modules/mob/mob_defines.dm b/code/modules/mob/mob_defines.dm index 118a98ca3e4..e42c5231ae2 100644 --- a/code/modules/mob/mob_defines.dm +++ b/code/modules/mob/mob_defines.dm @@ -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 diff --git a/html/changelogs/Nanako-Nutrition.yml b/html/changelogs/Nanako-Nutrition.yml new file mode 100644 index 00000000000..1a87562bd17 --- /dev/null +++ b/html/changelogs/Nanako-Nutrition.yml @@ -0,0 +1,36 @@ +################################ +# Example Changelog File +# +# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb. +# +# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.) +# When it is, any changes listed below will disappear. +# +# Valid Prefixes: +# bugfix +# wip (For works in progress) +# tweak +# soundadd +# sounddel +# rscadd (general adding of nice things) +# rscdel (general deleting of nice things) +# imageadd +# imagedel +# maptweak +# spellcheck (typo fixes) +# experiment +################################# + +# Your name. +author: Nanako + +# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. +delete-after: True + +# Any changes you've made. See valid prefix list above. +# INDENT WITH TWO SPACES. NOT TABS. SPACES. +# SCREW THIS UP AND IT WON'T WORK. +# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries. +# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog. +changes: + - tweak: "Nutrition is now randomised on spawning"