Disaster modding

From Europa Universalis 4 Wiki
Jump to navigation Jump to search

Disasters is a new system introduced in patch 1.9 that replaced the previous MTTH event based system EU4 had to simulate national disasters.

The disaster file[edit]

The first thing you'll want to do is create an empty text file in the /Europa Universalis IV/common/disasters folder.

In this text file, the first line of script is the disaster's name, for example:

influenza_epidemic = {
}

Everything we want to script goes inside this set of brackets. In our example we're using the influenza epidemic that decimated the population of the New World.

Next determine what causes the disaster to be possible. When the potential triggers are true, the disaster will be visible to the player on the stability screen. This is different to what actually makes the disaster tick forward. The kind of arguments you can use are exactly the same as in decisions, events, and missions.

potential = {
        NOT = {
                has_country_flag = had_influenza_epidemic
        }
        OR = {
                technology_group = north_american
                technology_group = mesoamerican
                technology_group = andean
                technology_group = south_american
        }
        any_country = {
                technology_group = western
                has_discovered = ROOT
        }
}

So, the country must not have already had our disaster, they must have one of the New World tech groups, and they must have been discovered by a country in the Western group.

Now we determine what activates the disaster. This enables the "imminent disaster" alert in the UI.

can_start = {
        has_any_disaster = no
        is_year = 1500
}

As of 1.10, you can set conditions that will make disaster progress stop in its tracks:

can_stop = {
        has_any_disaster = yes
}

This condition will end progress if the country enters into a different disaster before this one begins.

And now we make the disaster tick forward. This is done using modifiers. You can determine what ticks the disaster and by how much.

progress = {
        modifier = {
                factor = 1
                any_country = {
                        technology_group = western
                        has_discovered = ROOT
                }
        }
        modifier = {
                factor = 2
                any_neighbor_country = {
                        technology_group = western
                }
        }
        modifier = {
                factor = 1
                any_neighbor_country = {
                        OR = {
                                has_country_flag = had_influenza_epidemic
                                has_disaster = influenza_epidemic
                        }
                }
        }
}

1 tick of progress is made simply for fulfilling a condition of the disaster: being discovered by a Western nation. 2 ticks occur if the country actually borders a Western nation. Finally, a further tick happens if the country borders another country which either has this disaster or has had it before.

Next we write the conditions that will make the disaster end:

can_end = {
        had_country_flag = { flag = flu_epidemic days = 3650 }
        stability = 2
}

In this case, the country must have had a flag (which will be set later, by event) for at least 10 years and have 2 stability.

You might want to create a country modifier that remains with the country until the disaster is over. Typically disasters increase national unrest.

modifier = {
        global_unrest = 3
        stability_cost_modifier = 0.5
}

This disaster increases national unrest by 3, and increases the cost of increasing stability by 50%.

In the final sections we create triggers for events related to the disaster. First, you'll probably want an event for when the disaster starts and when it ends:

on_start = epidemic.1
on_end = epidemic.2

Remember to set or remove flags as appropriate in these events. For example, epidemic.1 should set the flue_epidemic flag; this is important because having had the flag for at least 10 years is a vital trigger for the disaster ending.

Finally, we can set some events which fire while the disaster is going on, on a monthly pulse.

on_monthly = {
        events = {
        }
        random_events = { 
                1000 = 0
                100 = epidemic.3
                100 = epidemic.4	
        }
}

"events" will always fire on the monthly pulse if the triggers in the events are met. "random_events" are weighted. Here there's about a 1 in 6 chance of one of the two events firing each month. Now we're done with this text file.

Localisation[edit]

Once you've written all the events triggered by the disaster, you'll want to write some localisation, like so:

influenza_epidemic: "Influenza Epidemic"
desc_influenza_epidemic: "The nation is suffering from a deadly plague, spread by white devils from across the sea."

Remember to also localise your event titles, descriptions, and options.

Disaster icon[edit]

Finally, the disaster needs an image. You can copy an existing disaster image or make your own. You can find the disaster icons in /Europa Universalis IV/gfx/interface/disasters. Copy/paste one of them into your mod, rename it to the name of your disaster, and either edit the image with your 1337 photoshop skills or leave it alone.

The last thing you need to do to make the image display in-game is to define the icon as a sprite in the interface files. Create a file named influenza_epidemic.gfx (or any other name as long as it's unique and end with .gfx) in your mod's /Europa Universalis IV/interface/ folder. Add the following entry:

spriteTypes = {
 spriteType = {
  name = "GFX_disaster_influenza_epidemic"
  texturefile = "gfx//interface//disasters//influenza_epidemic.dds"
  noOfFrames = 3
  loadType = "INGAME"
 }
}

And we're done, we've created a disaster!

Documentation EffectsTriggersModifiersScopesVariablesLocalisationCustomizable localization
Scripting AdvisorsAgesBookmarksBuildingsCasus belliColonial regionsCountriesCultureDecisionsDefinesDiplomatic actionsDisastersEstatesEventsFactionsGovernmentGreat projectsHistoryIdea groupsInstitutionsMissionsModifiersNation designerPoliciesReligionRebel typesSubject typesTechnologyTrade companiesTrade goodsUnits
Map MapRandom New WorldTrade nodes
Graphics 3D ModelsInterfaceGraphical AssetsFontsParticlesShadersUnit models
Audio MusicSound
Other Console commandsChecksumJoroDox mod making toolMod structureTroubleshootingThe Validator
Guides Adding a province