718
edits
Kernelmethod (talk | contribs) mNo edit summary |
Kernelmethod (talk | contribs) (Start adding section on population tables) |
||
Line 96: | Line 96: | ||
* <code>ObjectBlueprints/Creatures.xml</code>: definitions of all of the creatures that exist in Caves of Qud. | * <code>ObjectBlueprints/Creatures.xml</code>: definitions of all of the creatures that exist in Caves of Qud. | ||
* <code>ObjectBlueprints/Items.xml</code>: definitions of all of the items available in Caves of Qud. | * <code>ObjectBlueprints/Items.xml</code>: definitions of all of the items available in Caves of Qud. | ||
* <code>PopulationTables.xml</code>: contains ''population tables'', which are used to figure out when and where creatures should spawn. | |||
* <code>Skills.xml</code>: contains all of the skill trees provided by Caves of Qud, and abilities within those trees. | * <code>Skills.xml</code>: contains all of the skill trees provided by Caves of Qud, and abilities within those trees. | ||
* <code>Quests.xml</code>: lays out the steps and rewards for non-procedurally generated quests. | * <code>Quests.xml</code>: lays out the steps and rewards for non-procedurally generated quests. | ||
Line 109: | Line 110: | ||
|} | |} | ||
We'll start by creating a mod that doesn't actually do anything. To do that, go to Caves of Qud's "offline mods" folder; you can find the location of this folder for your operating system by looking at the page of [[file locations]]. Inside this folder (it should be named <code>Mods</code>), create a folder called <code> | We'll start by creating a mod that doesn't actually do anything. To do that, go to Caves of Qud's "offline mods" folder; you can find the location of this folder for your operating system by looking at the page of [[file locations]]. Inside this folder (it should be named <code>Mods</code>), create a folder called <code>Snapjaw-Mages</code>. The first file we're going to create for our mod will be a '''''manifest file'''''; this contains metadata such as our mod's title, a description of the mod, and its version. Create a file called <code>manifest.json</code> inside the <code>Snapjaw-Mages/</code> folder, and paste in the following contents: | ||
<syntaxhighlight lang="json"> | <syntaxhighlight lang="json"> | ||
Line 136: | Line 137: | ||
<syntaxhighlight lang="text"> | <syntaxhighlight lang="text"> | ||
Snapjaw-Mages | |||
├── manifest.json | ├── manifest.json | ||
└── preview.png | └── preview.png | ||
Line 170: | Line 171: | ||
<syntaxhighlight lang="text"> | <syntaxhighlight lang="text"> | ||
Snapjaw-Mages | |||
├── manifest.json | ├── manifest.json | ||
├── ObjectBlueprints | ├── ObjectBlueprints | ||
Line 284: | Line 285: | ||
<syntaxhighlight lang="text"> | <syntaxhighlight lang="text"> | ||
Snapjaw-Mage | |||
├── manifest.json | ├── manifest.json | ||
├── ObjectBlueprints | ├── ObjectBlueprints | ||
Line 434: | Line 435: | ||
<syntaxhighlight lang="text"> | <syntaxhighlight lang="text"> | ||
Snapjaw-Mages | |||
├── manifest.json | ├── manifest.json | ||
├── ObjectBlueprints | ├── ObjectBlueprints | ||
Line 700: | Line 701: | ||
[[File:Snapjaw_Mages_--_mage_tome_equipped.webp|600px]] | [[File:Snapjaw_Mages_--_mage_tome_equipped.webp|600px]] | ||
== | == Controlling spawning: population tables == | ||
We've successfully added our mages and given them magical tomes. There's still one thing missing: our mages currently won't spawn in-game unless we use wishes. | |||
Caves of Qud uses '''''population tables''''' to decide when to spawn different items and creatures. Here's an example of one such population table (which you can find in the game data in <code>PopulationTables.xml</code>): | |||
<syntaxhighlight lang="xml"> | |||
<population Name="SaltMarshZoneGlobals"> | |||
<table Name="StandardSurfaceGlobals" /> | |||
<object Chance="90" Number="160-200" Blueprint="Watervine" /> | |||
<object Chance="90" Number="90-130" Blueprint="Brinestalk" /> | |||
<object Chance="50" Number="6-16" Blueprint="Dogthorn Tree" /> | |||
<object Chance="25" Number="1-4" Blueprint="Witchwood Tree" /> | |||
<object Chance="5" Number="1-4" Blueprint="Starapple Tree" /> | |||
<object Chance="50" Blueprint="Croc" /> | |||
<object Chance="75" Number="2d6" Blueprint ="Glowpad" Hint="Aquatic" /> | |||
<object Chance="75" Number="2d4" Blueprint ="Glowfish" Hint="Aquatic" /> | |||
<object Chance="50" Number="2d6" Blueprint ="GiantDragonfly" /> | |||
<group Chance="4" Name="ManySnapjaws" Style="pickeach"> | |||
<table Name="SnapjawParty1" Number="4" /> | |||
</group> | |||
</population> | |||
</syntaxhighlight> | |||
This table is used in the [[salt marsh]] to help decide what animals and plants should be spawned. Let's take a look at a few of these lines: | |||
* <code><table Name="StandardSurfaceGlobals" /></code>: this says that the <code>SaltMarshZoneGlobals</code> table should include all of the contents of another table called <code>StandardSurfaceGlobals</code>. You can find the definition of that table in <code>PopulationTables.xml</code>; it does things like add a chance of a {{favilink|Mechanimist pilgrim}} spawning in each zone. | |||
* <code><object Chance="50" Blueprint="Croc" /></code>: this adds a 50% chance of a {{favilink|Croc}} spawning in a given zone. | |||
* <code><group Chance="4" Name="ManySnapjaws" Style="pickeach">...</group></code>: this defines a "group" in the table. The usage here says (roughly speaking) that there's a 4% chance that we sample some creatures from the <code>SnapjawParty1</code> table. | |||
=== Adding snapjaw mages to population tables === | |||
There are a few different snapjaw-related population tables in the data files -- <code>SnapjawParty0</code>, <code>SnapjawParty1</code>, <code>SnapjawParty1-with-Warlord</code>, and <code>SnapjawParty2</code>. Each of these tables is used for different encounters with snapjaws. | |||
In your <code>Snapjaw-Mage</code> mod folder, create a new file called <code>PopulationTables.xml</code>: | |||
<syntaxhighlight lang=" | <syntaxhighlight lang="text"> | ||
Snapjaw-Mages | |||
├── manifest.json | ├── manifest.json | ||
├── ObjectBlueprints | ├── ObjectBlueprints | ||
│ ├── Creatures.xml | │ ├── Creatures.xml | ||
│ └── Items.xml | │ └── Items.xml | ||
├── PopulationTables.xml | |||
├── preview.png | ├── preview.png | ||
└── Textures | └── Textures | ||
Line 730: | Line 751: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Within this file, start by adding the following: | |||
<syntaxhighlight lang="xml"> | <syntaxhighlight lang="xml"> | ||
<?xml version="1.0" encoding="utf-8" ?> | <?xml version="1.0" encoding="utf-8" ?> | ||
< | <populations> | ||
</populations> | |||
</syntaxhighlight> | |||
Now, we need to modify the contents of the four tables that we listed previously: | |||
<syntaxhighlight lang="xml"> | |||
<?xml version="1.0" encoding="utf-8" ?> | |||
<populations> | |||
<population Name="SnapjawParty0" Load="Merge"> | |||
</population> | |||
<population Name="SnapjawParty1" Load="Merge"> | |||
</population> | |||
<population Name="SnapjawParty1-with-Warlord" Load="Merge"> | |||
</population> | |||
<population Name="SnapjawParty0" Load="Merge"> | |||
</population> | |||
</populations> | |||
</syntaxhighlight> | |||
{| style = "margin: 1em;font-family:Source Code Pro;" | |||
| style = "padding:0em 1em;"| [[File:Sprouting orb.png|40px]] | |||
| style= "color:#155352" | < | |||
| style = "border:1px solid #155352;padding:0.5em 1em;" | What does <code>Load="Merge"</code> do? | |||
|} | |||
{| style = "margin: 1em;font-family:Source Code Pro;" | |||
| style = "padding:0em 1em;"| [[File:Mopango_pilgrim.png|40px]] | |||
| style= "color:#155352" | < | |||
| style = "border:1px solid #155352;padding:0.5em 1em;" | We need to specify <code>Load="Merge"</code> to tell Caves of Qud that we want to merge new XML into an existing table called (for example) <code>SnapjawParty0</code>. This prevents us from creating a new population table called <code>SnapjawParty0</code> that overwrites the old one. | |||
It's possible to use <code>Load="Merge"</code> to modify the contents of most of the game's XML files. | |||
|} | |||
Each of these tables has a group named <code>Creatures</code>, for instance: | |||
<syntaxhighlight lang="xml"> | <syntaxhighlight lang="xml"> | ||
< | <population Name="SnapjawParty0"> | ||
< | <group Name="Creatures" Style="pickeach"> | ||
<object Chance="100" Number="1-3" Blueprint="Snapjaw Scavenger 0" /> | |||
<object Chance="75" Number="1-3" Blueprint="Snapjaw Scavenger 0" /> | |||
< | <object Chance="25" Number="1-3" Blueprint="Snapjaw Hunter 0" /> | ||
< | <object Chance="2" Number="1" Blueprint="Snapjaw Shotgunner 0" /> | ||
< | <object Chance="15" Number="1" Blueprint="Snapjaw Brute 0" /> | ||
< | <object Chance="10,3" Number="1" Blueprint="Snapjaw Warrior 0" /> | ||
<object Chance="10" Number="1" Blueprint="Snapjaw Warlord 0" /> | |||
<object Chance="3" Number="1" Blueprint="Snapjaw Hero 0" /> | |||
<table Name="HumanoidEnvironmentFeatures" Chance="25" /> | |||
<table Name="SnapjawParty0" Chance="10" /> | |||
</group> | |||
</population> | |||
</syntaxhighlight> | |||
So we'll also have our <code>PopulationTables.xml</code> merge new XML into each of these groups: | |||
=== Dynamic population tables === | |||
So far, the tables we've been working with have been '''''static''''' -- they're pre-defined based on the contents of <code>PopulationTables.xml</code>. It's also possible to generate a '''''dynamic''''' population table, by giving creatures and items a <code>DynamicObjectsTable</code> tag. | |||
== Conclusion == | |||
Congrats! You reached the end of the tutorial! | |||
{| style = "margin: 1em;font-family:Source Code Pro;" | |||
| style = "padding:0em 1em;"| [[File:Mopango_pilgrim.png|40px]] | |||
| style= "color:#155352" | < | |||
| style = "border:1px solid #155352;padding:0.5em 1em;" | Woohoo! | |||
|} | |||
{| style = "margin: 1em;font-family:Source Code Pro;" | |||
| style = "padding:0em 1em;"| [[File:Sprouting orb.png|40px]] | |||
| style= "color:#155352" | < | |||
| style = "border:1px solid #155352;padding:0.5em 1em;" | I'm ready to go face these mages in magical combat. | |||
|} | |||
=== Extra challenge === | === Extra challenge === |