• 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.
You should look up Events and Ping Events on the Wiki; but the gist should be something like...

(Someone else might want to confirm, though, since my events seem a bit hit-and-miss sometimes... :S )

Thank you for the help! I'm still learning the ropes here. So this is what I got:

Code:
# Initial event on Liege, singles out the Apprentice

character_event = {
   id = myevent.1
   hide_window = yes
   ...
   trigger = {
       ...
   }
   mean_time_to_happen = { days = 1 }
   immediate = {
       any_courtier = {
           limit = {
               has_minor_title = title_hermetics_apprentice
               prisoner = no
               NOT = { trait = incapable }
           }
           character_event = { id = myevent.2 }
       }
   }
}

# Event 2, sends Liege event 3 so that the Apprentice is stored in FROM

character_event = {
   id = myevent.2
   is_triggered_only = yes
   hide_window = yes
 
   trigger = {
       always = yes
       }
   immediate = {
       liege = {
           character_event = { id = myevent.3 }
       }
   }
}

# Event 3, sends Apprentice Stargazing decision back from the Liege, FROM is Apprentice here.

character_event = {
   id = myevent.3
   ...
   immediate = { FROM = {
       character_event = { id = MNM.1920 }
       }
   }
}

But I'm still having trouble getting the Apprentice to receive the 'Stargazing' decision from Liege
 
Last edited:
Thank you for the help! I'm still learning the ropes here. So this is what I got:

Code:
# Initial event on Liege, singles out the Apprentice

character_event = {
   id = myevent.1
   hide_window = yes
   ...
   trigger = {
       ...
   }
   mean_time_to_happen = { days = 1 }
   immediate = {
       any_courtier = {
           limit = {
               has_minor_title = title_hermetics_apprentice
               prisoner = no
               NOT = { trait = incapable }
           }
           character_event = { id = myevent.2 }
       }
   }
}

# Event 2, sends Liege event 3 so that the Apprentice is stored in FROM

character_event = {
   id = myevent.2
   is_triggered_only = yes
   hide_window = yes
 
   trigger = {
       always = yes
       }
   immediate = {
       liege = {
           character_event = { id = myevent.3 }
       }
   }
}

# Event 3, sends Apprentice Stargazing decision back from the Liege, FROM is Apprentice here.

character_event = {
   id = myevent.3
   ...
   immediate = { FROM = {
       character_event = { id = MNM.1920 }
       }
   }
}

But I'm still having trouble getting the Apprentice to receive the 'Stargazing' decision from Liege

Did you remember to add a namespace? I never in my example, but you'd need namespace = myevent at the top of the Event file.

----
Can someone see what is wrong with this code? Everything else in my Event fires, except for this one if-statement...

Code:
if = {      # If
 limit = {
  any_character = { # A character
   limit = {
    ai = yes # Who is controlled by the game
   }
   has_landed_title = c_szekelyfold # Holds szekelyfold
  }
 }          # Then
 540 = {         # Scope to Szekelyfold
  county = {       # Scope to the County Title
   save_event_target_as = Home_County # Save the Event Target (Title)
  }
 }
}

Home_County is already set immediately above this via a random_province Scope, but this is intended to over-ride that under certain conditions. For Testing, that is 100% of the time that the AI owns Szekelyfold. I have even tried changing 540 = { to the direct title, but no luck...

I know that Home_County and the other parts of the Script are working, as the randomly selected target plays out every time--it is just the over-ride block which seems to not be running.

Edit : Resolved. I realised I was trying to use my If-Limit like a Condition Limit.
 
Last edited:
Is it possible to make custom localization work in hover over tooltips?

Here's what i'm trying to achieve:
7d7f9af254ec4b52837f1eec4d6c8ca3.png

if i hover over the trait, everything works fine - i get my postfix.

If i hover over the answer i get this:
7e3d6ff958c84a4eb0f302879ac2970d.png

it just displays the script itself

Maybe it's in the wrong scope? But i can't change it, sinse it's a &TRAIT&
 
Hi folks, I'm completely new to modding with no experience, so I've been trying to create a simple event as practice but my brain is already imploding. Can anyone tell me what is wrong with this? My objective -- Get an event pop up (mean 2 days -- just for now) that has 3 options. Option 1 adds maimed trait to your spouse. Option 2 adds depressed trait to one of your consorts at random. Option 3 adds ambitious trait to a different random consort of yours.

Code:
namespace = deadlyharems

character_event  = {
  #Basic event information
  id = deadlyharems.111
  desc = EVTDESCdeadlyharems.111
  picture = GFX_evt_emissary

  #Fast event triggers
  has_concubinage = yes
  
     mean_time_to_happen = {
    #Randomness of the event (not applicable for triggered-only events)
    days = 2}

  option = {
    name = EVTOPTAdeadlyharems.111
    trigger = {age  = 16
      #Option A eligibility condition block
          }
          custom_tooltip = { text = Maimed }
          spouse = {add_trait = maimed}
     }

  option = {
    name = EVTOPTBdeadlyharems.111
    trigger = {
      #Option B eligibility condition block
          }
          custom_tooltip = { text = Depressed }
          random_consort = {add_trait = depressed}
     }

 option = {
    name = EVTOPTCdeadlyharems.111
    trigger = {
                }
        random_consort = {add_trait = ambitious}
      }
}

Using this code, my decision will pop up and option A (referring to the spouse) works great and as expected. However option B and C also point to my spouse, when I want them to point to a random consort of mine. Using the Validator tool tells me the problem is with using "random_consort" in option section, but how else can I reference a random consort? If I change that part to

consort = {add_trait = ambitious}

then it completely works, however all options point to the same consort, when I want it to be each option to point to a different one.
 
Last edited:
Hi folks, I'm completely new to modding with no experience, so I've been trying to create a simple event as practice but my brain is already imploding. Can anyone tell me what is wrong with this? My objective -- Get an event pop up (mean 2 days -- just for now) that has 3 options. Option 1 adds maimed trait to your spouse. Option 2 adds depressed trait to one of your consorts at random. Option 3 adds ambitious trait to a different random consort of yours.

Code:
namespace = deadlyharems

character_event  = {
  #Basic event information
  id = deadlyharems.111
  desc = EVTDESCdeadlyharems.111
  picture = GFX_evt_emissary

  #Fast event triggers
  has_concubinage = yes
 
     mean_time_to_happen = {
    #Randomness of the event (not applicable for triggered-only events)
    days = 2}

  option = {
    name = EVTOPTAdeadlyharems.111
    trigger = {age  = 16
      #Option A eligibility condition block
          }
          custom_tooltip = { text = Maimed }
          spouse = {add_trait = maimed}
     }

  option = {
    name = EVTOPTBdeadlyharems.111
    trigger = {
      #Option B eligibility condition block
          }
          custom_tooltip = { text = Depressed }
          random_consort = {add_trait = depressed}
     }

 option = {
    name = EVTOPTCdeadlyharems.111
    trigger = {
                }
        random_consort = {add_trait = ambitious}
      }
}

Using this code, my decision will pop up and option A (referring to the spouse) works great and as expected. However option B and C also point to my spouse, when I want them to point to a random consort of mine. Using the Validator tool tells me the problem is with using "random_consort" in option section, but how else can I reference a random consort? If I change that part to

consort = {add_trait = ambitious}

then it completely works, however all options point to the same consort, when I want it to be each option to point to a different one.

Hmm, maybe there are no valid other Consorts? If there was not, it would have to go to the same person... Are you sure you have a Consort/Concubine other than your Spouse? Presumably 'Consort' just scopes to the first Consort it finds (or maybe the last it finds?)

Doing a quick-test with your Script, I did get variation, but also some repetition. That was on a Tribal Ruler with 3 Concubines and a Spouse; firing the event via Console. So, it may be that your Script is working, but you are getting super-unlucky...

Code:
namespace = deadlyharems
character_event  = {
 id = deadlyharems.111
 desc = EVTDESCdeadlyharems.111
 picture = GFX_evt_emissary

 is_triggered_only = yes

 immediate = {
  random_consort = {
   limit = {
    NOT = {
     has_character_flag = MyConsort1
     has_character_flag = MyConsort2
    }
   }
   set_character_flag = MyConsort1
  }

  random_consort = {
   limit = {
    NOT = {
     has_character_flag = MyConsort1
     has_character_flag = MyConsort2
    }
   }
   set_character_flag = MyConsort2
  }
 }

 option = {
  name = EVTOPTAdeadlyharems.111
  spouse = {
   add_trait = maimed
  }
 }

 option = {
  name = EVTOPTBdeadlyharems.111

  any_realm_character = {
   limit = {
    has_character_flag = MyConsort1
   }
   add_trait = depressed
  }
 }

 option = {
  name = EVTOPTCdeadlyharems.111
  
  any_realm_character = {
   limit = {
    has_character_flag = MyConsort2
  }
  add_trait = ambitious
  }
 }
}

This seems to do the trick--it uses Immediate to grab the Consorts first, and produces repeatable results; you'll need to clr_character_flag on everyone when an option is chosen, however, or it will only ever choose them. I'd check more, but I need to go, sorry :/
 
Hmm, maybe there are no valid other Consorts? If there was not, it would have to go to the same person... Are you sure you have a Consort/Concubine other than your Spouse? Presumably 'Consort' just scopes to the first Consort it finds (or maybe the last it finds?)

Doing a quick-test with your Script, I did get variation, but also some repetition. That was on a Tribal Ruler with 3 Concubines and a Spouse; firing the event via Console. So, it may be that your Script is working, but you are getting super-unlucky...

Code:
namespace = deadlyharems
character_event  = {
 id = deadlyharems.111
 desc = EVTDESCdeadlyharems.111
 picture = GFX_evt_emissary

 is_triggered_only = yes

 immediate = {
  random_consort = {
   limit = {
    NOT = {
     has_character_flag = MyConsort1
     has_character_flag = MyConsort2
    }
   }
   set_character_flag = MyConsort1
  }

  random_consort = {
   limit = {
    NOT = {
     has_character_flag = MyConsort1
     has_character_flag = MyConsort2
    }
   }
   set_character_flag = MyConsort2
  }
 }

 option = {
  name = EVTOPTAdeadlyharems.111
  spouse = {
   add_trait = maimed
  }
 }

 option = {
  name = EVTOPTBdeadlyharems.111

  any_realm_character = {
   limit = {
    has_character_flag = MyConsort1
   }
   add_trait = depressed
  }
 }

 option = {
  name = EVTOPTCdeadlyharems.111
 
  any_realm_character = {
   limit = {
    has_character_flag = MyConsort2
  }
  add_trait = ambitious
  }
 }
}

This seems to do the trick--it uses Immediate to grab the Consorts first, and produces repeatable results; you'll need to clr_character_flag on everyone when an option is chosen, however, or it will only ever choose them. I'd check more, but I need to go, sorry :/

Thanks, Thezezeal! Appreciate it! I will test this out tonight. I was testing on a game specifically set up for the code; as an Indian King with 3 consorts and a spouse. Now that you mention it, in all my tests using the "consort" tag did keep referencing the last consort to be added, so I guess it does always scopes the last character added like you suspect.

What you have in the code under options makes sense to me, but I'm gonna have to read up on "has_character_flag" because I don't fully understand how it works. The part I don't get is, does a character who is assigned a flag have that flag permanently attached to them forever, or does that flag only last for this duration? IE could I have a second event where a different random consort possesses the "MyConsort1" flag, or would "MyConsort1" hereon always refer to the consort from this event?
 
Did you remember to add a namespace? I never in my example, but you'd need namespace = myevent at the top of the Event file.

----
Can someone see what is wrong with this code? Everything else in my Event fires, except for this one if-statement...

Code:
if = {      # If
 limit = {
  any_character = { # A character
   limit = {
    ai = yes # Who is controlled by the game
   }
   has_landed_title = c_szekelyfold # Holds szekelyfold
  }
 }          # Then
 540 = {         # Scope to Szekelyfold
  county = {       # Scope to the County Title
   save_event_target_as = Home_County # Save the Event Target (Title)
  }
 }
}

Home_County is already set immediately above this via a random_province Scope, but this is intended to over-ride that under certain conditions. For Testing, that is 100% of the time that the AI owns Szekelyfold. I have even tried changing 540 = { to the direct title, but no luck...

I know that Home_County and the other parts of the Script are working, as the randomly selected target plays out every time--it is just the over-ride block which seems to not be running.

Edit : Resolved. I realised I was trying to use my If-Limit like a Condition Limit.

Yes I have the namespace! I have some other events that are working as intended in the same namespace, just this one giving me some trouble.

UPDATE: Got it working, thank you for help
 
Last edited:
Is there a way to completely deactivate religious clothing (religious_male_clothes.dds etc.) based on culture or otherwise a way to have a "invisible" headgear and clothing characters of a specific culture uses?

Sadly the religious clothing does not seem to be tied to a specific culture and the religion definition don't seem to allow for conditions.
 
Last edited:
Is there a way to completely deactivate religious clothing (religious_male_clothes.dds etc.) based on culture or otherwise a way to have a "invisible" headgear and clothing characters of a specific culture uses?

Sadly the religious clothing does not seem to be tied to a specific culture and the religion definition don't seem to allow for conditions.

It would be nice if theocracy (and republics) were using the new mechanism for society clothing, as they serve the same purpose, without the hardcoded limitations.

Actually I'm wondering if this even not doable already, as there's a trigger portrait_gfx_culture, portrait_government and portrait_religion in the .exe (but do they work , since not used in vanilla ?!)
If you're not afraid of doing a bit of experimentation on the new system, theoretically you could do something like that (here for africangfx):
Code:
# Override clothing for African priests to not use the hardcoded sprites GFX_religious_male_clothes, GFX_religious_male_headgear, etc.
portraitType = {
       name = "PORTRAIT_clergy_african_clothing_male"
       
       weight = {
           additive_modifier = {
               value = 10000
               portrait_age > child
               portrait_is_female = no
               portrait_clothing = yes
               OR = { 
                   portrait_culture = ethiopian
                   portrait_culture = somali
                  # Or use portrait_gfx_culture = africangfx ?
               }
               portrait_government = theocracy_government
           }
       }
       
       # Override with clothing layers from PORTRAIT_africangfx_male
       layer = {
           "GFX_african_male_clothes_behind:c0"
           "GFX_african_male_headgear_behind:c1"
           "GFX_african_male_clothes:c2"
           "GFX_empty:c3"
           "GFX_empty:c4"
           "GFX_african_male_headgear:c5"
       }

       # Add allow_property_values = { } for some portrait_properties rules to select specific frames 
   }
 
Thanks, Thezezeal! Appreciate it! I will test this out tonight. I was testing on a game specifically set up for the code; as an Indian King with 3 consorts and a spouse. Now that you mention it, in all my tests using the "consort" tag did keep referencing the last consort to be added, so I guess it does always scopes the last character added like you suspect.

What you have in the code under options makes sense to me, but I'm gonna have to read up on "has_character_flag" because I don't fully understand how it works. The part I don't get is, does a character who is assigned a flag have that flag permanently attached to them forever, or does that flag only last for this duration? IE could I have a second event where a different random consort possesses the "MyConsort1" flag, or would "MyConsort1" hereon always refer to the consort from this event?

character_flags are permanent, but can be removed using clr_character_flag = FLAG_NAME

The problem is, trying to modify the Script I posted above, for some reason I cannot get it to clear them... :/ Might be a glitch at my end, though.
 
It would be nice if theocracy (and republics) were using the new mechanism for society clothing, as they serve the same purpose, without the hardcoded limitations.

Actually I'm wondering if this even not doable already, as there's a trigger portrait_gfx_culture, portrait_government and portrait_religion in the .exe (but do they work , since not used in vanilla ?!)
If you're not afraid of doing a bit of experimentation on the new system, theoretically you could do something like that (here for africangfx):
Code:
# Override clothing for African priests to not use the hardcoded sprites GFX_religious_male_clothes, GFX_religious_male_headgear, etc.
portraitType = {
       name = "PORTRAIT_clergy_african_clothing_male"
    
       weight = {
           additive_modifier = {
               value = 10000
               portrait_age > child
               portrait_is_female = no
               portrait_clothing = yes
               OR = {
                   portrait_culture = ethiopian
                   portrait_culture = somali
                  # Or use portrait_gfx_culture = africangfx ?
               }
               portrait_government = theocracy_government
           }
       }
    
       # Override with clothing layers from PORTRAIT_africangfx_male
       layer = {
           "GFX_african_male_clothes_behind:c0"
           "GFX_african_male_headgear_behind:c1"
           "GFX_african_male_clothes:c2"
           "GFX_empty:c3"
           "GFX_empty:c4"
           "GFX_african_male_headgear:c5"
       }

       # Add allow_property_values = { } for some portrait_properties rules to select specific frames
   }
Very interesting idea. If this works, we'd have a workaround for the republic clothing... Alas I don't have time to test (and little experience with portrait modding), so someone else pls test and confirm :D


And now to something completely different...
While I know variables are kinda broken atm, I am nevertheless coding a bit with them. But I ran into a problem:
I have an event that calculates a cost (depending on how many provinces are affected) via a variable. This all should work, but since it is a dynamic amount I can't tell how much it will be beforehand.
Now the problem is I want the AI to be aware of whether or not it can pay that amount, via an ai_chance modifier.
So how do I check if the treasury of a character is greater than a variable?
 
Last edited:
character_flags are permanent, but can be removed using clr_character_flag = FLAG_NAME

The problem is, trying to modify the Script I posted above, for some reason I cannot get it to clear them... :/ Might be a glitch at my end, though.
Why is that? Clearing flags has never been a problem for me, dunno why it would not work for you.
If you don't need the flags in a following event, an easy way to clear them could be to add a section like
Code:
after = {
    random_consort = {
        limit = {
            clr_character_flag = MyConsort1
        }
        clr_character_flag = MyConsort1
    }
    random_consort = {
        limit = {
            clr_character_flag = MyConsort2
        }
        clr_character_flag = MyConsort2
    }
}
That should clear the flags regardless of what option gets chosen.
Btw, another really useful thing are event targets. You still need to set flags for stuff, but I have found event targets to be much more easy to identify than say FROMFROM, because you can name them (e.g. target_ambitious_consort). Makes coding much easier if you can't memorize who PREVPREVPREVPREV was ^^
 
Is there a way to make a far-distant Character 'In Diplomacy Range'? (assuming what I want to do is possible at all--it looks like I can make a new Councillor slot, and I'd like a "Special Councillor who goes far afield" sort of guy...)

@LordPeter
No idea why it's being weird for me :/ It should be working, but for some reason they're just not clearing on that event I posted :shrug: I'll take another look tomorrow, if I think-on :)
 
Is there a way to make a far-distant Character 'In Diplomacy Range'? (assuming what I want to do is possible at all--it looks like I can make a new Councillor slot, and I'd like a "Special Councillor who goes far afield" sort of guy...)

@LordPeter
No idea why it's being weird for me :/ It should be working, but for some reason they're just not clearing on that event I posted :shrug: I'll take another look tomorrow, if I think-on :)
Adding new councillors has been proven to not really work. More precisely, the AI won't understand them at all and flat out ignore them, so they would give the player a huge advantage.
Also, diplomatic range is pretty much hardcoded. I understand you want an envoy-type councillor, who visits a distant realm to allow you to talk with that guy there? If that is it, than sadly, it is not possible afaik :/
 
Adding new councillors has been proven to not really work. More precisely, the AI won't understand them at all and flat out ignore them, so they would give the player a huge advantage.
Also, diplomatic range is pretty much hardcoded. I understand you want an envoy-type councillor, who visits a distant realm to allow you to talk with that guy there? If that is it, than sadly, it is not possible afaik :/

Yes, "Envoy" that was the word I was needing :p Bah, that sucks :/ It seemed like a cool alternative to the "wider diplomacy" Game Rule. Send him out, wait for an event to fire, and boom, now you can talk to this one guy, and maybe a few around him as though you'd opened relations.
 
It would be nice if theocracy (and republics) were using the new mechanism for society clothing, as they serve the same purpose, without the hardcoded limitations.

Actually I'm wondering if this even not doable already, as there's a trigger portrait_gfx_culture, portrait_government and portrait_religion in the .exe (but do they work , since not used in vanilla ?!)
If you're not afraid of doing a bit of experimentation on the new system, theoretically you could do something like that (here for africangfx):
Thanks, I will try it.

I have another question. Is it possible to influence the decision making process of the AI, for example to prevent rulers to marry their primary heir to someone with a specific trait (or make it more unlikely)?
 
Thanks, I will try it.

I have another question. Is it possible to influence the decision making process of the AI, for example to prevent rulers to marry their primary heir to someone with a specific trait (or make it more unlikely)?
Hardcoded AI behaviour like marriage decisions can not be modded. It's pretty annoying, as I had thought about doing such a thing as well.
I remembe a workaround that got suggested by someone was to disable the marriage system alltogether, and replace it with custom a targeted decision. However, that would be both an insanely huge amount of work, and also really preformance hungry - so not really an option.


I have another question of my own (in addition to the variable thing):
Is there a way to check if a province has been looted? Ingame, there is a tax income malus for looted province, but I can't find any condition to check for it.
Reason is I want an event to be more likely to fire if a province has been looted.
 
Hardcoded AI behaviour like marriage decisions can not be modded. It's pretty annoying, as I had thought about doing such a thing as well.
I remembe a workaround that got suggested by someone was to disable the marriage system alltogether, and replace it with custom a targeted decision. However, that would be both an insanely huge amount of work, and also really preformance hungry - so not really an option.


I have another question of my own (in addition to the variable thing):
Is there a way to check if a province has been looted? Ingame, there is a tax income malus for looted province, but I can't find any condition to check for it.
Reason is I want an event to be more likely to fire if a province has been looted.

Maybe use the "on_settlement_looted" on_action, and add a Province Modifier for however long suitable, and then check for that? (That's assuming the malus itself is not a "normal" Modifier? If so, has_province/holding_modifier might do the trick)

As to Variables, can't a Value be written to them? According to the Wiki you can run...
Code:
ROOT = {
  export_to_variable = { which = myvar value = stewardship who = FROM }
}
I assume you could use "Wealth" for Value; the question is, can you compare a Variable to another Variable... It does not look like it from the Wiki, but maybe give it a try?

If that won't work, a rough solution would be character_flags relative to increments of your Value (assuming you know a rough idea of what they might be).
 
Adding new councillors has been proven to not really work. More precisely, the AI won't understand them at all and flat out ignore them, so they would give the player a huge advantage.
Also, diplomatic range is pretty much hardcoded. I understand you want an envoy-type councillor, who visits a distant realm to allow you to talk with that guy there? If that is it, than sadly, it is not possible afaik :/
Eh not entirely true, you can set up a maintenance event and force the new councillors to do a job. Still not as good as the ai understanding it on its own but they can still be made to be use the new ones.
 
If a Character dies, can their ID be re-used by the Game? I noticed a random guy had a "faulty" name even though I have not touched his culture/title/etc. I looked him up in the Save File via his ID, and I have two people with the same ID, one being this guy, and the other being an Irish Count from one of my Mods... The Irish guy appears to be dead, but I cannot see the "death" entry (might just have missed it, though).