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

Kult der Krähe

Sergeant
9 Badges
Feb 14, 2017
65
0
  • Ancient Space
  • Stellaris: Synthetic Dawn
  • Stellaris
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Leviathans Story Pack
  • Stellaris - Path to Destruction bundle
  • Shadowrun Returns
  • Shadowrun: Dragonfall
  • Shadowrun: Hong Kong
I am building a mod I think could be interesting. However, its actualization hinges upon being able to spawn a permanent entity in every single system in the galaxy (at game start), something I am unable to figure out how to do, not being a script genius.

For the example, we'll use a Megastructure... say a tier 1 Think Tank. I would like to place a single Think Tank in every system. How is the best way of going about this?
 
from a global event i think you can:
every_system -> random_planet (which is not a star) -> place the megastructure

For the needed syntax you can take a look at the game start events for special empires like driven assimilators, etc.
 
You could for sure do this by painstakingly modifying all systems in solar_system_initializers, but that would be a terrible pain in the ass. As for doing it dynamically, you should look at spawn_planet, and spawn_megastructure. I'm not in front of my gaming computer; if this were me, the first thing I would do is search every paradox file for spawn_megastructure and see what they do with it. I'd do this from PowerShell, from within the events/ or common/ directory, like this:

ls -recurse *.txt | sls -pattern spawn_megastructure
 
from a global event i think you can:
every_system -> random_planet (which is not a star) -> place the megastructure

For the needed syntax you can take a look at the game start events for special empires like driven assimilators, etc.

Hmmm, fiddled around with it some. The advice definitely helped, but still no luck. I pushed the script to do... something... as evident by it pushing the game (and my computer) to the limit of its ability to process, but nothing actually happened :(

I'll try again in a few days when I get the time.



You could for sure do this by painstakingly modifying all systems in solar_system_initializers, but that would be a terrible pain in the ass. As for doing it dynamically, you should look at spawn_planet, and spawn_megastructure. I'm not in front of my gaming computer; if this were me, the first thing I would do is search every paradox file for spawn_megastructure and see what they do with it. I'd do this from PowerShell, from within the events/ or common/ directory, like this:

ls -recurse *.txt | sls -pattern spawn_megastructure

Yeah, modifying the base files was something I'd rather avoid. It makes what I want to do that much more difficult to maintain with the onslaught of patches.

Tried spawn_megastructure, but no luck... yet. I'll figure it out eventually (or at least, that's what I tell myself...)

Never heard of PowerShell. I'll have to look it up.
 
PowerShell replaces the cmd.exe prompt. It comes with Windows. You should use it over cmd.exe command line features, because, for one thing, PowerShell search functions are unicode-aware and cmd.exe is not.
 
You do not need anything complicated to search the game files. Just "find in files" in Notepad ++ (and select the Stellaris common and events folders). As for what you do, you want to set up an event on_game_start (so you make an on_action entry on that on_action to trigger your event) and then copy one of the Vanilla events on_game_start, rename it (to what you set to trigger in the on_action) and edit it to make the event do what cray says.
 
Maybe your script is just not that optimized. Showing your code whould greatly increase our possibility of help.


Heh... yeah... unoptimized I'm positive it is. Script writing isn't my strong suit at ALL, and I appear to have a difficult time grasping the basics, let alone finessing the finer points, meaning most of my actual successful scripts are pretty simple and blunt force in nature. I'm pretty sure that the script is missing SEVERAL lines that need to be there, but I don't know what to put, or where.

namespace = phantom_crash




planet_event = {
id = phantom_crash.1
hide_window = no
fire_only_once = no
trackable = yes


immediate = {
every_system_planet = {
random_planet = {
limit = { is_star = yes }
NOT = { has_megastructure = think_tank_1 }

}
spawn_megastructure = think_tank_1
location = this
}
}
}
}

I made it trackable, windowed, and fire repeatedly so that I could observe if it was actually doing anything. It was doing... something... but like I said, all it did was slow the game to a crawl as it kept popping, especially when I went into observer mode.


Like I said before, my only real goal is to try and spawn something, a Think Tank for the test script, at every single star system in the galaxy. If I can successfully get that to work, I can use that as a base script to accomplish other things.
 
I think you want an event with a trigger that causes the event. Open up the vanilla stellaris events file "colony_events.txt" and look at colony.4. This will cause something to trigger when the conditions are met, and then happen on average every 240 months. If you want it to be immediate, just remove the mean_time_to_happen. If you want it to only happen once, set fires_only_once = yes.

Regarding your event as shown, planet_events can only occur in two conditions that I know of: 1) they are invoked from some other context in which the specific planet has already been scoped, or 2) they are triggered, but with the condition that selects the planet. Since no trigger is shown, we can rule out #2, and somehow I don't suspect that you intend #1 (if you already picked a planet in some other code, why are we picking again, here?).

I think you might benefit from looking at common/on_actions. Specifically look at on_game_start. This is a good place to invoke an event that happens just once. Such events should always be just plain "event," not planet_event. If you use that method, I think your code would look like this:

Code:
namespace = mynamespace

# initialize

event = {
    id = mynamespace.1
    hide_window = yes
    is_triggered_only = yes

    immediate = {
         every_planet = {
            limit = { is_star = yes NOT = { has_megastructure = think_tank_1  } }
            log = "mynamespace.1 --> spawning megastructure [This.GetName]"
            spawn_megastructure = think_tank_1
        }
    }
}

I'm pretty sure the above will work, but I haven't tested it. Look in game.log for a bunch of outputs. Look in error.log for clues as to what is wrong with the code, if it doesn't work.
 
Heh... yeah... unoptimized I'm positive it is. Script writing isn't my strong suit at ALL, and I appear to have a difficult time grasping the basics, let alone finessing the finer points, meaning most of my actual successful scripts are pretty simple and blunt force in nature. I'm pretty sure that the script is missing SEVERAL lines that need to be there, but I don't know what to put, or where.

namespace = phantom_crash




planet_event = {
id = phantom_crash.1
hide_window = no
fire_only_once = no
trackable = yes


immediate = {
every_system_planet = {
random_planet = {
limit = { is_star = yes }
NOT = { has_megastructure = think_tank_1 }

}
spawn_megastructure = think_tank_1
location = this
}
}
}
}

I made it trackable, windowed, and fire repeatedly so that I could observe if it was actually doing anything. It was doing... something... but like I said, all it did was slow the game to a crawl as it kept popping, especially when I went into observer mode.


Like I said before, my only real goal is to try and spawn something, a Think Tank for the test script, at every single star system in the galaxy. If I can successfully get that to work, I can use that as a base script to accomplish other things.

The combination of every_planet and random_planet is a performance killer and won't do what you think it'll do. However Courageous already posted the fix.
 
No luck.

Experimented in many things. Trying to create an on_action didn't seem to help, nor did making triggers. I probably messed something up though, throughout my numerous variations of on_action types and trigger applications, given my general lack of understanding of what I'm doing.

My ambitions are grossly exceeding my competency it would seem.

This is getting extremely frustrating, extremely quickly.

Break time I guess.
 
This is what you want:

Code:
namespace = megatest_events

# initialize

event = {
    id = megatest_events.0
    hide_window = yes
    is_triggered_only = yes

    immediate = {
        log = "mynamespace.0 --> PROCESSING"  
        every_planet = {
            limit = {
                 is_star = yes
                NOT = { solar_system = { has_megastructure = think_tank_ruined } }
            }
            log = "mynamespace.0 --> spawning megastructure [This.GetName]"
            solar_system = { spawn_megastructure = { type = think_tank_ruined location = prev } }
       }
    }
}

So. How'd I figure that out?

1. I looked in error.log, and it told me clearly that neither has_megastructure nor spawn_megastructure could be used in the scope I was in.

2. I searched vanilla for both has_megastructure and spawn_megastructure to see how the main game used them.

Also, cwtools and vscode will tell you this before you even test
 
Last edited:
This is what you want:

Code:
namespace = megatest_events

# initialize

event = {
    id = megatest_events.0
    hide_window = yes
    is_triggered_only = yes

    immediate = {
        log = "mynamespace.0 --> PROCESSING"
        every_planet = {
            limit = {
                 is_star = yes
                NOT = { solar_system = { has_megastructure = think_tank_ruined } }
            }
            log = "mynamespace.0 --> spawning megastructure [This.GetName]"
            solar_system = { spawn_megastructure = { type = think_tank_ruined location = prev } }
       }
    }
}

So. How'd I figure that out?

1. I looked in error.log, and it told me clearly that neither has_megastructure nor spawn_megastructure could be used in the scope I was in.

2. I searched vanilla for both has_megastructure and spawn_megastructure to see how the main game used them.

Also, cwtools and vscode will tell you this before you even test



Yeah, I just found that out about the megastructure conditions/events myself before I got back here to see this.

As I said, I know extremely little about scripting, and I didn't even know where to find the error log until today. After purging the error log of useless info pertaining to other things, I was able to isolate key errors in the script and whittle them down, until yes, I came to the same discovery as you (though being more experienced, you appear to have figured out how to move past this).

It's becoming rather obvious just how clumsy and ignorant I am, but this exchange has definitely been useful to me, for which I say thank you. It's kinda appalling really, just how much basic shit I didn't/still don't know, but at least I know how to get better at figuring it out now.




Given that you've pretty much made the script for me, when I make something out of it, should I post it on Steam, I'll give you credit if you want it. The very least I can do.
 
Last edited:
> I'll give you credit if you want it. The very least I can do.

No thank you. Even when I post mods myself, I always post them "public domain," which gives away absolutely everything about them: all rights, credits, etc. I'm just trying to help you learn what to do. If you haven't tried it yet, I suggest you walk through the exercise of getting and installing VSCode (Microsoft Visual Studio Code) and then getting the CWTools plugin (see the pinned discussion in this forum) to work. It will help you a bit.

Once you learn to mod one game, you're starting to learn a process of modding them all. It's slow and requires a great deal of patience even for experience people (including SW professionals), as you are going to be reverse engineering. And that's hard. So we experienced folks learn to look in various logs, carefully read the errors, form a hypothesis,and then try things again and again.