Getting Started with Game Modding Europa Universalis 4 - Part Two

Picture shows Jason A. Martin - Software Engineer, Indie Game Developer, Tech Evangelist, Entrepreneur.

In Getting Started with Game Modding Europa Universalis 4 - Part One we laid the groundwork for an EU4 game mod. In this part of the series, we're going to fill in the event file to create an awesome event in the game. I'll explain this file line by line with documentation references and at the end of this article, I'll show the completed file.

For more information on event modding setup, you can read event modding.

Let's Make an Event

When we left off, we created the unicorn.txt file in /mod/unicorn/events/. Open up that file and let's get to building our event.

By the way, if you open up files in the /events/ folder for EU4, you can see how Paradox Interactive did those events to get ideas.

We're going to make an in-game event that triggers when the player's prestige is 1 or more (so right at game start). The event is going to present the player with two choices and each choice will have a mix of good and bad results.

Our event is the appearance of the Holy Unicorn. Once it appears, the player will have a choice to make:

  1. Shun the the unicorn as a false prophet and kill it.
  2. Embrace the unicorn and rub its belly.

Namespace

Your mod file needs to start with a namespace, which helps prevent code conflicts.

#############################
# The Holy Unicorn          #
#############################

namespace = UNICORN

In the above code, I create a new namespace "UNICORN."

Country Event

From here, we're going to create a country event. A blank event looks like this:

country_event = {}

Let's start filling this in.

	id = UNICORN.1
	title = "unicorn_1_title"
	desc = "unicorn_1_desc"
	picture = POPE_PREACHING_eventPicture

We begin with some basic information about this event.

id: This is the event id. It's good practice to use your namespace (UNICORN in this example) along with a number. It's possible to have multiple events, so you'd end up with UNICORN.1, UNICORN.2 and so on.

title/desc: This is the KEY for your localisation. We'll go over this localisation file in the next part of the series.

picture: This is the picture file to use for the event. You can navigate to the EU4 game folder and go into /gfx/event_pictures/ to see what pictures you have. You don't need to enter a file path or file extension here, just the name.

Trigger

The trigger section defines what causes the event to appear. Ours is extremely simple, but you could go to town with conditions in this space.

trigger = {
  prestige = 1
}

mean_time_to_happen = {
    days = 1
}

fire_only_once = yes

I am setting prestige = 1, which means if the player has a prestige of 1 or more, this event fires. In this case, the event will fire moments after starting the game (and starting time ticking).

The block mean_time_to_happen is how often you want the event to happen. For example, months = 6 means the event will fire about every 6 months on average. This block can have other logic in it, such as modifiers based on conditions. Check out the docs for more info.

Additionally, I'm telling this event to only fire once during the lifetime of the game. If this were to be removed, our example event would fire over and over.

Options

Ah, now we get into the meat of it. Our event is going to present the player with two options, which will each have some good and bad outcomes.

For a nice list of what you can modify, check out the modifier list.

Let's look at the first option (kill the unicorn):

option = {
	name = "unicorn_opt_1"
    add_treasury = 500
    add_mil_power = 200
    add_prestige = -30
}

name: This is the KEY for localisation.

add_treasury = 500: The user will get 500 ducats added to the coffers.

add_mil_power = 200: The user will get 200 military power added.

add_prestige = -30: The user's prestige will drop by 30.

And now, let's add the second option (rub its belly):

option = {
	name = "unicorn_opt_2"
    add_prestige = 20
    add_mil_power = -100
    add_adm_power = 50
    add_papal_influence = 50
}

name: The KEY for localisation.

add_prestige = 20: The player's prestige goes up by 20.

add_mil_power = -100: The player loses 100 military power.

add_adm_power = 50: The player gains 50 admin power.

add_papal_influence = 50: The player gains 50 influence with the Papal.

The Complete Event File

Here's the code for unicorn.txt. The formatting may be off (get from the GitHub repo if needed).

#############################
# The Holy Unicorn          #
#############################

namespace = UNICORN

country_event = {
	id = UNICORN.1
	title = "unicorn_1_title"
	desc = "unicorn_1_desc"
	picture = POPE_PREACHING_eventPicture

	trigger = {
  	prestige = 1
	}

	mean_time_to_happen = {
		days = 1
	}

    fire_only_once = yes

	option = {
	name = "unicorn_opt_1"
    add_treasury = 500
    add_mil_power = 200
    add_prestige = -30
	}

	option = {
	    name = "unicorn_opt_2"
        add_prestige = 20
        add_mil_power = -100
        add_adm_power = 50
        add_papal_influence = 50
	}
}

Now that we have the event setup, it's time to create the text for the event in the localisation file.

In Getting Started with Game Modding Europa Universalis 4 - Part Three We will talk about the localisation file (a common source of problems for many modders) and get ready for some in-game testing.