Modding:General Best Practices: Difference between revisions

From Caves of Qud Wiki
Jump to navigation Jump to search
m (Add shorter headers so they can be URL linked without putting a ladle in the tupperware.)
Line 1: Line 1:
[[Category:Modding]]{{Modding Info}}
[[Category:Modding]]{{Modding Info}}
= Prefix your object and table names with some unique ID =
=Prefixing=
Prefix your object and table names with some unique ID.
 
For instance, <code>alphabeardmods_{id}</code>. This will prevent namespace conflicts with official content and other mods in the future.
For instance, <code>alphabeardmods_{id}</code>. This will prevent namespace conflicts with official content and other mods in the future.


Line 12: Line 14:
</syntaxhighlight>
</syntaxhighlight>


= Only include your content and the minimum changeset via <code>Load="Merge"</code> in tables and object definitions =
=Merging=
Only include your content and the minimum changeset via <code>Load="Merge"</code> in tables and object definitions.
 
Don't copy the whole contents of the game xml. You only need to include new content.
Don't copy the whole contents of the game xml. You only need to include new content.



Revision as of 23:53, 19 February 2020

This page is about modding. See the modding overview for an abstract on modding.
This page is about modding. See the modding overview for an abstract on modding.

Prefixing

Prefix your object and table names with some unique ID.

For instance, alphabeardmods_{id}. This will prevent namespace conflicts with official content and other mods in the future.

<?xml version="1.0" encoding="utf-8"?>
<objects>
  <object Name="ALPHABEARDMODS_CoolNewSword" Load="Merge">
...
  </object> 
</objects>

Merging

Only include your content and the minimum changeset via Load="Merge" in tables and object definitions.

Don't copy the whole contents of the game xml. You only need to include new content.

For objects and encounter tables, if you're editing an existing item you can use Load="Merge" in it's tag and only specify new items. For example, if I wanted my mod to give chain mail a 2DV:

<?xml version="1.0" encoding="utf-8"?>
<objects>
  <object Name="Chain Mail" Load="Merge">
    <part Name="Armor" DV="2" />
  </object> 
</objects>

Random Functions

Main article: Modding:Random Functions

To avoid conflicts and to keep consistency between seeds, Stat.Random() and Stat.Rnd() should not be called. The ideal is to use GetSeededRandomGenerator() for your mod's randomness. The next best is calling RandomCosmetic() or Rnd2().

ObjectBlueprint Definitions

In general, unless you're defining a unique object, make sure you add the xml property Load="Merge" to prevent breaking behavior.

Stats

Prefer using value over sValue, unless you're creating a unique creature. When loading ObjectBlueprints, the code loads both sValue and value into a stat, then if sValue is set, prefers using that to set a stat over value.