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

Andrew0Red

Major
Mar 10, 2021
516
433
(First modding)

1: Modify action_settle_tribe, so I can settle in vassal lands: Done and working.

2: Get AI to settle tribe... I've added a title decision that sets the treasurer to settle tribe in a county. It's crude, but it works. But I want the AI to be slightly smarter when using it:

ai_will_do = { #40%-100% chance, depending on size
factor = .4

modifier = { #Prefer to settle in own demesne
factor = .5
NOT = {
ROOT = { owner = { character = FROM }}
}
}

# modifier = { #Prefer to settle in own demesne
# factor = 0
# AND = {
# NOT = { owner = ROOT }
# any_demesne_province = {
# NOT = { culture = ROOT }
# }
# }
# }

modifier = { #Prefer larger tribes....
factor = 1.25
ROOT = {
num_of_empty_holdings = 1
}
}

modifier = {
factor = 1.25
ROOT = {
num_of_empty_holdings = 2
}
}

modifier = {
factor = 1.25
ROOT = {
num_of_empty_holdings = 3
}
}

modifier = {
factor = 1.25 #... up to 100% for a tribe with +200% from empty holdings
ROOT = {
num_of_empty_holdings = 4
}
}
}

The four x1.25's should scale chance from 40-100% depending on size (more empty holdings = larger tribal bonus). The two other ones ... The x.5 one simply makes it less likely to happen in vassal lands, right? Would the x0 one actually prevent it from firing in vassal lands if any own province is wrong-culture?
 
A few things:
1. If you use code tags, the forums provide your script's formatting, even inside spoiler tags.
2. Factors need that leading zero before the dot.
3. Modifiers with a 0-factor can (and arguably should be) rewritten to be a 'trigger'-clause instead, to avoid inverted logic.
4. The ROOT scopes are not necessary.

Your script seems perfectly functional to me, however.
 
  • 1Like
Reactions:
Thank you, but just to clarify:
4: So just
Code:
NOT = {
owner = { character = FROM }
}
...
num_of_empty_holdings = 4
instead of
Code:
NOT = {
ROOT = { owner = { character = FROM }}
}
...
ROOT = { num_of_empty_holdings = 4 }
?

(3: Makes good sence. But for now I'll stick with 'crude, but working', since beginners are more likely to break than improve :) )
 
Thank you, but just to clarify:
4: So just
Code:
NOT = {
owner = { character = FROM }
}
...
num_of_empty_holdings = 4
instead of
Code:
NOT = {
ROOT = { owner = { character = FROM }}
}
...
ROOT = { num_of_empty_holdings = 4 }
?

(3: Makes good sence. But for now I'll stick with 'crude, but working', since beginners are more likely to break than improve :) )

Correct. Up to you whether to use inverted logic or not, but 99% of the time, the non-inverted logic is easier to write and easier to comprehend for others.
One more thing I missed: NOT = { owner = ROOT } won't work. This does: NOT = { holder = ROOT }.
Scopes can't be directly compared in CK2, so you need to scope and then use a trigger to do the comparison.

Edit:
Here's how I would write this:
Code:
ai_will_do = { #40%-100% chance, depending on size
	factor = 0.4

	modifier = { #Prefer to settle in own demesne
		factor = 0.5
		NOT = { holder = FROM }
	}

	trigger = { #Prefer to settle in own demesne
	 	trigger_if = {
			limit = { NOT = { holder = FROM } }

			FROM = {
				NOT = {
					any_demesne_province = {
						NOT = { culture = owner }
					}
				}
			}
		}
	}

	modifier = { #Prefer larger tribes....
		factor = 1.25
		num_of_empty_holdings >= 1
	}

	modifier = {
		factor = 1.25
		num_of_empty_holdings >= 2
	}

	modifier = {
		factor = 1.25
		num_of_empty_holdings >= 3
	}

	modifier = {
		factor = 1.25 #... up to 100% for a tribe with +200% from empty holdings
		num_of_empty_holdings >= 4
	}
}
 
  • 1Like
Reactions: