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..."
 
mNo edit summary
 
(3 intermediate revisions by the same user not shown)
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 all hero data parameters, asset references, 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 full index 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>).


---
---


== Available Variables ==
== Technical Reference Index ==


=== 📝 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 battle 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 raw comma-separated string from the database, the module automatically slices the data array into distinct outputs for clean wiki markup nesting:
{| 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>start_magic_1</code> || Returns the technical ID of the hero's primary starting spell/magic. || Returns an empty string (<code>""</code>) if the hero has no starting magic.
|-
|-
| <code>intelligence</code> || Starting Knowledge / Intelligence attribute (Mana pool).
| <code>start_magic_2</code> || Returns the technical ID of the hero's secondary starting spell/magic. || Returns an empty string (<code>""</code>) if the hero has fewer than two spells.
|-
| <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> || Technical ID linking to the hero's mechanical class 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>faction</code> || The alignment group or city archetype the hero is drafted under. || <code>dungeon</code>
|-
|-
| <code>icon</code> || The exact file name string used for their profile avatar. || <code>hero_dungeon_10_Kelarr</code>
| <code>class_type</code> || Archetype category profiling orientation. || <code>might</code> or <code>magic</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>icon</code> || The filename token assigned to the hero portrait graphic asset. || <code>hero_dungeon_3_Stinger</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>specialization_id</code> || Points to the unique combat skill perk assigned to this specific hero unit. || <code>dungeon_hero_3_specialization</code>
|-
|-
| <code>start_skill_levels</code> || Skill mastery levels aligned positionally with the starting skills. || <code>1,1</code>
| <code>source_path</code> || The file path location of the original repository data dump JSON. || <code>DB/heroes/dungeon/dungeon_hero_3.json</code>
|-
|-
| <code>start_magics</code> || Comma-joined list of starting spell IDs. || <code>day_17_magic_clear_view</code>
| <code>start_skills</code> || Raw comma-separated list of all starting skill IDs. || <code>skill_faction_dungeon,skill_battle_artistry</code>
|-
|-
| <code>specialization_id</code> || Unique trait / passive capability ID for the hero. || <code>dungeon_hero_10_specialization</code>
| <code>start_magics</code> || Raw comma-separated list of all starting spell or magic IDs. || <code>day_16_magic_arinas_chosen_special</code>
|}
|}
== Practical Examples ==


---
=== Example 1: Rendering Hero Portrait Images Dynamically ===
To render a hero portrait using their explicit database-defined icon file:
<pre>
[[File:{{#invoke:HeroData|get|dungeon_hero_3|icon}}.png|64px]]
</pre>


== Practical Examples ==
=== Example 2: Parsing Layout Blocks Conditionals via Virtual Fields ===
You can use the native MediaWiki <code>{{#if:}}</code> parser to change your layouts depending on whether a hero has a secondary starting skill or any starting magic:
<pre>
{{#if:{{#invoke:HeroData|get|dungeon_hero_3|start_skill_2}}
  | This hero starts with two skills. Secondary skill ID: {{#invoke:HeroData|get|dungeon_hero_3|start_skill_2}}
  | This hero starts with a single skill only!
}}


=== Example 1: Creating a Dynamic Introduction Sentence ===
{{#if:{{#invoke:HeroData|get|dungeon_hero_3|start_magic_1}}
<pre>
  | This hero has a starting spell: {{#invoke:HeroData|get|dungeon_hero_3|start_magic_1}}
'''{{#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.
  | This hero does not know any magic at the start.
}}
</pre>
</pre>
'''Output:'''
<blockquote>**Kelarr, son of Navarr** is a *magic* hero belonging to the **dungeon** faction.</blockquote>


=== Example 2: Rendering a Hero Profile Picture ===
=== Example 3: Cross-Module Integration Chaining ===
Pass the technical ID returned by this module directly into your skill formatting templates or modules to fetch human-readable information automatically:
<pre>
<pre>
[[File:{{#invoke:HeroData|get|dungeon_hero_10|icon}}.png|64px|link=]]
The primary starting skill name is: {{#invoke:SkillData|get|{{#invoke:HeroData|get|dungeon_hero_3|start_skill_1}}|name|fr}}
</pre>
</pre>
'''Output:''' Dynamically embeds the image file <code>hero_dungeon_10_Kelarr.png</code> rendered at a 64px width constraint.


[[Category:Module Documentation]]
[[Category:Module Documentation]]

Latest revision as of 20:28, 25 May 2026

This module allows for the dynamic extraction of all hero data parameters, asset references, 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 full index below).
  • LANGUAGE_CODE : (Optional) The localization code (e.g., en, fr, pl). Defaults to English (en).

---

Technical Reference Index

📝 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 battle motto. type="hero_motto"

⚔️ Split Starting Skills (Virtual Fields)

Instead of returning a raw comma-separated string from the database, the module automatically slices the data array into distinct outputs for clean wiki markup nesting:

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.
start_magic_1 Returns the technical ID of the hero's primary starting spell/magic. Returns an empty string ("") if the hero has no starting magic.
start_magic_2 Returns the technical ID of the hero's secondary starting spell/magic. Returns an empty string ("") if the hero has fewer than two spells.

⚙️ Core Technical Properties

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

Variable Description Example Value
class_id Technical ID linking to the hero's mechanical class archetype. might_dungeon
faction The alignment group or city archetype the hero is drafted under. dungeon
class_type Archetype category profiling orientation. might or magic
icon The filename token assigned to the hero portrait graphic asset. hero_dungeon_3_Stinger
specialization_id Points to the unique combat skill perk assigned to this specific hero unit. dungeon_hero_3_specialization
source_path The file path location of the original repository data dump JSON. DB/heroes/dungeon/dungeon_hero_3.json
start_skills Raw comma-separated list of all starting skill IDs. skill_faction_dungeon,skill_battle_artistry
start_magics Raw comma-separated list of all starting spell or magic IDs. day_16_magic_arinas_chosen_special

Practical Examples

Example 1: Rendering Hero Portrait Images Dynamically

To render a hero portrait using their explicit database-defined icon file:

[[File:{{#invoke:HeroData|get|dungeon_hero_3|icon}}.png|64px]]

Example 2: Parsing Layout Blocks Conditionals via Virtual Fields

You can use the native MediaWiki parser to change your layouts depending on whether a hero has a secondary starting skill or any starting magic:

{{#if:{{#invoke:HeroData|get|dungeon_hero_3|start_skill_2}}
  | This hero starts with two skills. Secondary skill ID: {{#invoke:HeroData|get|dungeon_hero_3|start_skill_2}}
  | This hero starts with a single skill only!
}}

{{#if:{{#invoke:HeroData|get|dungeon_hero_3|start_magic_1}}
  | This hero has a starting spell: {{#invoke:HeroData|get|dungeon_hero_3|start_magic_1}}
  | This hero does not know any magic at the start.
}}

Example 3: Cross-Module Integration Chaining

Pass the technical ID returned by this module directly into your skill formatting templates or modules to fetch human-readable information automatically:

The primary starting skill name is: {{#invoke:SkillData|get|{{#invoke:HeroData|get|dungeon_hero_3|start_skill_1}}|name|fr}}