#[Modding] Allow things like scripted triggers/effects/rules to be "appended"

2 messages · Page 1 of 1 (latest)

dusky thistle
#

I don't know exactly how the game engine handles loading/storing things like scripted triggers/rules/effects/etc, so I don't know how plausible this would be (especially if it requires changing how they are formatted), but I think it could be quite useful for modding and compatibility overall.

As it is, the game allows on_actions to essentially be "appended" together by including an on_actions block when defining a new on_action, like this:

on_game_start_after_lobby = {
  on_actions = { initial_game_start_onaction_effects }
}

initial_game_start_onaction_effects = {
  effect = {
    every_player = { add_piety = 100000 }
  }
  on_actions = { another_test_on_action }
}

another_test_onaction = {
  effect = {
    every_player = { add_gold = 10000000 }
  }
}

In this example, when the on_game_start_after_lobby action is triggered, it triggers the initial_game_start_onaction_effects action giving every player lots of piety, which then in turn triggers the another_test_onaction action giving every player lots of gold. This is nice in modding because you can easily add your own on_actions without having to worry about overwriting the base game ones and causing compatibility issues with other mods.

Because you can't do something like that for things like scripted effects/triggers, mods, especially large or total conversion mods, sometimes require a lot of compatibility patches because different mods need to modify the same base game effects/triggers/rules, but in different ways. While being able to "append" effects/triggers/rules won't solve all of these compatibility issues, it could definitely alleviate some of them.

#

An example of where this could definitely be useful would be from another modding suggestion to add a general trigger/rule that determines whether titles can be created. If this suggestion was implemented, you could have a scripted rule like this:

# Determine if the target title can be created. Available scope:
#    root: the ruler that could create the title
#     scope:title the title to create
can_title_be_created = {
    can_title_be_created_trigger = yes
}

This being a scripted rule would allow the scopes to be properly setup so they can be checked in the triggers, and the rule only checks that can_title_be_created_trigger = yes, and that trigger could then be setup as follows:

can_title_be_created_trigger = {
    trigger = {
        ...
        ALL THE GENERIC CONDITIONS THAT EVERY RULER MUST MEET TO BE ALLOWED TO CREATE TITLES
        ...
    }
}

This first trigger would just contain all of the generic conditions that any ruler must meet to create titles, or the ai_should_create_title scripted rule could be merged into this scripted trigger since they would be doing the same thing. (I added the trigger block here to mimic the on_action's effect block, but I don't know how necessary this would be. With this, the equivalent of the on_actions block would be something like scripted_triggers). THEN, separate triggers could be created and "appended" to this base trigger for whatever specific circumstances are needed. For example, in the modding suggestion referenced above, they mention using the new trigger to prevent Ritsuryo rulers from creating things like duchy titles anywhere (so you don't need to manually add this condition to every single title's can_create block in landed_titles, and so it would work with dynamic duchies as well), not just the few titles in Japan.