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

Vvallaria

Guest
Hi friendo's,


Currently writing a mod to go out and have a walk with your dog and a Spouse, Consort or Lover {SCL}. As you can have multiple SCL's I'm trying to randomly scope out 1 character between the 3 options, so you don't end up with having your spouses and/or consorts and lovers going for a dog walk together (that has to be akward at some point right?)

I use the following code for the scope and that gives me two main problems right now. I'm 99% sure it has to do with the random_list parameter but I have no idea how to work around that or if it's the correct one to use in this situation.

Problem 1: If I fire the event multiple times I will sometimes get a blank scope. I assign a character_flag in the option that stays on the scoped character so it excludes them from being scoped if the event fires again.

problem 2: The save_event_target_as will have a 1/3 chance of beeing applied to the scoped character.


immediate = {
random_list = {
33 = {
random_spouse = {
limit = {
NOT = { has_character_flag = dog_walk }
}
save_event_target_as = dog_walking
}
}
33 = {
random_lover = {
limit = {
NOT = { has_character_flag = dog_walk }
}
save_event_target_as = dog_walking
}
}
33 = {
random_consort = {
limit = {
NOT = { has_character_flag = dog_walk }
}
save_event_target_as = dog_walking
}
}
}
}

So pretty clear random is the culprit here.

I have no expierence in coding and still learning the mountain of options and parameters you can apply to where and to whom and to what and to... you get the gist. I use the wiki and mods for help otherwise.

Any help, tips and tricks are very much welcomed and thank you in advance. If you need more info or something isn't clear please let me know. Also if my grammar isn't correct you can tell me but atleast be willing to explain what I'm doing wrong. You can find me on the ck2 discord server if the list is to long to post here ;)

Thank you and kind regards,

Vallaria
 
Code:
immediate = {
    random_lover = { 
        limit = {
            NOT = { has_character_flag = dog_walk }
        }
        do stuff
    } 
}
I would just use that, as if I didn't love my wife or consort (thus they're not lovers) I wouldn't want to walk my dog with them anyway.
Code:
immediate = {
    random_list = {
        33 = {
            modifier = {    will exclude this option if not married
                factor = 0
                is_married = no
            }
            random_spouse = { 
                limit = {
                    NOT = { has_character_flag = dog_walk }
                }
                save_event_target_as = dog_walking
            } 
        }
        33 = {
            modifier = {    will exclude this option if no lovers
                factor = 0
                has_lover = no
            }
            random_lover = { 
                limit = {
                    NOT = { has_character_flag = dog_walk }
                }
                save_event_target_as = dog_walking 
            } 
        }
        33 = {
            modifier = {    will exclude this option if no consorts
                factor = 0
                is_senior_consort_party = no
            }
            random_consort = { 
                limit = {
                    NOT = { has_character_flag = dog_walk }
                }
                save_event_target_as = dog_walking 
            } 
        }
    }
}
I would 100% go for the first. It's neater and makes more sense. You going to spend time going for walks with someone you don't love?
 
Alternatively:
Code:
immediate = {
    random_courtier = {
        limit = {
            OR = {
                is_lover = ROOT
                is_consort = ROOT
                spouse = { character = ROOT }
            }
            NOT = { has_character_flag = dog_walk }
        }
        save_event_target_as = dog_walking
    }
}
It does mostly the same as CFH's second example, and is more succinct. Only difference is that it excludes spouses/lovers/consorts that are outside your court, which makes sense as you wouldn't travel to them for a dog walk anyway.
 
@CFH1985 - Tested both and the second one still gave me the same problems with not always applying the save_event_target_as. I will test this out more in another event and see how it should work so thank you for the info. I forgot to mention that the event was to eventualy add them as a lover (if they aren't already) kind of taking some time to know eachother during the walk. But still thank you as this just gave me a idea to create a special quest line for only lovers.

@Keizer Harm - Tested and works perfectly for what I was looking for and it has the solution to what should have been my next problem to select only courtiers in the players court.

Thank you both kindly for the help and idea's!
 
Last edited by a moderator: