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

Grave461

Captain
84 Badges
Nov 7, 2014
421
400
  • Victoria 3 Sign Up
  • Crusader Kings III
  • Stellaris: Nemesis
  • Crusader Kings II
  • Hearts of Iron IV: Colonel
  • Stellaris: Galaxy Edition
  • Europa Universalis IV
  • Imperator: Rome
  • Victoria 2
  • Victoria: Revolutions
  • Tyranny: Gold Edition
  • Cities: Skylines
  • Europa Universalis IV: Res Publica
  • Hearts of Iron IV: La Resistance
  • Europa Universalis IV: Wealth of Nations
  • Stellaris: Megacorp
  • Europa Universalis IV: Conquest of Paradise
  • Crusader Kings II: Sword of Islam
  • Victoria 2: A House Divided
  • Hearts of Iron IV: Together for Victory
  • Stellaris: Digital Anniversary Edition
  • Crusader Kings II: Way of Life
  • Stellaris: Leviathans Story Pack
  • Crusader Kings II: Monks and Mystics
  • Europa Universalis IV: Rights of Man
  • Cities: Skylines - Mass Transit
  • Europa Universalis IV: Mandate of Heaven
  • Victoria 2: Heart of Darkness
  • Hearts of Iron IV: Death or Dishonor
  • Crusader Kings II: Horse Lords
  • Cities: Skylines - Green Cities
  • Europa Universalis IV: Common Sense
  • Hearts of Iron IV: Expansion Pass
  • Crusader Kings II: Jade Dragon
  • Stellaris: Humanoids Species Pack
  • Stellaris: Apocalypse
  • Europa Universalis IV: Rule Britannia
  • Cities: Skylines - Parklife
  • Stellaris: Distant Stars
  • Europa Universalis IV: Dharma
  • Crusader Kings II: Holy Fury
  • Europa Universalis IV: Golden Century
  • Cities: Skylines - Campus
  • Stellaris: Ancient Relics
  • Stellaris: Lithoids
  • Stellaris: Federations
  • Imperator: Rome - Magna Graecia
  • Battle for Bosporus
  • Europa Universalis 4: Emperor
  • Stellaris: Necroids
What I'm trying to do is apply a leader_flag for newly spawned human rulers in empires controlled by the player. So far, I can get it to work if I do not try and scope specifically to either the player or the AI. If I try and add a scope pointing to either the player or AI, it will not apply the leader_flag to the ruler.



Here is a sample of my common/on_actions/on_action_test.txt file:
Code:
on_leader_spawned = {
    events = {
        ruler_test.1
    }
}

Below is the sample code in events/test_event.txt. This code DOES WORK in applying the appropriate leader_flag to the ruler, but this method would result in applying the leader_flag to rulers of both AI and human players.

How can I code it to apply only to human player controlled empires?

Code:
namespace = ruler_test

country_event = {             # a new human leader is generated for an empire, to be available for recruitment
    id = ruler_test.1
    is_triggered_only = yes
    hide_window = yes

    trigger = {
        FROM = {
            is_ruler = yes
            species = { species_portrait = human }
        }
    }

    immediate = {
        if = {
            limit = {
                THIS = { has_country_flag = human_1 }        # United Nations of Earth
            }
            FROM = { set_leader_flag = UNE_ruler }
            break = yes
        }
        if = {
            limit = {
                THIS = { has_country_flag = human_2    }        # Commonwealth of Man
            }
            FROM = { set_leader_flag = COM_ruler }
            break = yes
        }
        else = {                                                                      # Custom Empire
            FROM = { set_leader_flag = custom_empire_ruler }
            break = yes
        }
    }
}
 
Code:
namespace = ruler_test

# > on_leader_spawned
# a new leader is created
# scope: country, from: leader
country_event = {             # a new human leader is generated for an empire, to be available for recruitment
    id = ruler_test.1
    is_triggered_only = yes
    hide_window = yes

    trigger = {
        is_ai = no
        from = {
            is_ruler = yes
            exists = species
            species = { is_human_species = yes }
        }
    }

    immediate = {
        if = {
            limit = {
                has_country_flag = human_1        # United Nations of Earth
            }
            from = { set_leader_flag = modname_UNE_ruler }
        }
        else_if = {
            limit = {
                has_country_flag = human_2        # Commonwealth of Man
            }
            from = { set_leader_flag = modname_COM_ruler }
        }
        else = {
            from = { set_leader_flag = modname_custom_empire_ruler }        # Custom Empire
        }
    }

}

# modname: Name of your mod. Be careful with too generic labels, try to use abbreviations or the name of your mod to distinguish them from other mods.