Jump to content

CK2 Modding Quick Question Thread


Recommended Posts

Thanks for your answers!

 

As far as the trigger is concerned, why is it preferable to put the age and the character_flag  in the trigger box rather than use them as pre-triggers ?

 

As for days =, I think I understand what you are saying. In that case there is no point in using 360 days if I am using the on _yearly_pulse. Days = 1 would work just as well .

 

The fact that you mentioned the random list makes me think that the real problem is that I am not using any form of randomness. If the event is triggered by the on_yearly_pulse for the first time at age 40 the chance for the event firing is lower than it would be at age 41, but at age 40 there is no competition from age 41. Age 40 is the only age that ticks all the boxes  so that 40 will always trigger the event. Am I correct?

 

If so, then a solution using a random list such as

 

10  age = 40

 modifiers

20 age = 41

 modifiers

30 age = 42

 

etc would probably work better in getting a distribution over ages between 40 and 50.

 

Or am I completely of track?

   

Link to comment
50 minutes ago, joemann said:

Thanks for your answers!

 

As far as the trigger is concerned, why is it preferable to put the age and the character_flag  in the trigger box rather than use them as pre-triggers ?

 

As for days =, I think I understand what you are saying. In that case there is no point in using 360 days if I am using the on _yearly_pulse. Days = 1 would work just as well .

 

The fact that you mentioned the random list makes me think that the real problem is that I am not using any form of randomness. If the event is triggered by the on_yearly_pulse for the first time at age 40 the chance for the event firing is lower than it would be at age 41, but at age 40 there is no competition from age 41. Age 40 is the only age that ticks all the boxes  so that 40 will always trigger the event. Am I correct?

 

If so, then a solution using a random list such as

 

10  age = 40

 modifiers

20 age = 41

 modifiers

30 age = 42

 

etc would probably work better in getting a distribution over ages between 40 and 50.

 

Or am I completely of track?

   

There are only very few pre-triggers. Everything else renders your event invalid. Age isn't one of them (but max_age and min_age is), and has_character_flag can only work if that is the only one there, Any more has_character_flag will render your event invalid, which is why it's preferable to use that as a trigger instead because you can fit in more of them. You can drop age from the trigger and add min_age = 40 as your pre-trigger.

 

The more I think about weight_multiplier, the more I think I'm completely wrong. I think it's how many days after the on_actions pulse the event will fire if it is chosen from the random list. And on an on_yearly_pulse, it begins on Jan 1st, so modify the days or months accordingly. If you want it to fire on August 1st, set it to months = 8. I'm still correct about the normal modifier increasing the chance an event is chosen from the random list.

 

If you are lazy, like me, just do one event for the random_list and one that calls for nothing (if you want a random chance nothing happens instead), such as:

 

#on_actions
on_yearly_pulse = {
	random_events = {
		300 = 0 # This means nothing happens if picked
		200 = blahblahblah.1 (your age event)
	}
}


#age event

character_event = {
	blahblahblah
	stuff goes here
	blahblahblah

	weight_multiplier = {
		months = 8 # Will fire on August
		modifier = {
			factor = 1 # No change
			age == 40 # The == means exactly 40
		}
		modifier = {
			factor = 1.1 # The 200 chance now becomes 220
			age == 41
		}
		modifier = {
			factor = 1.2 # The 200 chance now becomes 240
			age == 42
		}
		#etc etc etc

Taking all this into account, nothing happens at a 60% chance and your age event happens at a 40% chance if you are exactly 40. If you are 41, this chance increases to 42% while nothing happens at a 58%.

The math formula is:

(A) = (random_events number for A) * (all applicable modifier factors for A)

(B) = (random_events number for B) * (all applicable modifier factors for B)

(Total) = (A) + (B)

(percentage chance of A getting picked) = (A) / (Total)

(percentage chance of B getting picked) = (B) / (Total)

 

Add in more if you have more random_events.

Link to comment

While waiting for your answer ( which is really helpful ! ) I pursued my other idea, and came up with the following, using a random list:

 

Spoiler

## onset of menopause
character_event = {
id = RSLB.904
hide_window = yes
is_triggered_only = yes  ## by on_action on yearly pulse
only_women = yes

 


    trigger = {    
            has_character_flag = has_cycle
            age = 40
            is_female = yes
            NOT = { has_character_flag = menopausal }

    }    
    random_list = {
                5 = {        
                    modifier = {
                            factor = 0.75
                            age = 40
                            OR = {
                                num_of_children = 2
                                trait = temperate
                                trait = curvaceous
                                trait = voluptuous
                            }
                                
                    }
                    modifier = {
                            factor = 1.25
                            age = 40
                            OR = {
                                num_of_children == 0
                                trait = gluttonous
                                trait = lithe
                                trait = slender
                            }
                                
                    }
                }
                5 = {
                    modifier = {
                            factor = 0.75
                            age = 41
                            OR = {
                                num_of_children = 2
                                trait = temperate
                                trait = curvaceous
                                trait = voluptuous
                            }
                                
                    }
                    modifier = {
                            factor = 1.35
                            age = 41
                            OR = {
                                num_of_children == 0
                                trait = gluttonous
                                trait = lithe
                                trait = slender
                            }
                                
                    }
                }
                6 = {
                    modifier = {
                            factor = 0.75
                            age = 42
                            OR = {
                                num_of_children = 2
                                trait = temperate
                                trait = curvaceous
                                trait = voluptuous
                            }
                                
                    }
                    modifier = {
                            factor = 1.45
                            age = 42
                            OR = {
                                num_of_children == 0
                                trait = gluttonous
                                trait = lithe
                                trait = slender
                            }
                                
                    }
                }
                6 = {
                    modifier = {
                            factor = 0.80
                            age = 43
                            OR = {
                                num_of_children = 2
                                trait = temperate
                                trait = curvaceous
                                trait = voluptuous
                            }
                                
                    }
                    modifier = {
                            factor = 1.50
                            age = 43
                            OR = {
                                num_of_children == 0
                                trait = gluttonous
                                trait = lithe
                                trait = slender
                            }
                                
                    }
                }
                8 = {
                    modifier = {
                            factor = 0.90
                            age = 44
                            OR = {
                                num_of_children = 2
                                trait = temperate
                                trait = curvaceous
                                trait = voluptuous
                            }
                                
                    }
                    modifier = {
                            factor = 1.55
                            age = 44
                            OR = {
                                num_of_children == 0
                                trait = gluttonous
                                trait = lithe
                                trait = slender
                            }
                                
                    }
                }
                10 = {
                    modifier = {
                            factor = 0.95
                            age = 45
                            OR = {
                                num_of_children = 2
                                trait = temperate
                                trait = curvaceous
                                trait = voluptuous
                            }
                                
                    }
                    modifier = {
                            factor = 1.60
                            age = 45
                            OR = {
                                num_of_children == 0
                                trait = gluttonous
                                trait = lithe
                                trait = slender
                            }
                                
                    }
                }
                12 = {
                    modifier = {
                            factor = 0.95
                            age = 46
                            OR = {
                                num_of_children = 2
                                trait = temperate
                                trait = curvaceous
                                trait = voluptuous
                            }
                                
                    }
                    modifier = {
                            factor = 1.60
                            age = 46
                            OR = {
                                num_of_children == 0
                                trait = gluttonous
                                trait = lithe
                                trait = slender
                            }
                                
                    }
                }
                13 = {
                    modifier = {
                            factor = 1.0
                            age = 47
                            OR = {
                                num_of_children = 2
                                trait = temperate
                                trait = curvaceous
                                trait = voluptuous
                            }
                                
                    }
                    modifier = {
                            factor = 1.65
                            age = 47
                            OR = {
                                num_of_children == 0
                                trait = gluttonous
                                trait = lithe
                                trait = slender
                            }
                                
                    }
                }
                25 = {
                    modifier = {
                            factor = 1.05
                            age = 48
                            OR = {
                                num_of_children = 2
                                trait = temperate
                                trait = curvaceous
                                trait = voluptuous
                            }
                                
                    }
                    modifier = {
                            factor = 1.75
                            age = 48
                            OR = {
                                num_of_children == 0
                                trait = gluttonous
                                trait = lithe
                                trait = slender
                            }
                                
                    }
                }
                15 = {
                    modifier = {
                            factor = 1.10
                            age = 49
                            OR = {
                                num_of_children = 2
                                trait = temperate
                                trait = curvaceous
                                trait = voluptuous
                            }
                                
                    }
                    modifier = {
                            factor = 1.85
                            age = 49
                            OR = {
                                num_of_children == 0
                                trait = gluttonous
                                trait = lithe
                                trait = slender
                            }
                                
                    }
                }
                50 = {
                    modifier = {
                            factor = 1.10
                            age = 50
                            OR = {
                                num_of_children = 2
                                trait = temperate
                                trait = curvaceous
                                trait = voluptuous
                            }
                                
                    }
                    modifier = {
                            factor = 1.95
                            age = 50
                            OR = {
                                num_of_children == 0
                                trait = gluttonous
                                trait = lithe
                                trait = slender
                            }
                                
                    }
                }
                80 = {
                    modifier = {
                            factor = 1.20
                            age = 51
                            OR = {
                                num_of_children = 2
                                trait = temperate
                                trait = curvaceous
                                trait = voluptuous
                            }
                                
                    }
                    modifier = {
                            factor = 2.0
                            age = 51
                            OR = {
                                num_of_children == 0
                                trait = gluttonous
                                trait = lithe
                                trait = slender
                            }
                                
                    }
                }
                
    }

    immediate = {
            clr_character_flag = has_cycle
            clr_character_flag = menstruating
            clr_character_flag = ovulating
            set_character_flag = menopausal
            f_shape_grows = yes
    }    


    
}

Your solution certainly looks easier. Being lazy myself, I'll remeber this for next time :)

I just see that I forgot to copy the commands into each random block.

 

Do you think this  will work? ( I haven't tested it yet ) and if so will it be very different in outcome from yours?

The thing I am unsure about is, if the event fires on a character of 40 years old, the chance of it producing an effect should be in the 3.75% to 7.5% range. So the chances of a no effect  should be high. Does a random_list deliver that?

 

As for days = , in this event there is no need to fire it on a specific date the event should work its effects sometime between age 40 and 50 with the chance increasing as age get higher.

Link to comment
12 minutes ago, joemann said:

While waiting for your answer ( which is really helpful ! ) I pursued my other idea, and came up with the following, using a random list:

 

  Hide contents

## onset of menopause
character_event = {
id = RSLB.904
hide_window = yes
is_triggered_only = yes  ## by on_action on yearly pulse
only_women = yes

 


    trigger = {    
            has_character_flag = has_cycle
            age = 40
            is_female = yes
            NOT = { has_character_flag = menopausal }

    }    
    random_list = {
                5 = {        
                    modifier = {
                            factor = 0.75
                            age = 40
                            OR = {
                                num_of_children = 2
                                trait = temperate
                                trait = curvaceous
                                trait = voluptuous
                            }
                                
                    }
                    modifier = {
                            factor = 1.25
                            age = 40
                            OR = {
                                num_of_children == 0
                                trait = gluttonous
                                trait = lithe
                                trait = slender
                            }
                                
                    }
                }
                5 = {
                    modifier = {
                            factor = 0.75
                            age = 41
                            OR = {
                                num_of_children = 2
                                trait = temperate
                                trait = curvaceous
                                trait = voluptuous
                            }
                                
                    }
                    modifier = {
                            factor = 1.35
                            age = 41
                            OR = {
                                num_of_children == 0
                                trait = gluttonous
                                trait = lithe
                                trait = slender
                            }
                                
                    }
                }
                6 = {
                    modifier = {
                            factor = 0.75
                            age = 42
                            OR = {
                                num_of_children = 2
                                trait = temperate
                                trait = curvaceous
                                trait = voluptuous
                            }
                                
                    }
                    modifier = {
                            factor = 1.45
                            age = 42
                            OR = {
                                num_of_children == 0
                                trait = gluttonous
                                trait = lithe
                                trait = slender
                            }
                                
                    }
                }
                6 = {
                    modifier = {
                            factor = 0.80
                            age = 43
                            OR = {
                                num_of_children = 2
                                trait = temperate
                                trait = curvaceous
                                trait = voluptuous
                            }
                                
                    }
                    modifier = {
                            factor = 1.50
                            age = 43
                            OR = {
                                num_of_children == 0
                                trait = gluttonous
                                trait = lithe
                                trait = slender
                            }
                                
                    }
                }
                8 = {
                    modifier = {
                            factor = 0.90
                            age = 44
                            OR = {
                                num_of_children = 2
                                trait = temperate
                                trait = curvaceous
                                trait = voluptuous
                            }
                                
                    }
                    modifier = {
                            factor = 1.55
                            age = 44
                            OR = {
                                num_of_children == 0
                                trait = gluttonous
                                trait = lithe
                                trait = slender
                            }
                                
                    }
                }
                10 = {
                    modifier = {
                            factor = 0.95
                            age = 45
                            OR = {
                                num_of_children = 2
                                trait = temperate
                                trait = curvaceous
                                trait = voluptuous
                            }
                                
                    }
                    modifier = {
                            factor = 1.60
                            age = 45
                            OR = {
                                num_of_children == 0
                                trait = gluttonous
                                trait = lithe
                                trait = slender
                            }
                                
                    }
                }
                12 = {
                    modifier = {
                            factor = 0.95
                            age = 46
                            OR = {
                                num_of_children = 2
                                trait = temperate
                                trait = curvaceous
                                trait = voluptuous
                            }
                                
                    }
                    modifier = {
                            factor = 1.60
                            age = 46
                            OR = {
                                num_of_children == 0
                                trait = gluttonous
                                trait = lithe
                                trait = slender
                            }
                                
                    }
                }
                13 = {
                    modifier = {
                            factor = 1.0
                            age = 47
                            OR = {
                                num_of_children = 2
                                trait = temperate
                                trait = curvaceous
                                trait = voluptuous
                            }
                                
                    }
                    modifier = {
                            factor = 1.65
                            age = 47
                            OR = {
                                num_of_children == 0
                                trait = gluttonous
                                trait = lithe
                                trait = slender
                            }
                                
                    }
                }
                25 = {
                    modifier = {
                            factor = 1.05
                            age = 48
                            OR = {
                                num_of_children = 2
                                trait = temperate
                                trait = curvaceous
                                trait = voluptuous
                            }
                                
                    }
                    modifier = {
                            factor = 1.75
                            age = 48
                            OR = {
                                num_of_children == 0
                                trait = gluttonous
                                trait = lithe
                                trait = slender
                            }
                                
                    }
                }
                15 = {
                    modifier = {
                            factor = 1.10
                            age = 49
                            OR = {
                                num_of_children = 2
                                trait = temperate
                                trait = curvaceous
                                trait = voluptuous
                            }
                                
                    }
                    modifier = {
                            factor = 1.85
                            age = 49
                            OR = {
                                num_of_children == 0
                                trait = gluttonous
                                trait = lithe
                                trait = slender
                            }
                                
                    }
                }
                50 = {
                    modifier = {
                            factor = 1.10
                            age = 50
                            OR = {
                                num_of_children = 2
                                trait = temperate
                                trait = curvaceous
                                trait = voluptuous
                            }
                                
                    }
                    modifier = {
                            factor = 1.95
                            age = 50
                            OR = {
                                num_of_children == 0
                                trait = gluttonous
                                trait = lithe
                                trait = slender
                            }
                                
                    }
                }
                80 = {
                    modifier = {
                            factor = 1.20
                            age = 51
                            OR = {
                                num_of_children = 2
                                trait = temperate
                                trait = curvaceous
                                trait = voluptuous
                            }
                                
                    }
                    modifier = {
                            factor = 2.0
                            age = 51
                            OR = {
                                num_of_children == 0
                                trait = gluttonous
                                trait = lithe
                                trait = slender
                            }
                                
                    }
                }
                
    }

    immediate = {
            clr_character_flag = has_cycle
            clr_character_flag = menstruating
            clr_character_flag = ovulating
            set_character_flag = menopausal
            f_shape_grows = yes
    }    


    
}

 

Do you think this  will work?

I don't need to test it to tell you that it absolutely, 100% will not work.

random_list is an effect, not a trigger or a replacement for MTTH or weighted_modifier. For random_list to work, stick it in the immediate field. But even then it wouldn't do anything because each portion of the random_list has no effects, only modifiers

Link to comment

Alternatively, try this:

 

# on_actions.txt

on_yearly_pulse = {
	events = {
		blah.1
	}
}


# events

character_event = {
	id = blah.1
	hide_window = yes
	is_triggered_only = yes
	trigger = {
		is_female = yes
		age = 40
		NOT = {
			has_character_flag = started_menopause
		}
	}

	immediate = {
		set_character_flag = started_menopause
	}
}

character_event = {
	id = blah.2
	desc = blahblah
	picture = GFX_blahblah
	title = blahblahT
	trigger = {
		has_character_flag = started_menopause
		NOT = {
			age = 46
		}
	}

	mean_time_to_happen = {
		days = 912 # The average of five years
	}

	option = {
		name = blahblahblah
		clr_character_flag = started_menupause
		clr_character_flag = has_cycle
		clr_character_flag = menstruating
		clr_character_flag = ovulating
		set_character_flag = menopausal
		f_shape_grows = yes
	}
}

Two simple events. The first is called by on_yearly_pulse when your character is 40 or over and starts the timer. On a MTTH of 912 days (from 40 to 45, averaged), the next event will fire. Simple and effective for what you need.

Link to comment

An other question on MTTH. The above event is triggered only once for each character that fulfills the trigger conditions. So I suppose  the MTTH calculation is only made once as well.

So if I have a female character that reaches the age of 40, the calculation to see at what date she will be become menopausal is made in the year that she reaches 40, according to the criteria of the MTTH formula. The outcome of the calculation is, I suppose, a future date. This may result in the corresponding commands being implemented anywhere between ages 40 to 50.

 

Now I have added modifiers, because I want the chance of a higher age to be much higher than a lower age. Here is an example:

Spoiler

modifier = {
                                    factor = 1.25
                                    age = 44
                                    OR = {
                                        num_of_children == 0
                                        trait = gluttonous
                                        trait = lithe
                                        trait = slender
                                    }
                                        
                            }

My question is, if the MTTH calculation is made at age 40 does it take into account the modifier, which contains a higher age than the current age, to determine the date on which the commands are implemented or will it just ignore the modifier?

Link to comment
14 minutes ago, joemann said:

An other question on MTTH. The above event is triggered only once for each character that fulfills the trigger conditions. So I suppose  the MTTH calculation is only made once as well.

So if I have a female character that reaches the age of 40, the calculation to see at what date she will be become menopausal is made in the year that she reaches 40, according to the criteria of the MTTH formula. The outcome of the calculation is, I suppose, a future date. This may result in the corresponding commands being implemented anywhere between ages 40 to 50.

 

Now I have added modifiers, because I want the chance of a higher age to be much higher than a lower age. Here is an example:

  Hide contents

modifier = {
                                    factor = 1.25
                                    age = 44
                                    OR = {
                                        num_of_children == 0
                                        trait = gluttonous
                                        trait = lithe
                                        trait = slender
                                    }
                                        
                            }

My question is, if the MTTH calculation is made at age 40 does it take into account the modifier, which contains a higher age than the current age, to determine the date on which the commands are implemented or will it just ignore the modifier?

 

The MTTH is for the entire event, but you can indeed modify it for age. For example:

 

factor = x

age = 42

 

factor = x

age = 43

 

factor = x

age = 44

 

If your character is 42 and the event hasn't fired yet, the modifier will reduce/add to the MTTH by x. If your character is 43, then it will reduce/add to the MTTH by x, along with the modifier for being 42. If your character is 44, the same, but you're adding in the modifiers from 43 and 42, further reducing or increasing the MTTH with every age. If you just want a flat MTTH modifier for each age, then use age == x instead of age = x.

 

Note that mean_time_to_happen is different from weight_multiplier. With weight_multipler, higher numbers in the factor will increase the chance of the event firing. With MTTH, higher numbers will reduce the chance of the event firing. If you're going with increasing the chances with age, use 0.75 instead of 1.25, otherwise you're actually adding to the MTTH counter instead of decreasing it.

Link to comment

Got it! I didn't realize that the modifiers would be cumulative. I think the event works as it should now. However, I think I am going to see if I can get the age on which the mother became menopausal into the equation. So expect me back ?

 

When I started doing this almost a year ago I had never done any programming or modding. I am really enjoying this now, although I still find it very difficult at times. I wouldn't be able to do this without the help from people on this forum, so a big thanks!

 

 

Link to comment

I've recently started working on a total conversion mod for my own use as a sort of inspirational basis for a future DND setting. I'm trying to implement elves and am running into some issues with the game's implementation of immortality. I have essentially copied the Elder Kings system which assigns a racial trait with immortal = yes based on portrait gfx. The event runs on startup, birth and 5 year pulses. I've added around a hundred or so elves to the history files and they all get assigned the correct trait but a handfull of them are using child portraits. If I look at the save files these characters have a line saying Immortal = 8 or similar. The game seems to be assigning a random biological age to all my elves, although it seems that who gets what age isn't changing between sessions. I guess my question is, is there a way to set the immortal = x modifier either in the history files or through an event? Adding immortal = 25 to the character files seem to do nothing.

 

On another note, is it possible to effectively create character and title history from a save file? I'd love to be able to generate the worlds history, rather than just setting it all up manually.

 

Edit: I found the answer litterally five minutes after posting. Derp. The biological age of a character can be set by immortal_age=x in the character files, as described on the Character Modding page on the Wiki. If anyone has some insight on the history/save file thing I'd love to hear it though.

Link to comment
1 hour ago, rutars said:

On another note, is it possible to effectively create character and title history from a save file? I'd love to be able to generate the worlds history, rather than just setting it all up manually.

Kind of? It depends on how much work you really want to put into it.

 

In a normal character file, this is what a character looks like:

 

99889900 = {
	name="Kekvit"
	disallow_random_traits = yes
	dynasty = 9051300
	female = yes
	religion = lolth
	culture = drow
	health = 15
	fertility = 0 # No random kiddies
	trait = fair
	trait = genius
	trait = mastermind_theologian
	trait = mystic
	trait = big_tits
	trait = lustful
	trait = houseirae_drow
	trait = homosexual # Technically bisexual, but leans toward women
	trait = houseirae_drow_portrait27 # Kekvit's custom portrait					
	trait = houseirae_matron_mother # Makes Kekvit Immortal to bypass DW's immortal suicide mechanic
	trait = twin
	mother = 99889902	
	700.1.1={
		birth=yes
	}
	2000.1.1={
		death=yes
	}
}

 

 

Whereas this is what a character looks like in an uncompressed save file:

 

		99891804=
		{
			bn="Najib"
			b_d="832.12.12"
			att={8 3 8 8 5}
			traits={15 995 73 89 80 78 }
			rel="sunni"
			cul="bedouin_arabic"
			dna="ubrgowelzej"
			prp="egtffh000000000000"
			gov=republic_government
			fer=0.400
			health=6.000
			prs=10.000
			piety=5.000
			job="job_chancellor"
			wealth=23.15472
			emp=99891804
			host=167710
			emi=2.25329
			eme=0.67593
			eyi=27.03955
			eypi=27.03955
			lgr=
			{
				lastmonthincometable={2.05328 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.20001 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000}
				lastmonthexpensetable={0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.67593 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000}
				lastmonthincome=2.25329
				lastmonthexpense=0.67593
			}
			flags=
			{
				dw_junk_checked=867.1.1
				dw_virginity_checked=867.1.1
			}
			vars=
			{
				breast_size=3.000
				dick_size=2.000
			}
			cpos="pragmatist"
			dmn=
			{
				capital="b_hargeysa"
				liege_troops=
				{
					light_infantry_f=16.000
					archers_f=8.250
				}
				my_liegelevy_contribution=24
			}
		}

 

 

You're probably better off doing it by hand.

Link to comment
1 hour ago, lockeslylcrit said:

You're probably better off doing it by hand.

I guess I was hoping that someone had wrote a script that built character and province history files from a save file. If I had a little more experience with coding I would certainly try writing it myself. My hope is to be able to generate hundreds or even thousands of years of history, but I guess I can just let it run for a while and then extract all the important bits from the save file into a bookmark.

Link to comment

I'm trying to execute an event on_marriage for characters with a specific trait that removes the new spouse if they don't also have a said trait. I'm just not clear on how to use scopes here to make sure the event fires for the correct character. With the code below, the event does fire but it fires for the liege. The wiki says that the on_marriage action uses ROOT as the liege and FROM as one of the spouses. How do i redirect this event to trigger and execute for the FROM rather than the ROOT?

character_event = {
    id = arkan.1
    # desc = arkan0d
    hide_window = yes
    hide_from = yes
    
    is_triggered_only = yes

    trigger = {
        culture = arkan
        trait = pure_arkan
        #ai = yes
        spouse = {
            NOT = { trait = pure_arkan } 
        }
    }
    
    immediate = { remove_spouse = spouse }
    }  
}

 

The Wiki says that the syntax is like this:

 

trigger = {
    <scope_name> = {
        #Conditions to be met by at least one entity in the scope for the trigger to evaluate to true
    }
}

 

and for effects:

 

effect = {
    <scope_name> = {
        limit = { #Optional limit block (valid only for any_* and random_* scopes)
            #Further conditions to filter entities matched by the scope
        }
        #Commands to apply each entity in the scope
    }
}

 

But adding FROM ={ } around the trigger conditions and the "immediate" breaks the event it seems.

Link to comment
19 minutes ago, rutars said:

character_event = {
    id = arkan.1
    # desc = arkan0d
    hide_window = yes
    hide_from = yes
    
    is_triggered_only = yes

    trigger = {
        culture = arkan
        trait = pure_arkan
        #ai = yes
        spouse = {
            NOT = { trait = pure_arkan } 
        }
    }
    
    immediate = { remove_spouse = spouse }
    }  
}

You have an extra end bracket in your immediate.

 

Should be:

character_event = {
    id = arkan.1
    # desc = arkan0d
    hide_window = yes
    hide_from = yes
    
    is_triggered_only = yes

    trigger = {
        culture = arkan
        trait = pure_arkan
        #ai = yes
        spouse = {
            NOT = { trait = pure_arkan } 
        }
    }
    
    immediate = { remove_spouse = spouse }

}

 

 

When in doubt, use the Validator

Link to comment

Taking a further look into the code and the wiki, it says that ROOT is the liege. Whenever you see ROOT, that means that's who the event scopes to. Using remove_spouse = spouse will actually remove YOUR spouse, not the spouse of the one getting married. FROM is the courtier of ROOT, the one who is getting married. new_character is the new spouse of FROM.

 

Taking this into account, I believe this should work out for you:

 

    trigger = {
		OR = {
			FROM = {
				culture = arkan
				trait = pure_arkan
				#ai = yes
				spouse = {
					NOT = { trait = pure_arkan } 
				}
			}
			new_character = {
				culture = arkan
				trait = pure_arkan
				#ai = yes
				spouse = {
					NOT = { trait = pure_arkan } 
				}
			}
		}
    }
    
    immediate = { 
		FROM = {
			remove_spouse = spouse 
		}
	}

This way, the event will trigger if your courtier is pure_arkan but their spouse is not, or the third party spouse is pure_arkan but your courtier is not.

Link to comment
35 minutes ago, lockeslylcrit said:

Taking a further look into the code and the wiki, it says that ROOT is the liege. Whenever you see ROOT, that means that's who the event scopes to. Using remove_spouse = spouse will actually remove YOUR spouse, not the spouse of the one getting married. FROM is the courtier of ROOT, the one who is getting married. new_character is the new spouse of FROM.

Yes, this is exactly what happens with my original code.

Quote

 

Taking this into account, I believe this should work out for you:

This is what I tried before and it seems the event stops functioning all together. It doesn't do anything when I marry my ruler or any of their courtiers. Activating the event with the console gives me nothing. The console returns this:

Command broadcasted
MrHuman ran command event arkan.1
(X) One of these must be true:

Executed #1200001

And nothing happens. When I run the event without the extra OR statement I still get nothing and the console returns this:

Command broadcasted
MrHuman ran command event arkan.1

Executed #1200001

So it seems that adding FROM = {} to the immediate effects and the trigger conditions isn't sufficient to actually redirect the event.

Link to comment
22 minutes ago, rutars said:

And nothing happens.

That's because you are using the event console command to run an on_action event that requires both a second and third party. Since the on_marriage goes to the liege and not the person getting married, you'll need to test the event normally rather than use a console command. Use the add_trait console command to set up a character, then get them married and see what happens. Report back with the results and I'll see if I can further refine the event for you if it doesn't work.

Link to comment

I've tested both marrying my ruler (who has the trait and a liege of his own) to a courtier without the trait, and marrying two courtiers together (only one of whom has the trait). The result is the same regardless.

 

The original code runs as expected, with my ruler and his new trait-less wife being divorced the second I marry the two courtiers together.

Link to comment
22 minutes ago, rutars said:

I've tested both marrying my ruler (who has the trait and a liege of his own) to a courtier without the trait, and marrying two courtiers together (only one of whom has the trait). The result is the same regardless.

 

The original code runs as expected, with my ruler and his new trait-less wife being divorced the second I marry the two courtiers together.

It's clear that the event works as intended for ROOT, but we now need to figure out why FROM and new_character are not working. Try this:

 

Spoiler

character_event = {
    id = arkan.1
    # desc = arkan0d
    hide_window = yes
    hide_from = yes
    
    is_triggered_only = yes

    trigger = {
		OR = {
			FROM = {
				culture = arkan
				trait = pure_arkan
				#ai = yes
				new_character = {
					NOT = { trait = pure_arkan } 
				}
			}
			new_character = {
				culture = arkan
				trait = pure_arkan
				#ai = yes
				FROM = {
					NOT = { trait = pure_arkan } 
				}
			}
		}
    }
    
    immediate = { 
		FROM = {
			remove_spouse = spouse 
		}
		new_character = {
			remove_spouse = spouse 
		}		
	}
}

 

 

Link to comment
7 minutes ago, rutars said:

Still nothing. Could I maybe get around this by defining a scripted trigger and a scripted effect, and then running those via the event instead? I guess I would still have to be able to refer to FROM in the event though.

?

 

Instead of remove_spouse, try a separate character event.

 

    immediate = { 
		FROM = {
			character_event = { id = arkan.2 }
		}
	}
character_event = {
    id = arkan.2
    # desc = arkan0d
    hide_window = yes
    hide_from = yes
    
    is_triggered_only = yes

	immediate = {
		remove_spouse = spouse
	}
}

 

Link to comment

Still nothing. Posting the full event code here if you want to double check it.

 

character_event = {
    id = arkan.1
    # desc = arkan0d
    hide_window = yes
    hide_from = yes
    
    is_triggered_only = yes

    trigger = {
		OR = {
			FROM = {
				culture = arkan
				trait = pure_arkan
				#ai = yes
				new_character = {
					NOT = { trait = pure_arkan } 
				}
			}
			new_character = {
				culture = arkan
				trait = pure_arkan
				#ai = yes
				FROM = {
					NOT = { trait = pure_arkan } 
				}
			}
		}
    }
    
    immediate = { 
		FROM = {
			character_event = { id = arkan.2 }
		}
	}
}
character_event = {
    id = arkan.2
    # desc = arkan0d
    hide_window = yes
    hide_from = yes
    
    is_triggered_only = yes

	immediate = {
		remove_spouse = spouse
	}
}

 

Edit: I tried running arkan.2 by itself and it works fine.

Link to comment
13 minutes ago, rutars said:

Edit: I tried running arkan.2 by itself and it works fine.

When in doubt, scrap the whole on_marriage event.

 

character_event = {
    id = arkan.1
    # desc = arkan0d
    hide_window = yes
    hide_from = yes
    
    mean_time_to_happen = {
		days = 1
	}

    trigger = {
		culture = arkan
		trait = pure_arkan
		#ai = yes
		spouse = {
			NOT = { trait = pure_arkan } 
		}
    }
    
    immediate = { 
		remove_spouse = spouse
	}
}

 

This standalone event is not called by on_marriage, but rather it will rely solely on MTTH. It may take a day or two to fire.

Link to comment

That does work! I would have preferred for it to be instantaneous but in the end I can't come up with a good reason as to why. Thank you so much for the help!

 

Is there a way to add a modifier to the divorcee that makes them not try to marry again for a year or so?

Link to comment
12 minutes ago, rutars said:

That does work! I would have preferred for it to be instantaneous but in the end I can't come up with a good reason as to why. Thank you so much for the help!

 

Is there a way to add a modifier to the divorcee that makes them not try to marry again for a year or so?

Unfortunately, you're delving into the realm of divorce and marriage, both of which are hardcoded. What is NOT hardcoded, however, is the cannot_marry modifier for traits. Make your own (hidden) trait with cannot_marry = yes, assign that trait to the above event, and then add in a character event to remove it a year later.

 

Spoiler

character_event = {
    id = arkan.1
    # desc = arkan0d
    hide_window = yes
    hide_from = yes
    
    mean_time_to_happen = {
		days = 1
	}

    trigger = {
		culture = arkan
		trait = pure_arkan
		#ai = yes
		spouse = {
			NOT = { trait = pure_arkan } 
		}
    }
    
    immediate = { 
		remove_spouse = spouse
	}
}

 

 

Becomes:

Spoiler

character_event = {
    id = arkan.1
    # desc = arkan0d
    hide_window = yes
    hide_from = yes
    
    mean_time_to_happen = {
		days = 1
	}

    trigger = {
		culture = arkan
		trait = pure_arkan
		#ai = yes
		spouse = {
			NOT = { trait = pure_arkan } 
		}
    }
    
    immediate = { 
		remove_spouse = spouse
		add_trait = blahblahcannotmarrytrait
		character_event = { id = arkan.2 days = 365 }
	}
}

character_event = {
    id = arkan.2
    # desc = arkan0d
    hide_window = yes
    hide_from = yes
	is_triggered_only = yes
    
    immediate = { 
		remove_trait = blahblahcannotmarrytrait
	}
}

 

 

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