• 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.
Welcome to a brief unannounced surprise bonus dev diary!

PDXCon preparations are taking up most of our time, but with attendees getting some early hands-on time with the Distant Stars Story Pack, we figured we'd give the modders among you a glimpse of some of the under-the-hood-changes coming in the update. We've discussed the changes coming to Anomalies in 2.1 'Niven' in the past, but what do they actually mean for you, the intrepid modder? Well, hopefully the reworked Anomaly back-end will make your life a lot easier.

Now strap in, we're going to get a little bit technical.

Let's take a look back at an old favorite, Anomaly category "Buried in the Sand" as writ in the olden days:
00_anomaly_categories_3.txt said:
Code:
anomaly_category = {
    key = "DES_BURIED_CAT"
    desc = "DES_BURIED_DESC"
    picture = "GFX_evt_desert"
    level = 2

    spawn_chance = {
        modifier = {
            add = 3
            is_planet_class = pc_desert
            from = {
                owner = {
                    NOT = {
                        has_country_flag = masters_writings_politics_found
                        has_country_flag = ai_admiral_found
                    }
                }
            }
        }
    }

    on_spawn = {
    }

    on_success = {
    }

    on_fail = {
        ship_event = { id = anomaly_failure.4030 }
    }
}
00_anomalies_3.txt said:
Code:
anomaly = {
    event = anomaly.4030
    category = "DES_BURIED_CAT"

    weight = 1

    potential = {
        always = yes
    }
}

anomaly = {
    event = anomaly.4135
    category = "DES_BURIED_CAT"
   
    weight = 1
   
    potential = {
        owner = {
            NOT = { has_ethic = ethic_gestalt_consciousness }
        }
    }
}
Awful, right? That's 50 lines of script split into three entries across two different files. But fear not, the future is bright!

New script in 03_anomaly_categories.txt said:
Code:
DES_BURIED_CAT = {
    picture = "GFX_evt_desert"
    level = 4
   
    spawn_chance = {
        modifier = {
            add = 3
            is_planet_class = pc_desert
        }
    }

    max_once = yes
   
    on_success = {
        1 = anomaly.4030
        1 = {
            modifier = {
                factor = 0
                owner = { has_ethic = ethic_gestalt_consciousness }
            }
            anomaly_event = anomaly.4135
        }
    }
}
Less than 25 lines of script, all in one file! Clean. Efficient. Sleek, even.

We have prepared a handy explainer in case you want to start low-key updating your event mods for 2.1 already;
Code:
an_anomaly_category = {                # Anomaly category ID key

    should_ai_use = yes/no            # Allows AI empires to generate the category. Default: no

    desc = "key"                    # Optional, if no desc is given "<category key>_desc" is assumed

    desc = {                        # Can also use triggered descs. First valid entry will be used.
        trigger = { ... }            # Scope: planet, from = ship
        text = "key"                # Localization key for description
    }
    picture = GFX_picture            # Picture displayed in category window
    level = int                        # Anomaly level, 1 to 10

    null_spawn_chance = 0.5            # Default 0. 0.0 - 1.0 (0 to 100%) chance category will NOT spawn
                                    # even if it is picked by the anomaly die roll. Used to make
                                    # categories for unusual objects (e.g. black holes) actually rare.
   
    max_once = yes/no                # default NO, if true will spawn category only once per empire
    max_once_global = yes/no        # default NO, if true will spawn category only once per game

    spawn_chance = {                # Chance for this anomaly category to spawn, 
        base = <num>                # relative to other valid categories. Default: base = 0
        modifier = {                # Spawn chance modifier
            add/factor = <num>
            <triggers>                # Scope: planet, from = ship
        }
    }

    on_spawn = { <effects> }        # Executes immediately when anomaly category is spawned. 
                                    # Scopes are this/root: planet, from: ship
                                    # NOTE: on_spawn effects will not run if category is spawned through console

    on_success = {                    # Picks anomaly event to fire; similar to random_list
        1 = {                        # Base chance
            max_once = yes            # Individual outcomes default to max_once = yes,
            max_once_global = no     # and max_once_global = no
            modifier = {            # Optional modifiers
                add/factor = <num>
                <triggers>            # Scope: ship, from: planet
            }
            anomaly_event = <id>    # New effect anomaly_event fires specified event ID. Scope: ship, from: planet           
        }                            # Can also use ship_event, though it gets different scopes:
                                    # ship, from: ship, fromfrom: planet       

        1 = <event id>                # shorthand for 1 = { anomaly_event = <event id> }
    }

    on_success = <event id>            # Shorthand for on_success = { 1 = { anomaly_event = <event id> } }
}                                    # Only use if there is only one outcome in the category

That's all for now! Keep an eye and ear out for news from PDXCon.
 
So, this is an extra and we'll have a bigger Dev Diary today, or is this it until next Thursday?

Regardless, I like this. I don't mod Stellaris but sometimes I want to check something in the script to know how it works and it's currently a pain in the ass to do so.
 
So, this is an extra and we'll have a bigger Dev Diary today, or is this it until next Thursday?

Regardless, I like this. I don't mod Stellaris but sometimes I want to check something in the script to know how it works and it's currently a pain in the ass to do so.

Last week's dev diary said there wouldn't be one this week because of Pdxcon.
 
Love it :D
This will make making new anomalies a whole lot faster! Thank you for this :>
 
More importantly: Why did you bury the poor cat? I hope it was already dead!
 
should_ai_use = yes/no # Allows AI empires to generate the category. Default: no

Are there a lot of anomalies that the AI doesn't get, or is this intended more for long story-chain anomalies like Horizon Signal and Precursors?

null_spawn_chance = 0.5 # Default 0. 0.0 - 1.0 (0 to 100%) chance category will NOT spawn
# even if it is picked by the anomaly die roll. Used to make
# categories for unusual objects (e.g. black holes) actually rare.

Is a different anomaly category picked if the roll comes up negative, or is it just a lost anomaly opportunity in that case? When is this rolled, when the galaxy is created or when the survey is conducted?

on_success = { # Picks anomaly event to fire; similar to random_list

Is it possible to add additional events to an existing anomaly via a separate file/entry?
 
Less than 25 lines of script, all in one file! Clean. Efficient. Sleek, even.
Any chance that ship designs will receive a similar treatment?
 
So, they disrupted ability to simply add new outcomes to categories without overwrites, because now outcomes are part of category.
We don't know what overwriting behaviour the file will have
It might be possible to add new outcomes in separate files without breaking everything, like for the on_actions
 
Considering how many boolean data there is to the file, I highly doubt it would be able to merge.
I don't think it'd be a problem, we can already rewrite some parts of the landed_titles files from CK2 and they can contain quite a bit on information, they may have imported this possibility in Stellaris
 
Will there be some kind of composition or inheritance concept for the new anomaly categories? For example, if there are two definitions of a category with different "on_success" objects, will one overwrite the other, or will the final "on_success" be a union of the members of each? If they're a union, then what would happen if you redefined something with a different weight?
 
Cheers for the bonus DD LordMune :). Not a Stellaris modder m'self, but very much appreciate a more elegant scripting set-up, great work :D.

So, this is an extra and we'll have a bigger Dev Diary today, or is this it until next Thursday?

Regardless, I like this. I don't mod Stellaris but sometimes I want to check something in the script to know how it works and it's currently a pain in the ass to do so.

We will get a stream on Stellaris by Wiz via PDXCon, so I reckon we'll do alright for the week in terms of Stellaris news :).