Module:HeroData/doc: Difference between revisions

From Heroes of Might and Magic: Olden Era Official Wiki
Created page with "This module allows for the dynamic extraction of all variables, stats, and translations for a specific hero stored within the wiki's Cargo database. It automatically handles localized fallback to English if a translation in the requested language is missing. == Basic Syntax == To fetch a data field, use the following syntax: <pre>{{#invoke:HeroData|get|HERO_ID|VARIABLE|LANGUAGE_CODE}}</pre> * '''<code>HERO_ID</code>''' : The technical identifier of the hero (e.g., <cod..."
 
No edit summary
Line 1: Line 1:
This module allows for the dynamic extraction of all variables, stats, and translations for a specific hero stored within the wiki's Cargo database. It automatically handles localized fallback to English if a translation in the requested language is missing.
This module allows for the dynamic extraction of hero data parameters, technical properties, and translated profiles stored within the wiki's Cargo database (specifically from the <code>Hero</code> and <code>Translation</code> tables). It automatically handles localized fallback to English if a translation in the requested language is missing.


== Basic Syntax ==
== Basic Syntax ==
Line 5: Line 5:
<pre>{{#invoke:HeroData|get|HERO_ID|VARIABLE|LANGUAGE_CODE}}</pre>
<pre>{{#invoke:HeroData|get|HERO_ID|VARIABLE|LANGUAGE_CODE}}</pre>


* '''<code>HERO_ID</code>''' : The technical identifier of the hero (e.g., <code>dungeon_hero_10</code>, <code>necro_hero_16</code>).
* '''<code>HERO_ID</code>''' : The technical identifier of the hero (e.g., <code>dungeon_hero_3</code>).
* '''<code>VARIABLE</code>''' : The keyword for the specific data field you want to display (see the list below).
* '''<code>VARIABLE</code>''' : The keyword for the specific data field you want to display (see the list below).
* '''<code>LANGUAGE_CODE</code>''' : ''(Optional)'' The localization code (e.g., <code>en</code>, <code>fr</code>, <code>pt_br</code>). Defaults to English (<code>en</code>).
* '''<code>LANGUAGE_CODE</code>''' : ''(Optional)'' The localization code (e.g., <code>en</code>, <code>fr</code>, <code>pl</code>). Defaults to English (<code>en</code>).


---
---
Line 14: Line 14:


=== 📝 Text & Translations (Language-Dependent) ===
=== 📝 Text & Translations (Language-Dependent) ===
These variables query the <code>Translation</code> table and dynamically adapt to the requested language code.
These fields query the <code>Translation</code> table. They dynamically adapt to the requested language code and fallback to English seamlessly if missing.
{| class="wikitable" style="width:100%;"
{| class="wikitable" style="width:100%;"
! Variable !! Description !! Example Output (en)
! Variable !! Description !! Database Filter Relation
|-
|-
| <code>name</code> || The full display name of the hero. || Kelarr, son of Navarr
| <code>name</code> || The localized name of the hero. || <code>type="hero"</code>
|-
|-
| <code>description</code> || The official lore biography / background story of the hero. || Kelarr, a young minotaur, grew up in...
| <code>description</code> || The localized official biography or lore text of the hero. || <code>type="hero"</code>
|-
|-
| <code>motto</code> || The hero's personal quote or motto. || ''(Motto text)''
| <code>motto</code> || The hero's localized specific quote or motto. || <code>type="hero_motto"</code>
|}
|}


=== ⚔️ Core Combat Statistics ===
=== ⚔️ Split Starting Skills (Virtual Fields) ===
These variables return the initial numerical attributes of the hero from the main <code>Hero</code> table.
Instead of returning a comma-separated string from the database, the module automatically slices the data array into distinct outputs:
{| class="wikitable" style="width:100%;"
{| class="wikitable" style="width:100%;"
! Variable !! Description
! Variable !! Description !! Fallback Behavior
|-
|-
| <code>offence</code> || Starting Attack attribute.
| <code>start_skill_1</code> || Returns the technical ID of the hero's primary starting skill. || Always returns the first value found.
|-
|-
| <code>defence</code> || Starting Defense attribute.
| <code>start_skill_2</code> || Returns the technical ID of the hero's secondary starting skill. || Returns an empty string (<code>""</code>) if the hero only has one starting skill.
|-
| <code>spell_power</code> || Starting Spell Power attribute.
|-
| <code>intelligence</code> || Starting Knowledge / Intelligence attribute (Mana pool).
|-
| <code>luck</code> || The hero's base Luck value.
|-
| <code>morale</code> || The hero's base Morale value.
|-
| <code>start_level</code> || Initial level when recruiting the hero (usually <code>1</code>).
|-
| <code>view_radius</code> || Sight radius / fog-of-war clearing range on the adventure map.
|}
|}


=== 🎨 Identity & Assets ===
=== ⚙️ Core Technical Properties ===
Technical variables describing the hero's classification and visual file naming conventions.
Standard database values extracted directly from the primary <code>Hero</code> table records.
{| class="wikitable" style="width:100%;"
{| class="wikitable" style="width:100%;"
! Variable !! Description !! Example Value
! Variable !! Description !! Example Value
|-
|-
| <code>faction</code> || The hero's internal faction name (ideal for Navboxes and queries). || <code>dungeon</code>, <code>undead</code>, <code>temple</code>, etc.
| <code>class_id</code> || Pointers linking to the hero's mechanical archetype. || <code>might_dungeon</code>
|-
| <code>class_id</code> || The exact class ID assigned to the hero. || <code>magic_dungeon</code>, <code>might_undead</code>, etc.
|-
| <code>class_type</code> || The core archetype profile of the hero. || <code>magic</code> or <code>might</code>
|-
| <code>icon</code> || The exact file name string used for their profile avatar. || <code>hero_dungeon_10_Kelarr</code>
|-
|-
| <code>source_path</code> || The file location path of the original data dump JSON. || <code>DB/heroes/dungeon/dungeon_hero_10.json</code>
| <code>specialization_id</code> || Points to the unique skill perk assigned to this specific hero unit. || <code>dungeon_hero_3_specialization</code>
|}
 
=== 🧙‍♂️ Starting Skills & Spells (Lists) ===
These variables return comma-separated lists of raw database string identifiers.
{| class="wikitable" style="width:100%;"
! Variable !! Description !! Example Output
|-
|-
| <code>start_skills</code> || Comma-joined list of starting skill IDs. || <code>skill_faction_dungeon,skill_enlightenment</code>
| <code>faction</code> || The alignment group or city archetype the hero is drafted under. || <code>dungeon</code>
|-
| <code>start_skill_levels</code> || Skill mastery levels aligned positionally with the starting skills. || <code>1,1</code>
|-
| <code>start_magics</code> || Comma-joined list of starting spell IDs. || <code>day_17_magic_clear_view</code>
|-
| <code>specialization_id</code> || Unique trait / passive capability ID for the hero. || <code>dungeon_hero_10_specialization</code>
|}
|}


Line 80: Line 50:


== Practical Examples ==
== Practical Examples ==
=== Example 1: Creating a Dynamic Introduction Sentence ===
<pre>
'''{{#invoke:HeroData|get|dungeon_hero_10|name|en}}''' is a ''{{#invoke:HeroData|get|dungeon_hero_10|class_type}}'' hero belonging to the '''{{#invoke:HeroData|get|dungeon_hero_10|faction}}''' faction.
</pre>
'''Output:'''
<blockquote>**Kelarr, son of Navarr** is a *magic* hero belonging to the **dungeon** faction.</blockquote>
=== Example 2: Rendering a Hero Profile Picture ===
<pre>
[[File:{{#invoke:HeroData|get|dungeon_hero_10|icon}}.png|64px|link=]]
</pre>
'''Output:''' Dynamically embeds the image file <code>hero_dungeon_10_Kelarr.png</code> rendered at a 64px width constraint.
[[Category:Module Documentation]]

Revision as of 20:08, 25 May 2026

This module allows for the dynamic extraction of hero data parameters, technical properties, and translated profiles stored within the wiki's Cargo database (specifically from the Hero and Translation tables). It automatically handles localized fallback to English if a translation in the requested language is missing.

Basic Syntax

To fetch a data field, use the following syntax:

{{#invoke:HeroData|get|HERO_ID|VARIABLE|LANGUAGE_CODE}}
  • HERO_ID : The technical identifier of the hero (e.g., dungeon_hero_3).
  • VARIABLE : The keyword for the specific data field you want to display (see the list below).
  • LANGUAGE_CODE : (Optional) The localization code (e.g., en, fr, pl). Defaults to English (en).

---

Available Variables

📝 Text & Translations (Language-Dependent)

These fields query the Translation table. They dynamically adapt to the requested language code and fallback to English seamlessly if missing.

Variable Description Database Filter Relation
name The localized name of the hero. type="hero"
description The localized official biography or lore text of the hero. type="hero"
motto The hero's localized specific quote or motto. type="hero_motto"

⚔️ Split Starting Skills (Virtual Fields)

Instead of returning a comma-separated string from the database, the module automatically slices the data array into distinct outputs:

Variable Description Fallback Behavior
start_skill_1 Returns the technical ID of the hero's primary starting skill. Always returns the first value found.
start_skill_2 Returns the technical ID of the hero's secondary starting skill. Returns an empty string ("") if the hero only has one starting skill.

⚙️ Core Technical Properties

Standard database values extracted directly from the primary Hero table records.

Variable Description Example Value
class_id Pointers linking to the hero's mechanical archetype. might_dungeon
specialization_id Points to the unique skill perk assigned to this specific hero unit. dungeon_hero_3_specialization
faction The alignment group or city archetype the hero is drafted under. dungeon

---

Practical Examples