Jump to content

Need help with coding


Recommended Posts

Posted

Hey guys, I'm creating a mod just for fun and learning purposes — I'm not a modder or coder, just a curious guy. I had this simple idea and, after some research, reverse engineering, and help from ChatGPT, I managed to get something working.

The mod adds a custom trait and a nickname to a character if their spouse cheats on them. The cheating partner gets the vanilla "adulterer" trait, and the betrayed one is supposed to receive a custom "cucked" trait. I created the event, and it seems to work fine when triggered manually — it applies the trait along with some small debuffs.

The problem is that this event is supposed to trigger automatically: whenever a character’s spouse has the "adulterer" trait, the betrayed partner should get the "cucked" trait. But instead, the game is giving the trait to literally every married character in the game, lmao.

Most of the mod is working fine — even the custom nickname is showing up correctly — but I just can't figure out how to make it apply only when the spouse has the "adulterer" trait. Any help or guidance would be greatly appreciated!

cucked_mod.rar

Posted

In on_action:

random_yearly_everyone_pulse = 
{
   events = { 

spouse = { has_trait = adulterer } 
            trigger_event = {id = cuck.0001 }
        
    	     }
}

 

 

With the way you wrote this, you need to add it to a list of on_actions, otherwise it overwrites every other yearly everyone pulse. The on_action needs a limit block to restrict it, if your event didn't check for the conditions it would have been manually applied to every person every year.

random_yearly_everyone_pulse = {
	on_actions = {
		add_cuck_on_action
	}
}

add_cuck_on_action = {
   effect = { 
		if = {
			limit = {
				spouse = { has_trait = adulterer } 
			}
			trigger_event = { id = cuck.0001 }
		}
	}
}

The CK3 wiki has information on limits and conditional blocks.

 

 

However, this implementation has some problems. This will go through everyone, every year, which should be minimized for performance reasons. See if you can dynamically apply it instead. If a person marries someone who got the adulterer trait in a previous marriage, they will gain the cucked trait too which probably isn't what you want.

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