• 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.

Soviet_Onion

First Lieutenant
57 Badges
Aug 21, 2009
230
90
  • Crusader Kings II
  • Steel Division: Normand 44 - Second Wave
  • Stellaris: Synthetic Dawn
  • Stellaris - Path to Destruction bundle
  • Sword of the Stars II
  • Semper Fi
  • Ancient Space
  • Naval War: Arctic Circle
  • King Arthur II
  • Hearts of Iron III: Their Finest Hour
  • Hearts of Iron III
  • For the Motherland
  • Crusader Kings II: Sword of Islam
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: Charlemagne
  • Cities: Skylines - Campus
  • BATTLETECH
  • Surviving Mars
  • Age of Wonders III
  • Cities: Skylines - Mass Transit
  • Hearts of Iron IV: Expansion Pass
  • Stellaris: Humanoids Species Pack
  • Stellaris: Apocalypse
  • Surviving Mars: Digital Deluxe Edition
  • Steel Division: Normandy 44 -  Back to Hell
  • Cities: Skylines - Parklife Pre-Order
  • Cities: Skylines - Parklife
  • Stellaris: Distant Stars
  • Cities: Skylines Industries
  • Stellaris: Megacorp
  • Age of Wonders: Planetfall
  • Cities: Skylines - After Dark
  • Stellaris: Ancient Relics
  • Supreme Ruler 2020
  • Victoria 2
  • Rome: Vae Victis
  • 500k Club
  • Crusader Kings III
  • Crusader Kings II: Way of Life
  • Pillars of Eternity
  • Steel Division: Normandy 44
  • Cities: Skylines - Snowfall
  • Stellaris
  • Hearts of Iron IV: Cadet
  • Tyranny: Archon Edition
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Leviathans Story Pack
  • Cities: Skylines - Natural Disasters
I'm a complete noob in events but I have ideas :)


I try to create technological risks events tied to some buildings.

Example.
I created a nuclear power plant. I want it to have a low probability to become Tchernobyl (let say 0.01% on yearly pulse) and irradiate the tile on which it is.

I simply don't understand how to create the related events
Can anyone help me?
 
Well, there's two ways of going about it, you can either trigger it on a yearly pulse by using on_yearly_pulse (found in the file in common/on_actions) or you do it through a normal mean time to happen (mtth) event. The second I would say is easier, but the first is more easy to average out to a specific percentage if that is what you want.

In general I'd recommend you go through the test events to familiarise yourself with the structure and syntax of events, as well as look at other events to see how they have solved the things they want to do.

To start you off, here's Test Event 1 that I'll go through and explain the parts, never mind the #, as that just means that the game won't read the lines, as these are just for demonstration from the vanilla files:

Code:
#country_event = {
#    id = henrik.1
#    title = OK
#    desc = OK
#   
#    hide_window = yes
#   
#    mean_time_to_happen = {
#        days = 1
#    }
#   
#    trigger = {
#        is_ai = no
#    }
#   
#    immediate = {
#        random_country = {
#            limit = {
#                NOT = { is_same_empire = ROOT }
#                is_ai = yes
#            }
#            country_event = {
#                id = henrik.2
#                days = 3
#            }
#        }
#    }
#}

country_event this is what type of event it is, in this case it means unsuprisingly that it will be executed in a country scope. For your event you'll likely want a planet_event.

id is the id of the event. At the beginning of each file you have to declare a namespace (not seen in this snippet), in this case henrik, and then ID each event with a unique number for that namespace. Mainly, ID is used for triggering other events inside an event or from an on_action.

title and desc are which string from the localisation files they will get. In this case both of them will just take the OK as this event is only for debugging purposes.

hide_window = yes this means that no window will pop up for the player, useful for hidden events and game mechanics. By default this is no, so you don't need to have hide_window = no on an event you want to pop up.

mean_time_to_happen there are two types of events broadly speaking, triggered events and mtth events. Triggered events will only happen if directly triggered (they are marked with triggered_only = yes ) by another event or on_action. mean_time_to_happen has a random chance to be triggered as long as the event trigger is true and will average out to happen after the time in the mtth. You don't need to use days here, but can also use months and years.

trigger this is one of the most important part of the events, as this tells the event when to fire. In this case it only checks if the country which the event would fire for is AI. For your event you'd most likely want to have a condition along the line of any_tile = { has_building = nuclear_plant }

immediate (also option and after, although not used in this event) is the way the event applies its effects. In this case the effect is that a random country, which is limited to any other country and is ai, gets another event after 3 days. It is in this bracket that the meat of your event will be. Immediate effects will happen as soon as the event fires, but you can also use after to have the effects apply after the pop up window closes.

option is used for choices and player interaction. For any event that pops up you'll want an option, if nothing else to just have the player confirm and get rid of the pop up. You can also add effects to options, which then take effect when you select it.
 
For the record if paradox did their math right, the probability of a mtth event is one/mtth. So a event with a 1% chance per year is mtth=100 years.