• 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:
Nice. But the only thing I will probably mod in are name lists, since they are very easy. I'll use modded content from more experienced modders.
I look forward to Star Trek and Mass Effect mods! :)
 
  • 1
Reactions:
Always nice to see some improvements on modding support. I put my fingers into clausewitz modding with ck2, though didn't release anything due to very limited religion modding scope (reformations mainly). Though as a programmer I would still love to see paradox switch from custom language to proper api on established language like lua. It would make modding so much easier to do and support but I agree that it would be rather huge change on the engine. One can hope that eventually you will see the light...
 
  • 4
  • 1
Reactions:
Always nice to see some improvements on modding support. I put my fingers into clausewitz modding with ck2, though didn't release anything due to very limited religion modding scope (reformations mainly). Though as a programmer I would still love to see paradox switch from custom language to proper api on established language like lua. It would make modding so much easier to do and support but I agree that it would be rather huge change on the engine. One can hope that eventually you will see the light...

They actually used lua in HoI3 for the ai scripting, but due to unfamiliarity even in the dev team and bad performance, they decided to abandon it for HoI IV and I guess Stellaris as well this time. This is relevant: https://forum.paradoxplaza.com/foru...-iron-iv-development-diary-52-modding.920875/
 
  • 2
Reactions:
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.

Sounds like the kind of thing that will add a ton of longevity to the game, because with any finite set of anomalies eventually you'll have "seen them all".

I'd love to make a pack of anomalies on day 1, but I'd worry if I was making duplicates of stock ones and wouldn't know if mine were easier/harder or more/less generous with rewards.

This. @LordMune, can you provide some guidelines for creating anomalies in line/balanced with the ones in the base game? How strong should the effects be at different anomaly difficulty levels, and such?
 
I can't tell if that is a bad "Well..." or a good "Well..." :eek:

Paradox may already have my time, they may already have my wallet, but you don't have my soul!
(yet...)
I would like to think they might have made one, one of the often requested things in the ck2 modding scene is a full list of triggers, scopes and effects etc which are valid and what their uses are and then a visual way of seeing those in notepad. If not then the community will like they have done in ck2 to the best of their ability but a paradox made one would be super useful
 
Nothing really new or not expected from PI on this one.
Ok, a little improvement looking like some Json / javascript object but nothing really fantastic.
 
They actually used lua in HoI3 for the ai scripting, but due to unfamiliarity even in the dev team and bad performance, they decided to abandon it for HoI IV and I guess Stellaris as well this time. This is relevant: https://forum.paradoxplaza.com/foru...-iron-iv-development-diary-52-modding.920875/
AI is very demanding on performance front. Not knowing details on implementation, but since they claim performance issues I guess they tried to run most of the AI in lua. Not very good choise to start with since that kind of performance critical parts should not be run directly on any interpred language.
 
  • 1
Reactions:
It is "Japanese".
Such East Asian languages use multibyte characters, and it is difficult to localize for them because of some .exe(for example,eu4.exe)
If .exe of Stellaris supports multibyte, we can localize it easily by making some fonts.

Not only Japanese, but also other East Asian language. By the way, I think someone told me Stellaris is using utf-8 for text coding. Can I get a confirmation for that?

By the way, does mod in Stellaris support steam workshop?
 
Not only Japanese, but also other East Asian language. By the way, I think someone told me Stellaris is using utf-8 for text coding. Can I get a confirmation for that?
From what we know, it is the same as EU4 and CK2, which is ISO-8859-1.
 
Nice dev diary, I am hoping to get into scripting again!

Alas I have no idea how this new stuff works. I come from HoI2 modding/scripting which was quite a bit easier/simpler in scope.
 
seems nice but I've never been able to figure these things out by reading them. I need to actually work with them.
 
It is "Japanese".
Such East Asian languages use multibyte characters, and it is difficult to localize for them because of some .exe(for example,eu4.exe)
If .exe of Stellaris supports multibyte, we can localize it easily by making some fonts.

EU4 already has an unofficial Chinese localisation though. The problem is more likely that PDS doesn't find supporting non-European languages to be profitable cost benefit wise rather than some unassailable technical difficulty.

2013814101253875970.jpg


 
  • 1
Reactions:
seems nice but I've never been able to figure these things out by reading them. I need to actually work with them.

I found it easiest to start modding your savegames. HoI2 and Vicky1 required frequent save editing, especially in MP. Things like province swapping, Capital moving (faulty supply system frequently killed Japan for example), etc.

War merging was also a big thing. As well as AI production queue/priority editing.
 
Man i'd give paradox anything for a custom "Stellaris" Notepad++ language on release.

Well, assuming that Paradox releases the base script, I'll continue to update it as I do for EUIV.
 
  • 1
Reactions:
I found it easiest to start modding your savegames. HoI2 and Vicky1 required frequent save editing, especially in MP. Things like province swapping, Capital moving (faulty supply system frequently killed Japan for example), etc.

War merging was also a big thing. As well as AI production queue/priority editing.
I know how to mod I have modded plenty, I said that I'll have t get hands on with Stellaris modding specifically to figure out the quirks of modding for Stellaris.
 
  • 1
Reactions:
I guess we can also change the values for "on_fail" and "on_critical_fail", and maybe add a "on_critical_success" triggers in \Stellaris\common\defines\ ?
If I understand well, by default critical failure may be something like 1/10 of the fail chance. Can we add a on_critical_success that would be triggered with a value of 1/10 of the chances of success ?
Something like :
For an anomaly with 30% chance of failure (risk : 2, level of the scientist : 2)
on_fail has 27% chances to happen
on_critical_fail has 3% chances to happen
on_success* (default -> leads to the next step) has 63% chances to happen
on_critical_success (custom trigger -> would lead to an other anomaly or grant additional bonus and lead to the same event as on_success*) has 7% chances to happen