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

Autonomous Duck

Recruit
63 Badges
May 15, 2016
2
0
  • Europa Universalis IV: Wealth of Nations
  • Stellaris: Galaxy Edition
  • Europa Universalis IV: Mare Nostrum
  • Crusader Kings II: Reapers Due
  • Stellaris: Synthetic Dawn
  • Europa Universalis IV: Third Rome
  • Crusader Kings II
  • Europa Universalis IV: Res Publica
  • Europa Universalis IV: Call to arms event
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Art of War
  • Europa Universalis IV
  • Crusader Kings II: Sword of Islam
  • Crusader Kings II: Sunset Invasion
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: The Republic
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: Charlemagne
  • Europa Universalis IV: Mandate of Heaven
  • Crusader Kings II: Holy Fury
  • Surviving Mars
  • Europa Universalis IV: Cradle of Civilization
  • Victoria 3 Sign Up
  • Hearts of Iron IV: Expansion Pass
  • Stellaris: Humanoids Species Pack
  • Stellaris: Apocalypse
  • Europa Universalis IV: Rule Britannia
  • Surviving Mars: Digital Deluxe Edition
  • Stellaris: Distant Stars
  • Europa Universalis IV: Dharma
  • Shadowrun Returns
  • Surviving Mars: First Colony Edition
  • Stellaris
  • Victoria 2
  • Victoria 2: Heart of Darkness
  • Europa Universalis IV: El Dorado
  • Crusader Kings II: Way of Life
  • Europa Universalis IV: Common Sense
  • Crusader Kings II: Horse Lords
  • Europa Universalis IV: Cossacks
  • Crusader Kings II: Conclave
  • Stellaris - Path to Destruction bundle
  • Stellaris: Galaxy Edition
  • Hearts of Iron IV: Cadet
  • Europa Universalis IV: Rights of Man
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Leviathans Story Pack
  • Hearts of Iron IV: Together for Victory
Hi guys,

It's the first time I'm trying to make a mod. Spent yesterday with some trial and error, which was fun but what I want isn't happening yet so I hope you have some tips.

What I want to do is a little series of events where when an admiral reaches level 5 in a military republic, he or she can become a sort of Julius Ceasar. So you get a little window when the admiral reaches level 5 saying this very experienced and popular admiral could be trouble. I'm already running into trouble with this bit and haven't started the next part. Next I want that when the admiral enters the capital system there is a chance he/she will try to take over (cross the Rubicon/land on the capital planet) maybe you can stop this with some influence or else your government form will change into a military dictatorship with the erstwhile admiral as leader of the empire.

Just for some character to add to your empire, with a few more of these events for other government types/empire traits I hope to add a bit more flavor to your empire. Also it's fun to try to mod something :).

That's the plan at least.

On to the code:

I've got an on-action:
Code:
on_leader_level_up = {
    events = {
        mod_extra_events.2 #gatekeeper for various events
    }
}

Actual events:
Code:
namespace = mod_extra_events

country_event = {
    id = mod_extra_events.1
    title = "mod_extra_events.1.name"
    desc = "mod_extra_events.1.desc"
    picture = GFX_evt_federation_fleet
    location = ROOT
   
    is_triggered_only = yes
   
    trigger = {
        is_country_type = default
        has_government = military_republic
        hidden:fromfrom = { #hidden:fromfrom?
            leader = {       
                has_leader_flag = ambitious_admiral   
            }       
        }
    }
   
    immediate = {
        fromfrom = {
            leader = { save_event_target_as = officer }
            solar_system = { save_event_target_as = system }
        }
    }
   
    option = {
        name = "mod_extra_events.1.name.a"
#start event chain   
    }
}

country_event = {
    id = mod_extra_events.2
    hide_window = yes
    is_triggered_only = yes

    immediate = {
        from = { #error!  [[12:13:39][effect_impl.cpp:143]: Script Error: Invalid context switch[from], file: events/extra_events_1.txt line: 41, Scope:
                #type=country
                #id=0
                #random={ 791423972 791423972 }]
                # fromfrom also errror
            if = {
                limit = {
                    leader_class = admiral
                    has_level > 3   
                }
                set_leader_flag = ambitious_admiral
                owner = { country_event = { id = mod_extra_events.1} }
            }
        }
    }
}


Of course also a bit of not-finished flavor text but that's not important yet I guess (it's in the zipped attached mod).

Most of this code is just copy & paste and modified a bit, so there could be glaring mistakes. I'm not sure I fully understand scope. Are there any guides for that, I couldn't find any.

In any case when I use the console with: "mod_extra_events.2" I get the following error in the error.log [
[12:13:39][effect_impl.cpp:143]: Script Error: Invalid context switch[from], file: events/extra_events_1.txt line: 41, Scope:
type=country
id=0
random={ 791423972 791423972 }
]

Now I guess because the event then is a country scope, not a leader scope? But if I use "skills 1" to level up an admiral to 5 nothing happens either. (that why now it's got "has_level > 3" before I had "has_level = 5" but well there was no difference and it's an easy change).

Does anyone know how to make this happen? Do you need more information from me? Thanks for taking a look!
 

Attachments

  • cstellarismodtest.rar
    1,9 KB · Views: 0
Well, the error is because, as you expect, you're trying to use a leader as from without getting one assigned. From trying Skills 1 in vanilla it seems that might not be triggering on_leader_level_up. I suggest simply trying it by leveling your admirals up the hard way. To reduce unnecessary event firing you may also want to change the trigger of event 1 and add a limit to the owner={ country_event} part.

Also, note that in the current build, declaring an on_action in another file will overwrite any previous identitcal on_action. So if you want leaders to still be able to gain traits from leveling up, you need to rewrite the on_action to

Code:
on_leader_level_up = {
events = {
leader.20 #gatekeeper for various events
mod_extra_events.2 #gatekeeper for various events
}
}

This should be fixed by 1.1 from what Divine has said.
 
Thanks!

First gonna level some admirals and see what happens. Tried a bit but was too eager so my generals died haha. Good tip about the the event firing, gonna take a look at that if it works with a admiral that levels up. Great tip about the on_action, would've never figured that out.

Update: It didn't work. Not sure why, will try some more things if I can find the time.
 
Last edited: