Jump to content

Modding Question: Making an event to change a character's sex


BorisTheFurious

Recommended Posts

I'm fairly new to CK2 modding, and I'm in the process of putting a together a society mod that allows for some 'customisation' of prisoners.

 

As part of that, I'm trying to build an event that will change the sex of a character, but I'm having no luck. My best guess so far as has been to use:

 

change_variable = { which = "female" value = 1 }

 

But that doesn't seem to work.

 

Does anyone know if this is actually possible, and if so, what the best way to go about it would be?

Link to comment
  • 2 weeks later...

You can do this by creating a new character and killing off the old one, but there's a number of difficulties with this.

 

Not only will you have the dead pre-gender-change character left in history, every single variable and character flag, event modifier, opinion modifier, attribute value, trait, title, event spawned military units, wealth, prestige, piety, ambition, plot, character focus, lover, rival, spouse, concubine, and their mother, father, and real father would need to be correctly transferred. And while, there's a possibility that I've forgotten something else that would need to be transferred (quite possible), there's still one very horrifying thought: many of these would need extremely expensive scope changes to make absolutely sure you catch EVERYTHING. You'd have to catalogue every opinion modifier that CAN be used to check for all of them so you can transfer them. You'd also have to check for every dynamic flag your selected choice of compatible mods uses. Many other things, such as the variables to check for, the plots the character might have in effect, or be part of, the list of event modifiers you'd need to copy... all would work the same way. You'd have to know in advance which ones to check for and transfer. And the more mods you want this to be compatible with, the more glue code or other such scripting you'd have to write for it.

 

Trust me, there's a reason why nobody's done it yet. It's hell on Earth to try. And the entire reason why Paradox doesn't just add a command to swap genders? "Because CK2 is not set in a fantasy world, and thus has no need for gender changing mechanics." Paraphrased, but accurately enough. I also seriously doubt they'll ever add it either.

 

The better way, I think, will be to work more accurately with reality. All CK2 characters have a biological sex, obviously. Give them gender as well. A flag would do nicely.

 

set_character_flag = modname_gender_male
set_character_flag = modname_gender_female

You can, with such flags, set up additional genders as well. Of course, the portraits will look the same as before. I'm not 100% certain, but I suspect you might be able to mod portraits so that you could check for traits (but not flags) and adjust which portraits are used. This would be a difficult, and fairly experimental task. And there's no guarantee it would work. If you, or somebody else, wanted to try this, you might try adding an allow_property_values block to portraitTypes entries in /interface/portraits/portrait.gfx. That block was added for clothing in patch 2.7, but I don't know if it'll work with non-clothing layers.

 

If that doesn't work, the next possibility would be to create alternative cultures for gender changed individuals, using inverted portraits (tell the male portrait definitions in .gfx files to use the female graphics, and vice versa).

 

On top of all that, you'd probably need to add some events to get your gender changed character romantic or just plain filthy with the right gender. And that's when you'll have to cope with sexuality. CK2 currently has only heterosexual (the default) and homosexual (with a trait). Amusing, since the term "homosexual" was never used during at least most of the time period CK2 is set in. Before the term had been created and defined, it wasn't the sort of issue it's been turned into today. In fact, many ancient cultures really didn't care overly much. Though in most, what we'd call the "bottom" today was generally considered an inferior, weak, or low class individual. Conversely, the "top" would generally not have faced any real shame from the act. Unfortunately, CK2 wasn't built to allow attraction to individuals to be simply specified. TBH, I'm not sure if CK2 can handle same sex marriage using the add_spouse and add_spouse_matrilineal commands, or concubines either. It CAN handle same sex lovers, though.

 

Oh, and... as far as pregnancy goes... I actually don't know if it's possible to use the impregnate command to get a male pregnant by another male. It MIGHT work if you use it in the scope of a male, without referencing a second character, like this:

impregnate = yes

If that does get the dude preggers, you might be able to set the infant's mother to said male, then set the infant's real_father (and father if you want a different choice for that) using: set_mother, set_real_father, and set_father.

 

Then again, CK2 might complain that the characters involved aren't the right sex.

 

Good luck!

Link to comment

Thanks mate, I appreciate you taking the time to give such an in-depth answer.

 

I think a limited implementation of your first suggestion might be my best bet - creating a new character with identical genetics, dynasty, parents, stats, and traits. I have this working to some extent, though I'm still figuring it out (the parents, dynasty, culture, and race were easy enough, but I'm a bit unsure of how to copy across the traits and stats). I figure that titles and relationships are of less import, considering that I doubt that if Charlemagne rocked up to Paris one day as a woman he'd be accepted by either his nobles or his wife...

Link to comment

Copying traits is one of those situations where you have to know ahead of time what traits you want to copy. Let's say you have your event such that you're in the pre-change character's scope, and using the create_character command followed by the new_character scope to copy over parents, etc.

# In pre-change character's scope here.
create_character = {
	# ...
	random_traits = no # to make sure only the traits you copy are on the post-change character
}
new_character = {
	# Copy parents, etc.
	# Copy traits.
	if = { limit = { PREV = { trait = amateurish_plotter } } add_trait = amateurish_plotter }
	if = { limit = { PREV = { trait = flamboyant_schemer } } add_trait = flamboyant_schemer }
	if = { limit = { PREV = { trait = intricate_webweaver } } add_trait = intricate_webweaver }
	if = { limit = { PREV = { trait = elusive_shadow } } add_trait = elusive_shadow }
	# ...
	# etc. for every trait you want to copy over. Other traits WILL NOT BE COPIED.
}

Opinion modifiers would actually be even more difficult, I think, since you'd have to use the any_opinion_modifier_target scope to get each person targeted by the original character's opinion modifiers, then do a block of if statements for each opinion modifier you want to copy over. Also note that traits like seducer and seductress need to also check for the gender being switched to, and traits like shieldmaiden may not make sense applied to a F2M character. Eunuch wouldn't make much sense for a F2M character either, I'd think.

 

Copying stats would need to make use of variables.

# In pre-change character's scope here.
create_character = {
	# ...
	attributes = { # do this so you can use the change_martial, etc. commands with variable values.
		diplomacy = 0
		martial = 0
		stewardship = 0
		intrigue = 0
		learning = 0
	}
	random_traits = no # to make sure only the traits you copy are on the post-change character
}
new_character = {
	# hopefully these copy the base stat value from the base character. If they don't, then you'll need to remove
	# traits from the base character before doing this, but AFTER copying traits to the new character.
	export_to_variable = { which = modname_copy_diplomacy   who = PREV value = diplomacy }
	export_to_variable = { which = modname_copy_martial     who = PREV value = martial }
	export_to_variable = { which = modname_copy_stewardship who = PREV value = stewardship }
	export_to_variable = { which = modname_copy_intrigue    who = PREV value = intrigue }
	export_to_variable = { which = modname_copy_learning    who = PREV value = learning }
	change_diplomacy = modname_copy_diplomacy
	change_martial = modname_copy_martial
	change_stewardship = modname_copy_stewardship
	change_intrigue = modname_copy_intrigue
	change_learning = modname_copy_learning
}

There's a list of the stats you can export to variables here. One that might make sense is health. you could set health = 0 in your create_character block, then use the health command to add an exported variable to the new character's base health. At least with health I KNOW it's base health, because that's what you use to export it: base_health.

Link to comment
On 11/21/2017 at 10:29 AM, BorisTheFurious said:

I'm fairly new to CK2 modding, and I'm in the process of putting a together a society mod that allows for some 'customisation' of prisoners.

 

As part of that, I'm trying to build an event that will change the sex of a character, but I'm having no luck. My best guess so far as has been to use:

 

change_variable = { which = "female" value = 1 }

 

But that doesn't seem to work.

 

Does anyone know if this is actually possible, and if so, what the best way to go about it would be?

as others mentioned impossible or if possible difficult

 

if you really want this you should find the warhammer mod and look up slaanesh cult and see how they did the Gender Swap event.

Link to comment
  • 1 month later...

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...