Programming carnivores

Started by jakowitz, April 29, 2014, 10:37:00 PM

Previous topic - Next topic

jakowitz

Hi it's jakowitz again, I was wondering if there is any way to program animals to be a carnivore. I tried messing around with it to no avail. Any help or guide would be greatly appreciated.

Tynan

Under <race>, there is a <diet> field, which can be:

   NeverEats
   Omnivorous
   Herbivorous
   Carnivorous

This won't make them attack prey, but it will make them consume meat. Or at least, it should.
Tynan Sylvester - @TynanSylvester - Tynan's Blog

jakowitz

Thank you, do you have any tips on how to make the animals attack their prey?

Tynan

You'd have to create a custom ThinkTree and probably a custom coded ThinkTreeNode that finds targets for them to attack when they're hungry.
Tynan Sylvester - @TynanSylvester - Tynan's Blog

jakowitz


pidggit

#5
Quote from: Tynan on April 30, 2014, 09:46:40 PM
You'd have to create a custom ThinkTree and probably a custom coded ThinkTreeNode that finds targets for them to attack when they're hungry.

I'm actually working on this exact thing. I have a ThinkTree that makes pawns find other pawns that have a smaller body size than itself and attack it. However, I'm having trouble trying to find a way to have it eat the corpse.

I've run through a few different ideas of how to get this done. I was thinking the easiest way would be to convert the corpse to meat and let the normal eating process take care of itself. I think I would prefer to see the carnivore just go through the eating steps on the corpse itself, as it feels more authentic. But I can't seem to figure out how the eating process works.

I'm using dotPeek to look through the existing decompiled code to get a sense of how to make a JobDriver, but all the code is unreadable in dotPeek.

Is there more to a JobDriver than just creating the Toils needed to complete the Job? Below is my JobDriver_EatCorpse.MakeNewToils() method.


        protected override IEnumerable<Toil> MakeNewToils()
        {
            Log.Message("Making new toils to EatCorpse: " + this.TargetA.ToString() + " for: " + pawn.ToString());
            List<Toil> toils = new List<Toil>();
            toils.Add(Toils_Reserve.ReserveTarget(TargetIndex.A, ReservationType.Feed));
            toils.Add(Toils_Goto.GotoThing(TargetIndex.A, PathMode.InteractionSquare));
            toils.Add(Toils_Food.ChewFood(pawn, 1.0f));
            toils.Add(Toils_Food.FinishChewing(pawn));

            return toils;
        }


I suspect I'll need to make a new Toil that takes a corpse and replenishes Hunger needs off of it, but I'm unsure of that, as well, since most of the code around eating is also obfuscated to me.

Any help would be greatly appreciated.

EDIT: Oo, just saw that you posted some of the Source Code.. time go delving. Maybe I'll be able to figure this out off of that, alone. :)

bleedo

The muffalobreeding mod has some code that makes toils. See jobdriver_breeding. :)

Tynan

You should get the basics of what you need from the source code.
Tynan Sylvester - @TynanSylvester - Tynan's Blog