Modding:Encounters and Population: Difference between revisions

Differentiate further between DynamicObjectsTable, DynamicInheritsTable, and DynamicSemanticTable, and add some more information on ExcludeFromDynamicEncounters.
(Add new info about population table merging)
(Differentiate further between DynamicObjectsTable, DynamicInheritsTable, and DynamicSemanticTable, and add some more information on ExcludeFromDynamicEncounters.)
Line 80: Line 80:
The game sometimes uses dynamically generated population tables, which are constructed from objects in ObjectBlueprints.xml.
The game sometimes uses dynamically generated population tables, which are constructed from objects in ObjectBlueprints.xml.


For example, <code>XRL.World.Parts.PsionicDervish</code> may select an object from the <code>DynamicInheritsTable:BaseLongBlade:Tier5</code>, <code>DynamicInheritsTable:BaseLongBlade:Tier7</code>, or <code>DynamicInheritsTable:BaseLongBlade:Tier9</code> tables depending on the type of dervish. This table will select any item that inherits from "BaseLongBlade" as long as it does not have the <code>ExcludeFromDynamicEncounters</code> tag. For dynamic tables of this type with a tier, the game will strongly weight items of the specified tier, but items of other tiers can also be selected.
There are three methods of constructing dynamic tables:
* Through the use of <code>DynamicObjectsTable</code>, which identifies all of the objects that have been tagged as belonging to a particular table.
* Through inheritance and the use of <code>DynamicInheritsTable</code>.
* Through <code>DynamicSemanticTable</code>, which collects all objects that are in the intersection of a set of categories.


=== DynamicObjectsTable ===
A <code>DynamicObjectsTable</code> contains all objects that have been tagged as belonging to that table. Here's an example from the definition of {{favilink|shrewd baboon}} in <code>ObjectBlueprints/Creatures.xml</code>:
<syntaxhighlight lang="xml">
<object Name="Shrewd Baboon" Inherits="Baboon">
  <part Name="Render" DisplayName="shrewd baboon" ColorString="&amp;B" />
  <stat Name="AV" Value="3" />
  <stat Name="Intelligence" Boost="1" />
  <stat Name="Hitpoints" Value="20" />
  <property Name="Role" Value="Leader" />
  <tag Name="DynamicObjectsTable:Baboons" />
</object>
</syntaxhighlight>
Shrewd baboon has been given <code>&lt;tag Name="DynamicObjectsTable:Baboons" /&gt;</code>, so it automatically belongs to the <code>Baboons</code> dynamic objects table.
=== DynamicInheritsTable ===
A <code>DynamicInheritsTable</code> contains all objects that inherit from another object. For example, here's the population table for <code>GritGateWorkbench</code> population table, which is 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.
A <code>DynamicInheritsTable</code> can be weighted based on the tier of an item by appending <code>:Tier&lt;zonetier&gt;</code>.
For example, <code>DynamicInheritsTable:BaseLongBlade:Tier5</code> will give a weight of 1000 to items of the specified tier, a weight of 100 to items one tier above or below that, a weight of 10 to items two tiers above or below that, and a weight of 1 to all other items. This results in a population table being constructed by the game similar to the following:
For example, <code>DynamicInheritsTable:BaseLongBlade:Tier5</code> will give a weight of 1000 to items of the specified tier, a weight of 100 to items one tier above or below that, a weight of 10 to items two tiers above or below that, and a weight of 1 to all other items. This results in a population table being constructed by the game similar to the following:


Line 145: Line 182:
| 1000
| 1000
|}
|}
=== DynamicSemanticTable ===
A <code>DynamicSemanticTable</code> can generate any object within an intersecting list of categories. 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>&lt;stag Name="Medical" /&gt;</code> and <code>&lt;stag Name="Furniture" /&gt;</code> in their definition. The <code>4:6</code> bit will weight objects more heavily as their tier gets closer to 4 or their tech tier gets closer to 6.
=== Excluding objects from dynamic tables ===
Finally, it's possible to explicitly exclude an object from all dynamic tables by adding the following tag to it:
<syntaxhighlight lang="xml">
<tag Name="ExcludeFromDynamicEncounters" />
</syntaxhighlight>
This is especially helpful when creating unique or rare NPCs and items, who aren't expected to simply appear in random zones. It is also useful when defining base objects, who serve as a template on which to construct other objects but should not themselves appear in-game.


== Additional Info ==
== Additional Info ==