Jump to content

CK2 Modding Quick Question Thread


Recommended Posts

Posted
16 hours ago, joemann said:

How does the condition <is_dying> work? Does it kick in when health reaches 0 ?

 

I am trying to use it in a trigger for an event but without success.

 

  Hide contents

# death under torture
character_event = {
    id = RSLCourt.5342
    desc = RSLCourt5342
    picture = dead_prisoner
    title = rsl_bungeled
    
    
    trigger = {
            event_target:rsl_victim_target = {
                                            is_dying = yes
                                            OR = {
                                                had_character_flag = { flag = resisting_ransomee days = 7 }
                                                had_character_flag = { flag = resisting_plotter days = 7 }
                                                had_character_flag = { flag = resisting_heretic days = 7 }
                                                had_character_flag = { flag = resisting_slave days = 7 }
                                                has_character_flag = resisting_ransomee
                                                has_character_flag = resisting_plotter
                                                has_character_flag = resisting_heretic
                                                has_character_flag = resisting_slave
                                            }
            }    
    }    
    option = {                        
    
            name = EVTOPT_Court_5343
            death = {
                    death_reason = rsl_death_torture
                    killer = event_target:rsl_player_target
                    
            }
            any_courtier_or_vassal = {
                                    has_minor_title = rsl_court_torturer
                                            
            }
    
            
            prestige = -15
            change_learning = -1
    }
}

I suppose the trigger should work just before the victim dies because all the stats of a dead character seem to disappear (at least in the charinfo of the console) That's why is_dying seemed very promising but it doesn't seem to work. Does anybody have any experience with this?

is_dying only works when the character is in the process of dying.

The only time a character is in the process of dying but isn't actually dead yet is from an on_death event.

Posted

I simplified the event as much as possible, confirmed with charinfo that the  pre_trigger_flag was present but the event refuses to fire. If anyone has a suggestion it would be more than welcome. When are pre-triggers checked before or after death?

Spoiler

# on_death ROOT is the dead character
on_death = {
        events = {
                RSLCourt.5342   #death under torture
        }
}

 

## death under torture
narrative_event = {
    id = RSLCourt.5342
    desc = RSLCourt5342
    picture = dead_prisoner
    title = rsl_bungeled
    
    prisoner = yes
    has_character_flag = in_torture_chamber
    
    is_triggered_only = yes # on_death
    
    trigger = {
            is_dying = yes
    }
    
    
    
    
    
    option = {                        
            name = EVTOPT_Court_5342        
    }
}

 

Posted

When you assign an on_death event, the event fires just before the actual death, so any pre-triggers or triggers will still count as if the character is alive.

 

Try removing the trigger = { is_dying = yes } and try it again

Posted

Tried it, also tried putting in is_dying as a pre-trigger with and without the character_flag. Nothing works. Thanks for your help. I'll leave it alone for a while and then try something else.

Posted

Is there some kind of equation like health = the age you die? If I wanted to have a race die at 250, for example, could that be done by giving it x amount of health (via trait or etc)? Or could that only be done by adding hidden events that randomly kill said race after a certain age?

Posted
11 minutes ago, rookie189 said:

Is there some kind of equation like health = the age you die? If I wanted to have a race die at 250, for example, could that be done by giving it x amount of health (via trait or etc)? Or could that only be done by adding hidden events that randomly kill said race after a certain age?

Higher health allows for a longer lifespan, but there is no known equation as age-related deaths are hardcoded. The other problem with adding health is that they will be much more resistant to disease.

 

A better option would be to add in a hidden trait with immortal = yes on an on_adulthood event, and then remove that trait on a character event with a minimum age and a MTTH (to simulate randomness of age deaths). If you don't want any random factors and just want them to die as a certain age ala Logan's Run, just make an on_yearly_pulse event with age = 250 in the trigger.

Posted
9 minutes ago, lockeslylcrit said:

Higher health allows for a longer lifespan, but there is no known equation as age-related deaths are hardcoded. The other problem with adding health is that they will be much more resistant to disease.

 

A better option would be to add in a hidden trait with immortal = yes on an on_adulthood event, and then remove that trait on a character event with a minimum age and a MTTH (to simulate randomness of age deaths). If you don't want any random factors and just want them to die as a certain age ala Logan's Run, just make an on_yearly_pulse event with age = 250 in the trigger.

Thats what I figured, I've read it pulls a random number, the number increasing with age, and if your health is below the number then you die but I dont know if thats true and even if it is I doubt 100+ was factored in.

 

I've never understood MTTH, does the MTTH only start once the potential/trigger is met? Or is it running all the time just only effecting targets the potential/trigger would apply to?

Posted
4 hours ago, rookie189 said:

I've never understood MTTH, does the MTTH only start once the potential/trigger is met? Or is it running all the time just only effecting targets the potential/trigger would apply to?

Presumably the event will look at the MTTH first and then fire it when appropriate if the trigger is met.

 

If you want a true MTTH that starts counting down only when a character is 250, then use min_age = 250 in the pretriggers. The event will never even be looked at until the pretrigger is met.

Posted
8 hours ago, lockeslylcrit said:

Presumably the event will look at the MTTH first and then fire it when appropriate if the trigger is met.

 

If you want a true MTTH that starts counting down only when a character is 250, then use min_age = 250 in the pretriggers. The event will never even be looked at until the pretrigger is met.

Ok cool, a hidden trait tied to a MTTH event sounds perfect then. Thanks for the help.

Posted

I want to make an event whereby if I have a plotter in my prison I can torture him so that he betrays one or more co_plotters. The first hurdle I encounter is that a plotter is identified as such in charinfo but as soon as he is imprisoned nothing seem to flag him as such. If I have several characters in my prison how do I select the plotter?

I tried using the following (the OR block comes from vanilla and wiki but the option does not show up in relation to the imprisoned plotter.

 

Spoiler

option = { # Confess to plotting Divulge other members of plot (providing grounds for imprisoning them)
        trigger = {
                event_target:rsl_victim_target = {
                                                is_adult = yes
                                                OR = {
                                                    has_plot = plot_gain_title
                                                    has_plot = plot_kill_character
                                                    has_plot = plot_kill_spouse
                                                    has_plot = plot_weaken_fellow_vassal
                                                    has_plot = plot_gain_liege_title
                                                    has_plot = plot_gain_fellow_vassal_title
                                                }
                }                                
            
        }
        name = EVTOPTB_Court_5105
        if = {
            limit = {
                event_target:rsl_victim_target = {
                                                check_variable = { which = willpower value = 5 } #If our victim has at least a willpower of 5 they refuse
                }
            }
            event_target:rsl_victim_target = {
                                        set_character_flag = resisting_plotter
                                        opinion = {
                                                modifier = rsl_opinion_asshole
                                                who = event_target:rsl_player_target
                                        }
                                        opinion = {
                                                modifier = rsl_opinion_asshole
                                                who = event_target:rsl_torturer_target
                                        }
            }
            narrative_event = { id = RSLCourt.5200 } # Refusal: Leads to the will_breaking process to start
            break = yes # Removes us from this option block
        }

 

Posted

The problem is that plotters are hardcoded instead of being assigned to a character flag or modifier, as noted by the has_plot condition. Once a character that is plotting or backing a plot is imprisoned, they are removed from that plot.

 

You might want to setup a targetted_decision against a plot backer and then set up a routing event that assigns event_targets to the relevant backers/plotter. It could also work with the primary plotter, but the moment the plotter goes to prison, the plot falls apart.

Posted

Thanks for the clarification. It means (I think) that there is not really a point to my event, in the sense that the prisoner is no longer a plotter and cannot reveal the other plotters. No point in torturing an amnesiac ?

 

Posted

Hi, can we checking between two localisation scope is equal? (https://ck2.paradoxwikis.com/Localisation#Scopes)

I want to check between two value of character ID ([This.GetID]) is equal or not.

 

    text = {
        trigger = {
            is_variable_equal = { // is_variable_equal only for example, I don't use it
                which = [This.GetID] value = [This.GetOtherID]
            }
        }
        localisation_key = The Character ID is SAME
    }

Posted

If you want to check whether the characters are the same you can always use

trigger = {
	character = ROOT
}

Or if you want to check a specific ID

trigger = {
	character = 7757 # Matilda of Tuscany
}

I don't see any reason why you would want to compare localization keys.

Posted
39 minutes ago, cherisong said:

If you want to check whether the characters are the same you can always use


trigger = {
	character = ROOT
}

Or if you want to check a specific ID


trigger = {
	character = 7757 # Matilda of Tuscany
}

I don't see any reason why you would want to compare localization keys.

 

It was to prevent script resulting wrong one with same person name, I had two localisation key will be only one displayed on character tooltip.

If between two Ids is equal then display none, if not then display person name.

 

If first character id (1111) and second character id (2222) are not equal => localisation_key = [This.GetID]
If if equal then => localisation_key = None

 

Is it possible to do that?

Posted

Can you explain what your use case for this is? What exactly are you trying to display that you have to do this kind of localization hacking? If you show us the code, we can probably find a better way to check the trigger that doesn't involve comparing character IDs.

 

Note also that if two characters have the same ID, they ARE the same character. There is no such thing as two characters with the same ID in CK2.

Posted

Got it, so I currently create a mod that will display a character lover name on tooltip.
However I can't make it work correctly, in the game if the character doesn't had lover it will display the character name itself.

 

There two result: 
A Character (Basilus) had lover = Working Correctly to display the character lover name (Schuvi)
A Character (Basilus) Doesn't had lover = Not Working, display the character name itself (Basilus)

So i trying to check the scope with set a variable and still couldn't make it work.

 

	text = {
		set_variable = { which = CharacterID1 value = [This.GetID] }
		trigger = {
			is_variable_equal = {
				which = CharacterID1 value = [This.Lover.GetID]
			}
		}
		localisation_key = None
	}
	text = {
		localisation_key = [This.Lover.GetFullName]
	}

 

Posted

I am trying to create a slaver character by using the create title command and am using as an example the Shepard crusade vanilla event. However, I can't get my first modded event to fire. It is a province event and I haven't used these before. Can somebody telle me where I am going wrong?

Spoiler

#Slave trade events
# Set up  ROOT is Province Slesvig
province_event = {
    id = RSLT.1
    hide_window = yes
    
    
    mean_time_to_happen = {
            days = 1
            
    }
        

    immediate = {
            264 = {
                if = {
                    limit = {
                            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 }
                    }
                
                        province_event = { id = RSLT.2 days = 1 random = 10 }
                        set_province_flag = slave_trade_north
                }
            }                    
            
        
    }
}

 

 

Posted
50 minutes ago, joemann said:

I am trying to create a slaver character by using the create title command and am using as an example the Shepard crusade vanilla event. However, I can't get my first modded event to fire. It is a province event and I haven't used these before. Can somebody telle me where I am going wrong?

Did you set a proper namespace = RSLT ?

Posted
1 hour ago, niznet said:

So i trying to check the scope with set a variable and still couldn't make it work.

The problem with your code is you're trying to assign a localization key to a variable. Variables can only store floating point numbers (and anyway, I don't think it's possible to reference loc keys in code like that).

 

This should be a simple fix to your problem:

	text = {
		trigger = {
			NOT = { num_of_lovers = 1 }
		}
		localisation_key = None
	}
	text = {
		localisation_key = [This.Lover.GetFullName]
	}

 

1 hour ago, joemann said:

I am trying to create a slaver character by using the create title command and am using as an example the Shepard crusade vanilla event. However, I can't get my first modded event to fire. It is a province event and I haven't used these before. Can somebody telle me where I am going wrong?

There are a few problems with your event:

  • There is no trigger = {} defined, which is likely why the event isn't firing.
  • The event fires for every province every month. You should add a condition in the trigger block that the province is the province you want.
  • If this is a one-time event for a character to spawn in a specific province, a far less CPU-intensive way to trigger this event is using an on_action:
on_yearly_pulse = {
	events = {
		# [...]
		HF.49100 # Check if to start Northern Crusade
		# [...]
	}
    # [...]
}

If you want it to only trigger a few months/years into the game, you can make a dummy event to trigger it the way Paradox did it, like so:

# Setting up Northern Crusade - 1
province_event = {
    id = HF.49102
    hide_window = yes
    is_triggered_only = yes

    immediate = {
        if = {
            limit = {
                has_global_flag = qa_testing
            }
            333 = {
                province_event = { id = HF.49103 days = 1 }
            }
        }
        else = {
            333 = {
                province_event = { id = HF.49103 days = 1825 random = 1825 }
            }
        }
    }
}

Note that on_yearly_pulse fires from character scope, so your dummy event would have to be a character_event.

EDIT: And yeah, make sure your namespace is properly defined.

Posted
1 hour ago, niznet said:

Got it, so I currently create a mod that will display a character lover name on tooltip.

I honestly don't think it's possible to use localisation keys in variables.

 

Even if you could, your is_variable_equal is always going to be false because it's checking against your character's ID and your character's lover's ID.

 

You could try this instead:

text = {
	trigger = {
		has_lover = yes
		num_of_lovers == 1
	}
	localisation_key = GetLoverName
}

 

Posted

Thanks for the help.

I added a trigger ( I did have namespace)  but it does not seem to help:

 

Spoiler

namespace = RSLT

#Slave trade events
# Set up  ROOT is Province Slesvig
province_event = {
    id = RSLT.1
    hide_window = yes
    
    
    
    trigger = {
            264 = {
                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 = {
            264 = {
                if = {
                    limit = {
                            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 }
                    }
                
                        province_event = { id = RSLT.2 days = 1 random = 10 }
                        set_province_flag = slave_trade_north
                }
            }                    
            
        
    }
}

There are seven event in all, copied from vanilla with some modifications. Validator has no issues and each event tested in the console seems to work, but running it in a new game doesn't fire the visible events. Mean_time_to_happen days = 1 should occur within a few days right?

Posted
1 hour ago, lockeslylcrit said:

I honestly don't think it's possible to use localisation keys in variables.

 

Even if you could, your is_variable_equal is always going to be false because it's checking against your character's ID and your character's lover's ID.

 

You could try this instead:


text = {
	trigger = {
		has_lover = yes
		num_of_lovers == 1
	}
	localisation_key = GetLoverName
}

 

 

2 hours ago, cherisong said:

The problem with your code is you're trying to assign a localization key to a variable. Variables can only store floating point numbers (and anyway, I don't think it's possible to reference loc keys in code like that).

 

This should be a simple fix to your problem:


	text = {
		trigger = {
			NOT = { num_of_lovers = 1 }
		}
		localisation_key = None
	}
	text = {
		localisation_key = [This.Lover.GetFullName]
	}

 

 

Thank you! your both solution is working. I didn't know there "num_of_lovers" at conditions wiki page.

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