• 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.

Stellaris Dev Diary #31 - Modding (Scripting Anomalies)

Hello, earthlings. My name might be unfamiliar to some dev diary readers; I’ve been working on Stellaris for some time now and am in charge of scripting/content design duties for Stellaris while the eminent Goosecreature is away rearing his brood. This week’s dev diary is the first in a two-part series on modding, which you will read, enjoy, and be enlightened by. We’re here to get our hands dirty, so don’t expect any pretty screenshots! Only functional screenshots.

Stellaris is built on the Clausewitz engine, and has had a lot of functionality ported over from our other games. Since we use a random galaxy generated at game start (unless you mod in a static one) we have to approach things a bit differently than you would in a game with a pre-set map of Europe - if you’ve modded a Paradox Development Studio title before you may come across a few surprises, but you should feel right at home soon enough.

General Modding
Like our other games, Stellaris is very mod-able. Take a look in the \Stellaris\common\ folder and you’ll see. It contains mostly everything that determines how the game functions. Edicts, ethics, game rules, army attachments, name lists, country types, planet classes, modifiers, buildings and so on can all be found here. In \Stellaris\common\defines\ you will find a LUA script file that regulates a lot of basic game behaviors and settings, like the base soft cap on the number of core planets ( CORE_SECTOR_PLANET_CAP = 5 ) or the camera field-of-view ( NCamera = { FOV = 35 } ) available for easy tweaking. Most of these values come with fairly informative comments!

Scripted Triggers & Effects, Chained Event Targets
We recently inherited scripted triggers and effects from Hearts of Iron IV! They’re very good. One addition to the scripting language that originated in Stellaris and may or may not find its way to other games in the future is event target chaining. It allows us to chain targets/scopes/saved event targets together in a way not unlike how we do it in localization. For example, what was once written
Code:
from = {
    owner = {
        establish_communications = root
    }
}
can now be rendered as the much more digestible
Code:
from.owner = { establish_communications = root }
Amazing!

Anomalies
Swiftly moving on to Anomalies, the lifeblood of early game exploration in Stellaris. Incidentally, anomalies are also rather unlike the events found in our other games You can and should make your own! I will show you how.

An anomaly is made up of a minimum of four components; the anomaly category, the anomaly, the event and localization.
  1. \Stellaris\common\anomalies\00_anomaly_categories.txt
  2. \Stellaris\common\anomalies\00_anomalies.txt
  3. \Stellaris\events\00_anomaly_events.txt
  4. \Stellaris\localisation\events_l_english.yml

Anomaly categories define what planets are viable for a certain category of anomalies to spawn on. Anomalies refine this selection further and link to specific events. The event that is eventually fired… does stuff. The localization file provides the text for the event and the category window.

I feel that a picture is worth more than a thousand words, so I’m going to show you pictures of words to maximize efficiency. See if you can follow along!

Step 1 - 00_anomaly_categories
1anomalycategory.png


Step 2 - 00_anomalies
2anomaly.png


Step 3 - 00_anomaly_events
3event.png


Step 4 - events_l_english
4localization.png



And the end result!
Planet Surveyed
5categorywindow.png


Anomaly Researched
6eventwindow.png




That’s all for now, planet-dwellers. Next week, art director Aerie will explain how to get your own art into the game. Exporters! Graphics! Spaceships!
 
Last edited by a moderator:
  • 159
  • 48
Reactions:
What I was looking to achieve was to add a permanent bonus on every tile that had a blocker (removed or not) to one of the 5 ressources according to the blocker's difficulty

The quickest (but not necessarily cleanest) way to do this is probably just to create an event that is fired by on_game_start in 00_on_actions. It might look something like this:

Code:
event = {
    id = blockermod.1
    hide_window = yes

    fire_only_once = yes
    is_triggered_only = yes

    every_planet = {
        every_tile = {
            limit = {
                has_blocker = yes
            }
            if = {
                limit = {
                    has_blocker = tb_noxious_swamp
                }
                clear_deposits = yes
                add_deposit = d_rich_society_deposit
            }
            if = {
                limit = {
                    has_blocker = tb_volcano
                }
                clear_deposits = yes
                add_deposit = d_vast_mineral_deposit
            }
            if = {
                [etc etc etc...]
            }
        }
    }
}
 
The quickest (but not necessarily cleanest) way to do this is probably just to create an event that is fired by on_game_start in 00_on_actions. It might look something like this:

Code:
event = {
    id = blockermod.1
    hide_window = yes

    fire_only_once = yes
    is_triggered_only = yes

    every_planet = {
        every_tile = {
            limit = {
                has_blocker = yes
            }
            if = {
                limit = {
                    has_blocker = tb_noxious_swamp
                }
                clear_deposits = yes
                add_deposit = d_rich_society_deposit
            }
            if = {
                limit = {
                    has_blocker = tb_volcano
                }
                clear_deposits = yes
                add_deposit = d_vast_mineral_deposit
            }
            if = {
                [etc etc etc...]
            }
        }
    }
}

ohh I didn't see the probleme this way :) Thank you !
 
I hope I understud that. A Flag is some kind of marker that was given to the ship itself earlier. Not the Scientist on that ship.

Thanks for trying to explain it to me. I start with something easier, look over some code sripted by other modders and definetly read up on the EU4 modding wiki. And thanks for making this great game i was long waiting for such a SciFi strategie game.
 
Good day all,
I have been looking at modding this games events but their seems to be a file missing. Please can someone tell me where to find this file.
  1. \Stellaris\common\anomalies\00_anomaly_categories.txt (found)
  2. \Stellaris\common\anomalies\00_anomalies.txt (missing)
  3. \Stellaris\events\00_anomaly_events.txt (found)
  4. \Stellaris\localisation\events_l_english.yml (found)
 
Thanks for the time taken in showing me where the file is located but i mixed up the files.

\Stellaris\common\anomalies\00_anomaly_categories.txt (found)
\Stellaris\common\anomalies\00_anomalies.txt (found)
\Stellaris\events\00_anomaly_events.txt (missing) see attached image of the events folder.
\Stellaris\localisation\events_l_english.yml (found)
events.png
 
Right, my bad. It's not 00_anomaly_events, but anomaly_events_1 through 6. You can create anomaly_events_7.txt or anomaly_events_MyMod.txt or whatever you want.
 
Hey, lordmune, quick question regarding modding, but not quite modding anomolies.
Is the formula for how damage reduction/amour works publicly available and able to be changed, or is it like, hard coded into the game right now?
If we can change it around, could you point me in the right direction? I know of the damage reduction integer in 00_defines, but, so far, that is all i have been able to find.
 
Take a look in common\component_templates for ship component values.

EDIT: That might not be all you're looking for, but as far as I am aware the rest is hard-coded.
 
Last edited:
@LordMune not certain if this thread is being monitored any longer, but here goes.

if I were to mod the the core sector systems, would it break my save games?

I think there are mods that do that already.
 
I was in class and looking to change the limit, I saw one on the workshop that just increases the limit and doesn't change anything else, giving that a shot right now.

If you're looking for one that lets you change your planet cap to anything you want, check out Flexible Core Planet & Resettlement Cost by Legendarymarvin.
 
  • 1
Reactions:
So about Events. I know from vanilla events its possible to have events triggered by a planetary flag. I was wondering if in making a new event of this type it is possible to create a new flag or if you have to use existing ones. Also how would one do this?
 
Please do not neco threads @Fenrir9

If you've not done so already, please register your game and post that question in the modding sub forum which will be thus revealed.