Project K9 is back - Spawning new PawnKinds on the map

Started by isistoy, June 15, 2015, 02:03:43 PM

Previous topic - Next topic

isistoy

Hello,

Some of you might have heard about mod project K9 trying to be re-upped and we are certainly in need of your modding and game knowledge to help us with our endeavor.

The main objective of this mod, for those who don't know what I am talking about, is to have dogs, as herds, who could be tamed by colonists.

They start wild and can be tamed by "Social" pawns. When done, they can take part to some colony's basic works, like hauling stuff, herding around with colonist hunting, and other things I'd be glad to describe in details.
If you wish to know more and possibly participate with us to the mod itself, we are looking for other people's help, with the tech side also (Project K9 (Third Times the Charm!))

My questions start when you tame the dogs: they have to become newly permanent "guest" pawns (a new faction is allocated to them currently, when tamed) and we would like to be able to make them rely on their specific random Stories (potential Bio, Traits and Skill Sets).

I posted a quick screenshot of what we currently have.

Now, this is what some part of the code that deals with the Bio part when spawning a new Pawn (PawnGenerator.GeneratePawn()):
PawnBioGenerator.GiveAppropriateBioTo(newPawn, faction.def);
...
GiveRandomTraitsTo(newPawn);
newPawn.story.GenerateSkillsFromBackstory();
if (faction.def == FactionDefOf.Colony)
{
       newPawn.workSettings.EnableAndInitialize();
}


Then, in BioGenerator, code to select a bio from AllBios:
public static void LoadAllBios()
{
    IEnumerator<PawnBio> enumerator = XmlLoader.LoadXmlDataInResourcesFolder<PawnBio>("Backstories/PlayerCreated").GetEnumerator();
...
IEnumerable<PawnBio> source = SolidBioDatabase.allBios.Where<PawnBio>(new Func<PawnBio, bool>(storeyab.<>m__125));
...
storeyab.<>m__125:
for (int i = 0; i < bio.adulthood.spawnCategories.Count; i++)
{
      if (bio.adulthood.spawnCategories[i] == this.backstoryCategory)
      {
            return true;
      }
}


Question: where can I edit these resources? Do we have examples of BackStories, possibly also some structure to link with Skill & Trait sets maybe?

PS: I will also post sthg else regarding worksettings, related to ThinkTrees, as we also define specific nodes and JobGivers there for our doggys.

Thanks in advance for your reading and might :)

[attachment deleted due to age]
<Stay on the scene like a State machine>

isistoy

Upping it up...
No one to help what's with these Backstories/PlayerCreated ?
<Stay on the scene like a State machine>

Tynan

You can't change backstories by changing files, I think. I believe you'd have to modify the backstory database (sorry I can't remember the class name) at runtime. Some things might be private so you may have to inject data using reflection.
Tynan Sylvester - @TynanSylvester - Tynan's Blog

isistoy

Yes, discussing with friends, we thought maybe this was some reserved part, not open to direct edition.
OK, thanks Tynan.

EDIT: I believe the class in question to be the well-named BackstoryDatabase, which possess a public AddBackstory() method.
After adding new ones at the start of the game, I think it's possible to try the BioGenerator methods with the BackstoryCategory criteria present in factions.
Hopefully, looking good this way...
EDIT2, for self: the join can be made on Backstory.SpawnCategory = FactionDef.BackstoryCategory
<Stay on the scene like a State machine>

mipen

Bit of a self plug here, but if you take a look at by Backstories mod, it handles creating and adding new backstories through the use of defs. Anyways, from what I've learned of the backstories, all their data is stored in a UnityEngine assests file, which means that we cannot edit them. It is possible to change them during runtime though. I can't remember the method and class names, but the BackstoryDatabase holds all the loaded backstories, and you can add and remove backstories from it during runtime. Each backstory is given a generated unique save key (just  a string) which is used as the key to retrieve it from the database. This makes it difficult as they use randomly generated numbers appended to their titles as the save key, so it isn't really possible to get them totally accurately. But anyways, if you're looking to add your own backstories, use my backstories mod. In runtime, you can run the BackstoryDef.GetUniqueSaveKeyFor() method which will give you the save key for the backstory def, so you can retrieve it from the database. Just add the BackstoriesCore assembly as a reference like you do for the RimWorld assembly. In the def, if you add <shuffleable>false</shuffleable> then the backstory will not be able to be randomly assigned to any pawn, you will have to specifically assigned it in runtime. This lets you make backstories that aren't used by any random pawns, only the ones you specifically want to use it. You don't want to use PawnBios, as they are a combination of a name and childhood and adulthood backstory, and are only used once per game. So you'll only ever see one pawn with any one bio. They are unique. If you make your own method to spawn your pawns, you can assign everything it needs, the backstories, the different trackers it will use, everything. Sorry for the information dump :) Let me know if you need any help, I've had to deal with a lot of the problems that come with adding new pawns.

isistoy

Hello mipen,

I am going to have a look. Thanks for help guys!
<Stay on the scene like a State machine>

isistoy

By the way, this game is really amazing!
The fact that the team that designed this piece of simulation art here is so small leaves me breathless.

<Stay on the scene like a State machine>

isistoy

UPDATE: I now have problems with paths of our custom pawns.
They conditionaly can wander the colony when they are tamed, but currently, they cross doors without problems and without activating doors animations (pass-through).

QUESTION: anyway I can avoid it when Wander colony is active in their thinktree node?
<Stay on the scene like a State machine>