• 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:
Seems like anomalies are quite open to modding. That's great!
 
Would it be possible to spawn a colony ship that has an entirely new randomized spices on it? Or maybe spawn a character that is a whole new species?
Under the control of an existing empire? Maybee.
As a nomadic faction, I strongly doubt it.
 
  • 1
Reactions:
Under the control of an existing empire? Maybee.
As a nomadic faction, I strongly doubt it.

Was thinking that of so that they are brought under control from the one that receive the event. Like you find a derelict ship and find out that it belongs to the last remnant of a species in cryo and that they will join your empire if you help them find a safe haven.
 
  • 2
Reactions:
Was thinking that of so that they are brought under control from the one that receive the event. Like you find a derelict ship and find out that it belongs to the last remnant of a species in cryo and that they will join your empire if you help them find a safe haven.
That might be doable.
 
  • 1
Reactions:
I think Stellaris will be my first trip in to Modding. I'm excited and looking forward to it.

Hehe, I was thinking the same thing. After I've done a play through or two anyway.
 
  • 1
Reactions:
If it means that it makes it far easier for someone to make a Star Gate Mod then I gained a lot from this Dev diary.

I don't know if I can wait 2 weeks for this game, it's going to be torture.
 
  • 1
Reactions:
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!

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!

While I'm personally focussed on HoI4 (Stellaris is still my second-most anticipated game in years :)), these modding features look awesome - chained event targets looks potentially brilliant :). Whether or not I get around to modding Stellaris, I have no doubt I'll be enjoying mods that take advantage of these features - big props to you and the team :).


Would be awesome if ya did :).
 
Nice!

I only have one question: Can you mod a grand campaign start into the game like eu4?

It would open a lot up for modding!
Thank you.
 
Can I suggest that we hold some place in the wiki as a "code library" where modders can show examples of the basics and show off their advanced pyrotechnics? Preferably in the shape of source code with indications about how the less advanced can swipe and customize it, or fit it into a full mod?
 
  • 1
Reactions:
About random vs. static galaxy
In my opinion, as posted in another thread, the galaxy is a little bit to sorted, the star systems are too even arranged, nearly all have the same distance to each other, there's no crowded spot of closer systems to the core f.e and way more distances in the outer rims etc.
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

Or how easy / hard is it to mod the galaxy?


An editor would be great where you can just "drag and drop" or "move" star systems around in your galaxy.How they look like in the game then is random.
I know that the starting conditions in this case are not the same, but... ey, thats random challenge!!!

like this f.e.:
View attachment 173150
I couldn't agree more with your idea, in fact this was my first reaction to Stellaris, Stars being to evenly distributed. You should make separate thread on this.
 
How are the chance modifiers handled (Add=X and Factor=X) when multiple of each kind apply.
E.g. is
Add = 4
Factor = 5
Add = 3
Factor = 2

(4+3)*(2+5) or 4*5 + 3*2 ?
 
How are the chance modifiers handled (Add=X and Factor=X) when multiple of each kind apply.
E.g. is
Add = 4
Factor = 5
Add = 3
Factor = 2

(4+3)*(2+5) or 4*5 + 3*2 ?
Neither. It calculates each step in order, so

base 0 = 0
add 4 = 4
factor 5 = 20
add 3 = 23
factor 2 = 46
 
  • 3
Reactions: