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

Zarine

Field Marshal
134 Badges
Feb 28, 2007
4.827
686
  • Europa Universalis IV: Res Publica
  • Gettysburg
  • Hearts of Iron III
  • Heir to the Throne
  • Europa Universalis III Complete
  • Knights of Pen and Paper +1 Edition
  • Leviathan: Warships
  • The Kings Crusade
  • Magicka
  • Majesty 2
  • Majesty 2 Collection
  • March of the Eagles
  • Europa Universalis III Complete
  • For the Motherland
  • Victoria: Revolutions
  • Rome Gold
  • Semper Fi
  • Sengoku
  • Ship Simulator Extremes
  • Sword of the Stars
  • Supreme Ruler: Cold War
  • The Showdown Effect
  • Victoria 2
  • Victoria 2: A House Divided
  • Victoria 2: Heart of Darkness
  • Hearts of Iron IV: No Step Back
  • Crusader Kings II: Sword of Islam
  • Arsenal of Democracy
  • Hearts of Iron II: Armageddon
  • Cities in Motion
  • 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
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: Sunset Invasion
  • A Game of Dwarves
  • Commander: Conquest of the Americas
  • Darkest Hour
  • East India Company Collection
  • Europa Universalis III
  • Europa Universalis III Complete
  • Divine Wind
  • Europa Universalis IV
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Wealth of Nations
I got some intel from devs about what makes an event efficient or not. So if you create many events and see that the game is slowing compared to vanilla, you might want to look at what can make it run smoother.

Doomdark said:
Some simple rules though:
* Opinion triggers are very CPU heavy and should be checked after all other triggers
* For regular MTTH events, try to exclude as many characters as possible with the super fast triggers 'only_playable = yes', 'only_men = yes' etc.
Doomdark said:
I should add that triggers checking for flags and character modifiers are also fairly slow.


This might not be clear for everyone, so what does it means:

* For regular MTTH events, try to exclude as many characters as possible with the super fast triggers 'only_playable = yes', 'only_men = yes' etc.
Code:
character_event = {
    only_ruler = yes
    trigger = {
        <other triggers>
    }
}

is better than

Code:
character_event = {
    trigger = {
        is_ruler = yes
        <other triggers>
    }
}

Also means that you should use it as much as possible to restrict the possible targets.
Those are the possible conditions found so far (yes/no and number are variable):
age = 16
is_prisoner = no
is_ruler = yes
max_age = 11
capable_only = yes
min_age = 16
only_capable = yes
only_men = yes
only_playable = yes
only_rulers = yes
only_women = yes
prisoner = no



* Opinion triggers are very CPU heavy and should be checked after all other triggers

Code:
character_event = {
    trigger = {
        <other triggers>
        any_vassal = {
            <other triggers about vassal>
            opinion = { who = ROOT value =  0 }
        }
    }
}

is better than

Code:
character_event = {
    trigger = {
        any_vassal = {
            opinion = { who = ROOT value =  0 }
            <other triggers about vassal>
        }
        <other triggers>
    }
}


* I should add that triggers checking for flags and character modifiers are also fairly slow.
Code:
character_event = {
    trigger = {
        <other triggers>
        has_character_flag = loan_taken
    }
}

is better than

Code:
character_event = {
    trigger = {
        has_character_flag = loan_taken
        <other triggers>
    }
}

AND

Code:
character_event = {
    trigger = {
        <other triggers>
        has_character_modifier = proving_bravery
    }
}

is better than

Code:
character_event = {
    trigger = {
        has_character_modifier = proving_bravery
        <other triggers>
    }
}
 
Last edited:
Thanks for sharing this, Zarine!

So you mean that this:

Code:
character_event = {
	id = ffhumours.xx
	desc = "EVTDESCffhumours.xx"
	picture = "GFX_evt_royalcourt"
	
	trigger = {
		age = 16
		NOT = { num_traits = 4 }
		NOT = {
			has_character_flag = genetics_check
		}
	}

could be written as this:

Code:
[B][COLOR="#00FF00"]character_event = {
	id = ffhumours.xx
	desc = "EVTDESCffhumours.xx"
	picture = "GFX_evt_royalcourt"
	age = 16
	NOT = { num_traits = 4 }

	trigger = {
				NOT = {
			has_character_flag = genetics_check
		}
	}[/COLOR][/B]

and this would be more efficient, then?
 
could be written as this:

Code:
[B][COLOR="#00FF00"]character_event = {
	id = ffhumours.xx
	desc = "EVTDESCffhumours.xx"
	picture = "GFX_evt_royalcourt"
	age = 16
	NOT = { num_traits = 4 }

	trigger = {
				NOT = {
			has_character_flag = genetics_check
		}
	}[/COLOR][/B]

and this would be more efficient, then?

Almost, there is some elements that you can put outside and some that you can't (still don't have a full list...)
And those elements change name when being put outside : age -> min_age (or max_age if you have a NOT in front).
And you can't put a "secondary" character attributs outside the trigger part

In your case, best performance writting should be :

Code:
character_event = {
	id = ffhumours.xx
	desc = "EVTDESCffhumours.xx"
	picture = "GFX_evt_royalcourt"
	min_age = 16

	trigger = {
		NOT = { num_traits = 4 }
		NOT = {
			has_character_flag = genetics_check
		}
	}
}
 
Thanks, Zarine!

If you learn more about this (or get a full list that would be workable outside the trigger instead of inside), let us know.
I wish we could hear more from the devs on the modding forum... Yes, I'm aware they are hard at work!:ninja:
it's just that in the end this might work to the benefit of all (modders, devs and players alike)
 
While doing the work behind my events thread I did find a bunch of those performance triggers. This is the section, with my commentry:

Events then have what look to be some sort of trigger conditions, but they don't use the normal trigger syntax that I gave examples of in my first post above. My assumption is that the designers have deliberately put down this smaller list of triggers, which you can't nest to improve efficiency. They aren't required but if you want to use them here are the ones I've seen:
age = 16
is_prisoner = no
is_ruler = yes
max_age = 11
capable_only = yes
min_age = 16
only_capable = yes
only_men = yes
only_playable = yes
only_rulers = yes
only_women = yes
prisoner = no

Hope this helps.
 
age = 16
is_prisoner = no
is_ruler = yes
max_age = 11
capable_only = yes
min_age = 16
only_capable = yes
only_men = yes
only_playable = yes
only_rulers = yes
only_women = yes
prisoner = no

That the list corresponding to this:
"For regular MTTH events, try to exclude as many characters as possible with the super fast triggers 'only_playable = yes', 'only_men = yes' etc."

The unknown part is if that's all of them or only a part of them.
 
Almost, there is some elements that you can put outside and some that you can't (still don't have a full list...)
And those elements change name when being put outside : age -> min_age (or max_age if you have a NOT in front).
And you can't put a "secondary" character attributs outside the trigger part

In your case, best performance writting should be :

Code:
character_event = {
	id = ffhumours.xx
	desc = "EVTDESCffhumours.xx"
	picture = "GFX_evt_royalcourt"
	min_age = 16

	trigger = {
		NOT = { num_traits = 4 }
		NOT = {
			has_character_flag = genetics_check
		}
	}
}

Hey Zarine,
I don't know.
Ran some tests and it seems once the min_age is outside the trigger, the game engine ignores it.
So, er, well, yeah, it doesn't seem to work for many elements besides the "big ones" (playable, men, etc)
 
Ok, ok...
My bad.
I was using "age = 16" instead of "min_age = 16", so I guess that explains it. :eek:o

By the way, I did try to call it through the console and it shows the other triggers but not what's outside it - at least, it didn't show the age (like the example that I've posted a few posts above...)
 
Well, about it not showing when you trigger the event with the console, from my point of view it's normal:


!!! The following is only a guess based on the facts that I'm a software engineer and the elements available to be put out. I might be totally wrong about that or totally correct, but it's a logical explanation from my point of view. !!!

Each character got a list of event that can be triggered. This list is based on the fast check elements which are in fact elements check at each major change in a character life (birth, birthday, title granted, being put in jail...).
At each of those changes, it checks if the outside elements are valid or not.
If it is valid, they add the event to the character list, if it is not valid, they don't.
Now that they have eliminated 80% of the events to check, at each event pulses, they can check all the events that are set as valid and don't even try the already invalid one.

As those elements change maybe 2/3 times a year at most, it is less consumming than check-in them at every event pulse.

Because of this system, you don't get to see the age condition if you put min_age = X because it's only a condition to be in the valid list, not a condition to trigger, which is different even if the effect is the same.
 
Last edited:
I don't know if I'm saying something new but in "defines.lua" there is the "NEngine" part including only one variable ruling the periodocity of event check. In vanilla it is set to 20 (days) with a comment explaining that reducing this value is CPU heavy (I personally set it to 1 and saw no differences - but I have 16Gb of RAM so it's not representative).

Maybe this variable has something to see with the event lists you're talking about.
 
I no ive wrote this elsewhere but im not getting the anwsers i need i want to no to write an event based on the death of an ai character what command would i use on_death=yes
religious_head=yes
Would that work to trigger an event from the death of a religious head ???
 
You may be able to trigger such an event from the on_actions.txt file. In the on_death (or on_assassination or else) you can define to always trigger an event (in events = {}) or to set it to fire randomly differents events (in random_events = {})

So if you have such an event you just have to add its event.id in these sections. To lighten the engine loads, if your event is meant to be triggered for a specific character, set the character id as the first trigger because the engine will check to launch the event each time a character die ...
 
I'm adding this herebecause I think it could useful :

I've seen some mods (or even vanilla files) still using the 'min_age = 16' check to be sure that events fire only to adult people. But the adulthood age is defined in defines.lua and some mods alter it to set it to 14 or 15. The problem is that leads to have child-event firing to adults and adult events not firing for all adults characters. So I've seen that in some patch, PDS added the 'is_adult = yes' trigger.

So I think this trigger should be much more used since it helps mod compatibilities AND ease the engine by not comparing age values but only checking boolean operators.
 
Thank you what it is that i wana do is have an event triggerd by the death of a religious head or a ruler an ai character not one that im controling myself i want it to inform me of the death then ask if i would like to be invited to the coronation of the new monarch or religious head and obviously get piety n prestige n what have you for saying yes and lose prestige and piety for rejecting the invite .