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

Pyrrus

Sergeant
63 Badges
Dec 3, 2013
90
48
  • Crusader Kings II: Charlemagne
  • Europa Universalis IV: Third Rome
  • Tyranny - Tales from the Tiers
  • Stellaris - Path to Destruction bundle
  • Stellaris: Leviathans Story Pack
  • Crusader Kings II: Jade Dragon
  • Europa Universalis IV: Mare Nostrum
  • Europa Universalis IV: Pre-order
  • Victoria 2: Heart of Darkness
  • Victoria 2: A House Divided
  • Semper Fi
  • Europa Universalis IV: Res Publica
  • March of the Eagles
  • Hearts of Iron III Collection
  • Hearts of Iron III: Their Finest Hour
  • For the Motherland
  • Crusader Kings II: The Republic
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: Sunset Invasion
  • Crusader Kings II: Sword of Islam
  • Crusader Kings II
  • Hearts of Iron III
  • 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
  • Victoria 3 Sign Up
  • Tyranny - Bastards Wound
  • Age of Wonders III
  • Europa Universalis IV: Cradle of Civilization
  • Stellaris: Synthetic Dawn
  • Hearts of Iron IV: Expansion Pass
  • Stellaris: Apocalypse
  • Europa Universalis IV: Rule Britannia
  • Stellaris: Distant Stars
  • Europa Universalis IV: Dharma
  • Europa Universalis IV: Golden Century
  • Imperator: Rome Deluxe Edition
  • Imperator: Rome
  • Imperator: Rome - Magna Graecia
  • Crusader Kings III
  • Europa Universalis 4: Emperor
  • Crusader Kings II: Conclave
  • Europa Universalis IV
  • Victoria 2
  • Europa Universalis IV: El Dorado
  • Crusader Kings II: Way of Life
Hi everyone,

I have a problem with my mod (WIP)...
I'd like to generate characters and marry them automatically to people over 24 years old and not already married, but the new char doesn't seem to be generated. :confused:

For info, the "add_trait = ###" before "create_character" is working so it seems everything is good up to this point.

Code:
namespace = valentines_day

valentines_day.1 = {
    type = country_event
    hidden = yes

    trigger = {
         has_land = yes
    }

    immediate = {
        every_character = {
            limit = {
                is_alive = yes
                 is_married = no
                 age > 24
            }
            save_scope_as = char_not_married # Save the Scope for later

            if = {
                limit = {
                    is_female = yes
                }
                add_trait = lustful # Just to see if the event fires and comes so far

                create_character = { # EFFECT - Create a character
                    female = no
                    age = 25
                    culture = root.capital_scope.culture
                    religion = root.capital_scope.religion
                    no_traits = yes
                    no_stats = yes
                    add_trait = lustful
                    add_martial = 5
                    add_finesse = 5
                    add_charisma = 5
                    add_zeal = 5
                    save_scope_as = new_male_char # Save the Scope for later
                }

                # The marriage
                scope:char_not_married = {
                    marry_character = scope:new_male_char
                }
            }
            else = {
                add_trait = chaste # Just to see if the event fires and comes so far
                create_character = { # EFFECT - Create a character
                    female = yes
                    age = 25
                    culture = root.capital_scope.culture
                    religion = root.capital_scope.religion
                    no_traits = yes
                    no_stats = yes
                    add_trait = lustful
                    add_martial = 5
                    add_finesse = 5
                    add_charisma = 5
                    add_zeal = 5
                    save_scope_as = new_female_char # Save the Scope for later
                }

                # The marriage
                scope:char_not_married = {
                    marry_character = scope:new_female_char
                }
            }
        }
    }
}
 
Maybe it's an issue of the game not able to create a character in a character scope.
Try changing the scope to the country of the "every_character" scope, or root (since it's a country event already) or employer.

Code:
. . .
               if = {
                limit = {
                    is_female = yes
                }
                add_trait = lustful # Just to see if the event fires and comes so far

                country = { # try country, or root (since it's a country event already) or employer
                    create_character = { # EFFECT - Create a character
                        female = no
                        age = 25
                        culture = root.capital_scope.culture
                        religion = root.capital_scope.religion
                        no_traits = yes
                        no_stats = yes
                        add_trait = lustful
                        add_martial = 5
                        add_finesse = 5
                        add_charisma = 5
                        add_zeal = 5
                        save_scope_as = new_male_char # Save the Scope for later
                    }

                    # The marriage
                    scope:char_not_married = {
                        marry_character = scope:new_male_char
                    }
                }
            }
. . .
 
Maybe it's an issue of the game not able to create a character in a character scope.
Try changing the scope to the country of the "every_character" scope, or root (since it's a country event already) or employer.

Code:
. . .
               if = {
                limit = {
                    is_female = yes
                }
                add_trait = lustful # Just to see if the event fires and comes so far

                country = { # try country, or root (since it's a country event already) or employer
                    create_character = { # EFFECT - Create a character
                        female = no
                        age = 25
                        culture = root.capital_scope.culture
                        religion = root.capital_scope.religion
                        no_traits = yes
                        no_stats = yes
                        add_trait = lustful
                        add_martial = 5
                        add_finesse = 5
                        add_charisma = 5
                        add_zeal = 5
                        save_scope_as = new_male_char # Save the Scope for later
                    }

                    # The marriage
                    scope:char_not_married = {
                        marry_character = scope:new_male_char
                    }
                }
            }
. . .

Damn that worked perfectly ! You're the man, thanks ! :D
 
I don't understand why this code doesn't work ...
It seems the second break is not triggering for some reason. :confused:
Does anyone got an idea ?

Code:
valentines_day.1 = {
    type = country_event
    hidden = yes

    trigger = {
         has_land = yes
    }

    immediate = {
        # Iterate through all families in a country (FN1)
        every_family = {
            limit = {
                num_of_members > 0
                #num_of_members < 15 # To not have an exponential growth of members
            }

            # Iterate through all members of a family (FMN1)
            every_family_member = {
                limit = {
                    is_alive = yes
                    is_married = no
                    NOT = { has_variable = marriage_proposal_ongoing }
                    age > 24
                    age < 46
                    prisoner = no
                }
                # Save the Scope for later
                save_scope_as = char_not_married_1

                # Search for a companion in the great families pool
                country = {
                    # Iterate through all families in a country (FN2)
                    every_family = {
                        limit = {
                            num_of_members > 0
                        }

                        # Iterate through all members of a family (FMN2)
                        every_family_member = {
                            limit = {
                                is_alive = yes
                                is_married = no
                                NOT = { is_same_gender = scope:char_not_married_1 }
                                NOT = { has_variable = marriage_proposal_ongoing }
                                age > 24
                                age < 46
                                prisoner = no
                                NOT = { is_close_relative = scope:char_not_married_1 }
                            }
                            # Save the Scope for later
                            save_scope_as = char_not_married_2
                            
                            # The marriage
                            scope:char_not_married_1 = {
                                marry_character = scope:char_not_married_2
                            }

                            # Exit loop of every_family_member (FMN2) once char_not_married_1 has found a companion
                            break
                        }

                        if = {
                            limit = {
                                 scope:char_not_married_1 = {
                                    is_married = yes
                                 }
                            }
                            # Exit loop of every_family (FN2) once char_not_married_1 has found a companion
                            break
                        }
                    }
                }
...
 
For the ones that are interested, the breaks were not working as intended ( or not the same as in C ... ).
So I switched to a ( slightly ) more performance heavy algorithm.

Here's the new code for the curious :

Code:
every_family = {
            limit = {
                num_of_members > 0
                #num_of_members < 15 # To not have an exponential growth of members
            }

            # Iterate through all members of a family (FMN1)
            every_family_member = {
                limit = {
                    is_alive = yes
                    is_married = no
                    NOT = { has_variable = marriage_proposal_ongoing }
                    age > 24
                    age < 46
                    prisoner = no
                }
                # Save the Scope for later
                save_scope_as = char_not_married_1

                # Search for a companion in the great families pool
                country = {
                    # Iterate through all families in a country (FN2)
                    every_family = {
                        limit = {
                            scope:char_not_married_1 = { is_married = no }
                            num_of_members > 0
                        }

                        # Iterate through all members of a family (FMN2)
                        every_family_member = {
                            limit = {
                                scope:char_not_married_1 = { is_married = no }
                                is_alive = yes
                                is_married = no
                                NOT = { is_same_gender = scope:char_not_married_1 }
                                NOT = { has_variable = marriage_proposal_ongoing }
                                age > 24
                                age < 46
                                prisoner = no
                                NOT = { is_close_relative = scope:char_not_married_1 }
                            }
                            # Save the Scope for later
                            save_scope_as = char_not_married_2

                            # The marriage
                            scope:char_not_married_1 = {
                                marry_character = scope:char_not_married_2
                            }
                        }
                    }
                }
...