User:Kernelmethod/Sandbox: Difference between revisions

no edit summary
(Start adding section on population tables)
No edit summary
Line 759: Line 759:
</syntaxhighlight>
</syntaxhighlight>


Now, we need to modify the contents of the four tables that we listed previously:
Next, we need to modify the contents of the four tables that we listed previously:


<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
Line 808: Line 808:
</syntaxhighlight>
</syntaxhighlight>


So we'll also have our <code>PopulationTables.xml</code> merge new XML into each of these groups:
Because the group has <code>Style="pickeach"</code>, the population table will go over each item (each XML tag) in the group and sample creatures based on the rules defined by that item:
* Based on the first line (<code>&lt;object Chance="100" Number="1-3" Blueprint="Snapjaw Scavenger 0" /&gt;</code>), there's a 100% chance that 1-3 {{favilink|snapjaw scavenger|plural}} spawn).
* The second line (<code>&lt;object Chance="75" Number="1-3" Blueprint="Snapjaw Scavenger 0" /&gt;</code>) adds a 75% chance for an additional 1-3 snapjaw scavengers to spawn.
* The fifth line (<code>&lt;object Chance="15" Number="1" Blueprint="Snapjaw Brute 0" /&gt;</code>) adds a 15% chance for a {{favilink|snapjaw brute}} to spawn.
* The last line (<code>&lt;table Name="SnapjawParty0" Chance="10" /&gt;</code>) adds a 10% chance for another snapjaw party (also sampled from the <code>SnapjawParty0</code> table) to spawn alongside this party.
 
To guarantee that each snapjaw party spawns with a fire mage and an ice mage, we'll merge some new XML into each of these groups:
 
<syntaxhighlight lang="xml">
<?xml version="1.0" encoding="utf-8" ?>
<populations>
  <population Name="SnapjawParty0" Load="Merge">
    <group Name="Creatures" Load="Merge">
      <object Number="1" Blueprint="Pyovya_SnapjawMage_Fire Mage" />
      <object Number="1" Blueprint="Pyovya_SnapjawMage_Ice Mage" />
    </group>
  </population>
 
  <population Name="SnapjawParty1" Load="Merge">
    <group Name="Creatures" Load="Merge">
      <object Number="1" Blueprint="Pyovya_SnapjawMage_Fire Mage" />
      <object Number="1" Blueprint="Pyovya_SnapjawMage_Ice Mage" />
    </group>
  </population>
 
  <population Name="SnapjawParty1-with-Warlord" Load="Merge">
    <group Name="Creatures" Load="Merge">
      <object Number="1" Blueprint="Pyovya_SnapjawMage_Fire Mage" />
      <object Number="1" Blueprint="Pyovya_SnapjawMage_Ice Mage" />
    </group>
  </population>
 
  <population Name="SnapjawParty0" Load="Merge">
    <group Name="Creatures" Load="Merge">
      <object Number="1" Blueprint="Pyovya_SnapjawMage_Fire Mage" />
      <object Number="1" Blueprint="Pyovya_SnapjawMage_Ice Mage" />
    </group>
  </population>
</populations>
</syntaxhighlight>
 
Now when you encounter a band of roving snapjaws, they should include one fire mage and one ice mage:
 
[[File:Snapjaw Mages -- snapjaw party.webp|600px]]
 
=== Creating new tables ===
 
Having two mages appear alongside every party of snapjaws feels like a lot -- ideally, we'd have ''either'' one fire mage ''or'' one ice mage show up. We could try using <code>Chance</code> to reduce the probability of each type of mage showing up, for example:
 
<syntaxhighlight lang="xml">
<object Number="1" Chance="50" Blueprint="Pyovya_SnapjawMage_Fire Mage" />
<object Number="1" Chance="50" Blueprint="Pyovya_SnapjawMage_Ice Mage" />
</syntaxhighlight>
 
But all that does is give us a 50% chance of spawning a fire mage, ''and'' a 50% chance of spawning an ice mage. That means that there's a 25% chance that ''both'' mages show up, and a 25% chance that ''neither'' mage shows up.
 
Here's what we can do instead: let's define a ''new'' population table. This table will be set up so that whenever we sample an item from the table, we will either pick a fire mage, ''or'' we'll pick an ice mage:
 
<syntaxhighlight lang="xml">
<population Name="Pyovya_SnapjawMage_Mages">
  <group Name="Mages" Style="pickone">
    <object Number="1" Blueprint="Pyovya_SnapjawMage_Fire Mage" />
    <object Number="1" Blueprint="Pyovya_SnapjawMage_Ice Mage" />
  </group>
</population>
</syntaxhighlight>
 
By giving the <code>Mages</code> group <code>Style="pickone"</code>, we're telling the game "whenever we pick an item from the <code>Pyovya_SnapjawMage_Mages</code> table, we want to pick ''one of'' the items listed in our <code>Mages</code> group".


=== Dynamic population tables ===
=== Dynamic population tables ===