• 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:
Neither. It calculates each step in order, so

base 0 = 0
add 4 = 4
factor 5 = 20
add 3 = 23
factor 2 = 46
Would it not be better to do all additions first before multiplication? That is how ck2 does it and it makes it easier if you want to do an addition and do not have to scroll through a bunch of modifiers to get back to before you were doing multiplication and put in the add 2 or whatever
 
Would it not be better to do all additions first before multiplication? That is how ck2 does it and it makes it easier if you want to do an addition and do not have to scroll through a bunch of modifiers to get back to before you were doing multiplication and put in the add 2 or whatever

But when it does them in order, neither additions or multiplications firsts, why would you have to go back if all you want to do is add 2?
Wouldn't that just be:

base 0 = 0
add 4 = 4
factor 5 = 20
add 3 = 23
factor 2 = 46
add 2 = 48

I think you lost me, do you mean add 2 to total? add 2 to a previous modifier? or something completely third that my only half awake brain can't understand?
 
But when it does them in order, neither additions or multiplications firsts, why would you have to go back if all you want to do is add 2?
Wouldn't that just be:

base 0 = 0
add 4 = 4
factor 5 = 20
add 3 = 23
factor 2 = 46
add 2 = 48

I think you lost me, do you mean add 2 to total? add 2 to a previous modifier? or something completely third that my only half awake brain can't understand?
Because there is a difference between doing it each way.
If you do (Ignoring proper order of operations obviously) 1 * 5 + 3 = 8
Which is different to 1 + 3 * 5 = 20

Also it kinda makes more sense to do all the addition first with ai chances etc so then your additions have a bigger impact as seen by my example above, it just to me logically makes more sense to do all the adding first to get your base to a big amount then multiply them all.
 
  • 2
Reactions:
Because there is a difference between doing it each way.
If you do (Ignoring proper order of operations obviously) 1 * 5 + 3 = 8
Which is different to 1 + 3 * 5 = 20

Also it kinda makes more sense to do all the addition first with ai chances etc so then your additions have a bigger impact as seen by my example above, it just to me logically makes more sense to do all the adding first to get your base to a big amount then multiply them all.

I don't necessarily disagree, but i think it's kind of a preference more than a matter of what's logical, when it does each in order the way it appears to do, what exactly would be stopping you from just placing all the additions first in the code? wouldn't that produce the same effect as what you want it to do?

(genuinely asking since this is not my area of expertise in coding, the internal math and all that, so i don't have that much of a clue compared to you i'd imagine :p)
 
All "methods" of doing and processing the math/numbers has advantages and disadvantages - depending on what you are aming for one might be better or easier to use then the other.
But in the end, as long as you know how the numbers are handled it is fine. (My preference btw is to finally elevate the Clausewitz Scripting language to be able Variables and Arithmetic Functions fully.)
 
  • 2
Reactions:
(My preference btw is to finally elevate the Clausewitz Scripting language to be able Variables and Arithmetic Functions fully.)

Oh dear Blorg in heaven, save me from this madness :eek:

Jokes aside:p as long as the game only uses additive modifiers in the actual gameplay i'm content,
I mean, we aren't all Arumba ;) i'd imagine most "casual" players don't have the patience nor the mental fortitude to have to use mental math to calculate multiplicative modifiers when playing a video game... (including me :confused:)
 
  • 2
Reactions:
I don't necessarily disagree, but i think it's kind of a preference more than a matter of what's logical, when it does each in order the way it appears to do, what exactly would be stopping you from just placing all the additions first in the code? wouldn't that produce the same effect as what you want it to do?

(genuinely asking since this is not my area of expertise in coding, the internal math and all that, so i don't have that much of a clue compared to you i'd imagine :p)
That is my point, say they are carried out in the order they are written and you want it to be addition first. You order them addition first then multipliers afterwards. If you want to then put in another addition you have to find where the last addition is and put your new one after that, this can be a pain in the arse if you have a bunch of modifiers.
Also it makes a nice consistency between the different games when you mod them
 
That is my point, say they are carried out in the order they are written and you want it to be addition first. You order them addition first then multipliers afterwards. If you want to then put in another addition you have to find where the last addition is and put your new one after that, this can be a pain in the arse if you have a bunch of modifiers.
Also it makes a nice consistency between the different games when you mod them

Or you in cases where you want to modify Factors by a certain amount - depending on the number and trigger conditions you might end up having to write several extra factors covering every possible combination of outcomes instead of having only one check and an addition...
 
Yeah a scipting language that could actually do math would be nice, basic integers doubles and mathematical functions would do wonders for modabbility.
 
  • 2
Reactions:
Can we get a full fleshed out official name list pre launch? We saw the avian example on here, but it was quite brief. An example of gendered names with weights was posted on somethingawful's forums that showed things not on the avian list. I've seen example lists with armies having names like stations/ships as well. Thanks!
 
  • 2
Reactions:
Interesting.
 
Can we get a full fleshed out official name list pre launch? We saw the avian example on here, but it was quite brief. An example of gendered names with weights was posted on somethingawful's forums that showed things not on the avian list. I've seen example lists with armies having names like stations/ships as well. Thanks!

Would've being better to get not another example, but set of rules instead.

Ok, on the subject of namelist i have a number of questions:

1. is "full_names_male" and "full_names_female" a legit construction, or pre scripted full names cannot be gender specific?
2. is it possible to set multiple "sequential_name" or set of incremental names in one category, for example for spaceports, so in the end you will get results like "spaceport_name_one 1st; spaceport_name_two 1st; spaceport_name_two 2nd; spaceport_name_one 2nd"?
3. what kind of increments are possible? we saw already %O% and %R%, and only able to speculate on their true nature.
4. is it possible to set prefix and add to it name from random list? like we set "Observation Post " and then took one of the names from the list.
 
Last edited:
  • 1
Reactions:
What programs can I use to change stuff and make anomalies, and where to get said program?