Event modding

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

An event is a popup with text that occurs either when conditions are met, or the event is triggered through a command. These events will have options that can execute commands, and display text.

A regular event must contain the following:

  • A unique id
  • A title
  • A description
  • A picture
  • A trigger and "mean time to happen"
    • Alternatively, it can be marked as "is_triggered_only = yes", meaning it is only triggered by a command.
  • One or more options for the player or AI to pick.
  • Optional: localisation

A news event must contain the following:

  • A unique id
  • A picture
  • A trigger and "mean time to happen"
    • Alternatively, it can be marked as "is_triggered_only = yes", meaning it is only triggered by a command.
  • One or more options for the player or AI to pick.
  • Optional: localisation

This is an example of a regular event:

country_event = {
	id = nuke_dropped.0 # The unique id. nuke_dropped is the namespace, which can be used for better organization.
        title = nuke_dropped.0.t # The localisable text that appears as a header
        desc = nuke_dropped.0.d # The localisable main text body that appears
	picture = GFX_report_event_election_vote # Image displayed alongside the text.

	is_triggered_only = yes # Optional : if set to "yes" the event will only occur by command

	hidden = yes # Optional : if set to "yes" no one will see the event

	fire_only_once = yes # Optional : if set to "yes" the event will never occur more than once

	immediate = { # Optional : all the following will occur once the event occurs
		if = {
			limit = {
				tag = ITA
				has_government = fascism
				FROM = { state = 378 }
			}
			set_country_flag = duce_nukedem_flag
		}
		news_event = { id = nuke_dropped.1 days = 1 }
	}
	
	option = { # This is an example of an option that has no function
		name = dummy_nuke_option.1.a # The localisable text that appears on the button.
	}
        option = { # This is an example of an option that has a function
		name = dummy_nuke_option.1.b # The localisable text that appears on the button.
                add_political_power = 100
	}
}

This is an example of a news event:

news_event = {
	id = nuke_dropped.0 # The unique id. nuke_dropped is the namespace, which can be used for better organization, and is used in localisation.
	picture = GFX_news_event_nuke # Image displayed alongside the text.

	major = yes # Optional : if set to "yes" every country in the world will see this event

	is_triggered_only = yes # Optional : if set to "yes" the event will only occur by command

	hidden = yes # Optional : if set to "yes" no one will see the event

	fire_only_once = yes # Optional : if set to "yes" the event will never occur more than once

	immediate = { # Optional : all the following will occur once the event occurs
		if = {
			limit = {
				tag = ITA
				has_government = fascism
				FROM = { state = 378 }
			}
			set_country_flag = duce_nukedem_flag
		}
		news_event = { id = nuke_dropped.1 days = 1 }
	}
	
	option = { # This is an example of an option that has no function
		name = dummy_nuke_option.1.a # The localisable text that appears on the button.
	}
        option = { # This is an example of an option that has a function ( usually not done on a news event )
		name = dummy_nuke_option.1.b # The localisable text that appears on the button.
                add_political_power = 100
	}
}

The two types of events are news_event and country_event.

news_event is generally used to notify players about stuff. country_event is generally used to make the player/ai decide something.

The Meantime to Happen, usually referred to as MTTH, states the average time it will take for the event to occur

	mean_time_to_happen = {
		days = 500
		modifier = {
			factor = 0.4 # If true multiply 500 by 0.4 = 200
			NOT = { country_exists = SOV }
		}
		modifier = {
			factor = 0.4 # If true multiply 200 by 0.4 = 40
			NOT = { country_exists = ENG }
		}
		modifier = {
			factor = 0.1 # If true multiply 40 by 0.1 = 4
			NOT = { country_exists = ENG }
			NOT = { country_exists = SOV }
		}
	}

The Trigger block is what is required for the event to fire. The event console command ignores this block.

	trigger = {
		country_exists = USA
	}

It is possible to have multiple descriptions for the same event. For this, you need a "text" (the description name) and a trigger - these can NOT be the same as the other description. For example:

	desc = {                               #This is the first description, it will be used if the ace pilot is promoted in any country except the major ones (listed below).
		text = ace_promoted.1.d        #this is the localisable text name, which needs to be unique.
		trigger = {                    #this is needed trigger.
			NOT = { tag = GER }    #This means that the description will not trigger if the pilot is promoted in Germany, Italy, France, Japan, the United States, the United Kingdom or the Soviet Union.			
                        NOT = { tag = ITA }
			NOT = { tag = FRA }
			NOT = { tag = JAP }
			NOT = { tag = USA }
			NOT = { tag = ENG }
			NOT = { tag = SOV }
		}
	}
	desc = {    #This is the second description, it will be used if the ace pilot is promoted in any major country (of the ones listed below).
		text = ace_promoted.1.d_major
		trigger = {
			OR = {
				tag = GER       #This means that the description will only trigger if the pilot is promoted in Germany, Italy, France, Japan, the United States, the United Kingdom or the Soviet Union.
				tag = ITA       
				tag = FRA
				tag = JAP
				tag = USA
				tag = ENG
				tag = SOV
			}
		}
	}

That is the basis of event modding. If you want more information, you may want to be trying to look at the EUIV wiki for modding until the pages for modding on the HOI IV wiki fill up more. Expect the Scopes, defines, commands, and other related things to be different, though.

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