• 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.
Well yes every single character has a yearly pulse and your conditions will be true for all of them, that's why vanilla only fires important golbal events on the pope and hip uses the isis character the same way. Restrict your event trigger to only fire on one of those and the major = yes flag will make it appear for everyone.

Makes no sense. I have used the same algorythm to fire other events for several characters at the same time an those work correctly. Also, the on_yearly_pulse one works fine. It's the on_character_convert_religion, on_new_holder and on_war_ended_victory cases that are doing the event bombing. Anyway I tried your solution by changing the "immediate" part

Code:
immediate = {
        c_606060 = { narrative_event = { id = ri.0016 } } #Isis id = 606060
    }

but it didn't work, so either I am doing it wrong or that was not the problem.

I suspect it may have to do something with the ROOT and FROM and how those on_action clauses handle them but it's just guessing. Everything I learned about modding ck2 has been basically through reverse engineering, since the wiki leaves much to be desired, so there are may be "simple" things I have yet to understand. If you could be more precise about how to fix the events I would appreciate
 
It's the on_character_convert_religion, on_new_holder and on_war_ended_victory cases that are doing the event bombing.
Because you are firing them for every single character that ever converts religion, gets a new title or wins a war. Your trigger is saying is this true in the world, its equally applicable to every single character in the game, so every character doing that gets the event, then every character in the game see's the event from every other because you set it as a major event.
Anyway I tried your solution by changing the "immediate" part
That's just firing the same event on isis from several thousand sources, this is what HIP events do to make it it fire only for isis, its check the religion for efficiency first then checks they have the right title and that the event hasn't fired used a flag.

Code:
# Detect end of the Reconquista
character_event = {
    id = ri.0015
    hide_window = yes
    is_triggered_only = yes

   religion = hip_religion

    trigger = {
        has_landed_title = e_hip
        NOT = { has_global_flag = stopspam }
        NOT = {
            any_province = {
                county = {
                    region = world_europe_west_iberia
                }
                owner = {
                    OR = {
                        AND = {
                            independent = yes
                            NOT = {
                                religion_group = christian
                            }
                        }
                        top_liege = {
                            NOT = {
                                religion_group = christian
                            }
                        }
                    }
                }
            }
        }
    }
    immediate = {
         set_global_flag = stopspam
         narrative_event = { id = ri.0016 }
    }
}
 
Last edited:
I was wondering if anyone knew if there was some sort of formula that governed the baseline relationship between all of the different types of troops?

I know that modifiers and terrain will affect the relative values of different kinds of troops considerable, I'm just after the baseline in the interests of preserving rough balance - so what I mean is is there a formula that says for example:

x light infantry yield the same combat advantage as y heavy infantry and z pikemen etc?
 
Tried to copy-paste your version, and this time no event popped at all.

Because you are firing them for every single character that ever converts religion, gets a new title or wins a war.

Yes, but not everybody is doing those things at the same time. If a character wins a war, converts or gets a title the first event should only fire for him. I would later add flags to prevent the event from firing everytime someone does one of those things, but each time it should fire for just one person. The problem must come from firing the second event.

Either that or if the event is actually firing for everybody as you say, then the solution must have something to do with ROOT and or FROM. Some on_action events launch a 2nd event like this:

FROM/ROOT = { narrative_event = { id = ri.0016 } }

But I also tried that to no avail.

Other similar on_action events seem to work without the need to invoke the Pope or Isis, and the vanilla reconquista (though not an on_action event) invokes the 2nd event with a mere "any_playable_ruler"

Anyway, I tried your solution and this time, no event. I also played a lot with your Isis and flag lines, moving them around in both events, and most times still no event.


Basically, my pseudocode is:
IF (war ended OR character converted OR a title changed holder) THEN
(
IF (all Iberia is christian) THEN (fire narrative event for everybody)
)
 
I am wondering if I make modifications to a landed_title, what can I put in a separate file? For example, let's say I want to add a single barony (b_asdf) to c_vestisland, can I just have a second file, my_title.txt, that only includes:

Code:
c_vestisland = {
       b_asdf = {}
}

What I want to happen is to only add a single barony to a county without changing the de jure structure above it, but I also want to keep my mod as lightweight as possible so it is compatible with as many things as possible. Will the above code:

1) Add b_asdf to c_vestisland without changing anything else?

2) Change c_vestisland to only have one allowed barony?

3) Try to pull c_vestisland out of all other de jure structure so that it no longer sits in d_island, k_norway and e_scandinavia?

4) Create two tags for c_vestisland and mess the whole thing up?
 
I am wondering if I make modifications to a landed_title, what can I put in a separate file? For example, let's say I want to add a single barony (b_asdf) to c_vestisland, can I just have a second file, my_title.txt, that only includes:

Code:
c_vestisland = {
       b_asdf = {}
}

What I want to happen is to only add a single barony to a county without changing the de jure structure above it, but I also want to keep my mod as lightweight as possible so it is compatible with as many things as possible. Will the above code:

1) Add b_asdf to c_vestisland without changing anything else?

2) Change c_vestisland to only have one allowed barony?

3) Try to pull c_vestisland out of all other de jure structure so that it no longer sits in d_island, k_norway and e_scandinavia?

4) Create two tags for c_vestisland and mess the whole thing up?
Definitely not #3 or #4.

And the thing is, c_vestisland already has 7 baronies in the title file, so there's really no need to add 1 more. Safer to just re-use one from the list. That's what the events that give a castle to holy orders do. You can even re-name it if you like (set_name command).
 
Hi, I'm just getting back into CK2 modding after a hiatus of several years, so I'm very rusty with event/scripting stuff.

I created some new minor titles for my small personal mod, and I think I have them set up and working okay, but I wanted to make sure that they are lost when the holder becomes king/emperor, as they're really only meant for heirs.

Firstly, what is the correct trigger to use here? I'm guessing something like this:

Code:
NOT= {
        primary_title = {
            OR = {
                tier = king
                tier = emperor
            }
        }
}

Secondly, I'd like to set up one of these titles so that an event fires whenever the title is lost (due to the holder dying or becoming king/emperor himself) - I assume that's what the 'lose_effect = {' part is for, but I'd like to know how to set it to fire an event that only fires for people in that realm. I don't want every character in the world being told that some random guy in the kingdom of Burgundy has died. :p

Ideally it would be nice if the event only fired for every count tier character or above in the top realm (Francia, HRE, Hispania, etc.) the title is related to. Does that make sense?

So, two examples:

A) John is duke of York and holds the minor title of co-king of England, which is a title he holds as heir to the throne because he has been granted it by his father the king. The king dies and John becomes king by primogeniture, and so he should automatically lose the co-king minor title (so I need a trigger for that to happen), and every landed (count or higher) character within de jure Britannia (the empire title) should get an event saying that John is no longer co-king because he has become full/proper king.

B) John is duke of York and holds the minor title of co-king of England, which is a title he holds as heir to the throne because he has been granted it by his father the king. He dies prematurely, before his father, and every landed (count or higher) character within de jure Britannia (the empire title) should get an event saying that John has died and never managed to become king in his own right.

So what I'm after is a kind of template for a news event that only fires for landed feudal characters within de jure Britannia, and only fires under those particular circumstances, which I assume is via the 'lose_effect = {' part.

Thanks, and hope it's pretty simple!

Forget about lose_effect. Just make an on_death event that fires for kings and emperors whose heir had this title. Firing an event in the any_realm_character scope will fire it for everyone in the realm.

Also is there a modifier for a minor title to make the holder more likely to be voted for in elections/tanistry?

No. You do that by modding the elective rules in succession_voting.

Tried to copy-paste your version, and this time no event popped at all.



Yes, but not everybody is doing those things at the same time. If a character wins a war, converts or gets a title the first event should only fire for him. I would later add flags to prevent the event from firing everytime someone does one of those things, but each time it should fire for just one person. The problem must come from firing the second event.

Either that or if the event is actually firing for everybody as you say, then the solution must have something to do with ROOT and or FROM. Some on_action events launch a 2nd event like this:

FROM/ROOT = { narrative_event = { id = ri.0016 } }

But I also tried that to no avail.

Other similar on_action events seem to work without the need to invoke the Pope or Isis, and the vanilla reconquista (though not an on_action event) invokes the 2nd event with a mere "any_playable_ruler"

Anyway, I tried your solution and this time, no event. I also played a lot with your Isis and flag lines, moving them around in both events, and most times still no event.


Basically, my pseudocode is:
IF (war ended OR character converted OR a title changed holder) THEN
(
IF (all Iberia is christian) THEN (fire narrative event for everybody)
)

On actions fire only for the character that had the event happen - the one who converted or gained the new title, or whatever. You then fire an event with major = yes for each of those characters, and major = yes means that everyone sees the event. So everyone sees one event for each character who experienced the religion conversion/title gain/what-have-you. The modification suggested won't work because it relies on the holder of e_hip (if that title even exists) to have personally converted, or gained a title, or whatever. What you need to do is set a global flag in the first event, and have that event check for that flag so that it only ever fires once. Then have that first event launch an event on a single character (like the Pope, or whoever Isis is) with major = yes. Alternatively you could use any_playable_ruler, but then you have to remove major = yes or everyone will see everyone else's event.
 
Definitely not #3 or #4.

And the thing is, c_vestisland already has 7 baronies in the title file, so there's really no need to add 1 more. Safer to just re-use one from the list. That's what the events that give a castle to holy orders do. You can even re-name it if you like (set_name command).

Glad to hear it's not #3 or #4. I'll play around with some things and see what happens. I was just using c_vestisland as an example here. I'm looking at making some decisions that re-build some legendary cities around the map, like Babylon or Carthage and wondering if I'd have to copy all of landed_files.txt across or if I could be a little more picky. I was initially hoping to avoid using set_name, but perhaps that is the best option.
 
On actions fire only for the character that had the event happen - the one who converted or gained the new title, or whatever. You then fire an event with major = yes for each of those characters, and major = yes means that everyone sees the event. So everyone sees one event for each character who experienced the religion conversion/title gain/what-have-you. The modification suggested won't work because it relies on the holder of e_hip (if that title even exists) to have personally converted, or gained a title, or whatever. What you need to do is set a global flag in the first event, and have that event check for that flag so that it only ever fires once. Then have that first event launch an event on a single character (like the Pope, or whoever Isis is) with major = yes. Alternatively you could use any_playable_ruler, but then you have to remove major = yes or everyone will see everyone else's event.

BRAVO, BRAVO!!! I used the any_playable_ruler without major = yes and it almost worked. I am so thankful to you.

The on_yearly_pulse and on_character_convert_religion work perfect, firing only once and showing the portrait of the character who converted.

There is still. however, a minor problem with the on_war_ended_victory case and on_new holder . The event will fire only once but it will show the portrait of a random character who had nothing to do with the war or the title. The idea is for the event to show the winner of the warand the inheritor, and while I know the conditions to modify event portraits, I don't know how to select the war winner. The war winner should be FROM in the first event but I don't know how to take that FROM and use it on the second event for portrait use.

The current code is the following:

Code:
## Detect end of the Reconquista
character_event = {
    id = ri.0015
    hide_window = yes
    is_triggered_only = yes
    trigger = {
        NOT = { has_global_flag = reconquista_ended }
        NOT = {
            any_province = {
                county = {
                    region = world_europe_west_iberia
                }
                owner = {
                    OR = {
                        AND = {
                            independent = yes
                            NOT = {
                                religion_group = christian
                            }
                        }
                        top_liege = {
                            NOT = {
                                religion_group = christian
                            }
                        }
                    }
                }
            }
        }
    }
    immediate = {
         set_global_flag = reconquista_ended
         any_playable_ruler = { narrative_event = { id = ri.0016 } }
    }
}

# End of the Reconquista
narrative_event = {
    id = ri.0016
    desc = EVTDESC_HF_49452
    title = EVTTITLE_HF_49452
    picture = GFX_evt_beatification
    border = GFX_event_narrative_frame_religion
    is_triggered_only = yes
    option = {   
        name = EVTOPTA_HF_49452
        trigger = {
            religion_group = christian
        }
    }
    option = {
        name = EVTOPTB_HF_49451
        trigger = {
            NOT = {
                religion_group = christian
            }
        }
    }
}
 
Last edited:
How can I use variables as trigger in trigger_switch.
Code:
#pseudo_code
set_variable = {
  which = "global_num_trigger" value = 1
}
trigger_switch = {
  on_trigger = global_num_trigger
  4   = { set_name = "A" }
  3   = { set_name = "B" }
  2   = { set_name = "C" }
  1   = { set_name = "D" }
}
"on_trigger" only accept a right-hand-side argument, while "check_variable" used by variables is a clause.
Is there any way to export var to string(flag) or boolean?

Tried
Code:
set_character_flag = @global_num_trigger
, not working
 
Last edited:
How can I use variables as trigger in trigger_switch.
Code:
#pseudo_code
set_variable = {
  which = "global_num_trigger" value = 1
}
trigger_switch = {
  on_trigger = global_num_trigger
  4   = { set_name = "A" }
  3   = { set_name = "B" }
  2   = { set_name = "C" }
  1   = { set_name = "D" }
}
"on_trigger" only accept a right-hand-side argument, while "check_variable" used by variables is a clause.
Is there any way to export var to string(flag) or boolean?

Tried
Code:
set_character_flag = @global_num_trigger
, not working
Based on the way variables and trigger_switch work, you will not be able to do this. You'll have to resort to cascading if blocks:
Code:
if = {
    limit = { check_variable = { which = "global_num_trigger" value = 4 } }
    set_name = "A"
}
else_if = {
    limit = { check_variable = { which = "global_num_trigger" value = 3 } }
    set_name = "B"
}
else_if = {
    limit = { check_variable = { which = "global_num_trigger" value = 2 } }
    set_name = "C"
}
else = {
    set_name = "D"
}
 
The on_yearly_pulse and on_character_convert_religion work perfect, firing only once and showing the portrait of the character who converted..

So I got some insight on this. First, I removed the on_yearly_pulse because it's useless and may not work with changes y have to make. So now I have three cases in which EVENT 1 fires. According to the wiki, this is how it should work:

- on_character_convert_religion: ROOT is the converted character, then EVENT 1 fires EVENT 2 for everyone and ROOT from EVENT 1 becomes FROM from EVENT 2 and his portrait is displayed . THIS WORKS

-on_new_holder: ROOT is the character who gets the title, then EVENT 1 fires EVENT 2 for everyone and ROOT from EVENT 1 becomes FROM from EVENT 2 and his portrait is displayed. THIS DOESN'T WORK. On EVENT 2 FROM is a random character

-on_war_ended_victory: FROM is the attacker who won, ROOT is the defender who lost. I have yet to find out how to make FROM fire the event instead of ROOT without messing the other cases, but just to see what happened I tested it anyway and on EVENT 2 FROM was a random character instead of ROOT from EVENT 1

I have no idea of what is happening with FROMs and ROOTs and all that. It doesn't seem to behave in the way the wiki explains

Code:
# Detect end of the Reconquista
character_event = {
    id = ri.0015
    hide_window = yes
    is_triggered_only = yes
    trigger = {
        NOT = { has_global_flag = reconquista_ended }
        NOT = {
            any_province = {
                county = {
                    region = world_europe_west_iberia
                }
                owner = {
                    OR = {
                        AND = {
                            independent = yes
                            NOT = {
                                religion_group = christian
                            }
                        }
                        top_liege = {
                            NOT = {
                                religion_group = christian
                            }
                        }
                    }
                }
            }
        }
    }
    immediate = {
         set_global_flag = reconquista_ended
         any_player = { narrative_event = { id = ri.0016 } }
    }
}

# End of the Reconquista
narrative_event = {
    id = ri.0016
    desc = EVTDESC_HF_49452
    title = EVTTITLE_HF_49452
    picture = GFX_evt_beatification
    border = GFX_event_narrative_frame_religion
    is_triggered_only = yes
    option = {    
        name = EVTOPTA_HF_49452
        trigger = {
            religion_group = christian
        }
    }
    option = {
        name = EVTOPTB_HF_49451
        trigger = {
            NOT = {
                religion_group = christian
            }
        }
    }
}
 
CK2 doesn't allow to mod in new holding types, so I was thinking to simulate new holding types. Did anybody do that before? Is there a mod that simulates new holding types? Does anybody have experience with this?
 
When I put title = "XYZ_TITLE" into a landed title (not titular title) eg c_example and do the according entry in a localisation file then I end up with the title holder having the special title "XYZ" but I'm wondering if there is a way to make a special title either culture or religion dependent or both. Is there a way to do that?
Also I don't know why but my renaming of a county isn't working. c_example stays Example ingame despite having the condition of xyz_culture = "Example_B", it should be renamed Example_B but it isn't, same thing is happening with the barony of the county. As far as I remember and know you only have to do culture = "rename" if you want any title to change its name if the culture changes or am I missing something?
 
So I got some insight on this. First, I removed the on_yearly_pulse because it's useless and may not work with changes y have to make. So now I have three cases in which EVENT 1 fires. According to the wiki, this is how it should work:

- on_character_convert_religion: ROOT is the converted character, then EVENT 1 fires EVENT 2 for everyone and ROOT from EVENT 1 becomes FROM from EVENT 2 and his portrait is displayed . THIS WORKS

-on_new_holder: ROOT is the character who gets the title, then EVENT 1 fires EVENT 2 for everyone and ROOT from EVENT 1 becomes FROM from EVENT 2 and his portrait is displayed. THIS DOESN'T WORK. On EVENT 2 FROM is a random character

-on_war_ended_victory: FROM is the attacker who won, ROOT is the defender who lost. I have yet to find out how to make FROM fire the event instead of ROOT without messing the other cases, but just to see what happened I tested it anyway and on EVENT 2 FROM was a random character instead of ROOT from EVENT 1

I have no idea of what is happening with FROMs and ROOTs and all that. It doesn't seem to behave in the way the wiki explains

I don't know why you are getting random characters - are you sure they are random?

If you want the FROM of the first event to be the FROM of the second event, just fire an invisible event for FROM from the first event, which will then fire the second event. That means you'll have to make a different event for on_war_ended_victory.
 
So I did a custom title with custom localisation but my problem is that it shows [Root.Owner.GetExampleTitle] as a title in the selection screen of a character that has the title, so "[Root.Owner.GetExampleTitle] character name". Ingame the title works fine and is shown properly. Sure this is due to the localisation for the custom title being EXAMPLE_TITLE;[Root.Owner.GetExampleTitle];;;;;;;;;;;;;x in the localisation. Is there a way to fix this so that the custom title is shown on the selection screen?
 
What do you need to do to add society clothing to a new society (specifically, to reuse vanilla's DW clothes)?
 
Ok, I am giving a completely new approach to my Reconquista event. Any discussions I had about it prior to this post are now irrelevant. The following code is meant to work only on_new_holder.

As the wiki says: ROOT = new holder FROM = title FROMFROM = old holder

Trigger checks the following: this hasn't happened already, iberia is christian (basic)
Trigger also checks new holder is christian, old holder is not christian, either the new holder or a vassal is from iberia. (This is to make sure that if an inheritance ends the Reconquista making iberia christian, the event doesn't pop for another title transfer that may happen on the same day. Many title transfers may happen on the day the Reconquista is over, so I want the event to fire only for the right one. More conditions may be added I find them insufficient)

Code:
# End of the Reconquista
narrative_event = {
    id = ri.0015
    desc = EVTDESC_HF_49452
    title = EVTTITLE_HF_49452
    picture = GFX_evt_beatification
    border = GFX_event_narrative_frame_religion
    is_triggered_only = yes
    major = yes
    trigger = {
        NOT = { has_global_flag = reconquista_ended }
        NOT = {
            any_province = {
                county = {
                    region = world_europe_west_iberia
                }
                owner = {
                    OR = {
                        AND = {
                            independent = yes
                            NOT = {
                                religion_group = christian
                            }
                        }
                        top_liege = {
                            NOT = {
                                religion_group = christian
                            }
                        }
                    }
                }
            }
        }
        ROOT = { religion_group = christian }            
        NOT = { FROMFROM = { religion_group = christian } }
        ROOT = {
            OR = {
                capital_scope = {
                        region = world_europe_west_iberia
                }
                any_realm_lord = {
                    capital_scope = {
                        region = world_europe_west_iberia
                    }
                }
            }
        }
    }
    immediate = {
         set_global_flag = reconquista_ended
    }
    option = {  
        name = EVTOPTA_HF_49452
        trigger = {
            religion_group = christian
        }
    }
    option = {
        name = EVTOPTB_HF_49451
        trigger = {
            NOT = {
                religion_group = christian
            }
        }
    }
}

Start a new game 867 and introduce cheat code "titleowner k_andalusia 1235004". This gives Andalusia to the catholic count of Álava, finishing the Reconquista. This is however the kind of event I get:
upload_2019-8-8_12-48-30.png


The event fires on a landless character with no titles. Charinfo reveals that he is somehow ROOT and FROM and there is no FROMFROM. This contradicts the on_new_holder rules I previously explained. It should fire on the count (now king) of Álava

The event will work correctly if the command to switch title is introduced on the first day, when the AI does basically nothing that may interfere