Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - o-o-o

#1
Super double-plus extra thanks bigly to erdelf for his Humanoid Alien Races mod, github site, discord channel, and near-real time code updates yesterday to accommodate my requests (think I'm kidding? check mod update history against chat text in his discord help channel)
Special thanks to Xnope for his Xnopecore mod and github site, which got me into modding, taught me a lot about XML and showed that what I wanted to do was possible.

I was able to get backstories pushed down to the PawnKindDef level as desired by doing the following:
1.  Download latest version of Humanoid Alien Races 2.0 (HAR) by erdelf
2. for each pawn type with its own <PawnKindDef> add the following code:
Quote<modExtensions>
      <li Class="AlienRace.Info">
        <usePawnKindBackstories>true</usePawnKindBackstories>
        <allowHumanBios>false</allowHumanBios>
        </li>
      </modExtensions>

The <usePawnKindBackstories> is what pushed the backstory to the pawn kind level, as supported within
The <allowHumanBios>false is what turns off the special (backer?) bios, that would otherwise also get used for the pawns.  Setting this to false forces the pawns to ONLY have backstories from your new category

you will also need to set the backstory category in <PawnKindsDef> with the following line:

Quote<backstoryCategory>Miner</backstoryCategory>

This makes your pawn type only pull backstories that carry the "Miner" tag

3. Your custom backstory will then start like this: 

Quote<Defs>
   <AlienRace.BackstoryDef>
       <defName>Miner1</defName>
      <slot>Adulthood</slot><!-- choose Childhood or Adulthood -->
      <title>Miner short</title>
      <titleShort>Prospector</titleShort>
      <baseDescription>HECAP was a miner for a heart of gold.</baseDescription>
      <spawnCategories><li>Miner</li></spawnCategories> 

Note that the <spawnCategories>Miner in the last line is what gives this the "Miner" tag, and thus findable by PawnKindsDef.

I have been testing this with my faction mod and works like a charm. 
Note that when starting Rimworld, the other pawntypes in my faction that I have not yet done this process to gives some yellow level error; basically they all want the <modExtensions> thing to set their backstories or something.  When I get around to fleshing all of them out this warning on startup will go away.   

#2
Partial success, making good progress using the AlienRaces framework.  Will write up a solution when I get all the pieces together.  I can get my custom backstories introduced at the <PawnKindDef> level, so each pawnkind could have their own set of backstories.  But I can't figure out how to disable the backer backstories from still being injected. 

Does anyone know how to disable the backer backstories from a faction?  I am ok with them being in the rest of the game, just not for my custom faction.
#3
@jamaicancastle - good question actually, not sure why I was sure that it didn't work that way, but because of that never bothered to try.  Some of the notes for Xnopecore indicated that you could list a backstory category at the PawnKindsDef level, but that it would be ignored by the program and only pulled from the faction level.  Plus if you could do it, I figured someone would have already put it in a mod by now, and I scoured a lot of XML from faction mods learning my way around without finding any pawn level backstories.

@LasurDragon - thanks for the update, want to verify first that backstories don't work at the PawnKindsDef level, but will then try the updated version.
#4
Preface - I am currently modding XML files only.  I aspire to move to C# coding at some point, but have been working to push my mod ideas as far as I can using XML before making the leap into coding. But I have something central to my mod idea that, as far as I can tell, requires code work.

I am working on a mod for a new faction of miners.  Basically, there are four different pawn kinds created for this faction as <PawnKindDefs>; Miners, Guards, Teamsters and Cooks.  I can currently assign a new backstory category for the faction in <FactionDef>, but that would randomly assign these backstories to each and all of these four pawn types.  What I want to do is instead "push" the backstory category down to the <PawnKindDef> level.  This would allow the Miners to have their own group of backstories, the Guards to also have their own backstories, etc. 

What this gets me is that my Miners could always be miners.  All of their backstories would have significant boosts to mining and construction, as well as some minor nerfs to other skills (like -2 to artistic or -2 to growing).  And I could force <requiredWorkTags> to make sure that they could mine and construct - if I allowed the use of vanilla child backstories it would not use any that disabled mining and/or construction.  Similarly, my Guards would be guards, focused on shooting and melee, eliminating any traits or options that would make them non-violent.  My Teamsters would be animal handlers, maybe with some minor bonus to medicine.  And my Cooks would of course have a bonus to cooking.

As far as I can tell, this can not be done in XML but requires code modification.

Fortunately, this code modification has already been done.  Unfortunately, the original modder has apparently abandoned his mod as of A17.  I tried using it in the current B18, got a bunch of errors, and quickly gave up on it.  The mod in question is called Xnopecore by Xnope and is available via the steam workshop.  He also has his code linked in github (link found in in Xnopecore steam page).  I have tried to contact him to request an update to B18, but received no response.  The code is open to the community; on github he states "I love my utilities, but feel free to copy my pasta. Credit would be a nicety, but not necessary." 

Note that the Xnopecore mod has a bunch of other tools in it for calculating triangles and areas and stuff that were to be used in a major content (unfinished?) mod by the author.  I don't really know what they do or how you would use them.  I am only interested in the backstory content of the Xnopecore mod.

Can anyone help resurrect the backstory portion of this mod, or alternatively write it up fresh?  Bonus points if you can show me how to do it solely within XML files.
#5
Using StockGenerator_MultiDef worked, I was able to add just chicken, pig and cow meat to the caravan trade items.  I had seen that function a bunch when looking at the vanilla TraderKindDefs, but did not have a sense of how and where to use it. 

As an added bonus, I also now know how to have traders sell human meat, useful for when I finally make my cannibal faction!
#6
Preface - I am currently only working with XML files; actual programming remains out of reach

I am attempting to restrict the types of meat that my custom faction traders will sell to only domesticated animals - beef, pork and chicken only , and no boomrat, cobraflesh or yorkshire terrier meat for sale.  I used the <tradetags> function a bunch to successfully restrict what guns and clothes the traders would sell, but I can't get it to work for meat.  The <tradetags> for animals appears to be only for the sale of whole animals (so I could potentially make a vendor only sell chickens, cows or pigs) and not their meat products. 

The option I want to pursue is to make a custom ThingCategoryDef that is a child of the MeatRaw ThingCategoryDef.  That way I can just use the StockGenerator_Category function to pull from that group.  But I can't seem to find where you actually populate a ThingCategoryDef.  Is this hardwired in code, or did I miss it somewhere?

Alternatively, is there another way of doing this?
#7
Awesome, this was exactly what I was looking for.  All of my tinkering so far has been in the XML files.  I aspire to (someday) do some code work via Harmony to implement some features that are not XML possible, but for now the code is one big black box for me.  So I would have had a very hard time finding this on my own.
#8
While working with TraderKindDefs for a new faction, I want to allow for some pricing flexibility and arbitrage (buy low from this faction, sell high to that faction), but the only useful price modifier that I can find is <price>Expensive</price>.  In looking at other faction mods, I found <price>Normal</price> in the Umbra Company mod, but figure this has no real pricing effect.  I was pretty sure I came across something like "Cheap" or "Inexpensive" in some of these other mods, but didn't write it down at the time and can not find it now.

Anyone know what the other available price modifiers are?

Note that I checked the CoreXML A17 file, which is normally a really good asset.  I now strongly suspect that it was built by querrying all of the vanilla XML docs; this generated a list of all of the functions that were used, but that there are other existing functions that were not used in the vanilla XML files that is does not report.
#9
I am working on spawn inventory for my faction mod, and can't figure out how to do what I figured was a simple change.  My faction is of a mining group, so I wanted them to spawn with some silver, some gold, and maybe some jade.  Just about every faction example I found uses the <subOptionChooseOne> command to choose a single thing from a list of 2 or 3 item types.  I can force pawns to 100% spawn with a single item type, but can not get them spawn with 2 or more item types. 

I found a post from 2016 that showed the use of a <subOptionTakeAll> command to allow a list of different items to generate upon spawn, but either I can't get the syntax right or that function has been removed from the code.  The XML Auto-Documentation for Rimworld 0.17.1557 does not list <subOptionTakeAll> as a current function, and all of my testing results in errors.

Is there another command to pull spawn inventory from a list?

EDIT - I got sloppy with all my copy and paste of trial code, I left an extra </inventoryOptions> at the bottom.  The <subOptionsTakeAll> command works for allowing multiple spawned inventory item types.

And yet it doesn't show up on the XML Auto-doc list.  Wonder if that list was generated from functions used in xml code, but functions that exist but never get used just don't show up? 

#10
A bunch of stuff worked.

Method 1 worked with slight modification (forgot slash at end of tags)
Quote<Operation Class="PatchOperationReplace">
    <xpath>Defs/ThingDef[defName = "Apparel_VestPlate"]/apparel/tags</xpath>
    <value>
      <tags>
          <li>RaidMonkey</li>
          <li>Military</li>
      </tags>
    </value>
  </Operation>

I didn't want to try Method 2 - as I understand it, it looks for a specific location (first item in list) and replaces whatever it finds, as opposed to searching for the specific target (Outlander) and just replacing that.  Seems like a potential nightmare when things change in the vanilla code in chasing down those misapplied operations.

Both of the advanced querry methods worked:

Quote<Operation Class="PatchOperationReplace">
    <xpath>*/ThingDef[defName = "Apparel_VestPlate"]/apparel/tags/li[.="Outlander"]</xpath>
    <value>
      <li>RaidMonkey</li>
      </value>
    </Operation>

and

Quote<Operation Class="PatchOperationReplace">
    <xpath>*/ThingDef[defName = "Apparel_VestPlate"]/apparel/tags/li[text()[contains(.,"Outlander")]]</xpath>
    <value>
      <li>RaidMonkey</li>
      </value>
    </Operation>

My rich pawns with the Outlander apparel tag never spawned armored vests, and my rich pawns with both Outlander and RaidMonkey tags spawn standard apparel plus the armored vests.

Can you comment on the differences between the two advanced querry operations?  Is one more efficient than the other? Are there more complex cases where one would be preferable to the other?



#11
Still playing around with faction and pawn generation.  Looking to include some significant variation in pawns.  Found <skipChance> and <subOptionsChooseOne> functions while looking at vanilla and other mods, but according to the CoreXML list I found they both have InventoryOptions as a parent.  These functions will be very useful when I turn my attention to changing the makeup of spawned pawn inventory items, but I was hoping (and failing) at using them for spawned apparel and weapons.

I would have liked, for example, to have a pawn spawn with <apparelRequired> of a Bowler hat, Jacket and Collar shirt, OR to spawn with <apparelrequired> of a Cowboy hat, T-shirt and a Duster.  The <subOptionChooseOne> function would work for this, but it appears to only work for inventory items (as opposed to equipped items). 

Is there another RNG function that can be applied to aspects other than inventory?
#12
I think there is a list in the source code.  Still kind of new at this, but anywhere I see <li>stuff</li> i read that as a list, even if it has only a single entry.  The Apparel_VestPlate/apparel/tags section has two entries:
Quote<tags>
        <li>Outlander</li>
        <li>Military</li>
      </tags>

I want to replace "Outlander" with "RaidMonkey".   I don't know how to correctly select the list item "Outlander" in order to get xpath to replace it.  I am fine with leaving "Military" as-is.  I am also fine with Outlanders spawning without the benefit of an armored vest.  Why would city-folk need body armor anyway?  City guards could always use the Military apparel tag.
#13
I am working on faction mods, and have made good use of some very basic xpath stuff.  Specifically, I have been adding tags to weapons so that custom pawntypes would wield specific vanilla weapons.  All good there so far; all my dudes spawn with their proper weapons. 

While trying to tweak the spawn apparel for the new pawns, I was bothered that my mostly non-violent industrial-tech and Outlander apparel tag pawns wanted to take a lot of their apparel money and buy armor vests.  Instead of forcing a lot of specific apparel on the pawns and leaving no money left over for the armor vests, I decided to use xpath to just modify the armor vests.  Specifically, I wanted to replace one of the list items under Apparel_Various/Apparel_VestPlate/apparel/tags.  I would keep the Military list item, but change the Outlander list item to a custom new tag ("RaidMonkey" in this case).  I can't seem to get the path properly selected, or don't understand the subtleties of nodes vs list items or something.  Using the following code I get an error that my list items do not correspond to any field type in type ApparelProperties.



Quote<Operation Class="PatchOperationReplace">
    <xpath>*/ThingDef[defName = "Apparel_VestPlate"]/apparel/tags</xpath>
    <value>
      <li>Military</li>
      <li>RaidMonkey</li>
      </value>
    </Operation>

I have not found any good examples of replacing list items in patches in the other faction mods I have been looking at, nor did I find an example in this thread that was easy enough for me to translate to my specific case.  The more I see of xpath, the more I like it for modding, so I expect to get a lot of mileage out of replacing or removing list items found in tags or weaponTags.
#14
Been doing a lot recently with xpath to force pawntypes to wield specific vanilla weapons by adding new <weaponTags>, so patching a tag onto the apparel would not be a problem.

But that approach would only force them to spawn with specific apparel, when what I really want to do is force them to not spawn with specific apparel. 

I could force an entire outfit (hat, jacket, shirt and pants) and give them essentially no <apparelMoney> to afford an armored vest upon spawn, but would that give them crappy starting apparel because of the low money value, or is forced apparel not taken out of the <apparelMoney> pool?
#15
I am making a relatively non-violent industrial-era faction, but when giving them the money in <PawnKindDef> to get some decent clothing, they frequently want to spawn with an armored vest.  I thought I ran across a method for prohibiting apparel types when poring over other mods for new factions, but can not remember where I saw it (or if it even exists).

is there a way to prohibit pawns from spawning with specific apparel?  Can I stop my peaceniks from spawning with body armor?