• 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.
Showing developer posts only. Show all posts in this thread.
Regarding ai_chance, would I be correct in the commented out code if I were to do this?:

Code:
option = {
       name = amareturn.13a
       ai_chance = {
           factor = 95
           modifier = {
               factor = 73               # If mother's stubborn, there's 73% chance she agrees, and 27% refuses.
               trait = stubborn
           }
           modifier = {
               factor = 8               # If mother's cynical or kind, there's 92% she agrees, and 8% chance refuses.
               OR = {
                   trait = cynical
                   trait = kind
               }
           }
       }
   }

   option = {
       name = amareturn.13b
       ai_chance = {
           factor = 5
           modifier = {
               factor = 27               # If mother's stubborn, there's just a 73% chance she agrees, and 27% refuses.
               trait = stubborn
           }
           modifier = {
               factor = 92               # If mother's cynical or kind, there's a 92% chance she declines and 8% refuses.
               OR = {
                   trait = cynical
                   trait = kind
               }
           }
       }
   }

Do the numbers work out to the percentage math that I laid out, or is that not how ai_chance works?
You can't have options within options like you've got unless that is just a copy and paste error.
Other than that your script is right but your calculations are wrong. The way it works is all the factors from the ai aoptions have any applicable modifiers for that option applied to them, then the chance of one specific option happening is the modified weight of that option divided by the total modified weights of all options. So in your case if the character is stubborn then the chance they pick option A is (95*73)/((95*73)+(5*27) = 0.98 so it is 98%.
 
Thanks, the wiki literally uses the term "percentages" now, so I was somewhat confused.
Its because the weightings are converted into percentages chances for each option to happen.
If you have outcomes A, B and C with weights 50, 100 and 200 respectively then the chance for outcome A is (A/(A+B+C)*100 so in this case (50/350)*100 = 14% the outcome for B is (100/350)*100 = 29% and C is (200/350)*100 = 57%
If any of the options have modifiers those are applied before the percentage chance is calculated
 
Hi!

Is it possible to change a character's beard and hairstyle through events? If so, how?

Currently I've written this:

Code:
character_event = {
    id = TOG.9001
    title = EVTTITLE_TOG_9001
    desc = EVTDESC_TOG_9001 # I am king over a united Norway!
    picture = GFX_evt_viking_battle_oldgods
    border = GFX_event_normal_frame_war

    is_triggered_only = yes
  
    trigger = {
        has_dlc = "The Old Gods"
        has_landed_title = k_norway
        has_character_flag = is_harald_fairhair
        has_global_flag = fairhair_wars
        prisoner = no
        NOT = { year = 900 }
        NOT = { has_nickname = nick_fairhair }
    }
  
    option = {
        name = EVTOPTA_TOG_9001 # Bring me a razor and a comb!
        remove_nickname = nick_shockhair
        give_nickname = nick_fairhair
        add_trait = fair
        properties = "0b0cac"
        prestige = 200
    }
}

Audax Validator says that "properties" is an invalid node. What node am I supposed to use, if there even is one?
You cannot change dna or properties by command. You can change the weighting used for different portrait properties based on different conditions like traits etc. in the interface/portrait_properties folder
 
Does anyone know anything about font modding? For the Seven Kingdoms mod we're considering changing the font to the font found in the Game of Thrones TV show.
Your best bet would be to ask the guy who does the CK2 UI font mod but also using the likely copyrighted font is probably a really good way to get your stuff taken down.
 
EDIT : According to the "cheatbox", the event gold.4 doesn't exist. I have checked several times, I can't point the mistake. I have renamed it, changed it, it's now on_yearly_pulse, the game just can't see the event. I've spent the last two hours trying just to launch it by cheating "event gold.4" and the other names I've tried and it is not working.......
Have you actually defined the namespace "gold" for your event file?
 
I saw that you needed to do that somewhere... I am completely clueless in modding... how should it actually be done?
You should only ever use replace_path if you wish to overwrite every file in a set folder. Otherwise creating your own file in the same folder name is the way to do it.
 
It needs to be .zip I believe, because otherwise nothing happens. I added a character thing just to check, and the game only changed with the .zip... though it's unpopulated...
path = BLAH should lead to a folder, if you are going to zip your mod you should do archive = mod/BLAH.zip
But archive should never be used as it is only useful for when you upload your mod onto the Steam Workshop and the Workshop automatically converts you uploaded folder into a zip and adjusts the .mod file correctly.
 
Anyone have any idea as to what could be causing crashing in relation to trade routes? Specifically a route I have, when added, causes a crash at random during play.

The crash only occurs so long as the trade route is included in the mod. It functions correctly ingame but a crash still happens nonetheless. Logs give nothing useful (only an exception on crash, the usual).

Any help would be appreciated, thanks!
You tried using the validtator and see if it spits out any errors about them?
 
Yea I found a way to get that to work by using flags. Well I have an event problem

Code:
character_event = {
    id = DAWN.3
    desc = "EVTDESCDAWN.3"
    picture = GFX_sword_of_the_morning
    major = yes
    is_triggered_only = yes

  
    only_playable = yes
  
    trigger = {
        NOT = {
            has_global_flag = DAWN_event_3
        }
    }
    major_trigger = {
        FROM = {
            has_artifact = dawn
        }
    }

    immediate = {
        set_global_flag = DAWN_event_3
    }
    option = {
        name = "EVTOPTADAWN.3"
        ai_chance = {
            factor = 1
            modifier = {
                factor = 1
                OR = {
                    trait = kind
                    trait = bleeding_heart
                    trait = honourable
                }
            }
        }
    }
    option = {
        name = "EVTOPTBDAWN.3"
        ai_chance = {
            factor = 1
            modifier = {
                factor = 1
                OR = {
                    trait = cruel
                    trait = heartless
                    trait = dishonorable
                }
            }
        }
    }
      after = {
         clr_global_flag = DAWN_event_3 #for when others wield it
      }
}
any idea why this wont work?

edit: Ingame when I do event DAWN.3 it doesnt exist
If the game says an event doesn't exist it can mean there are some bad bracketing near it, look at the previous event and make sure the brackets are all correct
 
I posted my question at the base ck2 forum, but I am posting it here as well. Thoughts?

Details:
Guide: Your first mod

Question:
Guide: Your first mod
As I just responded to you there, if you are unsure of any rule or if what you are doing is fine according to the rule then post in the User Mod rules thread that I linked you in that thread and ask your question.
 
Is there a way to destroy titular county titles? I tried using both "destroy_landed_title" and "unsafe_destroy_landed_title", but it doesn't seem to work.

Here is my code, by the way:

Code:
title_decisions = {
   destroy_titular_county = {
       only_playable = yes
       filter = owned
       ai_target_filter = owned
      
       from_potential = {
           is_playable = yes
       }
      
       potential = {
           owner = {
               character = FROM
           }
           is_titular_county_trigger = yes
       }

       allow = {
           FROM = {
               primary_title = {
                   NOT = { title = ROOT }
               }
           }
       }

       effect = {
           unsafe_destroy_landed_title = THIS
       }

       revoke_allowed = {
           always = no
       }

       ai_will_do = {
           factor = 0
       }
   }
}
You cannot destroy count tier titles as they are meant to be always be tied to a province. Don't use titular count titles, use duke or above ones instead as that way you can destroy them and also use the activate_title command to ensure they cannot be recreated unless activated again in script.
 
Is there any way to give existing characters a random first name (from their culture, as occurs with newly-born characters)? It would be very useful for setting the name of history characters for whom I have data only on the surname.

I'm using this code at the moment:

Code:
    save_event_target_as = name_target
   random_character = {
       limit = {
           culture = PREV
           religion = PREV
       }
       event_target:name_target = {
           copy_name = PREV
       }
   }

It works, but isn't really a good way to go about doing it, specially in regards to performance (though since this is done only when loading history, it is not as bad as doing it in an event).
Create a new character then copy the name and kill the created character?
 
I've had a look, and I can't find anything (there obviously is something). That was my first go to, and I'm pretty sure you're right.

Code:
character_event = {
    id = dynastyname.0
   
    is_triggered_only = yes
    hide_window = yes
    only_men = yes
   
    trigger = {
        OR = {
            father_even_if_dead = {
                dynasty = 721
                dynasty = ROOT
                ai = yes
            }
            mother_even_if_dead = {
                dynasty = 721
                dynasty = ROOT
                ai = yes
            }
        }      
        NOT = { father_even_if_dead = { ai = no } }
        NOT = { mother_even_if_dead = { ai = no } }
        NOT = {
            liege = {
                ai = no
                any_child = {
                    any_child = {
                        character = ROOT
                    }
                }
            }
        }
    }

    immediate = {
        random_list = {
            100 = { }
            100 = { set_name = "Étienne" }
            100 = { set_name = "Thiébaut" }
            50 = { set_name = "Eudes" }
        }
    }
    option = {
        name = OK
    }
}
character_event = {
    id = dynastyname.1
   
    is_triggered_only = yes
    hide_window = yes
    only_men = yes
   
    trigger = {
        always = no
        OR = {
            father_even_if_dead = {
                dynasty = 93
                dynasty = ROOT
                ai = yes
            }
            mother_even_if_dead = {
                dynasty = 93
                dynasty = ROOT
                ai = yes
            }
        }      
        NOT = { father_even_if_dead = { ai = no } }
        NOT = { mother_even_if_dead = { ai = no } }
        NOT = {
            liege = {
                ai = no
                any_child = {
                    any_child = {
                        character = ROOT
                    }
                }
            }
        }
    }
   
    immediate = {
        random_list = {
            100 = { }
            100 = { set_name = Hugues }
            25 = { set_name = Guy }
        }
    }

    option = {
        name = OK
    }
}
character_event = {
    id = dynastyname.2
   
    is_triggered_only = yes
    hide_window = yes
    only_men = yes
   
    trigger = {
        always = no
        OR = {
            father_even_if_dead = {
                dynasty = 723
                dynasty = ROOT
                ai = yes
            }
            mother_even_if_dead = {
                dynasty = 723
                dynasty = ROOT
                ai = yes
            }
        }      
        NOT = { father_even_if_dead = { ai = no } }
        NOT = { mother_even_if_dead = { ai = no } }
        NOT = {
            liege = {
                ai = no
                any_child = {
                    any_child = {
                        character = ROOT
                    }
                }
            }
        }
    }
   
    immediate = {
        random_list = {
            150 = { }
            150 = { set_name = Foulques }
            100 = { set_name = Geoffroy }
        }
    }

    option = {
        name = OK
    }
}

character_event = {
    id = dynastyname.3
   
    is_triggered_only = yes
    hide_window = yes
    only_men = yes
   
    trigger = {
        culture_group = central_germanic
        OR = {
            father_even_if_dead = {
                dynasty = 650
                dynasty = ROOT
                ai = yes
            }
            mother_even_if_dead = {
                dynasty = 650
                dynasty = ROOT
                ai = yes
            }
        }      
        NOT = { father_even_if_dead = { ai = no } }
        NOT = { mother_even_if_dead = { ai = no } }
        NOT = {
            liege = {
                ai = no
                any_child = {
                    any_child = {
                        character = ROOT
                    }
                }
            }
        }
    }
   
    immediate = {
        random_dynasty_member_even_if_dead = {
            limit = {
                NOT = { character = ROOT }
                same_sex = ROOT
                is_alive = no
               
                NOT = {
                    sibling = ROOT
                }
            }
            save_event_target_as = old_ruler
        }
        character_event = { id = dynastyname.19 }
    }

    option = {
        name = OK
    }
}
#character_event = {
#    id = dynastyname.4
#  
#    is_triggered_only = yes
#    hide_window = yes
#    only_men = yes
#  
#    trigger = {
#        always = no
#        culture = frankish
#        OR = {
#            father_even_if_dead = {
#                dynasty = 650
#                dynasty = ROOT
#                ai = yes
#            }
#            mother_even_if_dead = {
#                dynasty = 650
#                dynasty = ROOT
#                ai = yes
#            }
#        }      
#        NOT = { father_even_if_dead = { ai = no } }
#        NOT = { mother_even_if_dead = { ai = no } }
#        NOT = {
#            liege = {
#                ai = no
#                any_child = {
#                    any_child = {
#                        character = ROOT
#                    }
#                }
#            }
#        }
#    }
#  
#    immediate = {
#        random_list = {
#            150 = { }
#            150 = { set_name = Guelph }
#            100 = { set_name = Henri }
#        }
#    }
#
#    option = {
#        name = OK
#    }
#}
character_event = {
    id = dynastyname.5
   
    is_triggered_only = yes
    hide_window = yes
    only_men = yes
   
    trigger = {
        culture_group = central_germanic
        OR = {
            father_even_if_dead = {
                dynasty = 25061
                dynasty = ROOT
                ai = yes
            }
            mother_even_if_dead = {
                dynasty = 25061
                dynasty = ROOT
                ai = yes
            }
        }      
        NOT = { father_even_if_dead = { ai = no } }
        NOT = { mother_even_if_dead = { ai = no } }
        NOT = {
            liege = {
                ai = no
                any_child = {
                    any_child = {
                        character = ROOT
                    }
                }
            }
        }
    }
   

    immediate = {
        if = {
            limit = { is_female = no }
            random_dynasty_member_even_if_dead = {
                limit = {
                    NOT = { character = ROOT }
                    same_sex = ROOT
                    is_alive = no
                    OR = {
                        is_close_relative = yes
                        higher_tier_than = BARON
                    }
                    NOT = {
                        sibling = ROOT
                    }
                }
                save_event_target_as = old_ruler
            }
            character_event = { id = dynastyname.19 }
        }
        if = {
            limit = { is_female = yes }
            random_dynasty_member_even_if_dead = {
                limit = {
                    NOT = { character = ROOT }
                    same_sex = ROOT
                    is_alive = no
                    NOT = {
                        sibling = ROOT
                    }
                }
                save_event_target_as = old_ruler
            }
            character_event = { id = dynastyname.19 }
        }
    }
    option = {
        name = OK
    }
}
character_event = {
    id = dynastyname.6
   
    is_triggered_only = yes
    hide_window = yes
   
    trigger = {
        culture = frankish
        OR = {
            father_even_if_dead = {
                dynasty = 25061
                dynasty = ROOT
                ai = yes
                NOT = {
                    OR = {
                        primary_title = c_vermandois
                        AND = {
                            has_landed_title = c_vermandois
                            NOT = {
                                tier = KING
                            }
                        }
                    }
                }
            }
            mother_even_if_dead = {
                dynasty = 25061
                dynasty = ROOT
                ai = yes
                NOT = {
                    OR = {
                        primary_title = c_vermandois
                        AND = {
                            has_landed_title = c_vermandois
                            NOT = {
                                tier = KING
                            }
                        }
                    }
                }
            }
        }      
        NOT = { father_even_if_dead = { ai = no } }
        NOT = { mother_even_if_dead = { ai = no } }
        NOT = {
            liege = {
                ai = no
                any_child = {
                    any_child = {
                        character = ROOT
                    }
                }
            }
        }
    }
   

    immediate = {
        if = {
            limit = { is_female = no }
            random_dynasty_member_even_if_dead = {
                limit = {
                    NOT = { character = ROOT }
                    same_sex = ROOT
                    is_alive = no
                    OR = {
                        is_close_relative = yes
                        higher_tier_than = BARON
                    }
                    NOT = {
                        sibling = ROOT
                    }
                }
                save_event_target_as = old_ruler
            }
            character_event = { id = dynastyname.19 }
        }
        if = {
            limit = { is_female = yes }
            random_dynasty_member_even_if_dead = {
                limit = {
                    NOT = { character = ROOT }
                    same_sex = ROOT
                    is_alive = no
                    NOT = {
                        sibling = ROOT
                    }
                }
                save_event_target_as = old_ruler
            }
            character_event = { id = dynastyname.19 }
        }
    }
    option = {
        name = OK
    }
}

I can't make heads or tails of it.
Have you actually defined the "dynastyname" namespace at the top of the file? Make sure to double check you have namespace = dynastyname at the top of the file
 
Oh!
Well, that's a major relief then. Thx for calculating that for me :)
Yeah, I would assume 2MB wouldn't hurt much, even though I'm not 100% sure that they take excactly as much space as a "normal" integer. I remember reading about the memory print of flags vs modifiers vs variables somewhere... they have their name to store as well. But anyway, I feel almost confident enough to risk it now ^^
That last part is interesting, but I doubt that it really works that way. For example, if some calculation means that prosperity_value would end up as zero, but later would be increased again - then the variable would first disappear, and the latter operation fail? Doesn't really seem right.

So yeah, thx a lot for answering, but I feel a tiny bit confused now so I'm gonna do a think I rarely do, and bother someone official:
@Meneth or @blackninja9939, can someone confirm that this is correct, and I won't run into trouble using this many variables? And do variables indeed get cleared when set to zero?
Variable set to 0 get removed from a save game yes, if you do any effect with them in game then they just change it from 0.
For example if you make a simple event or run the effect change_variable = { which = "test_var" value = 10 } on a character then even if you have not explicitly set the variable it still gets changed by 10 as if you had set it as 0 to begin with. Same with any other variable commands or conditions.

As for using lots of variables, I think it will be highly unlikely you manage to cause a crash by using lots of them. You might bloat your save a bit but unlikely to levels here it corrupts or cannot be loaded.
 
I completely understand.
EK uses the method I described as the scoping method didn't work properly 3 or 4 (5?) years ago when I first wrote the script, maybe it's been fixed but that method at least is proven to work. I'm sure @blackninja9939 will be around to post the correct method sometime ;)

It'd be great to simplify my own scripts if it works.
@Drakons @Korbah
It definitely works with scopes, maybe there is an issue with some specific scopes or in certain use cases but I tested it by just making a file in Documents/Paradox Interactive/Crusader Kings 2 called test.txt and added the following to it:
Code:
create_character = {
    random_traits = yes
    culture = english
    dynasty = ROOT
}
new_character = {
    ROOT = { 
        set_father = PREV
        set_graphical_culture = PREV
    }
}
Then get in game and start as a character who is say Muslim and type in the console "run test.txt" and you will get a newly generated father and your graphical culture will change to be his aka the English graphics.
 
Wait… you can do that? Just execute a text file of commands from the console? That is *so* cool! Is that in the production version, or just the dev build?
Yep it is in the public build and has been for a few versions now, not sure when it was added though
 
Well, I'm going to document this for the wiki, since it's not there yet. :)

From your post, the text file needs to be directly in the CK2 documents directory. The commands are run in the scope of the player who consoles it. I assume no FROM-type scopes are set (wouldn't make sense).
Yeah the file needs to be directly in the documents directory and when you run it in game you need to include the .txt extension in the console.
ROOT is the character running the effect, it does not take an option character to set as ROOT but you can work around that by turning on charinfo and using direct scoping to the character you want to run effects on by doing c_1234 for a character with ID 1234. And yeah do not bother using FROM or chains of FROM.
 
It did not work either.
Not sure exactly what you are doing but I noticed you are using the lowborn condition, currently the is_lowborn condition is inverted. If you want to check someone is lowborn you must do is_lowborn = yes.
This has already been fixed for 2.8 though but in 2.7.2 it is still inverted.