TUTORIAL - Creating Custom Scenarios

Started by ItchyFlea, February 07, 2014, 12:02:11 AM

Previous topic - Next topic

ItchyFlea

First and foremost: If anything in this article doesn't make sense, or seems to skip a step or two, let me know and I'll fix it.
Updates to RimWorld during the alpha phase of development may change how information is stored in save files, so for the time being, this article is accurate for RimWorld 0.1.334 only.

Getting Started:
The very first thing to do is generate a world that will fit with what you want to accomplish. Depending on luck, this could end up being the most time consuming part. To save yourself some time, don't worry about what storyteller you pick, or what your colonists are like. They can be changed later on.
If a map looks semi-suitable but not ideal, save it before generating another map.  You may never find a better map.

Building the World:
This can be done in two ways, through normal gameplay or through God mode.
Normal gameplay has the advantage of the map looking 'lived in'. Blood spots in useful places, rubble in others, things like that. If you don't want to be bothered by the Storyteller AI sending raiders at you, it can be disabled in two ways.
First, open your save file in Notepad++ (or normal Notepad, or your OS equivalent.) and find this section: (Make a backup copy of the save file first before doing this.)
<Storyteller Class="Storyteller_ClassicEasy">
Once there, look through that section and find this part:
<StoryState>
<LastThreatQueueTime>-1</LastThreatQueueTime>
<NumThreatsQueued>0</NumThreatsQueued>
<LastQueueTicks>
<KeyList />
<ValueList />
</LastQueueTicks>
</StoryState>

To completely disable the AI, remove the entire <StoryState> section and replace it with this:
<StoryState IsNull="True" />
To disable the AI for a set period of time, just put in the amount of time (in ticks) in this section:
<LastThreatQueueTime>18500</LastThreatQueueTime>
I have yet to figure out exactly how many ticks are in a day in RimWorld, but it averages ~18,500 per in-game day.

God mode is found by ticking 'Development mode' in the Options screen, and then clicking on it in-game.

Development mode is quickest if you are building an elaborate base, or even just something simple like a containment area, and don't need the map to look lived-in.

Things that can be done:
IMPORTANT: Make frequent backups because if something goes wrong, RimWorld won't tell you, it'll just fail to load. Even something as small as a missed capitol letter is enough for a crash.

Disabling the StoryTeller AI:
See Building the World.

Changing the StoryTeller AI:
See attached file StoryTellers.txt.
Replace the entire StoryTeller section with the one you want from that file. (All 5 are in there.)

Changing teams:
This is actually quite easy, but a side effect is that the player cannot interact with things that are not on the Colonist team.

Almost everything in game looks a little like this inside the save file:
<Thing Class="Building">
<Def>Wall</Def>
<ID>Wall50901</ID>
<Pos>(106, 0, 44)</Pos>
<Team>Colonist</Team>
<Health>280</Health>
</Thing>

In this case, we're looking at the <Team>Colonist</Team> section.

There are a few teams:
� Colonist
   ◦: This is everything that the player can control or interact with.
� Traveller
   ◦: These are the guys that wander from one side of the map to the other.
� Raider
   ◦: These are the guys that attack you from time to time.
� Psychotic
   ◦: When things have a mental break, they get put into this state. They will attack anything, sometimes even other members of their team.

There are a few special cases that need to be addressed if you change the team that humans and animals use, but nothing really to worry about with buildings. For buildings, if you want the player to not be able to interact with them, change them to 'Traveller'. If you don't want the raiders attacking them, change them to 'Raider'.

The section, <Health> is not as useful as it may appear. Setting it to a higher amount does nothing useful at all, because as soon as it takes any damage, the value shown reverts to it's correct amount. <Pos> is the items exact location in the world. This is useful for precise placement of pawns if your scenario requires it, or for building otherwise impossible things, like doubledoors.

The way I go about doing this is by placing a blueprint for sandbags where I want the new item. Then I save and quit the game, and search for this in the save file: Sandbags_Blueprint which will give me this to work with:
<Thing Class="Blueprint">
<Def>Sandbags_Blueprint</Def>
<ID>Sandbags_Blueprint30051</ID>
<Pos>(25, 0, 19)</Pos>
<Team>Colonist</Team>
</Thing>

If we change that to this:
<Thing Class="Building_Door">
<Def>Door</Def>
<ID>Door30051</ID>
<Pos>(25, 0, 19)</Pos>
<Team>Colonist</Team>
<Health>240</Health>
<DesirePowerOn>True</DesirePowerOn>
</Thing>

We now have a shiny new door instead of the sandbag blueprint. Please note the <ID> section. This must ALWAYS contain a unique number, and its best to use the number the game assigned to the blueprint.

Unfortunately triple doors are not completely possible at this time. They can be made, but only in one orientation.

That's it for teams.

Trader Ships:
You'll find them listed under: <VisitorManager>

I recommend getting a save file that contains at least one of each type of trade ship, as it's much easier to copy and paste them, rather than write them up from scratch. This save contains 3 of the 4 possible trade ships, Farming, Slaver and Combat. It does not have Industrial.
When it comes to traders, you can affect most things, except the prices for which they buy and sell things. That is controlled by the game at this point, and is affected the the social skill of whoever is communicating with the ship.

What each section covers:

<Visitor Class="Trader">
Pretty self explanatory. I don't think there are any other classes, so don't modify this section. Of course you can if you want to, but I don't know what will happen if you do.

<Name>John Larman</Name>
Do I really need to explain this?  :D

<TicksUntilDeparture>40000</TicksUntilDeparture>
This is how long they will stay in orbit before they leave. Remember, approx.~18,500 ticks is one day.
You can set this to an absurbly high number if you wish to make them stay in orbit for pretty much indefinitely.

<traderType>Slaver</traderType>
This determines what they can buy or sell.
The given example is a slave trader ship. Ships that deal with weapons are given this: <traderType>Combat</traderType>
Farming ships don't have this section at all. I don't know what industrial ships have.

<things>
This is a big section. If it's empty, instead of the header being <things>, it's <things />
I highly suggest just having a look at the attached file, and seeing the structure they have.
I've also attached what weapons they can have. Technically there are two more weapons, but they are unfinished and/or extremely overpowered. (One of them is the LM-15, the weapon the turret uses, the other is even more OP than that. (Hint: <Def>Gun_Minigun</Def>)

<commodities>
This is what the trader has as items you can buy and sell.
� <KeyList>
   ◦: Things like food, metal, uranium, etc. It's best not to modify this list, problems can occur.
� <ValueList>
   ◦: This is how many of each thing they have. The max number I use is 999999999, although you could probably use a higher number. There is an upper limit at which point problems start occurring. I don't know what that number is.

That's it for traders.

Letters
You'll find this listed under: <LetterStack>

These are the sometimes annoying notes that pop up on the side of the screen. You can use these to convey a message to the player.

� <Letters>
   ◦: This is just a container. If there are no letters, this will be: <Letters />
� <Letter Class="UI.Letter">
   ◦: This is the letter itself. I do not know if there are classes other than "UI.Letter".
� <Text>
   ◦: What the message is. Don't make the message too long.
� <LookTarget IsNull="True" />
   ◦: This is where the "Show me" button takes you inside letters such as notes about raiders landing. I have never dealt with this, so I always leave this as shown.

That's it for letters.

Research Topics:
You'll find this listed under: <ResearchManager>

� <CurrentProject>
   ◦: The currently selected topic for research.
� <ProjectList>
   ◦: Everything that can be researched. Note: It is impossible to remove research topics. The game reinserts them if removed.
� <ResearchProject Class="ResearchProject">
   ◦: The container for each different thing that can be researched. Inside here you will find this:
<ResearchProject Class="ResearchProject">
<RType>Hydroponics</RType>
<Label>Hydroponics</Label>
<Progress>0</Progress>
<TotalCost>22000</TotalCost>
<Description>Allows you to build hydroponics tables to rapidly grow crops indoors.</Description>
</ResearchProject>

Except for <RType> all these can be modified. So you can make a particular research item take far longer to research, or make it much quicker to research by changing the <TotalCost> section.
You can also set a research topic to being something that has already been researched by changing the <Progress> section to equal +1 of the <TotalCost> section. In this case, setting it to <Progress>22001</Progress> will mark Hydroponics as already researched.

That's it for research.

The Reservation Manager:
You'll find this listed under: <ReservationManager>

Ever tried to select something and seen a note stating that somebody else was already doing it? That's this section.
I've never really dealt with this section, but if you intend to give custom movement to pawns (Yes, you can make pawns walk from A to B if you want.) knowing about this section may help.

� <Reservations>
   ◦: The container for things reserved.

This is a typical reservation:
<ThingReservation Class="AI.ThingReservation">
<claimant>Pawn29549</claimant>
<resType>Total</resType>
<target>
<TargetThing>Potatoes24482</TargetThing>
</target>
</ThingReservation>

I haven't personally needed to make or edit these, so I can't tell you much about them. If you have, please explain what each section is in a reply below and I'll add it to this section.

However, I have needed to remove things from here. The <claimant> is the <ID> tag of the pawn who reserved this particular item. So if you manually remove something from the save, you'll need to remove their reservation from here as well.
Also, if you remove plants from the save file (not a fun task), be sure to remove all references to said plants from the reservation manager.

If you see something that has this: <claimant>Null</claimant> Remove it. This happens as a result of not using unique <ID> numbers for pawns, and essentially breaks anything that attempts to interact with the claimed thing.

That's it for the reservation manager.

The Raider Controller:
You'll find this listed under: <AIKingManager>

This is what raiders use to determine when to attack you after they have landed, and under what conditions they should consider fleeing from the fight.

� <KingList>
   ◦: The container for controlled raider teams. If you remove raiders from the game, it's best to remove them from this section as well, but not essential.

This is almost a typical AIKing: (This one is taken from my Zombie Defence scenario.)
<AIKing Class="AI.AIKing">
<Config>
<Team>Raider</Team>
<StagingTime>281610</StagingTime>
<AssaultingTime>320000</AssaultingTime>
</Config>
<FleeChecker>
<NumPawnsGained>1</NumPawnsGained>
</FleeChecker>
<Cortex>
<TicksSpentStaging>0</TicksSpentStaging>
<TicksSpentAssaulting>0</TicksSpentAssaulting>
</Cortex>
<BaseCenter>(10, 0, 189)</BaseCenter>
<OwnedPawns>
<Ref>Pawn110111</Ref>
</OwnedPawns>
</AIKing>


About each section.
First, this one:
<Config>
<Team>Raider</Team>
<StagingTime>281610</StagingTime>
<AssaultingTime>320000</AssaultingTime>
</Config>


� <Team>
   ◦: Pretty self explanatory.
� <StagingTime>
   ◦: How long they wander around before deciding to attack you. In this case, this guy will wait for 15 days before attacking.
� <AssaultingTime>
   ◦: The difference between this number and the <StagingTime> number is how long they spend attacking before giving up and leaving. I suggest looking into a normal raider AIKing to see what a normal number for this section would be. I have intentionally high for a reason.

Now about this section:
<FleeChecker>
<NumPawnsGained>1</NumPawnsGained>
</FleeChecker>


� <NumPawnsGained>
   ◦: To have the raiders leave under normal losses conditions, this is set to the exact number of raiders there are. Setting this to a number higher than the number of actual raiders will cause the raiders to leave after suffering fewer losses than what a normal raider would leave under. Setting this to a lower number will cause the raiders to stay, even after suffering heavy losses. Setting this to 1 will cause the raiders to never flee from a fight. They will fight until they are all dead.

Now about this section:
<Cortex>
<TicksSpentStaging>0</TicksSpentStaging>
<TicksSpentAssaulting>0</TicksSpentAssaulting>
</Cortex>


This is basically how long they have been in the world since they first landed. I suggest modifying the <Config> section rather than this one.

And the final two sections:
<BaseCenter>(10, 0, 189)</BaseCenter>
<OwnedPawns>
<Ref>Pawn110111</Ref>
</OwnedPawns>


� <BaseCenter>
   ◦: This is a single point on a map that they will basically revolve around while waiting. It's a circle with a 6 tile radius. Unless the raiders are actually contained somewhere, they may attack your colonists sooner than you anticipate if a colonist wanders too close. If you build a containment building out of ordinary walls, make sure to set the <team> of the walls to Raider, otherwise the walls will be attacked.

� <OwnedPawns>
   ◦: <Ref> is the <ID> tag of specific pawns.  You can have as many raiders as you like listed here, each with their own specific <Ref> tag. The most I've ever added to this section is 128 individual pawns. Other than a short pause in-game when they decide to attack (caused by the game taking the time to assign targets and generating paths for each of the raiders to follow), there is no harm done. I have no idea if there is an upper limit to this.
If the pawn in question does not exist, and there was only one to begin with, the game will still display the "Raiders have finished staging" message on the screen at the appropriate time.

That's it for the AIKing.

Pawns:
You'll find these listed as: <Def>Pawn</Def>

First, animals. Since they are all pretty much identical (with a few exceptions), the following applies to all of them:
<Def>Pawn</Def>
<ID>Pawn53855</ID>
<Pos>(181, 0, 83)</Pos>
<Rot>1</Rot>
<Kind>Squirrel</Kind>
<Sex>Female</Sex>
<Age>52</Age>

I think these are pretty much self-explanatory.
If an animal is psychotic, it'll also have this in this section: <Team>Psychotic</Team>

<mind Class="AI.Pawn_MindAnimal">
<MindState>
<EnemyTarget>null</EnemyTarget>
</MindState>
</mind>

Unless the animal is psychotic, nothing here changes. If it is psychotic, it'll have this as well: <BrokenState>Psychotic</BrokenState> Anything that does not have this is a potential target. This can be used to have an entire species of animal go insane and attack not only everything else, but also each other.

The sections <jobs> and <pather> will have their own separate category, as they are complex and apply to all Pawns.

<healthTracker>
<PawnHealth>17</PawnHealth>
<TicksToNextHeal>346</TicksToNextHeal>
</healthTracker>

I think these are pretty much self-explanatory as well.

The <inventory> section will be covered when talking about humans. For animals this section doesn't really apply.

I see absolutely no use whatsoever for the <filth> section. If you wish to remove whatever filth the animal is carrying, change the section to this:<filth>
<CarriedFilth />
</filth>



<food>
<PieceFood>
<CurLevel>72.04837</CurLevel>
</PieceFood>
</food>

The food level of the animal. 100 is the maximum. The lower this gets, the more likely the animal will eat. It also determines how much the animal will eat.

If the animal is starving, <CurLevel> will be replaced with this: <TicksToNextStarveDamage>2346</TicksToNextStarveDamage>

The rest of the animal doesn't apply to them:
<rest IsNull="True" />
<carryHands IsNull="True" />
<psychology IsNull="True" />
<prisoner IsNull="True" />
<ownership IsNull="True" />
<talker IsNull="True" />
<skills IsNull="True" />
<story IsNull="True" />
<apparel IsNull="True" />
<equipment IsNull="True" />



Click me to see the continuation of this post.
Because this happened while updating it:
The following error or errors occurred while posting this message:
The message exceeds the maximum allowed length (20000 characters).

[attachment deleted by admin: too old]
All my mods are licensed under a Attribution-NonCommercial-ShareAlike 4.0 International
Ask for permission before using in ModPacks

Click here for a list of the mods I've created

Coenmcj

Moderator on discord.gg/rimworld come join us! We don't bite

WolfgangPolska

I have no idea how, but it works!!!

WolfgangPolska

One more question: If i change Security turret team to riders, it will be shooting colonists?

I have no idea how, but it works!!!

ItchyFlea

#4
Human Pawns: (This will be a bit bare for a while, but I'll try to cover what I think are the important bits, and will not be in the same order as these things normally are in a savefile.)

� <inventory>
   ◦: Fairly basic right now. All it holds (that I've seen anyway) is whether or not a colonist has a doorkey. If they do, they can walk through doors unhindered. If they don't, they are blocked by doors.
<contents>
<Thing Class="ThingWithComponents">
<Def>DoorKey</Def>
<ID>DoorKey47134</ID>
<Health>30</Health>
</Thing>
</contents>


� <carryHands>
   ◦: This is how much of a resource can be carried by this pawn.
<container>
<maxStacks>1</maxStacks>
<maxTotalStackCount>75</maxTotalStackCount>
<contents />
</container>

While I haven't done much testing with this section, I know that doubling <maxTotalStackCount> to 150 does work in-game.

� <skills>
   ◦: If you've read this far, this section should be fairly straight-forward. Therefore I won't go into detail. Max level for a skill is 20. Anything over that can cause problems, such as locking out the UI, effectively crashing the game.

� <apparel>
   ◦: I have done almost nothing with this section. This is what clothing a colonist is wearing. If you wish to remove all of someone's clothing, replace this entire section with this:
<apparel>
<WornApparel>
<KeyList />
<ValueList />
</WornApparel>
</apparel>


   ◦: The most I have done was manage to change Tynan's clothing to tribal:
<apparel>
<WornApparel>
<KeyList>
<ApparelLayer>OnSkin</ApparelLayer>
</KeyList>
<ValueList>
<Apparel Class="Apparel">
<Def>Apparel_TribalA</Def>
<ID>Apparel_TribalA8</ID>
<Health>100</Health>
<Color>RGBA(0.959, 0.903, 0.983, 1.000)</Color>
</Apparel>
</ValueList>
</WornApparel>
</apparel>


� <equipment>
   ◦: Pretty much what gun the colonist has. If you want to remove a weapon from a colonist, change the section to this:
<equipment>
<Primary IsNull="True" />
<Secondaries />
</equipment>


Otherwise, change it to something like this: (Refer to the weapons.txt list for all normal in-game guns.) <Pos> should be the exact same as your colonist's current <Pos> tag.
<Primary>
<Def>Gun_M-24Rifle</Def>
<ID>Gun_M-24Rifle190771</ID>
<Pos>(90, 0, 95)</Pos>
<Health>100</Health>
</Primary>


That covers most things I think.

Job Driver and Pather:
Until I do some testing to see what's changed between the pre-release and alpha 1, all I'll give you is what I know of as a way to replace any job with basically nothing: (Just make sure that <NextSquare> is the same as your colonists <Pos> tag.)
<jobs>
<CurJob>
<jType>Wait</jType>
<targetA IsNull="True" />
<targetB IsNull="True" />
<targetsExtraA IsNull="True" />
<targetsExtraB IsNull="True" />
<expiryTime>1976</expiryTime>
</CurJob>
<CurJobDriver Class="AI.JobDriver_Wait">
<curToilIndex>0</curToilIndex>
<ticksInToil>38</ticksInToil>
<curToilCompleteMode>Never</curToilCompleteMode>
</CurJobDriver>
</jobs>
<pather>
<Moving>False</Moving>
<NextSquare>(11, 0, 188)</NextSquare>
<TotalMoveDuration>14</TotalMoveDuration>
<pathMode>Square</pathMode>
</pather>

In the mean time, I suggest collecting a bunch of saves where colonists are doing various things, then slightly modify those things to see what happens.

For the purposes of CustomScenarios, this section allows you to give one-time only custom movement from A to B. After that the AI takes over.

Until I write up the section about human pawns, try replacing some of the sections a human has with these and watch what happens. Some will break the game, otherwise will give interesting results.

A surprisingly large amount of things can be done with these.

I'll write this next time I have free time. There's a lot to cover. In the mean time, have a look at my Zombie Defence scenario to see how they are made to exist without dying from starvation or going insane and leaving.
All my mods are licensed under a Attribution-NonCommercial-ShareAlike 4.0 International
Ask for permission before using in ModPacks

Click here for a list of the mods I've created

ItchyFlea

#5
Managed to make the post longer than is allowed by the forums.  :)
Started talking about the possible changes that can be made to human pawns.

Most of what's missing (apart from the Job Driver stuff) wouldn't take too long to figure out on your own. I still suggest downloading and looking into scenario's I've released in the past, as well as looking at the Zombie Defence scenario. (As it works with Alpha 1, and therefore contains "correct" formatting.)
Also, I've attached to this post a couple I made but never released. They work with alpha 1, and may contain stuff that I haven't added to the tutorial yet.
The map was made with RimEdit made by Darker. I highly suggest checking that out, as it's awesome to use.

For the Alone Scenario, I think it's fairly self-explanatory. Tynan is stranded all alone, with just enough metal to make a small home.
For the Wolfenstein Scenario, it's my attempt at re-making the first level of Wolfenstein 3D in RimWorld. I didn't release it because I find it rather boring to play. The goal is/was to reach the doorkey laying on the ground, as that's where the level-exit is in Wolfenstein 3D.
Look for a post from me in the unfinished section, since I better lay out my plans for this now that I've revealed it here. (I do intend to recreate, at the very least, the first 'episode' from Wolfenstein 3D.) :D

[attachment deleted by admin: too old]
All my mods are licensed under a Attribution-NonCommercial-ShareAlike 4.0 International
Ask for permission before using in ModPacks

Click here for a list of the mods I've created

Tynan

Just wanted to note that this is really impressive! I'm sorry I didn't see this earlier.
Tynan Sylvester - @TynanSylvester - Tynan's Blog

Tynan

I'm unstickying this - maybe you can put it on the wiki? Permanent info like this should be wiki'd.
Tynan Sylvester - @TynanSylvester - Tynan's Blog