Jump to content

CK2 Modding Quick Question Thread


Recommended Posts

17 minutes ago, lockeslylcrit said:

instead of using is_triggered_only, use mean_time_to_happen

 

https://ck2.paradoxwikis.com/Event_modding#Mean_Time_to_Happen

I had tried that with a trait I had made, with the mean time to happen being set to 20 days, though it had seemed that every AI in my game had gained the trait. But it was probably an error on my part, with 20 days being too short of a time. 

But thank you, I'll look over that again and see if everything works out. 

Link to comment

Gentlemen, I have a serious question about CK2 mod coding.

 

It's about the priority. As we know, lots of in-game features are linked to culture, religion, government, etc. Like some culture (Norse, Berber) can enable raiding regardless of religion, and some government form can only be available if playing as certain religion (Monastic Feudal for Bonist).

 

My question is, when these conditions contradict with each other (say a Berber Jain, or a Nahua Cathar), how would the game engine determine which code could override the other one? Is there some kind of priority ranking within the game engine, or is there some code that i could use in order to achieve AND or OR logic between all these modifiers across different files?

 

Furthermore, is there any code I could use in order to disable certain effect without changing vanilla files(e.g. a decision or event that prevent castrating or blinding prisoners as Greeks, without editing the culture.txt file)?

Link to comment

I created a second  character within the new_character block of a previously created character. So the second newly created character becomes a courtier of the first new character.

I would like the second new character to be a prisoner. I have tried various options but I can't get it done. I'm probably mixing my scopes.

 

Spoiler

province_event = {
    id = RSLT.2
    hide_window = yes
    is_triggered_only = yes        
# There must be a Count in the Duchy of Moravia or the Duchy of Pomerania for this to trigger.
    trigger = {
        any_landed_title = {
            tier = COUNT
            OR = {
                kingdom = {
                    title = k_moravia
                }
                duchy = {
                    title = d_pommerania
                }
            }
            
        }
    }
    immediate = {
            random_landed_title = {            # Get a random character in the Ducky of Pomerania or Moravia, preferably an independent king or duke. Save them as slaver_target and their primary title as title_target
                        limit = {
                            tier = COUNT
                            OR = {
                                kingdom = {
                                title = k_moravia
                                }
                                duchy = {
                                title = d_pommerania
                                }
                            }
                        }            
                        preferred_limit = {
                                        owner = {
                                            OR = {
                                                AND = {
                                                    independent = yes
                                                    tier = COUNT
                                                }
                                                    top_liege = {
                                                            tier = COUNT
                                                    }
                                            }
                                        }
                        }
                        preferred_limit = {
                                        owner = {
                                            OR = {
                                                AND = {
                                                    independent = yes
                                                    tier = DUKE
                                                }
                                                    top_liege = {
                                                            tier = DUKE
                                                    }
                                            }
                                        }
                        }
                        preferred_limit = {
                                        owner = {
                                            OR = {
                                                AND = {
                                                    independent = yes
                                                    tier = KING
                                                }
                                                    top_liege = {
                                                            tier = KING
                                                    }
                                            }
                                        }
                        }
                        owner = {
                                save_event_target_as = rsl_slaver_target
                        }        
                        kingdom = {
                                save_event_target_as = rsl_title_target
                        }
                        
                        owner = {
                                capital_scope = {
                                                PREV = {    
                                                    create_random_soldier = {
                                                                    random_traits = yes
                                                                    dynasty = none
                                                                    religion = pagan
                                                                    culture = norse
                                                                    age = 25
                                                                    
                                                    }
                                                    # Give him all the slave trader traits, a landless Count-tier title, and an army
                                                    new_character = {                                
                                                        save_event_target_as = rsl_slave_trader
                                                        add_trait = brave
                                                        add_trait = ambitious
                                                        add_trait = greedy
                                                        add_trait = cruel
                                                        set_focus = focus_business
                                                        add_ambition = obj_amass_wealth
                                                        wealth = 200                      # give him some starting capital
                                                        set_character_flag = slave_trader
                                                        set_defacto_liege = THIS
                                                        create_title = {
                                                                    tier = COUNT
                                                                    culture = THIS
                                                                    landless = yes
                                                                    adventurer = yes
                                                                    name = "SLAVE_TRADER"
                                                                    holder = THIS
                                                                    ruler = "CAPTAIN"
                                                        }
                                                                    
                                                        spawn_unit = {
                                                                province = PREVPREV #goes to owners capital scope
                                                                home = PREVPREV        #goes to owners capital scope
                                                                owner = THIS
                                                                troops = {
                                                                        light_infantry = { 4000 4000 }
                                                                }
                                                                attrition = 0
                                                                is_looter = yes
                                                                can_toggle_looting = no
                                                                
                                                        }
                                                        any_army = {
                                                                set_can_toggle_looting = no
                                                                set_looting = yes
                                                        }
                                                        create_character = {                # Give him some inventory
                                                                        random_traits = no
                                                                        name =  Anna
                                                                        dynasty = NONE
                                                                        female = yes
                                                                        age = 20
                                                                        culture = italian
                                                                        religion = catholic
                                                                        attributes = {
                                                                                        martial = 6
                                                                                        diplomacy = 10
                                                                                        stewardship = 6
                                                                                        intrigue = 14
                                                                                        learning = 7
                                                                        }
                                                                        health = 5
                                                                        fertility = 0.8
                                                                        trait = slave
                                                                        trait = average
                                                                        trait = curvaceous
                                                                        trait = big_tits
                                                                        trait = small_pussy
                                                                        trait = regular_butt_f
                                                                        trait = tiny_anus
                                                                        trait = attractive
                                                                        trait = proud
                                                                        trait = greedy
                                                                        trait = lustful
                                                                        trait = cynical
                                                                        trait = seductress    
                                                                        flag = rsl_slave_1
                                                        }
                                                    
                                                                        
                                                                        
                                                                    
                                                                    
                                                    }
                                                    
                                                }
                                }
                                
                        }    
                
            }
            event_target:rsl_slave_trader = {
                                                   any_courtier = {
                                                                     limit = {
                                                                        has_character_flag = rsl_slave_1
                                                                   }
                                                     }            
                                                    imprison = yes
            }    

                    
            any_player = {  
                    narrative_event = { id = RSLT.4 days = 5 }        
            }                                
    }
}

Where should this go?

Link to comment
10 hours ago, figandsalt said:

Gentlemen, I have a serious question about CK2 mod coding.

 

It's about the priority. As we know, lots of in-game features are linked to culture, religion, government, etc. Like some culture (Norse, Berber) can enable raiding regardless of religion, and some government form can only be available if playing as certain religion (Monastic Feudal for Bonist).

 

My question is, when these conditions contradict with each other (say a Berber Jain, or a Nahua Cathar), how would the game engine determine which code could override the other one? Is there some kind of priority ranking within the game engine, or is there some code that i could use in order to achieve AND or OR logic between all these modifiers across different files?

 

Furthermore, is there any code I could use in order to disable certain effect without changing vanilla files(e.g. a decision or event that prevent castrating or blinding prisoners as Greeks, without editing the culture.txt file)?

For event desc and picture, if two or more conditions exist such as...
 

Spoiler

	desc = {
		trigger = {
			has_character_flag = condition1
			}
		text = text1
	}
	desc = text2

 

Then the game will randomly pick from all available choices. In this case, if you don't have the character flag condition1, then only text2 will be displayed. If you have the character flag, then the game will randomize between text1 and text2.

 

For if/else_if/else, it works in that order.

Spoiler

if = {
	limit = {
		has_character_flag = condition1
	}
	<commands here>
}
else_if = {
	limit = {
		has_character_flag = condition2
	}
	<more commands here>
}
else_if = {
	limit = {
		has_character_flag = condition3
	}
	<more commands here>
}
else = {
	<fallback commands here>
}

 

if is checked first. If that limit returns false, then it moves on to the else_if. If that condition returns false, it then checks the next else_if. If all conditions return false, else is the fallback. Note that else and else_if are entirely optional. In the case of having only if, and that condition returns false, nothing happens.

In the case of having two or more if blocks...

Spoiler

if = {
	limit = {
		has_character_flag = condition1
	}
	<commands here>
}
if = {
	limit = {
		has_character_flag = condition2
	}
	<more commands here>
}

 

Both blocks will be checked, and the appropriate commands will fire.

 

If you want priorities set up, then you'll need to manually set up them using preferred_limit in a random_* scope

Spoiler

random_courtier_or_vassal = {
	limit = {
		religion = catholic
	}
	preferred_limit = {
		culture = irish
	}
	preferred_limit = {
		culture = frankish
	}
	preferred_limit = {
		culture = welsh
	}
	<commands here>
}

 

limit is the hard condition. Any courtier or vassal who is not catholic will be skipped. Then the game picks from a list using the top preferred_limit as the first priority. If any courtier or vassal isn't irish, it then checks for frankish, and then welsh. If none of those are true, the commands wont fire.

 

You can also set up priorities in an if block too using AND, OR, NAND, NOR, NOT, etc.

Spoiler

if = {
	limit = {
		NAND = {
			religion = catholic
			OR = {
				culture = irish
				culture = frankish
				culture = welsh
			}
		}
	}
	<commands here>
}
else_if = {
	limit = {
		religion = catholic
		OR = {
			culture = irish
			culture = frankish
			culture = welsh
		}
	}
	<commands here>
}

 

NAND means that one or more condition can work, but if all conditions are true, then the limit block returns false. In other words, you could have a Catholic character that isn't Irish, French, or Welsh (or vice versa - Irish/French/Welsh but not Catholic), it will do the commands. If the character is BOTH Catholic and either Irish, French, or Welsh, then the code skips that and moves on to the else_if block.

Link to comment
6 hours ago, joemann said:

            event_target:rsl_slave_trader = {
                                                   any_courtier = {
                                                                     limit = {
                                                                        has_character_flag = rsl_slave_1
                                                                   }
                                                     }            
                                                    imprison = yes
            }  

Well, first of all, your imprison = yes is in the wrong place. You are actually going to imprison the slave trader, not the slave. Move that line up one above the brace so that it is the any_courtier that is imprisoned.

 

Second, you can define scopes in imprison. You can change it to imprison = event_target:rsl_slave_trader if you specifically want the courtier to be imprisoned by the slave trader.

Link to comment

Thank you. It works and it doesn't. I think it works because if I use this, in game the courtier does not show up any more. If I combine this with the fact that the slave trader  while amassing huge amounts of gold while looting does not capture  a single prisoner the conclusion seems to be that a landless character can not have prisoners.

 

The wiki on create_title mentions:

 

"Landless dynamic titles require a landed home province to both hold prisoners and to act as a fallback if the title gets destroyed. This command should be run from the home province scope, otherwise the whole court will end up stuck in province 0 when the holder dies. "

 

So to hold prisoners I apparently need a landed home province but how does a landless character get a landed home province ? ( there seems to be a contradiction here)

 

I tried setting landless to no but the new_character then does not appear?

Link to comment
18 minutes ago, joemann said:

Thank you. It works and it doesn't. I think it works because if I use this, in game the courtier does not show up any more. If I combine this with the fact that the slave trader  while amassing huge amounts of gold while looting does not capture  a single prisoner the conclusion seems to be that a landless character can not have prisoners.

 

The wiki on create_title mentions:

 

"Landless dynamic titles require a landed home province to both hold prisoners and to act as a fallback if the title gets destroyed. This command should be run from the home province scope, otherwise the whole court will end up stuck in province 0 when the holder dies. "

 

So to hold prisoners I apparently need a landed home province but how does a landless character get a landed home province ? ( there seems to be a contradiction here)

 

I tried setting landless to no but the new_character then does not appear

Take a browse over on House Irae. Laela is basically a modified version of Seljuk, spawning with a landless title and created courtiers and armies.

Link to comment

First you create a regular narrative event (the pop-up) as explained in the event modding page. This must include the line is_triggered_only = yes. Once you have created this event, you go to the on_action file in the common directory of your mod and add the unique id of your event to the relevant on action, in your case on_marriage.

In the on action file it should look like this

 

Spoiler

# Sent to employers of both spouses - ROOT is employer. FROM is employers "employee". new_character is the other spouse.
on_marriage = {
    events = {
        XXX.555  this is the id number of the event
        XXX.33
        
     }
}

 

  In writing the event you must respect the scopes connected to the  specific on_action. In the event modding page you can find a list of the different on action and their scopes.

Link to comment

I copied large parts of the leila files into my event but am still struggling.

Spoiler

#Slave trade events
# Set up  ROOT is Province Slesvig
province_event = {
    id = RSLT.1
    hide_window = yes
    
    
    
    trigger = {
            province = 264 # This only triggers if this province is 264 (Slesvig)
            
            OR = {
                has_building = rsl_slave_market_1
                has_building = rsl_slave_market_2
                has_building = rsl_slave_market_3
                has_building = rsl_slave_dungeon_1
                has_building = rsl_slave_dungeon_2
                has_building = rsl_slave_dungeon_3
                has_building = rsl_slave_wagon_1
                has_building = rsl_slave_wagon_2
                has_building = rsl_slave_wagon_3
                has_building = rsl_slave_wagon_4
                has_building = rsl_slave_wagon_5
                has_building = rsl_slave_port_1
                has_building = rsl_slave_port_2
                has_building = rsl_slave_port_3
                has_building = rsl_slave_pen_1
                has_building = rsl_slave_pen_2
                has_building = rsl_slave_pen_3
            }
            NOT = { has_province_flag = slave_trade_north }
            
    }    
                
    mean_time_to_happen = {
            days = 1
            
    }        
        

    immediate = {
            set_province_flag = slave_trade_north
            
                
        
        # Tell all rulers of the same religion that the slave trade has spawned    
            any_player = {  
                        narrative_event = { id = RSLT.2 }        
            }    
    }
}

# Slave trade has appeared
narrative_event = {
    id = RSLT.2
    title = "The Slave Trade"
    picture = GFX_evt_market
    desc = "The slave trade has appeared in Slesvig"
    is_triggered_only = yes
    
    option = {
        name = OK
        # create slave_trader.
                character_event = {
                id = RSLT.3
                days = 1
                }
    }
}


# Slave_trader created
character_event = {
    id = RSLT.3
    #hide_window = yes
    is_triggered_only = yes    
    
    only_playable = yes                # slave_trader is created in players court
    trigger = {
        NOT = {
            has_character_flag = slave_trader
        }
    }
    immediate = {
            create_random_soldier = {
                                random_traits = yes
                                dynasty = none
                                religion = pagan
                                culture = norse
                                age = 25
                                                                    
            }
            new_character = {                                
                        save_event_target_as = rsl_slave_trader
                        add_trait = brave
                        add_trait = ambitious
                        add_trait = greedy
                        add_trait = cruel
                        set_focus = focus_business
                        add_ambition = obj_amass_wealth
                        set_character_flag = do_not_disturb
                        set_character_flag = slave_trader
            }
    }        
    option = {
        name = ok    
            character_event = {
                id = RSLT.4
                days = 1
            }
    }
}


character_event = {
    id = RSLT.4
    hide_window = yes    
    is_triggered_only = yes
    
    prisoner = no
    only_playable = yes  
    
    trigger = {
        is_alive = yes
        NOT = { trait = blinded }
        NOT = { trait = eunuch }
        NOT = { trait = infirm }
        lower_tier_than = king
    }

    option = { # jaemtland
        trigger = {
            OR = {
                has_game_rule = {
                    name = slave_drive
                    value = slave_drive_random
                }
                has_game_rule = {
                    name = slave_drive
                    value = slave_drive_norway
                }
            }
        }
        
        ai_chance = {
            factor = 50
        }
        
        282 = {
            province_event = {
                id = RSLT.5
                days = 2
            }
        }
        
        clr_character_flag = do_not_disturb
    }

    option = { # Mecklenburg
        trigger = {
            OR = {
                has_game_rule = {
                    name = slave_drive
                    value = slave_drive_random
                }
                has_game_rule = {
                    name = slave_drive
                    value = slave_drive_mecklenburg
                }
            }
        }
        
        ai_chance = {
            factor = 50
        }
        
        260 = {
            province_event = {
                id = RSLT.5
                days = 2
            }
        }
        
        clr_character_flag = do_not_disturb
    }

    option = { # Ostfriesland
        trigger = {
            OR = {
                has_game_rule = {
                    name = slave_drive
                    value = slave_drive_random
                }
                has_game_rule = {
                    name = slave_drive
                    value = slave_drive_frisia
                }
            }
        }
        
        ai_chance = {
            factor = 50
        }
        
        85 = {
            province_event = {
                id = RSLT.5
                days = 2
            }
        }
        
        clr_character_flag = do_not_disturb
    }

    option = { # Novogord
        trigger = {
            OR = {
                has_game_rule = {
                    name = slave_drive
                    value = slave_drive_random
                }
                has_game_rule = {
                    name = slave_drive
                    value = slave_drive_russia
                }
            }
        }
        
        ai_chance = {
            factor = 50
        }
        
        414 = {
            province_event = {
                id = RSLT.5
                days = 2
            }
        }
        
        clr_character_flag = do_not_disturb
    }    
}

# Ping the target province
province_event = {
    id = RSLT.5
    #hide_window = yes
    
    is_triggered_only = yes
    
    option = {
    #immediate = {
        FROM = {
            character_event = {
                id = RSLT.6
            }
        }
    #}
    }
}

# Slave_trader goes on a slave hunt
character_event = {
    id = RSLT.6
    #hide_window = yes
    
    is_triggered_only = yes
    
    prisoner = no
    only_capable = yes
    
    trigger = {
        is_alive = yes
        NOT = { trait = blinded }
        NOT = { trait = eunuch }
        NOT = { trait = infirm }
        lower_tier_than = king
    }
    
    immediate = {
        wealth = 200
        liege = {
            capital_scope = {
                        FROM = {
                            owner = {
                                top_liege = {
                                        ROOT = {
                                            set_defacto_liege = ROOT
                                            create_title = {
                                                    tier = COUNT
                                                    landless = yes
                                                    temporary = no
                                                    adventurer = yes
                                                    culture = ROOT
                                                    name = "SLAVE TRADER"
                                                    holder = ROOT
                                                    ruler = "CAPTAIN"
                                            }
                    
                                            
                    
                                            spawn_unit = {
                                                        province = PREVPREVPREVPREV
                                                        home = PREVPREVPREVPREV        
                                                        owner = THIS
                                                        troops = {
                                                                light_infantry = { 4000 4000 }
                                                        }
                                                        attrition = 0
                                                        is_looter = yes
                                                        can_toggle_looting = no                                            
                                            }
                                            any_army = {
                                                        set_can_toggle_looting = no
                                                        set_looting = yes
                                            }
                    
                                        }
                                }
                            }
                        }
            }
        }
        
                    # Give him some inventory
                    create_character = {    
                                    random_traits = no
                                    name =  Anna
                                    dynasty = NONE
                                    female = yes
                                    age = 20
                                    culture = italian
                                    religion = catholic
                                    attributes = {
                                        martial = 6
                                        diplomacy = 6
                                        stewardship = 6
                                        intrigue = 10
                                        learning = 6
                                        }
                                    health = 5
                                    fertility = 0.8
                                    trait = slave
                                    trait = average
                                    trait = curvaceous
                                    trait = big_tits
                                    trait = small_pussy
                                    trait = regular_butt_f
                                    trait = tiny_anus
                                    trait = attractive
                                    trait = proud
                                    trait = greedy
                                    trait = lustful
                                    trait = cynical
                                    trait = seductress    
                                    flag = rsl_slave_1
                    }
                    new_character = {    
                                set_variable = { which = pussy_size value = 2 }
                                set_variable = { which = butt_size_f value = 3 }
                                set_variable = { which = anus_size value = 1 }
                                set_variable = { which = f_shape_size value = 7 }
                                set_variable = { which = height_size value = 5 }
                                set_variable = { which = breast_size value = 4 }
                                set_character_flag = rsl_virginity_checked
                                set_character_flag = pussy
                                set_character_flag = height
                                set_character_flag = shape
                                set_character_flag = butt
                                set_character_flag = anus
                                set_character_flag = breasts
                                
                    }
                                        
        }

        option = {
        name = ok
        event_target:rsl_slave_trader = {
                                    any_courtier = {
                                                limit = {
                                                    has_character_flag = rsl_slave_1
                                                }
                                                imprison =     event_target:rsl_slave_trader        
                                    }            
                                    
        }    
        any_player = {  
                    narrative_event = { id = RSLT.7 days = 5 }        
            }
    }
}

# Slave drive has started
narrative_event = {
    id = RSLT.7
    title = "The Slave Trade"
    picture = GFX_evt_market
    desc = "A slave war has started"
    is_triggered_only = yes
    
    option = {
        name = OK
        
    }
    
}

 

In game the events 1 ,2 and 3 fire. Event three creates the slave trader in my players court. This did not happen in my previous code and I suppose this is due to the only_playable = yes pre trigger. In my previous version I used ai = yes. Could this be the the condition "Landless dynamic titles require a landed home province to both hold prisoners and to act as a fallback if the title gets destroyed. " That the wiki referes to?

Unhappily I can't verify this because once I click on the ok of event 3 I get thegame ends chronicle pop up. I suppose the error is somewhere in event 4 but I copied the basic structure.

I suppose event 4 determines where the characters army spawns?

 

Ant idea why the game ends suddenly?

 

Link to comment
On 7/1/2019 at 10:00 PM, lockeslylcrit said:

Take a browse over on House Irae. Laela is basically a modified version of Seljuk, spawning with a landless title and created courtiers and armies.

I am still struggling with the scopes. In event Laela.4 could you tell me what are the scopes?

 

Is ROOT one of the four provinces and FROM the new character ( or the player?) The ping event confuses me.

 

Through the trigger who do you want to find? Leila?

 

Link to comment
19 hours ago, joemann said:

I am still struggling with the scopes. In event Laela.4 could you tell me what are the scopes?

 

Is ROOT one of the four provinces and FROM the new character ( or the player?) The ping event confuses me.

 

Through the trigger who do you want to find? Leila?

 

Laela.3 is the ping event. This is used to properly set up the scope for the province. Laela.2 is the character event for Laela to choose which province she goes after.

 

In Laela.2, assuming she picks Novgorod

		414 = {
			province_event = {
				id = Laela.3
				days = 2
			}
		}

ROOT is Laela, FROM is again Laela (chained from Laela.2)

 

In Laela.3

province_event = {
	id = Laela.3
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		FROM = {
			character_event = {
				id = Laela.4
			}
		}
	}
}

ROOT is Novgorod, FROM is Laela. As I've said before, this event is necessary to set up the proper scopes in later events.

 

In Laela.4

	immediate = {
		wealth = 500
		liege = {
			capital_scope = {
				FROM = {
					owner = {
						top_liege = {
							ROOT = {
								set_defacto_liege = ROOT
								create_title = {
									tier = DUKE
									landless = yes
									temporary = yes
									culture = ROOT
									name = "CLAIMANT_ADVENTURE"
									holder = ROOT
								}

ROOT is Laela (because she was assigned the character event from Laela.3), liege is Laela's current liege. capital_scope is the liege's capital province, FROM is the previous event ROOT (Novgorod), owner is whoever owns Novgorod, top_liege is a redundancy check in case whoever owns Novgorod isn't already the top liege, and then back to ROOT which is Laela.

The reason for this complex nesting is to ensure proper scoping using PREV, PREVPREV, PREVPREVPREV, or whatever.

 

Remember:

  1. ROOT is whoever or whatever gets the event.
  2. FROM is the ROOT of the previous event.
  3. PREV is the previous scope.
  4. PREVPREV is two scopes back.
  5. PREVPREVPREV is three scopes back.
  6. FROMFROM is the ROOT of two events back.

And so on and so forth.

Link to comment

Many thanks for this explanation. Scopes have baffled  me since I started modding and the wiki is not very clear on this issue. I am sure I will often come back to this post and not just for the event I am working on now. And now I'll try and get my event working.

Link to comment
3 hours ago, dwjlien said:

It is 100% the best layman friendly explanation of scopes I have ever seen. Actually understandable to people trying to learn, rather than legible to those already well versed in the jargon.

Here's a better explanation:

 

ROOT 

Whoever or whatever the event/decision goes to. In an on_action, the game looks for various triggers (on_birth, on_pregnancy, on_death, etc) and then fires (if the event is guaranteed) for that person in either a character_event, long_character_event, or narrative_event. Whoever triggered it and got the event will be ROOT (some exceptions apply, see the on_actions file).

This also applies to provinces, in the case of province_event. A province can be assigned as ROOT, and is sometimes required in routing events to ensure proper scoping, as seen above.

For decisions, ROOT is the decision target, not the person doing the decision.

 

FROM

FROM is who/whatever is the ROOT of the previous event in a chain (and ONLY in a chain), or is the decision taker in a targetted_decision. Let's say you set up a decision or event chain that has someone else get a character/long_character/narrative_event.

targetted_decisions = {
	blahblah_decision = {
		filter = realm
		ai_target_filter = none
		from_potential = {
			ai = no
		}
		potential = {
			ai = yes
			same_realm = FROM
			is_ruler = yes
		}
		allow = {
			always = yes
		}
		effect = {
			any_courtier = {
				limit = {
					is_female = yes
					is_adult = yes
					ai = yes
					is_lover = FROM
				}
				save_event_target_as = my_lover
			}
			event_target:my_lover = {
				character_event = { id = my_lover.1 }
			}
		}
	}
}

The potential is the person you are targeting, a ruler in the same realm as the decision taker. This is ROOT. from_potential is the person doing the decision, namely you. Now we have a third party as well, as the effect will make a certain courtier of ROOT (again, the target) an event target and fire an event on that target. In the event my_lover.1, the courtier will be the ROOT in this event, and the ruler will be FROM. You, the decision taker will be...

 

FROMFROM

You can stack FROM multiple times (I've only seen it go to x4, though). Each one goes back one event. In the example I gave, the event will fire on the courtier (ROOT), from the ruler (FROM). In this event, you, the decision taker, is FROMFROM, because you were previously FROM. You simply add on one more FROM for each chain.

Do note that the third_party_potential in third party decisions is going to be FROMFROM.

 

PREV

Scopes can be chained with extreme complexity, to ensure you get exactly the result you want.

<province scope> = {
	owner = {
		top_liege = {
			capital_scope = {
				PREV = {
					create_character = {
						blahblahblah
					}
				}
			}
		}
	}
}

In this scope chain, you're starting out in a province (either defined by the id number or whatever else method you choose), then it goes to the owner of that province, then the top liege of the province's owner, then the capital province of the top liege of the province's owner. The capital scope is defined only if you want to do something like create an army. PREV goes back to the top liege scope so that both the capital scope is properly defined in the chain as well as moving the current scope back to a character and not a province.

 

PREVPREV

Like FROMFROM, you can stack on multiple PREV together, and they will go back one scope each time. In the above example, if you changed the PREV to PREVPREV, it would create a character for the owner, not the top liege. If you did PREVPREVPREV, it would create a character for the province and likely crash the game.

 

THIS

Simply put, the current scope you're in. Required for certain things like spawn_army and create_character. Using the above example:

					create_character = {
						culture = THIS
						religion = PREVPREV
					}

Because you're already in the top_liege scope, defined by PREV, the randomly created character would get the culture of THIS (top_liege) but the religion of PREVPREV (province).

 

 

Link to comment
24 minutes ago, rookie189 said:

Quick question, how do I make my mods events use the custom window from Dark World Fantasy rather than the vanilla one?

 

If you are using Dark World Fantasy, use narrative_event instead of character_event. If not, then it requires a butt ton of editing of the interface .gui file with the background dds graphics files thrown in.

Link to comment

So my on_action event works... sort of. The dialogue box shows up, only issue is that the text does not display (i.e. instead of the actual text, it's EVTDESC_xxxx.0001), and it shows up for both rulers — my current character and his wife (who is unplayable).

Link to comment
2 hours ago, manicpixxxie said:

So my on_action event works... sort of. The dialogue box shows up, only issue is that the text does not display (i.e. instead of the actual text, it's EVTDESC_xxxx.0001), and it shows up for both rulers — my current character and his wife (who is unplayable).

What program are you using to edit the localisation.csv? Often word/office puts a     at the start of lines but dont display them.

Open the .csv in notepad++ and check.

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