Jump to content

Modding Help: Random events


zia

Recommended Posts

No event to troubleshoot or anything like that, more of just a general question:

 

How do you setup an event to fire randomly? I tried using the ck2 wiki but I just cant seem to wrap my head around it. So to all you more experienced modders: Mind telling me how its done?

 

Thank you in Advance!

Link to comment
1 hour ago, zia said:

No event to troubleshoot or anything like that, more of just a general question:

 

How do you setup an event to fire randomly? I tried using the ck2 wiki but I just cant seem to wrap my head around it. So to all you more experienced modders: Mind telling me how its done?

 

Thank you in Advance!

If you are firing from scratch (not from an already running event or decision), you generally put the event it into on_actions (such as on_yearly_pulse) in the random section.  The larger the number, the more likely the event is to fire that year.  If that won't work for what you want, there are a few other tricks one can use. 

<on_action_name> = {
	events = {
		#List of events that must always fire. 
		<event1>
		<event2>
	}
	random_events = {
		#List of events that may fire. Weight multiplier of each event will impact the probability of the event being selected.
		100 = <event3>
		50 = <event4>
		1 = <event5>
	}
}

I like to take the method above one step further and start with an on_action "random_event" that then fires a "helper" event with a random_list in it.  Each item in the list points to the same final event to run, but with a different amount of random days.  None of my uploaded mods are using this method at the moment (mostly since I am still heavily in testing mode and want the events to fire more predictably).  However, should you want, I could write up a code sample relatively easily (and probably faster than finding one I'm suing in one of my personal MODs).

 

EDIT: when firing from an existing event, you can use the following syntax as well:  character_event = { id = NoxTest.123 days = 1 random = 3650 } which means somewhere between 1 day and 3651 days from now (aka anytime within the next 10 years) the event will fire.

 

 

 

Link to comment

inside random_events, note that you can also use e.g. 100 = 0 to have a certain chance to fire no event at all.

 

You can also use mean_time_to_happen to provide a different kind of ststistical probability to fire. I think the wilo explsind mesn time to happen well enough.

Link to comment

 I assume you have read this?

https://ck2.paradoxwikis.com/Event_modding

 

It will give you all the reference you need, but its a bit dry to start with. I would suggest you download a small mod and take a look at the mod\events and mod\common\on_actions folders. Leaning form an example of an already working one is a LOT easier.

 

If you want to make a quick test that is easy to troubleshoot use something. It will create an event that will fire on your characters marriage poping up a dialog box with a single choice.

(mod\modName\common\on_actions\test_on_actions.txt)

Quote

# Test event
on_marriage = {
    events = {
        TEST.10 #test Event
     }
}

 

(mod\modName\events\test_events.txt)

Quote

namespace = TEST
character_event = {
    id = TEST.10
    desc = mymodprefix_event_0001
    option = {
       name = mymodprefix_event_0001A
    }
}

 

Note mymodprefix_event_0001 and mymodprefix_event_0001A are both localised string identifiers. Meaning you should have the following in mod\modName\localisation\text.csv) (not its a CSV not txt file, but you can edit it with notepad nontheless).

Quote

#CODE;ENGLISH;;;;;;;;;;;;;x
#Event Titles

 

mymodprefix_event_0001;Event name;;;;;;;;;;;;;x

mymodprefix_event_0001A;Choice description;;;;;;;;;;;;;x

 

 

I hope this helps you get started!

 

 

 

Link to comment

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use