Event coding

From Europa Universalis 2 Wiki
Jump to navigation Jump to search

Introduction

The code for the events are in the "Event files", which (although they don't have any special name conventions) often have a "*.eue" suffix or a "*.txt" suffix.

Let's look at a simple example:

#########################################################################
#  Random Revolt
#########################################################################
event = {
  id = 94001  # Paradox 1001
  trigger = {
    NOT = { countrysize = 30 } 
  }
  random = yes
  name = "EVENTNAME1" 
  desc = "EVENTHIST1" 
  action_a = {
    name = "OK" 
    command = { type = revolt which = -1 } 
  }
}

The code "event = {" begins the event and the last "}" ends the event.

The rest of the code (including code not showed in this example) can be divided in the following groups:

  • Comments (that have no influence on the behaviour of the event): "# Random Revolt " and " # Paradox 1001 ".
  • Identity of the event: "id = 94001".
  • Name and description of the event: " name = "EVENTNAME1" " and " desc = "EVENTHIST1" ".
  • Selective directives in the "trigger" clause: "trigger = { NOT = { countrysize = 30 } }".
  • Selective directives outside of the "trigger" clause: "country = MOS" or "province = 362" (none of this type is in the example above).
  • Non selective directives: "random = yes".
  • Actions to be taken when the event is triggered and really happens.

General Categories of Events

When dealing with events it's helpful to categorize them in the following manners:

  • Whether they are random ("random = yes") or not ("random = no").
  • Whether they are meant to happen to both the player and the ai countrys, or only for ai countrys ("ai = yes"), or only for the player ("ai = no").
  • Whether they should happen for a specific country ("country = MOS") or for a specific province ("province = 362") regardless which country the province is owned by.

Directives outside the trigger clause

Comments

Comments begins with a "#". This and the rest of the line is treated as a comment. They don't have any influence on the event.

IDs

Every event must have an identity, given through the "id" clause. The identity must be unique in the game. The events numbered 1 - 100000 is reserved for Paradox (the games vendor). You can use numbers within the 100001 - 4294967296 range. Note that each mod has its own range of event numbers (or, if we are unlucky, they clash with another or Paradox). You must check this before you give id's to your events. The format is:

id = event_number

Example:

id = 94001 

Other directives

Directive Values Purpose
country country's tag This statement tells which country the event should affect. This must be set to a valid country tag. If this statement is left out, the event will happen for all countries! The country can be omitted if the event is a random event or if you have other triggers deciding the country affected, like owned or control.
random yes/no This directive tells whether the event should be random or not. For country events, this is usually no. Random events are the only event that can happend more than once.
province province's id An alternative to using the country statement, this means that the event should happen for whoever owning a certain province.
style 1-5 This specifies the look of the event window depending on the time period when the event appears. (1=15th century, 5=19th.) Note: Style isn't used in EU2.
date { day = x month = y year = zzzz } This is the date when the event may first happen. If this directive is used alone (no offset), the event will happen on this exact date if triggers are valid. If triggers are not valid the event will never happend!
offset x This is a random offset in days, always used in conjunction with the date statement. It means that the event may happen on any of these days from the time specified in date. If the event has triggers it will start searching for triggers on this date. Note: After the first trigger check after a random number of days the triggers are checked again at intervalls defined by the offset. This means that for an 'offset = 360' the event will first check the triggers on a random day the first year after the set date, and then once every year! If a game is saved/reloaded in the middle of an offset, the event is checked at reload (which explains why you so often get certain events on reload).
deathdate { day = x month = y year = zzzz } This is the deadline of an event, after which it may no longer be triggered. The deathdate statement is only useful if the event has a trigger condition. Events without a deathdate will fire if other triggers are valid on the date specified by the date/offset parameters. If triggers are not valid on that date the event will never fire. If you want the event to keep looking for triggers you need to define a deathdate.


Name and Description

The name is what you get as a header in the event window in the game. The description is the descriptive text below. There are three types of name clauses:

name = "name-text-id"

an example:

name = "EVENTNAME1" 

or:

name = "user-supplied-text"

an example:

name = "Unprovoked Revolt" 

or a special variant:

name = "AI_EVENT" 

When using the "name-text-id" variant you is directing EU2 to get the header text from the "text.csv" file. Which of course must be found there to make it work. E g "name = "EVENTNAME1" " means that there is an entry in that file with the name "EVENTNAME1" that have accompanying text. The second example have the header text directly in the event itself. But this makes it difficult for these who want to translate the text to other languages. The third example is a special directive that - if it's an ai only event - hides the event from the game log. The effects of the event is still happening in the game.


There are two types of desc clauses:

desc = "desc-text-id"

an example:

desc = "EVENTHIST1" 

or:

desc = "user-supplied-text"

an example:

desc = "Revolts were almost part of everyday life for the rulers all over Europe. 
High taxes noblemen cruelties as well as cultural and religious differencies
caused unhappiness among the farmers and in the cities and in the most extreme
cases this led to rebellions with sometimes long lasting and drastic effect."

The workings of these are the same as for the first two in the name clause above.

Selective directives in the trigger clause

Overall

Command Values Purpose
ai yes / no Checks if the country receiving the event is AI controlled or not.
event xxxx Checks if event with id xxxx has happened.
flag flag name Checks if the country flag with the specified name is set.
year x Checks if the year is x or later. This is equivalent to using the date statement.

Diplomatic conditions

Command Values Purpose
alliance { country = aaa country = bbb ) Checks if aaa and bbb are in the same military alliance.
atwar yes / no Checks if the country is at war.
dynastic { country = aaa country = bbb ) Checks if aaa and bbb have a royal marriage.
vassal { country =aaa country = bbb } Checks if country bbb is a vassal of aaa.
war { country = aaa country = bbb ) Checks if country aaa is at war with country bbb.

Religious and cultural conditions

Command Values Purpose
provinceculture { prov = x data = y } Is true if province x has culture y.
provincereligion { province = x data = y } Is true if province x has religion y.
religion catholic / counterreform / protestant / reformed / orthodox / sunni / shiite / confucianism / buddhism / hinduism / pagan Checks the state religion of the country.

Based on monarchs and leaders

Command Values Purpose
leader xxxx Is true if leader with id xxxx is alive.
monarch xxxx Is true if monarch with id xxxx is alive.

Based on countries and provinces

Command Values Purpose
badboy x Is true if badboy is x or higher.
continent europe / america / asia / africa / oceania Checks on which continent the capital of the country getting the event lies.
control { province = x data = aaa } Is true if province x is controlled by country aaa (if data = -1 then it is for the country receiving the event)
core { province = x data = aaa } Is true if province x is a core province of country aaa (if data = -1 then it is for the country receiving the event).
cot x Is true if there is a center of trade in province x.
countrysize x Is true if the receiving country owns x provinces or more. Cities and colonies are counted. From 1.07 trading posts no longer count.
discovered x Is true if province x has been discovered by (any) europeans.
exists aaa Is true if country aaa exists. (Where aaa is the three letter tag of the country.)
neighbour x Is true if the receiving country is neighbour with country x.
owned { province = x data = aaa } Is true if province x is owned by country aaa (if data = -1 then it is for the country receiving the event)
relation { country = x value = y } Is true if the receiving country have relation y or better with country x.

Based on domestic affairs

Command Values Purpose
domestic { type = aristocracy / centralization / innovative / mercantilism / land / offensive / quality / serfdom value = x } Checks if a domestic policy slider is at value x or higher. (Use NOT to negate.)
infra x Checks if the infrastructure tech level is at x or higher. (0 to 10)
land x Checks if the land tech level is at x or higher. (0 to 60)
naval x Checks if the naval tech level is at x or higher. (0 to 60)
stability x Checks if the stability level is at x or higher. (-3 to 3)
trade x Checks if the trade tech level is at x or higher. (0 to 10)

See also