• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

grundy122

Private
Dec 9, 2022
22
0
I made a mod that spawns a character, and later, if the character has been imprisioned, I wanted to fire an event, which I understand is what these two commands are for.

I tried this;

character_event = {
id = BobEvents.1
hide_window = yes
is_triggered_only = yes
immediate = {
create_character = {
random_traits = no
name = "Bob"
dynasty = 4100001
religion = ROOT
culture = ROOT
race = swedish
dna = ckhbbhacaai
female = no
age = 20
historical = yes
attributes = {
martial = 2
diplomacy = 3
stewardship = 5
intrigue = 5
learning = 5
}
health = 6
fertility = 0.50
trait = thrifty_clerk
}
new_character = {
set_character_flag = is_bob
set_global_flag = gr_bob_created
set_global_flag = bob_is_alive
save_persistent_event_target = { name = gr_bob_character scope = event_target:ROOT }
imprison = ROOT
}
}
}

I know most of the code works because bob immeditally goes to prison on spawning, but then later I tried this narrative event;

narrative_event = { #EscapesFromPrison
id = BobEvents.1011
desc = BobEscapes
title = BobEscaping
picture = EmptyDungeon
ai = no
#is_triggered_only = yes
trigger = {
persistent_event_target:gr_bob_character = { prisoner = yes }
had_global_flag = {
flag = bob_is_imprisioned days >=60
}

}

immediate = {
persistent_event_target:gr_bob_character = {
imprison = no
banish = yes
}

}

option = {

name = BobEscapesF
narrative_event = { id = BobEvents.1012 }
}
}

And nothing works? I want Bob to leave prison and be banished immediatelly, but nothing happens. The event doesn't even pop up.

When I use the console to fire it manually, the even visually works just fine, but Bob still doesn't leave the prison and get banished. All I can think off it that I'm not using the event target function correctly
 
Neither is needed to fire events and you're definitely not using 'save_persistent_event_target' correctly. It's used to save a direct link to a scope in another scope. 'event_target:ROOT' makes no sense, simply use 'ROOT'.

When should the second event fire?
 
Neither is needed to fire events and you're definitely not using 'save_persistent_event_target' correctly. It's used to save a direct link to a scope in another scope. 'event_target:ROOT' makes no sense, simply use 'ROOT'.

When should the second event fire?

I tried using ROOT by itself, but using charinfo, it seemed to be saving bob's liege (the player character) as the target event instead of Bob

It should fire 6 months after bob was imprisoned, unless they are freed first.
 
Try this instead. Hopefully this clears up some confusion about the many very poorly named script elements that Paradox approved of for some reason.

Code:
character_event = {
	id = BobEvents.1
	
	hide_window = yes
	is_triggered_only = yes
	
	immediate = {
		create_character = {
			random_traits = no
			name = "Bob"
			dynasty = 4100001
			religion = ROOT
			culture = ROOT
			race = swedish
			dna = ckhbbhacaai
			female = no
			age = 20
			historical = yes
			attributes = {
				martial = 2
				diplomacy = 3
				stewardship = 5
				intrigue = 5
				learning = 5
			}
			health = 6
			fertility = 0.50
			trait = thrifty_clerk
		}
		new_character = {
			set_character_flag = is_bob
			set_global_flag = gr_bob_created
			set_global_flag = bob_is_alive
			imprison = ROOT
			narrative_event = { id = BobEvents.1011 months = 2 }
		}
	}
}

narrative_event = { #EscapesFromPrison
	id = BobEvents.1011
	desc = BobEscapes
	title = BobEscaping
	picture = EmptyDungeon
	
	is_triggered_only = yes
	
	prisoner = yes

	immediate = {
		imprison = no
		banish = yes
	}

	option = {
		name = BobEscapesF
		narrative_event = { id = BobEvents.1012 }
	}
}
 
Wouldn't that fire the event immediately after the previous one, though? Like he is impassioned impassioned immediately escapes, without 60 day passing?

Edit: wait no I saw the months passing part. Yeah that works, but it still limits Bob's journey to one event chain, right? I wanted to keep calling him on other future events, if possible
 
Try this then. Hopefully all is clear enough for you to expand upon.

Code:
character_event = {
	id = BobEvents.1
	
	hide_window = yes
	is_triggered_only = yes
	
	immediate = {
		create_character = {
			random_traits = no
			name = "Bob"
			dynasty = 4100001
			religion = ROOT
			culture = ROOT
			race = swedish
			dna = ckhbbhacaai
			female = no
			age = 20
			historical = yes
			attributes = {
				martial = 2
				diplomacy = 3
				stewardship = 5
				intrigue = 5
				learning = 5
			}
			health = 6
			fertility = 0.50
			trait = thrifty_clerk
		}
		new_character = {
			set_character_flag = is_bob
			set_global_flag = gr_bob_created
			set_global_flag = bob_is_alive
			imprison = ROOT
			repeat_event = { id = BobEvents.2 days = 5 }
		}
	}
}

# Pick random events
character_event = {
	id = BobEvents.2
	
	is_triggered_only = yes
	hide_window = yes
	
	prisoner = yes
	
	immediate = {
		random_list = {
			1 = {
				trigger = { NOT = { has_character_flag = bob_event_1011 } }
				narrative_event = { id = BobEvents.1011 } # Escapes
			}
			1 = {
				trigger = { NOT = { has_character_flag = bob_event_1021 } }
				narrative_event = { id = BobEvents.1021 } # Something else happens
			}
			1 = {
				trigger = { NOT = { has_character_flag = bob_event_1031 } }
				narrative_event = { id = BobEvents.1031 } # Or this happens
			}
		}
	}
}

narrative_event = { #EscapesFromPrison
	id = BobEvents.1011
	desc = BobEscapes
	title = BobEscaping
	picture = EmptyDungeon
	
	is_triggered_only = yes
	
	prisoner = yes

	immediate = {
		set_character_flag = bob_event_1011
		imprison = no
		banish = yes
	}

	option = {
		name = BobEscapesF
		narrative_event = { id = BobEvents.1012 }
	}
}

narrative_event = {
	id = BobEvents.1021
	desc = BobDoesSomething
	title = HiBobHere
	
	is_triggered_only = yes
	
	prisoner = yes

	immediate = {
		set_character_flag = bob_event_1021
		character_event = { id = BobEvents.2 days = 5 } # Call this event again if more events should happen to Bob
	}

	option = {
		name = SOMETHING
		narrative_event = { id = BobEvents.1022 }
	}
}
 
  • 1Like
Reactions:
Try this then. Hopefully all is clear enough for you to expand upon.

Code:
character_event = {
    id = BobEvents.1
   
    hide_window = yes
    is_triggered_only = yes
   
    immediate = {
        create_character = {
            random_traits = no
            name = "Bob"
            dynasty = 4100001
            religion = ROOT
            culture = ROOT
            race = swedish
            dna = ckhbbhacaai
            female = no
            age = 20
            historical = yes
            attributes = {
                martial = 2
                diplomacy = 3
                stewardship = 5
                intrigue = 5
                learning = 5
            }
            health = 6
            fertility = 0.50
            trait = thrifty_clerk
        }
        new_character = {
            set_character_flag = is_bob
            set_global_flag = gr_bob_created
            set_global_flag = bob_is_alive
            imprison = ROOT
            repeat_event = { id = BobEvents.2 days = 5 }
        }
    }
}

# Pick random events
character_event = {
    id = BobEvents.2
   
    is_triggered_only = yes
    hide_window = yes
   
    prisoner = yes
   
    immediate = {
        random_list = {
            1 = {
                trigger = { NOT = { has_character_flag = bob_event_1011 } }
                narrative_event = { id = BobEvents.1011 } # Escapes
            }
            1 = {
                trigger = { NOT = { has_character_flag = bob_event_1021 } }
                narrative_event = { id = BobEvents.1021 } # Something else happens
            }
            1 = {
                trigger = { NOT = { has_character_flag = bob_event_1031 } }
                narrative_event = { id = BobEvents.1031 } # Or this happens
            }
        }
    }
}

narrative_event = { #EscapesFromPrison
    id = BobEvents.1011
    desc = BobEscapes
    title = BobEscaping
    picture = EmptyDungeon
   
    is_triggered_only = yes
   
    prisoner = yes

    immediate = {
        set_character_flag = bob_event_1011
        imprison = no
        banish = yes
    }

    option = {
        name = BobEscapesF
        narrative_event = { id = BobEvents.1012 }
    }
}

narrative_event = {
    id = BobEvents.1021
    desc = BobDoesSomething
    title = HiBobHere
   
    is_triggered_only = yes
   
    prisoner = yes

    immediate = {
        set_character_flag = bob_event_1021
        character_event = { id = BobEvents.2 days = 5 } # Call this event again if more events should happen to Bob
    }

    option = {
        name = SOMETHING
        narrative_event = { id = BobEvents.1022 }
    }
}

Yes, that works! Thanks man