New to modding - Looking for API docs/Guides to adding events

  • We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

JusticiarIV

Corporal
45 Badges
Mar 13, 2016
39
5
  • Europa Universalis IV
  • Stellaris: Synthetic Dawn
  • Europa Universalis IV: Third Rome
  • Cities: Skylines - Snowfall
  • Europa Universalis IV: Cossacks
  • Cities: Skylines - After Dark
  • Europa Universalis IV: Pre-order
  • Majesty 2 Collection
  • Europa Universalis IV: Call to arms event
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Res Publica
  • Europa Universalis IV: Dharma
  • Cities: Skylines - Green Cities
  • Stellaris: Federations
  • Europa Universalis IV: Cradle of Civilization
  • Stellaris: Humanoids Species Pack
  • Stellaris: Apocalypse
  • Europa Universalis IV: Rule Britannia
  • Cities: Skylines - Parklife Pre-Order
  • Cities: Skylines - Parklife
  • Stellaris: Distant Stars
  • Surviving Mars: First Colony Edition
  • Stellaris: Megacorp
  • Cities: Skylines - Campus
  • Stellaris: Ancient Relics
  • Stellaris: Lithoids
  • Surviving Mars
  • Cities: Skylines
  • Europa Universalis IV: El Dorado
  • Europa Universalis IV: Common Sense
  • Europa Universalis IV: Mare Nostrum
  • Stellaris
  • Europa Universalis IV: Rights of Man
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Leviathans Story Pack
  • Cities: Skylines - Natural Disasters
  • Stellaris - Path to Destruction bundle
  • Cities: Skylines - Mass Transit
  • Europa Universalis IV: Mandate of Heaven
  • Age of Wonders III
  • Cities: Skylines Industries
  • Surviving Mars: First Colony Edition
  • Crusader Kings II
Never modded a game before, but as a computer science student with a few programming classes under my belt I thought it would be fun, and not too challenging, to set up a mod that adds a handful of events to the game. This seems like it should be easy to simply add a few text pop ups and modifiers depending on which option the player selects in response.

I'm not really sure how to get started though, and my searching for any kind of API documentation or guides to adding events, but coming up pretty short. I've looked through the stellaris/events and common/anomalies text files, and I have a basic grasp on the syntax and how things should look, but for example:

In this vanilla event

### Asteroid Fossils
ship_event = {
id = anomaly.15
title = "anomaly.15.name"
desc = "anomaly.15.desc"
picture = GFX_evt_mining_station
show_sound = event_ship_bridge
location = FROM

is_triggered_only = yes

option = {
name = FASCINATING
owner = {
add_monthly_resource_mult = {
resource = society_research
value = @tier1researchreward
min = @tier1researchmin
max = @tier1researchmax
}
}
}
}

It looks pretty clear that the id, title, and desc are calling a method in a different class somewhere, but I can't seem to see where it is or what methods the class contains that I can work with. So is there any official documentation I can look into to see more information? is there just a well written guide on how to events I can see? any help would be appreciated.
 

Idhrendur

Keeper of the Converters
107 Badges
Feb 27, 2009
11.438
3.135
  • Hearts of Iron IV: No Step Back
  • Hearts of Iron IV: By Blood Alone
  • Crusader Kings II
  • Victoria 3 Sign Up
  • Stellaris: Nemesis
  • Sengoku
  • Pillars of Eternity
  • Tyranny: Archon Edition
  • Europa Universalis IV
  • March of the Eagles
  • Victoria 2
  • 500k Club
  • Stellaris: Galaxy Edition
  • Hearts of Iron IV: Colonel
  • Shadowrun Returns
  • Imperator: Rome Deluxe Edition
  • Crusader Kings III: Royal Edition
  • Commander: Conquest of the Americas
  • Darkest Hour
Sadly, the documentation isn't really the best. The easiest method seems to be examining the existing events and such and emulating them.
 

JusticiarIV

Corporal
45 Badges
Mar 13, 2016
39
5
  • Europa Universalis IV
  • Stellaris: Synthetic Dawn
  • Europa Universalis IV: Third Rome
  • Cities: Skylines - Snowfall
  • Europa Universalis IV: Cossacks
  • Cities: Skylines - After Dark
  • Europa Universalis IV: Pre-order
  • Majesty 2 Collection
  • Europa Universalis IV: Call to arms event
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Res Publica
  • Europa Universalis IV: Dharma
  • Cities: Skylines - Green Cities
  • Stellaris: Federations
  • Europa Universalis IV: Cradle of Civilization
  • Stellaris: Humanoids Species Pack
  • Stellaris: Apocalypse
  • Europa Universalis IV: Rule Britannia
  • Cities: Skylines - Parklife Pre-Order
  • Cities: Skylines - Parklife
  • Stellaris: Distant Stars
  • Surviving Mars: First Colony Edition
  • Stellaris: Megacorp
  • Cities: Skylines - Campus
  • Stellaris: Ancient Relics
  • Stellaris: Lithoids
  • Surviving Mars
  • Cities: Skylines
  • Europa Universalis IV: El Dorado
  • Europa Universalis IV: Common Sense
  • Europa Universalis IV: Mare Nostrum
  • Stellaris
  • Europa Universalis IV: Rights of Man
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Leviathans Story Pack
  • Cities: Skylines - Natural Disasters
  • Stellaris - Path to Destruction bundle
  • Cities: Skylines - Mass Transit
  • Europa Universalis IV: Mandate of Heaven
  • Age of Wonders III
  • Cities: Skylines Industries
  • Surviving Mars: First Colony Edition
  • Crusader Kings II
Alright so far I have created a common, events, and localisation folders in my mod directory. under common i made a 00_anomalies text file with this in it

###Justiciar's Anomaly Events###


# test event
anomaly = {
event = anomaly.3000
category = "PLACEHOLDER" #Haven't figured out what file has the categories in them yet

weight 100 # Trying to guarantee this event spawns for testing purposes

potential = {
always = yes
}
}

In the events folder I have anomaly_events_1.txt

#### Test event
#Just a test
ship_event = {
id = anomaly.3000
title = "anomaly.3000.name"
desc = "anomaly.3000.desc"
picture = GFX_evt_gas_giant
show_sound = event_scanner
location = FROM

is_triggered_only = yes

immediate = { from = { orbital_deposit_tile = { clear_deposits = yes } } }

option = {
name = FASCINATING
FROM = {
add_modifier = {
modifier = "zro_ice"
days = -1
}
hidden_effect = {
orbital_deposit_tile = {
add_deposit = d_zro_deposit
}
}
}
}
}

And under localization I have events_1_I_english.ypp

anomaly.3000.name:0 "Test Anomaly" anomaly.3000.desc:0 "[From.getName] is a test planet designed to test this mod.


Didn't see it pop up during a quick game where I just had about 20 science ships scanning at full speed for 30 years so I'm obviously doing something wrong. Anything that sticks out as to what I'm missing?
 

Swizzlewizzle

First Lieutenant
7 Badges
May 6, 2016
214
49
  • Magicka
  • Stellaris
  • Stellaris: Leviathans Story Pack
  • Stellaris - Path to Destruction bundle
  • Stellaris: Megacorp
  • Crusader Kings III
  • Crusader Kings III: Royal Edition
I suggest you look at the "Captain's log" post by Divine stickied on the top of this forum and check out what he wrote regarding the Log command. I made a request after launch to get Log into the mod API specifically for this reason and they were able to add it in one of the recent versions (1.4 I think?).

Anyways, log the heck out of your effects and it will get you to the point of writing working events very quickly. Definitely more effective then relying on people to respond here... i'm not sure the reason but compared to other modding communities this one doesn't really see a lot of people responding to each other on the forum... well except the "quick questions" thread.. that one is always hopping, though it is REALLY hard to search through and I wish that people would stop using it.
 

Talvos

First Lieutenant
67 Badges
Mar 23, 2009
230
79
  • Heir to the Throne
  • Europa Universalis IV: Common Sense
  • Europa Universalis IV: Pre-order
  • Stellaris - Path to Destruction bundle
  • Victoria 2: Heart of Darkness
  • Victoria 2: A House Divided
  • Europa Universalis IV: Res Publica
  • March of the Eagles
  • Magicka
  • Knights of Pen and Paper +1 Edition
  • Europa Universalis IV: Call to arms event
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Art of War
  • Cities in Motion
  • Europa Universalis III Complete
  • Cities in Motion 2
  • Crusader Kings II
  • Crusader Kings II: Charlemagne
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: The Republic
  • Europa Universalis III
  • Divine Wind
  • Europa Universalis III: Chronicles
  • Crusader Kings II: Sons of Abraham
  • Deus Vult
  • Crusader Kings II: Sword of Islam
  • Crusader Kings II: Monks and Mystics
  • Crusader Kings II: Reapers Due
  • Crusader Kings III
  • Stellaris: Leviathans Story Pack
  • Stellaris Sign-up
  • Hearts of Iron IV Sign-up
  • Stellaris: Digital Anniversary Edition
  • Stellaris
  • Crusader Kings II: Conclave
  • Europa Universalis IV: Cossacks
  • Crusader Kings II: Horse Lords
  • Magicka 2
  • Humble Paradox Bundle
  • Crusader Kings II: Way of Life
  • Magicka: Wizard Wars Founder Wizard
  • Europa Universalis IV: El Dorado
  • Crusader Kings II: Holy Knight (pre-order)
  • 500k Club
  • Victoria 2
  • Europa Universalis III Complete
  • Europa Universalis III Complete
If you're going to post code on the forums, please use code tags.

Writing (without the underscores)
[_code]
line_1 = {
line_2 = yes
}
[_/code]

(note that there are actually 4 spaces on line 2 above - they don't appear without the code block) appears as

Code:
line_1 = {
    line_2 = yes
}

it's much easier to read.

Also you should use notepad++ if you aren't using it already. Also see here for an anomaly modding tutorial. You should read through this all, as it explains how to add an anomaly.

Alright so far I have created a common, events, and localisation folders in my mod directory.

So you have the following folders?

\common\anomalies\
\events\
\localisation\english\

under common i made a 00_anomalies text file

It should be in \common\anomalies\, not in \common\.

with this in it 00_anomalies text file

Code:
###Justiciar's Anomaly Events###


# test event
anomaly = {
        event = anomaly.3000
        category = "PLACEHOLDER" #Haven't figured out what file has the categories in them yet
    
        weight 100  # Trying to guarantee this event spawns for testing purposes
    
        potential = {
                always = yes
        }
}

You need 'weight = 100' - you forgot the equals sign. The anomaly categories are in \common\anomalies\, under the different anomaly_categories text files. You'll need to make your own category, and link your anomaly here to it, or use one of the preexisting categories.

In the events folder I have anomaly_events_1.txt


Code:
#### Test event
#Just a test


ship_event = {
        id = anomaly.3000
        title = "anomaly.3000.name"
        desc = "anomaly.3000.desc"
        picture = GFX_evt_gas_giant
        show_sound = event_scanner
        location = FROM
    
        is_triggered_only = yes
    
        immediate = { from = { orbital_deposit_tile = { clear_deposits = yes } } }
    
        option = {
                name = FASCINATING
                FROM = {
                        add_modifier = {
                                modifier = "zro_ice"
                                days = -1
                        }
                        hidden_effect = {
                                orbital_deposit_tile = {
                                        add_deposit = d_zro_deposit
                                }
                        }
                }
        }
}

This looks OK, but you should really just make your own events file with their own event namespace. You should only be modifying the vanilla files to change something. Not to add your own content. This makes it much easier to update your mod with new patches, and makes it more compatible with other mods.
You should make a new event file, call it my_anomaly_events.txt or something (come up with something more creative than just 'my_xyz' - I'm just using it on this post as an example), and put:

Code:
namespace = my_anomaly_events

#### Test event
#Just a test

ship_event = {
  id = my_anomaly_events.1
  title = "my_anomaly_events.1.name"
  desc = "my_anomaly_events.1.desc"
  picture = GFX_evt_gas_giant
  show_sound = event_scanner
  location = FROM

  is_triggered_only = yes

  immediate = { from = { orbital_deposit_tile = { clear_deposits = yes } } }

  option = {
    name = FASCINATING
    FROM = {
      add_modifier = {
        modifier = "zro_ice"
        days = -1
      }
      hidden_effect = {
        orbital_deposit_tile = {
          add_deposit = d_zro_deposit
        }
      }
    }
  }
}

making sure to correct your localisation and anomaly files with correct event id.


And under localization I have events_1_I_english.ypp

Make sure it's under \localisation\english\, not just \localisation\. Also use 'localisation', not 'localization'. You also should make sure your own localisation file name does NOT follow paradoxes convention - leave events_# etc. to them, and use something else for yourself. Call it 'my_events_l_english.yml'. That is "my_events_'lower case el'_english", not "my_events_'upper case eye'_english". Best way to do this is to copy a vanilla localisation file over to your mod, rename it, and strip out all the localisation and add your own.

Code:
 anomaly.3000.name:0 "Test Anomaly"
 anomaly.3000.desc:0 "[From.getName] is a test planet designed to test this mod.

Looks okay. Just make sure you follow the style in the vanilla localisation files. So your entire localisation file would look like:

Code:
l_english:
 anomaly.3000.name:0 "Test Anomaly"
 anomaly.3000.desc:0 "[From.getName] is a test planet designed to test this mod.
Note the spaces.

Didn't see it pop up during a quick game where I just had about 20 science ships scanning at full speed for 30 years so I'm obviously doing something wrong. Anything that sticks out as to what I'm missing?

I mentioned it above - but it's because you don't have a category. The anomaly categories are the 'anomalies' you find in the game. The anomaly you made above is one of the outcomes to its category (in this case the PLACEHOLDER category - which is not defined). If you had multiple anomalies in the same category, then it would randomly choose one of the anomalies on success depending on the weight (you put 100 above, but even if you put 1 it would always be chosen since it's the only anomaly in its category).

Again, please see here for an anomaly modding tutorial.