• 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:
Additive modifiers is *amazing* news for us modders! The way you can only use multiplicative modifiers in CK2 and EU4 can be difficult to balance if you have a lot of modifiers, making things exponentially more or less common.

How moddable are the species art sets? What file format do they even come in? Gifs? :p

Also, CK2 and EU4 handles government changes by the AI really horribly, how is it in Stellaris? In CK2 they AI has most often pretty much ignored changes laws, and in EU4 there were huge restrictions in how the AI changes government, since it could only read "down the list of choics" (i.e. if it has government 4, it might upgrade to 5 or 6, but it was impossible for it to even consider changing to to government 3). I hope there's no such restrictions in Stellaris!
 
The tools and skills from modding CK2 and EU4 are transferable.
 
  • 2
Reactions:
For ease of modding I think it would be useful to have some kind of comprehensive java docs/wiki style documentation for all of those keywords, triggers and functions on external site. Maybe to stellaris wiki?

Also maybe custom code completion.

Man i'd give paradox anything for a custom "Stellaris" Notepad++ language on release.
 
  • 4
  • 1
Reactions:
Kinda relates to modding, saw this question in another thread but found no awnser

So we know that player-created empires can show up as AI, and be set up to show up always/sometimes/never. We also know that we can set empire's home system specifically as 'Sol', so that we can set up various (different) human factions. So logical question coming from the combination - if we set all human factions we make to show up 'sometimes', will it make sure that there's only one human/Sol-based empire? It's somewhat immersion-breaking if I start seeing like... 8 different Sols in the galaxy.
 
  • 1
Reactions:

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...)
 
  • 2
Reactions:
Will it be possible to mod the galaxy generation scripts the game uses? This would allow amazing things, for example:

A galaxy where a Fallen Human Empire is surrounded by 101 FTL Human empires, while the rest of the galaxy is populated by generic alien species. While this kind of scenario would be fun to replay, it wouldn't last more than a couple or runs If it was just a static map.

If the modders had these possibilities, it'd be possible to make mods that generate galaxies with a very specific history, that the player would be able to discover as he explores it.
 
Of course, what we really want is a full list of Scopes, Effects, Modifiers, Triggers and Localisation Strings...
I for one confess that I'll be studying the modifiers Rather A Lot. :)
 
So the demonstartion anomaly has an event for sucessfully surveying the anomaly, but none for eventual failures. What happens when the failure events are not existent like in this case and the anomaly survey fails?
 
  • 1
Reactions:
So, the fact that ships can be flagged really excites me. This means that my idea for a siege-event mod is very much plausible.
 
So the demonstartion anomaly has an event for sucessfully surveying the anomaly, but none for eventual failures. What happens when the failure events are not existent like in this case and the anomaly survey fails?
fail.PNG

The fail and crit fail was referenced in the category, but mostly i think they just weren't mentioned/shown in the DD because they are functionally almost identical to the normal success event in terms of code structure.
 
  • 1
Reactions:
So the demonstartion anomaly has an event for sucessfully surveying the anomaly, but none for eventual failures. What happens when the failure events are not existent like in this case and the anomaly survey fails?
It does have fail and crit fail events (dev_diary_fail.1 and dev_diary_crit_fail.2), I just don't show off their script.

If an anomaly has no failure events, failure will presumably be silent - there is no result.
 
  • 16
  • 2
Reactions:
The problem with your approach is that people & AI won't be able to expand at all if the distances are too great. Late game you then have one or two great empires who were lucky and got half the galaxy in FTL lvl 1 range while the rest are locked in into their small pockets and are still researching FTL lvl 2 because of low resources.

I would make sure that they can definately reach another System, but maybe not 4 or 5 in every direction.

But yeah, it's a little bit unfair, but that's life and only one static galaxy to check and play with less parties. So with if I like to Play with 10 species in a 1.000 System galaxy, it shouldn't be too hard

Btw. can starting points be predefined? This would help out, so they all start more in the center and reach the outer rim later in game. Yeah...this would be great!!!
 
Is it possible to get something like a random calculator for arranging star systems? To get more uneven results like the Star wars galaxy f.e
/.../
like this f.e.:
View attachment 173150

While I don't dislike your suggestion, that would introduce some balancing issues with the FTL variants. Wormhole and Warp drives would have a much easier time getting around than the Hyperspace drives, which rely on a pre-set network (which I assume would not link all the systems in a cluster).
On the other hand, Hyperspace drives would probably have an easier time crossing the large gaps ...

Wait ... that sounds kinda fun. You know what, you just made me change my mind. This looks like an awesome idea through and through!
 
  • 2
Reactions: