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

primem0ver

Major
16 Badges
Jul 15, 2015
563
70
  • Stellaris
  • Cities: Skylines
  • Cities: Skylines - After Dark
  • Cities: Skylines - Snowfall
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Leviathans Story Pack
  • Cities: Skylines - Natural Disasters
  • Stellaris - Path to Destruction bundle
  • Cities: Skylines - Mass Transit
  • Cities: Skylines - Green Cities
  • Cities: Skylines - Parklife Pre-Order
  • Cities: Skylines - Parklife
  • Cities: Skylines Industries
  • Stellaris: Synthetic Dawn
I am fairly new to the bulk of Stellaris modding. Most games use events to drive action in a game using a "cause-effect" relationship or chain. I need to understand how in-game events occur and how they're dealt with from the modding side. I can't seem to find any documentation on this. I don't mean events that occur from the players perspective. I don't mean events that the player experiences which you can add to the game. This is what I get every time I google "events" for steillars. There is some overlap here but I am specifically referring to key moments in time-line of the game engine that are typically used to trigger modded code/logic.

The "events" I need help "capturing" are theses:
  1. I need to be able to detect when a planet is finished terraforming... the moment it is done terraforming I need to trigger my own custom method to change the tiles on a planet. I have found conditions that refer to a planet "being" terraformed and "has ever been terraformed" but these won't do (as is) as I need the moment when terraforming is completed.
  2. I also need to be able to detect the moment when a "tile blocker" has been removed in order to implement some modded logic.
  3. I need to be able to detect when a space critter enters a system (such as amoebas and tiyanki) to trigger some logic. I may be able to figure this one out on my own because I have a mod that has events relating to this type... however any overall pointers will still be appreciated.
Can these kinds of things be done using Stellaris modding logic?
 

Guilliman88

Planet Modifier Guy
46 Badges
Mar 21, 2015
544
429
  • Magicka
  • Stellaris
  • Age of Wonders: Planetfall Deluxe edition
  • Cities: Skylines - Parklife
  • Stellaris: Distant Stars
  • Surviving Mars: First Colony Edition
  • Cities: Skylines Industries
  • BATTLETECH: Flashpoint
  • Stellaris: Megacorp
  • Prison Architect
  • Surviving Mars: First Colony Edition
  • Cities: Skylines - Campus
  • BATTLETECH: Season pass
  • Age of Wonders: Planetfall
  • BATTLETECH - Digital Deluxe Edition
  • Age of Wonders: Planetfall Premium edition
  • Age of Wonders: Planetfall Season pass
  • Stellaris: Lithoids
  • BATTLETECH: Heavy Metal
  • Stellaris: Federations
  • Crusader Kings III
  • Stellaris: Necroids
  • Stellaris: Nemesis
  • Surviving Mars: Digital Deluxe Edition
  • Cities: Skylines
  • Crusader Kings II: Way of Life
  • Pillars of Eternity
  • Cities: Skylines - After Dark
  • Cities: Skylines - Snowfall
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Leviathans Story Pack
  • Stellaris - Path to Destruction bundle
  • Cities: Skylines - Mass Transit
  • BATTLETECH
  • Surviving Mars
  • Age of Wonders III
  • Cities: Skylines - Green Cities
  • Stellaris: Humanoids Species Pack
  • Stellaris: Apocalypse
  • Stellaris: Ancient Relics
  • Stellaris: Synthetic Dawn
  • Age of Wonders: Planetfall - Revelations
  • Crusader Kings II
  • Crusader Kings II: Sword of Islam
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Legacy of Rome
1) not possible atm, I have asked to implement an on_action for terraforming. It's in the game but hardcoded and not accessible to modding right now..
The best I've found it create an event that checks every month to see if a planet has been terraformed. you let it run on the on_action -> on_monthly_pulse



Code:
namespace = terraformevent

### Terraform Finish
event = {
    id = terraformevent.100
    hide_window = yes
   
    is_triggered_only = yes
   
    immediate = {
        every_planet = {
           
            if = {
                limit = {
                    AND = {
                        NOT = {
                            has_planet_flag = this_event_already_fired
                        }
                        is_terraformed = yes
                    }
                }
               
                <your code here>
               
                set_planet_flag = this_event_already_fired
            }
        }
    }
}

2) using the on_action -> on_blocker_cleared you can trigger an event when a tileblocker is cleared.
Check the stellaris\common\on_action events for the events names and find the events in stellaris\events for examples. I don't have any examples on hand but that's where you can find some.

3) using the on_action -> on_entering_system you can trigger an event to check for the creature and do the code you want.
Same as above, I have no examples on hand but you can find them there.
 

primem0ver

Major
16 Badges
Jul 15, 2015
563
70
  • Stellaris
  • Cities: Skylines
  • Cities: Skylines - After Dark
  • Cities: Skylines - Snowfall
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Leviathans Story Pack
  • Cities: Skylines - Natural Disasters
  • Stellaris - Path to Destruction bundle
  • Cities: Skylines - Mass Transit
  • Cities: Skylines - Green Cities
  • Cities: Skylines - Parklife Pre-Order
  • Cities: Skylines - Parklife
  • Cities: Skylines Industries
  • Stellaris: Synthetic Dawn
Thank you very much for the tips. Two general questions:
  1. Where do I code the on_action triggers?
  2. I am assuming I can change the tiles on a planet but I just want to make sure.
One additional question about this particular advice::
The best I've found it create an event that checks every month to see if a planet has been terraformed. you let it run on the on_action -> on_monthly_pulse

Code:
namespace = terraformevent

### Terraform Finish
event = {
    id = terraformevent.100
    hide_window = yes
  
    is_triggered_only = yes
  
    immediate = {
        every_planet = {
          
            if = {
                limit = {
                    AND = {
                        NOT = {
                            has_planet_flag = this_event_already_fired
                        }
                        is_terraformed = yes
                    }
                }
              
                <your code here>
              
                set_planet_flag = this_event_already_fired
            }
        }
    }
}

Is there a way to catch the the beginning of terraforming? When the user starts terraforming the planet? Assuming a planet can be terraformed more than once (for example, from barren to desert, and then to continental) I would need to clear the "this_event_has_already_fired" event when that happens so that I can check it again. Or would I need to do another check and see if a planet is underging terraforming and clear it if it is?
 

Guilliman88

Planet Modifier Guy
46 Badges
Mar 21, 2015
544
429
  • Magicka
  • Stellaris
  • Age of Wonders: Planetfall Deluxe edition
  • Cities: Skylines - Parklife
  • Stellaris: Distant Stars
  • Surviving Mars: First Colony Edition
  • Cities: Skylines Industries
  • BATTLETECH: Flashpoint
  • Stellaris: Megacorp
  • Prison Architect
  • Surviving Mars: First Colony Edition
  • Cities: Skylines - Campus
  • BATTLETECH: Season pass
  • Age of Wonders: Planetfall
  • BATTLETECH - Digital Deluxe Edition
  • Age of Wonders: Planetfall Premium edition
  • Age of Wonders: Planetfall Season pass
  • Stellaris: Lithoids
  • BATTLETECH: Heavy Metal
  • Stellaris: Federations
  • Crusader Kings III
  • Stellaris: Necroids
  • Stellaris: Nemesis
  • Surviving Mars: Digital Deluxe Edition
  • Cities: Skylines
  • Crusader Kings II: Way of Life
  • Pillars of Eternity
  • Cities: Skylines - After Dark
  • Cities: Skylines - Snowfall
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Leviathans Story Pack
  • Stellaris - Path to Destruction bundle
  • Cities: Skylines - Mass Transit
  • BATTLETECH
  • Surviving Mars
  • Age of Wonders III
  • Cities: Skylines - Green Cities
  • Stellaris: Humanoids Species Pack
  • Stellaris: Apocalypse
  • Stellaris: Ancient Relics
  • Stellaris: Synthetic Dawn
  • Age of Wonders: Planetfall - Revelations
  • Crusader Kings II
  • Crusader Kings II: Sword of Islam
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Legacy of Rome
For the terraforming there is is_terraforming = yes
Works the same as the other is_terraformed checks if it is terraforming right now, but there is also no way to make it happen when terraforming starts. It's really annoying.


1) You make an event that does everything you need it to do in stellaris\events\your_event_file.txt
You 'call' that event in stellaris\common\on_actions\on_actions_file.txt on the on_action that you wish it to happen

2) I have no idea honestly :/
 

primem0ver

Major
16 Badges
Jul 15, 2015
563
70
  • Stellaris
  • Cities: Skylines
  • Cities: Skylines - After Dark
  • Cities: Skylines - Snowfall
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Leviathans Story Pack
  • Cities: Skylines - Natural Disasters
  • Stellaris - Path to Destruction bundle
  • Cities: Skylines - Mass Transit
  • Cities: Skylines - Green Cities
  • Cities: Skylines - Parklife Pre-Order
  • Cities: Skylines - Parklife
  • Cities: Skylines Industries
  • Stellaris: Synthetic Dawn
One more event I need to capture (that I forgot about above).

I need to be able to capture the colonize event. Basically when a colony ship lands on a planet and that planet is set up. I need to be able to modify what happens at that point. Are all these events (on_whatever) listed somewhere?
 

Guilliman88

Planet Modifier Guy
46 Badges
Mar 21, 2015
544
429
  • Magicka
  • Stellaris
  • Age of Wonders: Planetfall Deluxe edition
  • Cities: Skylines - Parklife
  • Stellaris: Distant Stars
  • Surviving Mars: First Colony Edition
  • Cities: Skylines Industries
  • BATTLETECH: Flashpoint
  • Stellaris: Megacorp
  • Prison Architect
  • Surviving Mars: First Colony Edition
  • Cities: Skylines - Campus
  • BATTLETECH: Season pass
  • Age of Wonders: Planetfall
  • BATTLETECH - Digital Deluxe Edition
  • Age of Wonders: Planetfall Premium edition
  • Age of Wonders: Planetfall Season pass
  • Stellaris: Lithoids
  • BATTLETECH: Heavy Metal
  • Stellaris: Federations
  • Crusader Kings III
  • Stellaris: Necroids
  • Stellaris: Nemesis
  • Surviving Mars: Digital Deluxe Edition
  • Cities: Skylines
  • Crusader Kings II: Way of Life
  • Pillars of Eternity
  • Cities: Skylines - After Dark
  • Cities: Skylines - Snowfall
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Leviathans Story Pack
  • Stellaris - Path to Destruction bundle
  • Cities: Skylines - Mass Transit
  • BATTLETECH
  • Surviving Mars
  • Age of Wonders III
  • Cities: Skylines - Green Cities
  • Stellaris: Humanoids Species Pack
  • Stellaris: Apocalypse
  • Stellaris: Ancient Relics
  • Stellaris: Synthetic Dawn
  • Age of Wonders: Planetfall - Revelations
  • Crusader Kings II
  • Crusader Kings II: Sword of Islam
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Legacy of Rome
every type of on_action is in the stellaris\common\on_action\00_on_action.txt file
 

primem0ver

Major
16 Badges
Jul 15, 2015
563
70
  • Stellaris
  • Cities: Skylines
  • Cities: Skylines - After Dark
  • Cities: Skylines - Snowfall
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Leviathans Story Pack
  • Cities: Skylines - Natural Disasters
  • Stellaris - Path to Destruction bundle
  • Cities: Skylines - Mass Transit
  • Cities: Skylines - Green Cities
  • Cities: Skylines - Parklife Pre-Order
  • Cities: Skylines - Parklife
  • Cities: Skylines Industries
  • Stellaris: Synthetic Dawn
Thanks! That was really helpful. One question. I am assuming the "events" are triggered events (chained effects). Or are they events that trigger the "on_whatever" event? I.E. are "events" a list of causes or effects?
 

ZomgK3tchup

Into the Future
128 Badges
Dec 25, 2009
4.993
4.708
  • Europa Universalis IV: Res Publica
  • Hearts of Iron III
  • Hearts of Iron III: Their Finest Hour
  • Heir to the Throne
  • Rome: Vae Victis
  • Knights of Pen and Paper +1 Edition
  • Lead and Gold
  • Leviathan: Warships
  • The Kings Crusade
  • Majesty 2 Collection
  • March of the Eagles
  • Victoria 2: Heart of Darkness
  • Pirates of Black Cove
  • Gettysburg
  • Victoria: Revolutions
  • Rome Gold
  • Semper Fi
  • Sengoku
  • Sword of the Stars
  • Sword of the Stars II
  • Supreme Ruler 2020
  • Supreme Ruler: Cold War
  • Teleglitch: Die More Edition
  • The Showdown Effect
  • Victoria 2
  • Victoria 2: A House Divided
  • Deus Vult
  • Cities in Motion
  • Crusader Kings II
  • Crusader Kings II: Charlemagne
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: The Republic
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: Sunset Invasion
  • Crusader Kings II: Sword of Islam
  • Commander: Conquest of the Americas
  • Darkest Hour
  • Arsenal of Democracy
  • Europa Universalis III
  • Europa Universalis III: Chronicles
  • Europa Universalis III Complete
  • Divine Wind
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Call to arms event
  • For The Glory
  • For the Motherland
Would this be helpful to you?

Code:
terraform_link = {
    from = "pc_barren"
    to = "pc_arid"
 
    energy = 10000
    duration = 7300
 
    condition = {
        has_technology = "tech_climate_restoration"
        from = { has_modifier = terraforming_candidate }
    }
 
    effect = {
        from = { remove_modifier = terraforming_candidate }
    }
}
This is from one of the vanilla terraforming files. When you terraform a barren planet with the "Terraforming Candidate" modifier to another type, in this case, Arid, the "Terraforming Candidate" modifier is removed.

You should be about to use the "Effect" section to add blockers, modifiers, etc. I haven't actually tried it, so I don't know 100%.
 

primem0ver

Major
16 Badges
Jul 15, 2015
563
70
  • Stellaris
  • Cities: Skylines
  • Cities: Skylines - After Dark
  • Cities: Skylines - Snowfall
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Leviathans Story Pack
  • Cities: Skylines - Natural Disasters
  • Stellaris - Path to Destruction bundle
  • Cities: Skylines - Mass Transit
  • Cities: Skylines - Green Cities
  • Cities: Skylines - Parklife Pre-Order
  • Cities: Skylines - Parklife
  • Cities: Skylines Industries
  • Stellaris: Synthetic Dawn
Would this be helpful to you?

Code:
terraform_link = {
    from = "pc_barren"
    to = "pc_arid"
 
    energy = 10000
    duration = 7300
 
    condition = {
        has_technology = "tech_climate_restoration"
        from = { has_modifier = terraforming_candidate }
    }
 
    effect = {
        from = { remove_modifier = terraforming_candidate }
    }
}
This is from one of the vanilla terraforming files. When you terraform a barren planet with the "Terraforming Candidate" modifier to another type, in this case, Arid, the "Terraforming Candidate" modifier is removed.

You should be about to use the "Effect" section to add blockers, modifiers, etc. I haven't actually tried it, so I don't know 100%.
Wow... cool. So if I understand correctly, the effect listed here is triggered as soon as someone initiates terraforming on a "pc_barren" planet to convert to an arid planet? Thanks! This this is true then this was also very helpful.
 

primem0ver

Major
16 Badges
Jul 15, 2015
563
70
  • Stellaris
  • Cities: Skylines
  • Cities: Skylines - After Dark
  • Cities: Skylines - Snowfall
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Leviathans Story Pack
  • Cities: Skylines - Natural Disasters
  • Stellaris - Path to Destruction bundle
  • Cities: Skylines - Mass Transit
  • Cities: Skylines - Green Cities
  • Cities: Skylines - Parklife Pre-Order
  • Cities: Skylines - Parklife
  • Cities: Skylines Industries
  • Stellaris: Synthetic Dawn
What is the difference between immediate = { and effect = { ?
 

ZomgK3tchup

Into the Future
128 Badges
Dec 25, 2009
4.993
4.708
  • Europa Universalis IV: Res Publica
  • Hearts of Iron III
  • Hearts of Iron III: Their Finest Hour
  • Heir to the Throne
  • Rome: Vae Victis
  • Knights of Pen and Paper +1 Edition
  • Lead and Gold
  • Leviathan: Warships
  • The Kings Crusade
  • Majesty 2 Collection
  • March of the Eagles
  • Victoria 2: Heart of Darkness
  • Pirates of Black Cove
  • Gettysburg
  • Victoria: Revolutions
  • Rome Gold
  • Semper Fi
  • Sengoku
  • Sword of the Stars
  • Sword of the Stars II
  • Supreme Ruler 2020
  • Supreme Ruler: Cold War
  • Teleglitch: Die More Edition
  • The Showdown Effect
  • Victoria 2
  • Victoria 2: A House Divided
  • Deus Vult
  • Cities in Motion
  • Crusader Kings II
  • Crusader Kings II: Charlemagne
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: The Republic
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: Sunset Invasion
  • Crusader Kings II: Sword of Islam
  • Commander: Conquest of the Americas
  • Darkest Hour
  • Arsenal of Democracy
  • Europa Universalis III
  • Europa Universalis III: Chronicles
  • Europa Universalis III Complete
  • Divine Wind
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Call to arms event
  • For The Glory
  • For the Motherland

primem0ver

Major
16 Badges
Jul 15, 2015
563
70
  • Stellaris
  • Cities: Skylines
  • Cities: Skylines - After Dark
  • Cities: Skylines - Snowfall
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Leviathans Story Pack
  • Cities: Skylines - Natural Disasters
  • Stellaris - Path to Destruction bundle
  • Cities: Skylines - Mass Transit
  • Cities: Skylines - Green Cities
  • Cities: Skylines - Parklife Pre-Order
  • Cities: Skylines - Parklife
  • Cities: Skylines Industries
  • Stellaris: Synthetic Dawn
So effect is for commands (such as change_pc) and immediate is for events? I would expect both to be immediate, especially if effect triggers commands (which are executed). Or does it mean that effects are put in a queue and executed when the engine gets to them?