National Focus modding

From Hearts of Iron 4 Wiki
Jump to: navigation, search

The focus trees allow the players (and the AI) to direct the development of their nation. Each country has a focus tree, representing a number of progression paths (branches) available to that nation.

National Focuses are found in /Hearts of Iron IV/common/national_focuses/*.txt.

National Focus Tree[edit]

A set of National Focuses are grouped together into a tree. It is best to think of the tree as seperate from the individual focuses.

A National Focus tree follows this format:

focus_tree = {
    id = <name>
    
    # Determines whether a country is assigned this tree
    country = {
        factor = 0  # 0 is used for all non-default trees.
        
        # Adds 10 when the set of triggers is met, assigning the tree to said country if the value is higher than
        # any other tree.
        modifier = {
            add = 10    
            
            <triggers>
        }
    }
    
    # Determines if this tree is considered the default (fallback) tree.
    default = yes / no
    
    focus = {
        # ...
    }
}

Here is a working example. Say you wanted to add a new tree for Germany, but you don't want to edit the original Germany tree. To do this, you'd create your new tree and in the country scope add a modifier that adds 20 if the current tag is Germany.

focus_tree = {
    id = alt_germany_focus
    
    country = {
        factor = 0
        
        modifier = {
            add = 20
            
            tag = GER
        }
    }
}

This adds 20, which is higher than the 10 used in germany.txt, meaning Germany will be assigned your custom tree.

Goal[edit]

Each National Focus tree is made up of multiple focuses (goals). These focuses detail when they can be taken, if they can be taken, what occurs when they are taken, etc.

A focus follows this format:

focus = {
    id = <name>     # Localized to give the focus its name
    icon = <image>  # Asset definition from a .gfx file (normally goals.gfx)
    text = <key>    # Assign a different localization key to use for the description
    
    x = <int>   # The x position of the focus in the National Focus window
    y = <int>   # The y position of the focus in the National Focus window
    
    cost = <int>   # Modifies the time the focus takes to complete. 1 = 7 days
    
    # Completed focuses required before this focus can be taken
    prerequisite = {
        focus = <focus> # Can add multiple
    }
    
    # Restricts usage of this focus if the listed focus has be taken
    mutually_exclusive = {
        focus = <focus> # Can add multiple
    }
    
    # Allows this focus to be bypassed if the triggers are met
    bypass = {
        <triggers>
    }
    
    # Determines if this focus is available to take.
    available = {
        <triggers>
    }
    
    # Determines if the focus should be cancelled.
    cancel = {
        <triggers>
    }
    
    # Determines if the AI should use this focus if the triggers are met (with Historical Focuses option active)
    historical_ai = {
        <triggers>
    }
    
    # States that the focus will lead to war with the specified tag
    will_lead_to_war_with = <tag>   # May have multiple
    
    # Stops the focus from cancelling if the available triggers become invalid.
    cancel_if_invalid = no
    
    # Makes this focus available whilst capitulated
    available_if_capitulated = yes
    
    # Tooltip to show instead of auto-generated effect tooltip from completion_reward
    complete_tooltip = {
        <effects>
    }
    
    # Effect to execute on focus completion
    completion_reward = {
        <effects>
    }

    # Determines the weight the AI uses when picking its next focus
    ai_will_do = {
        factor = <float>
        
        # Modifies the base factor if the triggers are met
        modifier = {
            factor = <float>
            <triggers>
        }
    }
}

When using prerequisite, note that adding multiple focuses within the scope is used to limit the focus to requiring one of the listed focuses (OR), whereas using multiple prerequisite scopes is used to limit the focus to requiring all of the listed focuses (AND).

When positioning a focus within a National Focus tree, remember than each integer on the y-axis is a row, and each integer on the x-axis is a column. Knowing this makes it trival to position the focuses.

Usage of complete_tooltip may seem confusing at first. It is used when the generated effect tooltip would be confusing or indeterminate. For example, in GER_air_innovation, random_owned_controlled_state is used in the completion_reward, but every_state is used in the complete_tooltip as a proxy, so the player knows that the effect may occur in any of their states.

Localization[edit]

Each focus must be localized in a .yml file in the localisation folder within your mod.

<focus>: ""
<focus>_desc: ""

Notes[edit]

  • It is very important to include National Focuses, as they control much of the AI's aggression. Without suitable focuses, the AI will not be very active.


Modding
Documentation EffectsTriggersModifiersScopesLocalisation
Scripting AIBookmarksBuildingsCosmetic tagsCountriesDivisionsDecisionsEquipmentEventsIdeasIdeologiesNational FocusesResourcesTechnologyUnits
Map MapTerrainStatesSupply areasStrategic regions
Graphical InterfaceGraphical Assets
Cosmetic PortraitsNamelistsMusicSound
Other Console commandsTroubleshootingMod structure