• 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.
As far as I can think of, there's only a few things that change the host of a landed character -- becoming unlanded (and initially being landed; various on_new_holder on_actions), becoming a prisoner/being released from prison (both have on_actions), being appointed a councillor or losing a council spot (gain_/lose_effect), and forced host changes for councillors (related to seclusion; force_host is pretty rare in general) -- so if that one doesn't work it might be possible to use other on_actions and a few specific tweaks to cover other stuff to make an event/effect fire.

That sounds like your imprisonment action did not change the character's host (for the purpose of the on_action, at least), but something else did a few months later.

You didn't happen to use one of your councillors as your test case, did you?!

Alternatively, and a bit less likely, you may not have carefully checked the FROM portrait in the visible event a few months after - maybe it was actually some other character?
I actually let the game run a little bit, to see if anything would fire the test event. During the process, I noticed that a vassal who my character was guardian of, to educate a matching culture for in order to get rid of the opinion malus, was given another guardian in his own court, and concluded that the on_action didn't work. Then, a few minutes later, but a few months longer in the game, I got the test event firing to notify me of that same vassal changing host, which is what confused me.
 
I actually let the game run a little bit, to see if anything would fire the test event. During the process, I noticed that a vassal who my character was guardian of, to educate a matching culture for in order to get rid of the opinion malus, was given another guardian in his own court, and concluded that the on_action didn't work. Then, a few minutes later, but a few months longer in the game, I got the test event firing to notify me of that same vassal changing host, which is what confused me.
I guess you've got a couple of ways you could go with this.

The easy (but somewhat unsatisfying) way is to assume it doesn't work, and put together a series of workarounds as suggested by @Silversweeeper .

Or you could refine your test event and investigate further. For example: always send the visible event to the player (any_player = { character_event = { id = onhostchange.1 } }); embed the character name (FROM), previous host name (FROMFROM), and new host name (FROMFROMFROM) in the localisation for that event; then let the game run for a while and try to figure out what's triggering it; and finally test your guesses, using the console if necessary (eg. imprisonment, yesman for guardian changes / invitations, reassigning councillors / councillor missions).
 
Another, unrelated question, is there any way to force a character to equip specific artifacts? It's incredibly bothersome when I gift a vassal an artifact, but they already have a lower-quality artifact equipped, and will never ever switch.

I don't see a relevant command for it.
Just to double-check, no one knows anything about such a thing?
 
Just to double-check, no one knows anything about such a thing?
If they will reliably equip artefacts when that have none, you could use the old "force them to gift the artefacts to another character until they equip the only one they have, then force them to be given back" trick. It is what I used to clear occupied trade posts.
 
  • 1Like
Reactions:
If they will reliably equip artefacts when that have none, you could use the old "force them to gift the artefacts to another character until they equip the only one they have, then force them to be given back" trick. It is what I used to clear occupied trade posts.
Yes, I was imagining some sort of workaround like this. I was just checking in case there was a simpler way, some kind of built-in command to equip a specific artifact would save time.
 
If they will reliably equip artefacts when that have none, you could use the old "force them to gift the artefacts to another character until they equip the only one they have, then force them to be given back" trick. It is what I used to clear occupied trade posts.
Even this is imperfect, because afaik there's no built-in way to detect which slot an artifact occupies. Sure, some artifacts may have flags set on them which reflect their slots, but that may not be true of every such artifact. (Eg: There no reason why every necklace would have the exact same flag - neck or similar.) If you return artifacts in a random order, except for the one that you want to force to be equipped, you may mess up their equipment choices for other slots.

If it's a reasonable assumption that an AI character should equip the highest-quality artifact available for each slot then returning the artifacts in reverse order of quality (ie. all quality 10+, then all quality 9, etc) might be the best workaround. (I have seen quality 10 modded artifacts, but there may well be higher quality levels out there, so starting at Q10+ and decreasing from there seems like the best compromise between compatibility and brevity of code.)

For bonus points, the temporary character could have a standardised name (eg: "John 'Artifact Sorter' Smith") and maybe a standardised culture etc, so that the artifact history can still kinda be understood.
 
  • 1Like
Reactions:
If it's a reasonable assumption that an AI character should equip the highest-quality artifact available for each slot then returning the artifacts in reverse order of quality (ie. all quality 10+, then all quality 9, etc) might be the best workaround. (I have seen quality 10 modded artifacts, but there may well be higher quality levels out there, so starting at Q10+ and decreasing from there seems like the best compromise between compatibility and brevity of code.)

This is unfortunately not a reasonable assumption; we had to forbid the Tenno (Emperor of Japan) from equipping all ceremonial weapons but Kusanagi (Q5) in Tianxia because the AI happily equipped lower tier ones (at least a Q4 one).
 
This is unfortunately not a reasonable assumption; we had to forbid the Tenno (Emperor of Japan) from equipping all ceremonial weapons but Kusanagi (Q5) in Tianxia because the AI happily equipped lower tier ones (at least a Q4 one).
I think we're actually in agreement, probably because I wasn't completely clear.

From the standpoint of a player/modder, I think it's a reasonable assumption that AI characters should equip the highest-tier artifact they have available in each slot.

However, I believe what actually happens is they equip the first artifact they receive for each slot, and they will never voluntarily change what's equipped. IE: They only change equipment if their currently-equipped artifact is unequipped for some reason, eg. due to being inactive.

(On inheritance, I believe artifacts are transferred in an undocumented-and-unpredictable order that we might as well treat as "random". Thus, if a successor AI character happens to receive a Q1 equippable crown before a Q5 equippable crown then I believe they'll always equip the Q1 crown, and they will keep it equipped until the end of their life. I believe this is how you get Byz/HRE non-Catholic emperors who own their special crowns but equip some Q1 rubbish. I'm not 100% sure how they choose a new artifact to equip if their currently-equipped artifact becomes inactive - I suspect they choose the highest-tier equippable artifact, but I haven't tested, so I can't rule out first-received or random. And this is why I specified non-Catholic before - Catholics can only equip crowns if they are "crowned", so they are forced to choose their crown sometime after succession, so they will often equip the "correct" one.)
(Note that these are all beliefs, ie. hypotheses which I have not managed to falsify. (Although I also haven't tried very hard.) If you have testing that falsifies some/all of this then please say so, because it impacts the suggested workaround!)

So, my suggestion for ensuring that selected AI always have the highest-tier artifacts equipped (including modded artifacts) is to forcibly remove all artifacts, then give them back in descending order of quality. (And it seems like this strategy would work for your Q5/Q4 example.)
 
Last edited:
What logic did you use to forbid it?
I assume they modified the activation conditions of all ceremonial crowns. (To add something like "Is NOT emperor of China". Possibly via a scripted_trigger, so that they don't have excessive code duplication in the artifact files.) This is very brute-force, but I can't think of a more elegant way to do it. However, if there is one, I'm all ears :)
 
  • 1
Reactions:
What logic did you use to forbid it?

Just a condition like "Is NOT the Tenno" for every other ceremonial weapon, which isn't very general. I suppose you could try some kind of "Has no equippable artefact with a higher tier if AI" for something more general, but there might be some cases where that doesn't make sense (e.g. "I will equip the Big Book of Backstabbing despite never contemplating murder plots, because it is better than the Tome of Temperance!").
 
Just a condition like "Is NOT the Tenno" for every other ceremonial weapon, which isn't very general. I suppose you could try some kind of "Has no equippable artefact with a higher tier if AI" for something more general, but there might be some cases where that doesn't make sense (e.g. "I will equip the Big Book of Backstabbing despite never contemplating murder plots, because it is better than the Tome of Temperance!").
The Big Book of Backstabbing has more alliteration than the Tome of Temperance, therefore it is always superior.
 
I want to check all landed lords' holdings in a player's realm to see if they have a certain building constructed (and if they do, to replace it with another building). I'll only check it from the decade pulse, but what would require less processing by the game?

1. Firing it for all rulers, and narrowing it down via normal triggers (landed only, top liege is player, etc)?

Or

2. Firing it only for the player, and scoping from there to any_realm_lord that meets the conditions?

Or would it not make a substantive difference?
 
I want to check all landed lords' holdings in a player's realm to see if they have a certain building constructed (and if they do, to replace it with another building). I'll only check it from the decade pulse, but what would require less processing by the game?

1. Firing it for all rulers, and narrowing it down via normal triggers (landed only, top liege is player, etc)?

Or

2. Firing it only for the player, and scoping from there to any_realm_lord that meets the conditions?

Or would it not make a substantive difference?
I think #2 is almost certainly more performant. (Except perhaps if the player has already completed a WC.)

Consider the situation where a player is small (~20 vassals, including barons) (ie. the worst case).
--- #1: Event fires on_decade_pulse for all characters, and is filtered out using pre-triggers so only the few thousand rulers execute the logic in the trigger block ("Do I have a liege at any level who is a player?"), and of those only 20 proceed to the main body of the logic.
--- #2: Event fires on_decade_pulse for all characters, and is filtered out using pre-triggers so only the one player executes the trigger block. Then the main logic occurs for all 20 of their vassals.
--- The difference between these two situations is that there are thousands of extra "wasted" calculations of the trigger block in #1.

Will this have a noticeable impact on performance? Probably not, as the impact will be spread out over a decade (3650 days), so that's about one "wasted" trigger calculation per day.

Still, every little bit helps, and #2 is a pretty reasonable design, so I suggest you use it.
 
  • 1
Reactions:
I want to check all landed lords' holdings in a player's realm to see if they have a certain building constructed (and if they do, to replace it with another building). I'll only check it from the decade pulse, but what would require less processing by the game?

1. Firing it for all rulers, and narrowing it down via normal triggers (landed only, top liege is player, etc)?

Or

2. Firing it only for the player, and scoping from there to any_realm_lord that meets the conditions?

Or would it not make a substantive difference?

I would always go with number two. It targets the exact thing you need, and if you're checking holdings, you can use any_title_under.
 
  • 1
Reactions:
Hello Whizzer, I am back again... tbh, this is a big question for quick modding ones, but I wanted to write here rather than a PM in case someone else knows.

I have been working on After the End: Eurasia, which has been in development hell for years due to inconsistent crashing on load. Drastic measures have been taken, but we cannot figure it out. It loads sometimes, it doesn't sometimes, and even if it does load, it only goes a month or so in game. We did switch the code base over to CleanSlate, but it was crashing like this before too.

One wacky problem is the game is assigning traits doubly. Like, a random courtier will have two instances of paranoid. We checked traits, which are all CleanSlated, but everything looks like what CleanSlate has besides the obvious mod specific ones.

Secondly, is that we have a file of Chinese characters which appear to be load bearing... if we have that file in, the game loads to the main menu and you can pick a character and sometimes it loads in and sometimes doesn't, and a variety of characters are tested but there is no rhyme or reason to it. When the Chinese chars are included, the game crashes during the load process. We have torn through the file, but really have no clue which character it is, besides one wife/mother who seems like the culprit but there are no errors in her code.

We appreciate your ideas in advance... we are about to tear our garments and run for the hills. Please help :)
 
Hello Whizzer, I am back again... tbh, this is a big question for quick modding ones, but I wanted to write here rather than a PM in case someone else knows.

I have been working on After the End: Eurasia, which has been in development hell for years due to inconsistent crashing on load. Drastic measures have been taken, but we cannot figure it out. It loads sometimes, it doesn't sometimes, and even if it does load, it only goes a month or so in game. We did switch the code base over to CleanSlate, but it was crashing like this before too.

One wacky problem is the game is assigning traits doubly. Like, a random courtier will have two instances of paranoid. We checked traits, which are all CleanSlated, but everything looks like what CleanSlate has besides the obvious mod specific ones.

Secondly, is that we have a file of Chinese characters which appear to be load bearing... if we have that file in, the game loads to the main menu and you can pick a character and sometimes it loads in and sometimes doesn't, and a variety of characters are tested but there is no rhyme or reason to it. When the Chinese chars are included, the game crashes during the load process. We have torn through the file, but really have no clue which character it is, besides one wife/mother who seems like the culprit but there are no errors in her code.

We appreciate your ideas in advance... we are about to tear our garments and run for the hills. Please help :)

Not Whizzer, but some ideas:


Regarding the trait thing, check setup.log. It will have entries like
Code:
[trait.cpp:1221]: Trait #1 tag = cat name = Cat
. If you've got two entries of the same tag, something is definitely up... and per the wiki the file structure behavior is for traits is

Merge, but traits with same name will co-exist, and generated characters may get both versions of the trait at the same time. The last definition gets assigned to a character when using commands.

which to me seems to indicate you're not overriding the directory properly or you've got the trait defined in two files present in the mod itself.


Regarding the crashes, it sounds like there are multiple causes, but you might want to look at the Troubleshooting page on the wiki. When you get a crash during setup, setup.log's last line will give you a hint as to where the issue was (the next file would be the issue, so if e.g.
Code:
[eventmanager.cpp:269]: Events loaded events/AA_events.txt' #1
is present, look at "AB_events.txt").

error.log might also give some hints regarding issues, but that gets a lot of false positives during setup (e.g. missing tech seeds for all duchies if you've got that set on the county level instead), so I personally tend to look at how many lines there are and then filter out everything that's "supposed" to be there.

A somewhat repeatable crash one month in does sound familiar, but I don't remember the exact issue (might have been something related to a focus (including childhood/adolescence), plot, or ambition), and there might be other ways to get something like that (e.g. any events randomly firing around that time could be part of the problem).

Ultimately, however, if you've got a bunch of unclear crashes, the Validator isn't giving you any hints, the logs aren't giving you any hints, manual checking of interface/graphics files doesn't show anything (I once had an issue with a transparent CoA causing a crash on startup that required manual checking), you probably need to go back to the last stable version and add back "a few" new/changed files at a time (in a sensible order; you'll create new issues if you e.g. have an on_actions file referencing a missing event) to see when things break, then narrow it down further by adding files one at a time. Keep adding back files slowly after fixing the first issue you discover is fixed; you might have more than one.

I strongly recommend getting in the habit of launching the mod and running an observer game for a bit whenever you've made sizeable changes to it (after first fixing any Validator and error.log issues that aren't just "Missing/broken loc stirng"), because if you e.g. break things today and don't test for a month you'll have a month's worth of files to check.


On the character issue, if the Validator isn't giving you anything relevant in the file and error.log isn't giving you anything relevant in the file, I'd try something similar to the "add back a few files at a time" approach with the characters in the file; the game can reach the main menu just fine with a good number of characters missing (tested by deleting Tianxia's Yamato/Japanese character file; which screws up a bunch of title histories). Also check on issues with the ID of the suspected character -- is it a duplicate, would it cause 32-bit integer overflow, or anything like that? -- and whether you've got some bracket issues (missing/extra or "wrapping" more than it should), missing equals signs, incorrect tags for anything, or stray characters anywhere (the Validator should catch these issues).
 
  • 2Like
  • 1
Reactions:
I'm trying to make an event that spawns a one-time army, but I can't figure out the correct code.

Event
1) To have the event appear immediately for a set character when you start playing as them at a certain date.
2) The option to spawn a reinforcing army with a set character as its commander.


namespace = reinforcements
# Reinforcements

character_event = {
id = reinforcements.1
desc = "EVTDESCreinforcements.1"
picture = "GFX_event_beach_landing"

hide_from = yes

is_triggered_only = yes

option = {
name = "EVTOPTAreinforcements.1
}
}
 
I'm trying to make an event that spawns a one-time army, but I can't figure out the correct code.

Event
1) To have the event appear immediately for a set character when you start playing as them at a certain date.
2) The option to spawn a reinforcing army with a set character as its commander.


namespace = reinforcements
# Reinforcements

character_event = {
id = reinforcements.1
desc = "EVTDESCreinforcements.1"
picture = "GFX_event_beach_landing"

hide_from = yes

is_triggered_only = yes

option = {
name = "EVTOPTAreinforcements.1
}
}
You want the spawn_unit command listed here https://ck2.paradoxwikis.com/Commands

Having it fire at an exact time when you play a set character at a set date might be a bit trickier. What defines this character and this date? Take a look at the various on_action triggers here to find one that fits best https://ck2.paradoxwikis.com/Event_modding#List_of_on_action_triggers
 
  • 1
Reactions: