Jump to content

CK2 Modding Quick Question Thread


Recommended Posts

Not really. Closest approximation would be to have a maintenance event fire from some on_action (or an event that repeats itself with a delay) that adds an oppinion modifiers where the conditions you want are met. Be warned though that depending on the implementation in could get quite CPU-intensive.

Link to comment
45 minutes ago, ngppgn said:

Not really. Closest approximation would be to have a maintenance event fire from some on_action (or an event that repeats itself with a delay) that adds an oppinion modifiers where the conditions you want are met. Be warned though that depending on the implementation in could get quite CPU-intensive.

yeaaaah, I also found something like this but hoped there could exist a better option, maybe I should just make a suggestion on paradox if it would be possible to add this "function" to traits and artifacts etc, it could maybe look like this...

 

trait_or_artifact = {
      effect= {

            sex_appeal_opinion = 20

            if = {

                  dynasty = ROOT

                  is_female = yes

            }

      }

      other things like the usuall stewardship = 2 and etc

}

 

Welp, I guess I will have to just find some workaround or make CPU heavy things because I doubt they would implement something like that...

Link to comment
  • 2 weeks later...

I am trying to add a menstruation cycle for females on_startup. I am doing this is the same way that body parts are added but using character_modifiers instead of traits.

Spoiler

 

character_event = {
id = RSLB.910
hide_window = yes
is_triggered_only = yes ## on_startup
only_women = yes
min_age = 16
max_age = 45
ai = yes
trigger = {
        is_female = yes
        is_pregnant = no
    
        }

    immediate = {        
             character_event = { id = RSLB.901 }
            set_character_flag = has_period

    }

 

In game checking shows that females get the has_period flag on startup but the event RSLB.901  doesn't seem to fire.
 

Spoiler

 

character_event = {
id = RSLB.901
hide_window = yes
is_triggered_only = yes ## event RSLB.900
only_women = yes
has_character_flag = has_period
ai = yes
trigger = {
         is_pregnant = no
         has_character_flag = has_period
        }
        
        
immediate = {
            add_character_modifier = { name = rsl_menstruating days = 7 }
            set_character_flag = menstruating
            clr_character_flag = luteal
            character_event = { id = RSLB.902 }
        
    }

}

 

The character modifier does not appear.

 

I suppose that using character modifiers on all female character on startup is very cpu heavy, but is that the reason it doesn't work?

I am also not sure on how the scoping works when using on_startup. It seems to be correct in the first event since only women get the has_period flag, but I don't know how this works in the follow up events. Tried to use " host = { character_event = { id = RSLB.901 }"  but this crashed the game on startup. Replacing host with ROOT FROM or FROMFROM had no effect.

 

All input is welcome

Link to comment

You're missing a closing bracket in the first event (and btw have a redundant trigger there).

 

Beware, too that in the first event you set the has_period flag after calling the second event, but the second evwnt requires the flag to fire, so that's probably why it's not firing.

 

In general, if a hidden wvent is only ever called from knside another single hidden wvent, you should just merge the two of them.

Link to comment

Thanks for your help ngppgn! The problem was indeed the incorrect position of the flag.

 

Now I have another problem which is driving me bonkers :scream:

 

Validator reacts with a comment which I do not understand:


 

Spoiler

 

--- Error 1 of 1 ---
Parse Failure
Path: <mod>\common\scripted_effects\rsl_ scripted effects1.txt
Approximate location: Line 194, column 54
Error: Token "=" at line 194, column 54 is part of a list and thus must be a literal.


 

 

It concerns the following scripted effect:

 

  

Spoiler

##### post_pregnancy_body_modifications #####    
    
 shape_impact_evaluation = {               # after giving birth
 
 if = {
    limit = {
            is_variable_equal = { number_of_pregnancies value = 0 }
        }
        
            random_list = {
 
                        25 = { change_variable = { which = shape_size value = 0 }
                            modifier = {
                                        factor = 0
                                        trait = gluttonous
                            }
                            modifier = {
                                        factor = 2
                                        trait = temperate
                            }
                        }
                        55 = { change_variable = { which = shape_size value = 1 }
                               set_character_flag = shape_size_increase_1
                        }    
                        20 = { change_variable = { which = shape_size value = 2 }
                            modifier = {
                                        factor = 2
                                        trait = gluttonous
                            }
                               set_character_flag = shape_size_increase_2
                        }    
                            
            }
        }
        if = {
            limit = {
                    is_variable_equal = { number_of_pregnancies value = 1 }
            }
            random_list = {
                        20 = { change_variable = { which = shape_size value = 0 }
                            modifier = {
                                        factor = 0
                                        trait = gluttonous
                            }
                            modifier = {
                                        factor = 2
                                        trait = temperate
                            }            
                        }
                        60 = { change_variable = { which = shape_size value = 1 }
                               set_character_flag = shape_size_increase_1
                        }    
                        20 = { change_variable = { which = shape_size value = 2 }
                            modifier = {
                                        factor = 2
                                        trait = gluttonous
                                        }
                               set_character_flag = shape_size_increase_2
                        }    
                            
            }
        }
        if = {
            limit = {
                    is_variable_equal = { number_of_pregnancies value = 2 }
            }
            random_list = {
 
                        15 = { change_variable = { which = shape_size value = 0 }
                            modifier = {
                                        factor = 0
                                        trait = gluttonous
                            }
                            modifier = {
                                        factor = 2
                                        trait = temperate
                            }
                        }                
                        60 = { change_variable = { which = shape_size value = 1 }
                               set_character_flag = shape_size_increase_1
                        }    
                        25 = { change_variable = { which = shape_size value = 2 }
                            modifier = {
                                        factor = 2
                                        trait = gluttonous
                            }
                               set_character_flag = shape_size_increase_2
                        }    
                            
            }
        }
}    
 

and it is supposed to work with the following event:

Spoiler

#    Female Body Shape @ on_post_birth ## ROOT is baby
character_event = {
    id = RSLB.126        
    is_triggered_only = yes  #by on_action
    hide_window = yes
    trigger = {
            mother = {
                    is_female = yes
                    has_character_flag = has_pregnant_body_shape
            }
    }
     immediate = {
                mother = {
                    remove_trait = pregnant_body1
                    add_trait = lactating_tits
                    export_to_variable = { which = number_of_pregnancies value = num_of_children }
                    shape_impact_evaluation = yes
                    add_f_shape = yes
                    clr_character_flag = has_pregnant_body_shape
                    set_character_flag = shape
                    character_event = { id = RSLBos.93 days = 180 }
                }    
    }
        option = { name = rsl_option1 }
}

  I have tried using check_variable instead of is_variable_equal, reread it 50 times (even found a typo) but I get the same comment every time. Does anybody spot something wrong?       

Link to comment

Hi there,

Stupid simple question:

Does anyone know how to get the different opinion types between two characters? 

e.g. the Sex_appeal_opinion and the dynastie opinion?

All I managed to get is normal and personal opinion.

 

Second question:

Has someone figured out a smarter way to get opinion into a variable than checking it stupidly for every value 

and setting the variable accordingly?

(It really hurts every time I see that part of the code again =( )

Link to comment

Thanks Herring! I would probably have missed it again after the 51st reading ?

 

I have a question about MTTH and Weight Multiplier.

 

According to the wiki : Mean time to happen (MTTH) is a measure of how much time it takes, on average, for a random event to occur. An MTTH of 90 days, for example, means that after 90 days, the probability of the event having been fired is exactly 50%.

 

Does this mean that after 180 days the chance for the event to occur is 100%?

 

I want an event to occur sometime between the age of 14 and 16.  MTTH seems the right choice. I just want to be sure that the event always happens although the exact moment is random.

 

I suppose the same is true  for Weight Multiplier ?

Link to comment
55 minutes ago, joemann said:

Does this mean that after 180 days the chance for the event to occur is 100%?

No, not really. In Theory you never reach 100% chance. Have a look at normal distribution for that.

If you want to get sure, use MTTH and set a flag. If character turns 16, check for flag, and if event has not happened, fire it hard.

 

The weight multiplier is a different thing. You use the weight multiplier to increase/decrease the chances in a list of events, which are mutually exclusive.

That means, you always fire one event, just altering the chance of which is selected. The math is (broken down) something like this:

event A: chance ca: 50 , weight 1

event B: chance cb: 50 , weight 1

 

when fired, a random number is generated between 0 and ca*weightA + cb*weightB ....

So in this case, it is a 50/50 chance for and b, but 100% that one of the two is fired

 

Increase now the weight of A to 2

 

Generate random number between 0 and ca*weightA + cb*weightB = 50*2 + 50*1 = 150

so now, event A has a chance of 66,66% of being selected, B 33,33%. But as before, one will always be selected

Link to comment

Thanks Kiara!  I'll experiment with this.

 

Another quick question: if you use ai = yes according to the wiki: If yes, will only fire for ai characters

 

                                                                                                   If no, will only fire for the player(s). Implies only_playable = yes

 

If you want an event to fire for all characters do you just not use the ai trigger or do you make two separate events, one with ai = yes and one with ai = no ?

 

 

 

Link to comment
4 hours ago, joemann said:

Thanks Kiara!  I'll experiment with this.

 

Another quick question: if you use ai = yes according to the wiki: If yes, will only fire for ai characters

 

                                                                                                   If no, will only fire for the player(s). Implies only_playable = yes

 

If you want an event to fire for all characters do you just not use the ai trigger or do you make two separate events, one with ai = yes and one with ai = no ?

 

 

 

I could be wrong here, but I always handled it, that ai=yes just means that the ai can use it too. The player can always use events, if you made it so that the player can receive it.

Link to comment
2 hours ago, Kiara said:

I could be wrong here, but I always handled it, that ai=yes just means that the ai can use it too. The player can always use events, if you made it so that the player can receive it.

I fiear that you are: if you make a mtth event with ai = yes then the event will never fire for players. It might be that events fired from script ignore pre-triggers, bur I wouldn't count on that either.

Link to comment

I remain confused ?

 

According to the wiki:

Spoiler

 

Characters in Base icon CK2.png Crusader Kings II, can be easily split in two categories. The first are the player characters: players use them whether in a singleplayer or multiplayer run. There are actions and events in-game that are restricted only for a player character.

The second category are the non-player characters: they are run by the AI and their traits, attributes etc play a major role in how they decide to act in the game. Like player characters, there are actions, events, and especially government types that are exclusive to non-player characters.

 

 

In game it seems there are three types I'll use Robert the Fox as an example

 

Robert himself is the character I am playing: the console charinfo says "AI controlled: No"

I would expect Robert's spouse Sichelgata , whom I am not playing,  to be ai controlled. However the charinfo reads "AI controlled : No"

Some of Robert's vassals are "AI controlled = yes", but others are not. Children and familly members are mostly  but not always "AI controlled = no"

 

All characters outside the desmense are "Ai controlled = yes". Since Robert has no liege I do not know if your liege would be AI controlled

 

The criteria for the difference  between ai controlled or not are not obvious to me.

 

Maybe it ties in with the notion of "playable" ?

 

According to the wiki:

 

in script, "playable" does not actually mean that the player can play the character. What it means is: count-tier or above, or a patrician, and is not a landless rebel. Using this pre-trigger completely eliminates evaluation of the event for anyone who does not meet the criteria, meaning that the event is checked for the ~1000 playable characters in the game, rather than all ~20k

 

However, it is obvious that, with the exception of the the player's character, the ai takes care of both the playable and the non playable characters.

 

So if I use ai = yes does the event  apply to all playable characters, i.e. , the ~1000 (minus the character I am playing) + the  ~20K other characters or only to the 20K characters.

 

My impression is that not using the ai trigger means that the event is applied to all characters regardless of whether they are AI Controlled or not. A lot of the body trait related mods which generate body traits to all characters at startup do not use the ai trigger. For the time being this suits me fine. But I still don't know how to correctly use ai =yes.

 

Does anybody have extra information on this?

Link to comment

A completely different question. If I understand correctly, MTTH and weight_multiplier do not have the same effect. However, according to the wiki you must use weight_multiplier in an on_action event (does that mean you can not use MTTH). If this is true how can I get the MTTH effect in an on_action event?

 

Example:


 

Spoiler

 

## first occurrence  of period for adolescents

character_event = {
id = RSLB.900
hide_window = yes
is_triggered_only = yes ## on_adolesence_pulse fires at age 12y and 6m and age 14 plus 6m and on yearly_childhood_pulse
only_women = yes
min_age = 12
max_age = 16


    trigger = {
            is_pregnant = no
            NOT = { has_character_flag = has_cycle }            
    }    
    weight_multiplier = {
                    days = 180
                    
                    modifier = {
                        factor = 3
                        age = 12
                    }
                    modifier = {
                            factor = 2
                            age = 13
                    }
                    modifier = {
                            factor = 1
                            age = 14
                    }
                    modifier = {
                            factor = 0.5
                            age = 15
                    }
    }    
                        
    immediate = {

    set_character_flag = has_cycle
    character_event = { id = RSLB.901 }

     }

}

 

I would like the event to occur earlier or later (than the 180 days) in function of the character's age. MTTH seems to be made for this. I am not sure I understand the relationship between days = 180 and the modifiers in weight_multiplier.

Link to comment
33 minutes ago, joemann said:

I remain confused ?

 

According to the wiki:

  Reveal hidden contents

 

Characters in Base icon CK2.png Crusader Kings II, can be easily split in two categories. The first are the player characters: players use them whether in a singleplayer or multiplayer run. There are actions and events in-game that are restricted only for a player character.

The second category are the non-player characters: they are run by the AI and their traits, attributes etc play a major role in how they decide to act in the game. Like player characters, there are actions, events, and especially government types that are exclusive to non-player characters.

 

 

In game it seems there are three types I'll use Robert the Fox as an example

 

Robert himself is the character I am playing: the console charinfo says "AI controlled: No"

I would expect Robert's spouse Sichelgata , whom I am not playing,  to be ai controlled. However the charinfo reads "AI controlled : No"

Some of Robert's vassals are "AI controlled = yes", but others are not. Children and familly members are mostly  but not always "AI controlled = no"

 

All characters outside the desmense are "Ai controlled = yes". Since Robert has no liege I do not know if your liege would be AI controlled

 

The criteria for the difference  between ai controlled or not are not obvious to me.

 

Maybe it ties in with the notion of "playable" ?

 

According to the wiki:

 

in script, "playable" does not actually mean that the player can play the character. What it means is: count-tier or above, or a patrician, and is not a landless rebel. Using this pre-trigger completely eliminates evaluation of the event for anyone who does not meet the criteria, meaning that the event is checked for the ~1000 playable characters in the game, rather than all ~20k

 

However, it is obvious that, with the exception of the the player's character, the ai takes care of both the playable and the non playable characters.

 

So if I use ai = yes does the event  apply to all playable characters, i.e. , the ~1000 (minus the character I am playing) + the  ~20K other characters or only to the 20K characters.

 

My impression is that not using the ai trigger means that the event is applied to all characters regardless of whether they are AI Controlled or not. A lot of the body trait related mods which generate body traits to all characters at startup do not use the ai trigger. For the time being this suits me fine. But I still don't know how to correctly use ai =yes.

 

Does anybody have extra information on this?

Since you are the player, you are not considered ai. So anything with ai = yes in it means it will not fire for you, but can for ANYBODY else, including playable_only characters. Anything with the ai = no will only fire for you and NOBODY else.

 

Playable means the character COULD be controlled by you, so anybody with a count title and above is considered playable. That is more about potential though, and ai = yes does apply to the people who are considered playable. This is mostly used like you said, to filter to only 1000 characters instead of all 20k+. This filter is simply used to reduce the need to check every character.

 

I don't really know anything about the whole ai controlled = yes/no. I have plenty of guesses but I have not tested anything around it so I dunno.

 

 

Link to comment

OK, first to get that playable thing straight.

playable is every character of count and above, as stated in the wiki. This only means, that you (the player) COULD play as one of these characters. You can't e.g. play as a random courtier, which doesn't hold any titles, or a simple major of a city. If you ever fall below count tier, you loose the game. The playable keyword thus is there to filter out all those very minor characters.

 

second, your MTTH problems.

You seem to try and make two systems work together here, which are designed to be mutually exclusive. MTTH is a trigger (as explained in the wiki) and thus used to trigger an event to occure.

You try to use it in an event, which is already triggered by an on_action event (which is another form of trigger)

 

you need to do something like this: (sorry, just pseudo code, tomorrow I can give you something better)

instead of triggering it by an on_action event

trigger = {
	NOT = { age = 16 }
	age = 14
}
mean_time_to_happen = {
	months = 1
	modifier = {
		factor = 2 # Decreases chances by half
		some_condition = yes
	}
	modifier = {
		factor = 0.5 # Increases chances by half
		some_condition = yes
	}
}

 

Link to comment

As promised, here a conversion of your event to use MTTH correctly:

 ## first occurrence  of period for adolescents

character_event = {
id = RSLB.900
hide_window = yes
#is_triggered_only = yes ## on_adolesence_pulse fires at age 12y and 6m and age 14 plus 6m and on yearly_childhood_pulse
# We trigger it here
#only_women = yes
#min_age = 12
#max_age = 16


    trigger = {
			is_female = yes
			age = 12
			NOT = { age = 17 }
            is_pregnant = no
            NOT = { has_character_flag = has_cycle }            
    }    
    mean_time_to_happen = {
                    days = 180
                    
                    modifier = {
                        factor = 3
                        NOT = { age = 13 } #keep in mind the = in CK2 engine is >=
                    }
                    modifier = {
                            factor = 2
                            NOT = { age = 14 }
                    }
                    modifier = {
                            factor = 1
                            NOT = { age = 15 }
                    }
                    modifier = {
                            factor = 0.5
                            NOT = { age = 16 }
                    }
                    modifier = {
                            factor = 0.25
                            NOT = { age = 17 }
                    }
    }    
                        
    immediate = {

    set_character_flag = has_cycle
    character_event = { id = RSLB.901 }

     }

}

This should work as expected. I have no way of checking it in CK2 at the moment.

Link to comment
On 8/17/2018 at 8:53 PM, joemann said:

I remain confused ?

 

According to the wiki:

  Hide contents

 

Characters in Base icon CK2.png Crusader Kings II, can be easily split in two categories. The first are the player characters: players use them whether in a singleplayer or multiplayer run. There are actions and events in-game that are restricted only for a player character.

The second category are the non-player characters: they are run by the AI and their traits, attributes etc play a major role in how they decide to act in the game. Like player characters, there are actions, events, and especially government types that are exclusive to non-player characters.

 

 

In game it seems there are three types I'll use Robert the Fox as an example

 

Robert himself is the character I am playing: the console charinfo says "AI controlled: No"

I would expect Robert's spouse Sichelgata , whom I am not playing,  to be ai controlled. However the charinfo reads "AI controlled : No"

Some of Robert's vassals are "AI controlled = yes", but others are not. Children and familly members are mostly  but not always "AI controlled = no"

 

All characters outside the desmense are "Ai controlled = yes". Since Robert has no liege I do not know if your liege would be AI controlled

 

The criteria for the difference  between ai controlled or not are not obvious to me.

 

Maybe it ties in with the notion of "playable" ?

 

According to the wiki:

 

in script, "playable" does not actually mean that the player can play the character. What it means is: count-tier or above, or a patrician, and is not a landless rebel. Using this pre-trigger completely eliminates evaluation of the event for anyone who does not meet the criteria, meaning that the event is checked for the ~1000 playable characters in the game, rather than all ~20k

 

However, it is obvious that, with the exception of the the player's character, the ai takes care of both the playable and the non playable characters.

 

So if I use ai = yes does the event  apply to all playable characters, i.e. , the ~1000 (minus the character I am playing) + the  ~20K other characters or only to the 20K characters.

 

My impression is that not using the ai trigger means that the event is applied to all characters regardless of whether they are AI Controlled or not. A lot of the body trait related mods which generate body traits to all characters at startup do not use the ai trigger. For the time being this suits me fine. But I still don't know how to correctly use ai =yes.

 

Does anybody have extra information on this?

The ai = yes/no has nothing to do with what you're seeing from charinfo non-rulers and courtiers are 'ai controlled: no' according to charinfo, but this only mean that they don't check for hardcoded diploactions whoch have coded ai logic (to reduce the strain on the engine). The wiki is right with respect to the meaning of ai = yes/no in script.

Link to comment
On 8/16/2018 at 3:59 PM, Kiara said:

Hi there,

Stupid simple question:

Does anyone know how to get the different opinion types between two characters? 

e.g. the Sex_appeal_opinion and the dynastie opinion?

All I managed to get is normal and personal opinion.

 

Second question:

Has someone figured out a smarter way to get opinion into a variable than checking it stupidly for every value 

and setting the variable accordingly?

(It really hurts every time I see that part of the code again =( )

Bump

Link to comment

I've written an event that modifies how the "Create new vassal" button on baronies works. In a nutshell it checks gender laws and creates a female vassal if the requirements are met. It is fired from on_new_holder.

It works, but there is a problem - all vassals created by this event are clones of each other, with identical traits, names, portraits (except hair), stats. Does anyone have any ideas on how to make the game stop creating a clone army?

event:

 

#ROOT is the new holder, FROM is the title, FROMFROM is the old holder
character_event = {
    id = LES.1016
    hide_window = yes
    only_men = yes
    is_triggered_only = yes
    trigger = {
        tier = BARON
        top_liege = { has_law = female_authority_3 }
    }
    immediate = {
        if = {
            limit = {
                FROM = {
                    OR = {
                        holding_type = castle
                        holding_type = city
                        holding_type = tribal
                    }
                }
            }
            create_character = {
                female = yes
                culture = FROM
                religion = ROOT
                random_traits = yes
                dynasty = none
            }
            new_character = {
                grant_title = FROM
            }
        }
    }
}
 

 

Link to comment
12 hours ago, Kiara said:

@Buzhidao Have a look at portrait modding and character modding in the wiki. If memory serves right, there are a few examples of more or less random chars

Those articles are irrelevant to the question.

The question was: how do I make "create_character" - a command that should create random characters (unless specified otherwise) - actually create random characters as it should?

Or at least why does it create clones in the first place?

Link to comment
5 hours ago, Buzhidao said:

Those articles are irrelevant to the question.

The question was: how do I make "create_character" - a command that should create random characters (unless specified otherwise) - actually create random characters as it should?

Or at least why does it create clones in the first place?

What is your test modus operandi?

 

create_character does a minimum, generates crap npc. Also random doesn't mean different, just not directed.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use