As some of you might have seen on the Eu4 mod forum, I have added code support for saving dynamic event targets. Since this feature is rather large, both in significance and the time it took to add, I will use this post to go into some details about it, and answer potential questions here rather than bloating the Captain's Log thread.
I have added a new effect called save_event_target_as. It means that anytime you want you can save the current scope's character, title or province number as a variable named by you, and then use it whenever you need as an event target (for either an effect or trigger) or as a right-side argument. It is also possible to use in localization.
When using the variable as an event target or as a right-side argument it needs to be prefaced by event_target: (in order for the parser to work). In the localization however you can use just the variable name.
The saved event targets will persist as long as an event chain is alive, and are freely accessed from anywhere within it, meaning you can save an event target in the first event and use it 15 events down the line.
In the first event above (test.1), you can see that I re-use the variable my_courtier twice. Normally this wouldn't work when it comes to the tooltip as the effect saving those new targets haven't been executed when the tooltip is built, and thus would not show the target as ever pointing to the second courtier. But I have solved that for this particular effect, so if you want to show these effects for the player and re-use a variable as I've done above, you can.
I've also added save_global_event_target_as, clear_global_event_target and clear_global_event_targets effects. Unlike the other effect, these event targets are not saved in an event chain but in the game state - which means that they work as global variables and that they are persistent. The two clear functions are there so that you can do a little house cleaning and avoid bloating the game state/savegame.
And of course, these saved event targets are also accessible from the localization.
Unfortunately, this will not be in the release version of Charlemagne - but I will try to get it out with the first patch.
I have added a new effect called save_event_target_as. It means that anytime you want you can save the current scope's character, title or province number as a variable named by you, and then use it whenever you need as an event target (for either an effect or trigger) or as a right-side argument. It is also possible to use in localization.
Code:
character_event = {
id = test.1
is_triggered_only = yes
option = {
random_courtier = {
limit = {
is_landed = no
is_female = no
age = 15
}
save_event_target_as = my_courtier
}
random_vassal = {
limit = {
any_child = {
vassal_of = PREV
is_landed = yes
age = 15
}
}
save_event_target_as = my_vassal
random_child = {
limit = {
vassal_of = PREV
is_landed = yes
age = 15
}
save_event_target_as = my_vassals_son
primary_title = {
save_event_target_as = vassal_sons_title_to_give_away
}
}
}
event_target:my_courtier = {
treasury = 500
}
random_courtier = {
limit = {
is_landed = no
is_female = yes
}
save_event_target_as = my_courtier
}
event_target:my_courtier = {
treasury = 250
}
character_event = { id = test.2 days = 3 }
}
}
character_event = {
id = test.2
desc = "test.2.DESC"
is_triggered_only = yes
option = {
event_target:vassal_sons_title_to_give_away = {
grant_title = event_target:my_courtier
}
event_target:my_vassals_son = {
opinion = {
who = ROOT
years = 50
modifier = opinion_furious
}
opinion = {
who = event_target:my_courtier
years = 50
modifier = opinion_furious
}
}
}
}
When using the variable as an event target or as a right-side argument it needs to be prefaced by event_target: (in order for the parser to work). In the localization however you can use just the variable name.
Code:
test.2.DESC;For some reason I have decided to punish my vassal [Root.my_vassal.GetFullName]! I will appropriate his son [Root.my_vassals_son.GetFullName]'s primary title, [Root.vassal_sons_title_to_give_away.GetFullName], and award it to my faithful courtier [Root.my_courtier.GetFullName]! [Root.my_vassals_son.GetFirstName] is furious and has sworn to exact revenge on me and [Root.my_courtier.GetFirstName].
The saved event targets will persist as long as an event chain is alive, and are freely accessed from anywhere within it, meaning you can save an event target in the first event and use it 15 events down the line.
In the first event above (test.1), you can see that I re-use the variable my_courtier twice. Normally this wouldn't work when it comes to the tooltip as the effect saving those new targets haven't been executed when the tooltip is built, and thus would not show the target as ever pointing to the second courtier. But I have solved that for this particular effect, so if you want to show these effects for the player and re-use a variable as I've done above, you can.
I've also added save_global_event_target_as, clear_global_event_target and clear_global_event_targets effects. Unlike the other effect, these event targets are not saved in an event chain but in the game state - which means that they work as global variables and that they are persistent. The two clear functions are there so that you can do a little house cleaning and avoid bloating the game state/savegame.
And of course, these saved event targets are also accessible from the localization.
Unfortunately, this will not be in the release version of Charlemagne - but I will try to get it out with the first patch.
- 3
- 1