Is it possible to make colonist eat more? Or walk better?

Started by CyberTao, May 04, 2015, 03:40:44 PM

Previous topic - Next topic

CyberTao

I had an idea for a mod, and by throwing together some crudely done files I've been more or less able to accomplish my goal, save for 1 thing.

I want colonist to need to eat more often depending on their attachments (Bionics), so I was wondering if it was even possible to increase the rate that the Food bar decreases based on metabolism (Which should affect it by default I feel, but it doesn't). Basically I want a colonist with 200% metabolism to have to eat twice as often.

The other question I have is if it is possible to change the tile speed modifier. Playing around with different kinds of bionic legs, it would be nice if some of them were more or less affected by the type of tile (Doubled or no movement speed penalty).

Latta

You would need to make a new need class and assign it to NeedDef, overwriting vanilla hunger.

For the second, I doubt it is possible.

CyberTao

Ahkay, I know where to focus my attention now. A shame about the move speeds, but there are other factors I could play with I guess.

Thanks for the direction o7

Edit; I have absolutely no idea what anything here does, but from what I've pulled out so far, I'm guessing this needs many files.

CyberTao

I hate to be the whiny, annoying wannabe modder, but I have idea what I am needing to do here.

I managed to copy the Need_Food from the Assembly.dll, and I got the mod to acknowledge it, but it keeps throwing a few errors at me and I don't know what they mean. http://imgur.com/a/qneSK#0

I dunno how to fix it, but I tried going around with an alternate method and not using a dll for my idea, but it's a lot shittier feeling to say the least. The code is basically unmodified save for the references at the top, I haven't even tried to alter it yet and it doesn't work. I'm probably missing something simple, but no one I know understands C# and Unity, and my understanding is basically sub-basic at best. Would laugh if I was going about this the wrong way the entire time.

Relevant code bit.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RimWorld;
using Verse;
using UnityEngine;

namespace CC
{
    public class NewNeed_Food : Need
    {
        private const float BaseFoodFallPerInterval = 2.666667E-05f;
        private const int TicksBetweenStarveDamage = 15000;
        private const float MalnutritionDamAmount = 0.066666f;
        private int tickToStarveDamage;

        public bool Starving
        {
            get
            {
                return this.CurCategory == HungerCategory.Starving;
            }
        }

        public float ThreshUrgentlyHungry
        {
            get
            {
                return this.pawn.RaceProps.FoodLevelWantEat * 0.45f;
            }
        }

        public float ThreshHungry
        {
            get
            {
                return this.pawn.RaceProps.FoodLevelWantEat * 0.9f;
            }
        }

        public HungerCategory CurCategory
        {
            get
            {
                if ((double)this.CurLevel < 0.00999999977648258)
                    return HungerCategory.Starving;
                if ((double)this.CurLevel < (double)this.ThreshUrgentlyHungry)
                    return HungerCategory.UrgentlyHungry;
                return (double)this.CurLevel < (double)this.ThreshHungry ? HungerCategory.Hungry : HungerCategory.Fed;
            }
        }

        public float FoodFallPerInterval
        {
            get
            {
                switch (this.CurCategory)
                {
                    case HungerCategory.Fed:
                        return 2.666667E-05f * this.pawn.RaceProps.hungerRate;
                    case HungerCategory.Hungry:
                        return (float)(2.66666665993398E-05 * (double)this.pawn.RaceProps.hungerRate * .5 );
                    case HungerCategory.UrgentlyHungry:
                        return (float)(2.66666665993398E-05 * (double)this.pawn.RaceProps.hungerRate * .25 );
                    case HungerCategory.Starving:
                        return (float)(2.66666665993398E-05 * (double)this.pawn.RaceProps.hungerRate * .150000005960464 );
                    default:
                        return 999f;
                }
            }
        }

        public override int GUIChangeArrow
        {
            get
            {
                return -1;
            }
        }

        public float NutritionWanted
        {
            get
            {
                return 1f - this.CurLevel;
            }
        }

        public NewNeed_Food(Pawn pawn)
            : base(pawn)
        {
            if (pawn.RaceProps.Humanlike)
                this.CurLevel = 0.8f;
            else
                this.CurLevel = Rand.Range(0.5f, 0.9f);
        }

        public override void ExposeData()
        {
            base.ExposeData();
            Scribe_Values.LookValue<int>(ref this.tickToStarveDamage, "ticksToNextStarveDamage", 0, false);
        }

        public override void NeedInterval()
        {
            this.CurLevel -= (float)((double)this.FoodFallPerInterval * 150.0);
            this.tickToStarveDamage -= 150;
            if (this.tickToStarveDamage > 0)
                return;
            if (this.Starving)
                HealthUtility.AdjustSeverity(this.pawn, HediffDefOf.Malnutrition, 0.066666f);
            else
                HealthUtility.AdjustSeverity(this.pawn, HediffDefOf.Malnutrition, -0.066666f);
            this.tickToStarveDamage = 15000;
        }

        public override void DrawOnGUI(Rect rect)
        {
            if (this.threshPercents == null)
                this.threshPercents = new List<float>();
            this.threshPercents.Clear();
            this.threshPercents.Add(this.ThreshHungry);
            this.threshPercents.Add(this.ThreshUrgentlyHungry);
            base.DrawOnGUI(rect);
        }
    }
}

soltysek

if i good understand you copy and past same class as exist in system ? Basicly error say that you reference to class itself not a instance of class . So basicly you reference to class prototype not class on object . This error is thro probably becouse system create instance of class need_food on pawn create and not your class , but i duno how to fix it i never mess with this part of game :/

CyberTao

I'm not entirely sure what cha mean, but I think I get it?

The Pawn class uses the Pawn_NeedsTracker, and Pawn_NeedsTracker uses Need_Food.
I set the Xmls to use CC.NewNeed_Food, but the Pawn verse is still dependent on the original Need_Food, so the errors are probably because of that difference. Need_Food is also referenced in JobGiver_GetFood (which I can't even edit, because a part of it is locked and prevents me from compiling a dll)

I originally played around with replacing those files as well, but you can imagine the headache caused by trying to replace the Pawn class (I couldn't get it to work, because there was 2 definitions of Pawn going around).

So I can't edit the other files (Pawn and JobGiver_GetFood) due to widespread complications and a locked verse(?). Is it possible to set it so that the code can use Need_Food and NewNeed_Food interchangeably? Another possibility is maybe trying to alter something else?

I've come across another bit called hungerRate found in RaceProperties, but I can not seem to find it anywhere else aside from in Need_Food. Would it be worth investigating that, or would it end up in a similar place as trying to edit Need_Food?

This probably all sounds like gibberish.

Dante King

200% would mean LESS eating, and many cybernetics mods do this, 50%would mean twice as much eating, the higher it goes, the more efficient it is.

CyberTao

Quote from: Dante King on May 07, 2015, 07:39:55 AM
200% would mean LESS eating, and many cybernetics mods do this, 50%would mean twice as much eating, the higher it goes, the more efficient it is.
Depends on how you look at it. A high metabolism means you convert food into energy at a faster rate, people who work out tend to have a higher metabolism because they require more energy, and the foods they eat are high in protiens, which can generate more energy. So 200% metabolism could mean that you are using 200% more energy than the average person, so when you are eating the same foods, you may need twice as much, and a lower metabolism means it would take longer to convert that food to energy (hence fat).
Just my basic understanding.

Do tell me which mods actually make Metabolism do something as well. I know there are mods that add parts that up the efficiency, but in testing it actually did bugger all for me. If I increase metabolism it doesn't affect the rate at which the food need drops at all. I put 2 pawns next to each other, one with twice the metabolism and there was no difference in the health.

Most of the stats (blood pumping, breathing, metabolism) do nothing, except cause death if they hit 0. I want to add more function onto them, if you know any mod that does that, feel free to share it so I can get a general idea of what I'm meant to do.

Dante King

Actually no, all stats effect skills and stats blood pumping and filtration means fasting healing

CyberTao

Quote from: Dante King on May 07, 2015, 08:21:14 AM
Actually no, all stats effect skills and stats blood pumping and filtration means fasting healing
Okay? Still doesn't help me. I want metabolism to affect the speed at which the Food need drains, which it currently does not (might affect Eating speed, but that is not what I want).

If you know a mod that affects the Food need, do share with me. I checked Surgery Extended and Bionics and Expanded Prosthetic & Organ Engineering (the 2 biggest Cybernetics mods that I know of). Neither of them alter the Food need at all, nor does Metabolism affect the need in vanilla.

Dante King

Then you need someone else, I've only made a buff mod so far.