diff --git a/docs/creature_text.md b/docs/creature_text.md index 7bbe8cd5..68e6e017 100644 --- a/docs/creature_text.md +++ b/docs/creature_text.md @@ -174,3 +174,8 @@ Id of the equivalent text found in [broadcast\_text](broadcast_text) ### comment This field allows you to label a text entry. + +## Related Tables + +- [creature\_text\_options](creature_text_options) — assigns a reusable option ruleset to a (CreatureID, GroupID) pair to enforce cooldown, trigger chance, and player-only filtering. +- [creature\_text\_option\_sets](creature_text_option_sets) — defines the reusable rulesets referenced by `creature_text_options`. diff --git a/docs/creature_text_option_sets.md b/docs/creature_text_option_sets.md new file mode 100644 index 00000000..ab75862d --- /dev/null +++ b/docs/creature_text_option_sets.md @@ -0,0 +1,45 @@ +# creature\_text\_option\_sets + +[<-Back-to:World](database-world) + +**The \`creature\_text\_option\_sets\` table** + +This table defines reusable option rulesets for creature text groups. Each ruleset controls cooldown, trigger chance, and player-only filtering for `SendChat()`. Rulesets are assigned to specific (CreatureID, GroupID) pairs via the [creature\_text\_options](creature_text_options) table. + +## Structure + +| Field | Type | Attributes | Key | Null | Default | Extra | Comment | +|------------------------|--------------|------------|-----|------|---------|-------|------------------------------------------| +| [SetID][1] | TINYINT | UNSIGNED | PRI | NO | | | | +| [Cooldown][2] | INT | UNSIGNED | | NO | 0 | | Group cooldown in milliseconds before it can fire again | +| [TriggerChance][3] | TINYINT | UNSIGNED | | NO | 100 | | 0-100 percent chance to fire at all | +| [PlayerOnly][4] | TINYINT | UNSIGNED | | NO | 0 | | Only fire if target is a player | +| [comment][5] | VARCHAR(255) | | | YES | | | | + +[1]: #setid +[2]: #cooldown +[3]: #triggerchance +[4]: #playeronly +[5]: #comment + +## Description of the fields + +### SetID + +Unique identifier for this option ruleset. Referenced by [creature\_text\_options.OptionSetID](creature_text_options#optionsetid). + +### Cooldown + +The minimum time in milliseconds that must pass before the same text group can fire again on a given creature. Set to `0` to disable cooldown enforcement. + +### TriggerChance + +A percentage value from `0` to `100` that represents the chance the text group will be triggered at all. A value of `100` means the text always fires when called; a value of `30` means it fires approximately 30% of the time. + +### PlayerOnly + +When set to `1`, the text group will only fire if the target that triggered it is a player. When set to `0`, the text will fire regardless of target type (players, pets, guardians, etc.). + +### comment + +An optional human-readable label for this ruleset. diff --git a/docs/creature_text_options.md b/docs/creature_text_options.md new file mode 100644 index 00000000..4af8cd0c --- /dev/null +++ b/docs/creature_text_options.md @@ -0,0 +1,40 @@ +# creature\_text\_options + +[<-Back-to:World](database-world) + +**The \`creature\_text\_options\` table** + +This table assigns a reusable option ruleset (defined in [creature\_text\_option\_sets](creature_text_option_sets)) to a specific (CreatureID, GroupID) pair from [creature\_text](creature_text). This enables data-driven control of cooldown, trigger chance, and player-only filtering for `SendChat()` calls without requiring per-script boilerplate. + +When `SendChat()` is called for a creature text group, the engine automatically: +1. Checks whether the group is on cooldown (if `Cooldown > 0`). +2. Rolls against `TriggerChance` to decide whether the text fires. +3. Checks whether the target is a player (if `PlayerOnly = 1`). + +If any check fails, the text is silently skipped. If all checks pass, the text fires and the cooldown timer is started. + +## Structure + +| Field | Type | Attributes | Key | Null | Default | Extra | Comment | +|------------------------|---------|------------|-----|------|---------|-------|---------| +| [CreatureID][1] | INT | UNSIGNED | PRI | NO | | | | +| [GroupID][2] | TINYINT | UNSIGNED | PRI | NO | | | | +| [OptionSetID][3] | TINYINT | UNSIGNED | | NO | | | | + +[1]: #creatureid +[2]: #groupid +[3]: #optionsetid + +## Description of the fields + +### CreatureID + +The entry of the creature from [creature\_template.entry](creature_template#entry) to which this option assignment applies. + +### GroupID + +The text group ID from [creature\_text.GroupID](creature_text#groupid) to which this option assignment applies. + +### OptionSetID + +The ID of the ruleset from [creature\_text\_option\_sets.SetID](creature_text_option_sets#setid) that defines the cooldown, trigger chance, and player-only behaviour for this (CreatureID, GroupID) pair. diff --git a/docs/database-world.md b/docs/database-world.md index e9508754..b9129e0d 100644 --- a/docs/database-world.md +++ b/docs/database-world.md @@ -47,6 +47,8 @@ - [creature_template_spell](creature_template_spell) - [creature_text](creature_text) - [creature_text_locale](creature_text_locale) +- [creature_text_option_sets](creature_text_option_sets) +- [creature_text_options](creature_text_options) ## D - [disables](disables)