User:Kernelmethod/Sandbox: Difference between revisions
Kernelmethod (talk | contribs) m Small editing pass |
Kernelmethod (talk | contribs) Add some deeper notes on dynamic tables, including DynamicInheritsTable and DynamicSemanticTable, as well as ExcludeFromDynamicEncounters. |
||
Line 718: | Line 718: | ||
That's because there's one thing we're still missing: we haven't told Caves of Qud when and where our new mages should spawn! | That's because there's one thing we're still missing: we haven't told Caves of Qud when and where our new mages should spawn! | ||
{| 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;" | In fact, it ''is'' already possible for our snapjaw mages to appear in game; it's just that the probability of this happening is very low at the moment. We'll talk about this more when we discuss [[#dynamic population tables|dynamic tables]]. | |||
|} | |||
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>): | 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>): | ||
Line 866: | Line 872: | ||
[[File:Snapjaw Mages -- snapjaw party.webp|600px]] | [[File:Snapjaw Mages -- snapjaw party.webp|600px]] | ||
You can use the <code>population:findtable</code> [[wish]] to check the likelihood that a snapjaw mage will spawn in each of the population tables. For instance, here's a snippet from the popup that appears when you wish for <code>population:findtable:Pyovya_SnapjawMage_Fire Mage</code>: | |||
[[File:Snapjaw Mages -- poptable probs.webp|600px]] | |||
As a result of the XML we merged into <code>PopulationTables.xml</code>, our mage has a 100% chance of appearing in each of the <code>SnapjawMage</code> tables. But we can also see that it has a nonzero chance of appearing in many other population tables; for instance, it has a 97% chance generating inside the {{favilink|waterlogged tunnel}}. That's because the <code>SnapjawParty</code> tables are used in turn by many other population tables for areas where snapjaws may be generated. | |||
=== Creating new tables === | === Creating new tables === | ||
Line 928: | Line 940: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
After this change, snapjaw parties that we run across will only have one mage rather than two. | After this change, snapjaw parties that we run across will only have one mage, rather than two. | ||
=== Dynamic population tables === | === 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, | 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, which is generated based on the tags that creatures have as well as their relationship to one another. For instance, let's take a look at the definition of {{favilink|shrewd baboon}} in the game's <code>ObjectBlueprints/Creatures.xml</code>: | ||
<syntaxhighlight lang="xml"> | <syntaxhighlight lang="xml"> | ||
Line 949: | Line 961: | ||
Caves of Qud primarily uses dynamic tables when it needs to be be able to get one of a particular type of item or creature -- for instance, a random type of [[energy cell]] or a random type of [[goatfolk]]. This is useful, for example, for identifying what creatures are able to own a lair. | Caves of Qud primarily uses dynamic tables when it needs to be be able to get one of a particular type of item or creature -- for instance, a random type of [[energy cell]] or a random type of [[goatfolk]]. This is useful, for example, for identifying what creatures are able to own a lair. | ||
There's a <code>Snapjaws</code> dynamic table that we can add our mages to. Doing so is fairly straightforward: open up <code>Creatures.xml</code> and add the following tag at the end of the definition of <code>Pyovya_SnapjawMage_Fire Mage</code> and <code>Pyovya_SnapjawMage_Ice Mage</code>: | There are several ways to create a dynamic table. One way is to add <code>DynamicObjectsTable</code>, as in the snippet for shrewd baboon. It's also possible to get added to a table by being descended from a base object and using <code>DynamicInheritsTable</code>. Consider, for instance, the <code>GritGateWorkbench</code> population table, used to generate the contents of the {{favilink|workbench|plural}} that appear in {{favilink|Grit Gate}}: | ||
<syntaxhighlight lang="xml"> | |||
<population Name="GritGateWorkbench"> | |||
<group Name="GritGateWorkbench" Style="pickeach"> | |||
<table Name="DynamicInheritsTable:Tool" Chance="15" /> | |||
<table Name="Junk {zonetier}" Chance="15" /> | |||
<table Name="DynamicObjectsTable:EnergyCells" Chance="15" /> | |||
</group> | |||
</population> | |||
</syntaxhighlight> | |||
This population table has a 15% chance of generating an item from the <code>DynamicInheritsTable:Tool</code> table, which includes any item that is descended (through inheritance) from <code>Tool</code>. This includes {{favilink|basic toolkit|plural}}, {{favilink|advanced toolkit|plural}}, {{favilink|pickaxe|plural}}, and several other items. | |||
{| 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;" | Because snapjaw mages are descended from the Snapjaw object, which in turn ultimately descends from the Creature object, it turns out that snapjaw mages were already included in some population tables before we started writing <code>PopulationTables.xml</code>! In particular, snapjaw mages could appear in the <code>DynamicInheritsTable:Creatures</code> table, although the probability of them being generated was pretty low. | |||
|} | |||
The third and final way of creating dynamic tables is through the use of <code>DynamicSemanticTable</code>. Here, a dynamic "semantic" table includes all objects with a given <code>stag</code>. To understand this, consider the population table for the ruined ward section of {{favilink|Bethesda Susa}}: | |||
<syntaxhighlight lang="xml"> | |||
<population Name="BethesdaSusaRuinedWard"> | |||
<!-- Skipping over most of the contents of this table... --> | |||
<table Chance="80" Number="1-8" Name="DynamicSemanticTable:Medical,Furniture:4:6" Hint="AlongWall" /> | |||
<table Chance="60" Number="1-4" Name="DynamicSemanticTable:Professional,Furniture:2:5" Hint="AlongWall" /> | |||
<table Chance="5" Number="1-3" Name="DynamicSemanticTable:Torture,Furniture:1:5" Hint="AlongWall" /> | |||
<table Chance="5" Number="1-2" Name="DynamicSemanticTable:Child,Furniture:1:5" Hint="AlongWall" /> | |||
<table Chance="5" Number="1-2" Name="DynamicSemanticTable:Normality,Furniture" Hint="AlongWall" /> | |||
</population> | |||
</syntaxhighlight> | |||
Picking out one line of this, <code>DynamicSemanticTable:Medical,Furniture:4:6</code> is a dynamic table which includes objects that have both <code><stag Name="Medical" /></code> and <code><stag Name="Furniture" /></code> in their definition. The <code>4:6</code> bit will weight objects whose tier is 4 or whose tech tier is 6 more heavily than others. | |||
{| 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;" | You can always use the <code>population:generate</code> wish to see what objects are in a given population table. For example, <code>population:generate:DynamicSemanticTable:Medical,Furniture#50</code> will sample from the "Medical,Furniture" dynamic semantic table 50 times, and show you how many times different objects were randomly sampled. | |||
|} | |||
Finally, it's worth pointing out that there's also ways of ''excluding'' objects from dynamic tables. You can add <code><tag Name="ExcludeFromDynamicEncounters" /></code> to a creature in <code>Creatures.xml</code> to ensure that that creature isn't added to any dynamic tables. This is especially helpful when creating unique or rare NPCs, whom you wouldn't just want showing up in the middle of a random zone. | |||
Returning to our mod: there's a <code>Snapjaws</code> dynamic table that we can add our mages to. Doing so is fairly straightforward: open up <code>Creatures.xml</code> and add the following tag at the end of the definition of <code>Pyovya_SnapjawMage_Fire Mage</code> and <code>Pyovya_SnapjawMage_Ice Mage</code>: | |||
<syntaxhighlight lang="xml"> | <syntaxhighlight lang="xml"> | ||
<tag Name="DynamicObjectsTable:Snapjaws" /> | <tag Name="DynamicObjectsTable:Snapjaws" /> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
One result of adding this tag is that legendary snapjaw mage lairs can now appear! Here's one that I found while traversing the overworld: | |||
[[File:Snapjaw Mages -- travelnote fire mage.webp|600px]] | [[File:Snapjaw Mages -- travelnote fire mage.webp|600px]] |