CK3 DatabaseCrusader Kings III · 1.20.1.2 “Crozier” · unofficial
Silk & Silverout Tue, Nov 17What's free, what needs the DLC, price →

Scripted effect

ai_budget_manipulation_effect

ai_budget_manipulation_effect = yes

game/common/scripted_effects/00_ai_budget_effects.txt, line 5 (688 lines). No parameters.

ai_budget_manipulation_effect is a scripted effect in Crusader Kings III, written at line 5 of its file. It takes no parameters: ai_budget_manipulation_effect = yes. The game's script calls it in 1 place, among them yearly_playable_pulse (on action). Patch 1.20.1.2, from game/common/scripted_effects/00_ai_budget_effects.txt.

The comment above it in the file

AI Tweaks			  #
For a better challenge, a better AI #

What it does

  • If played by the AI:
    • If

      • Is at not War
      • is_playable_character = yes
      • If has Treasury:
        • Treasury at least 50
        • treasury < minimum_ai_treasury_value_for_tyranny_wars
      • Otherwise:
        • Has 50
        • gold < minimum_ai_gold_value_for_tyranny_wars
      • Their government is not Nomadic
      • primary_title.tier >= tier_duchy
      • Years from game start at least 3
      • domain_size < domain_limit
      • has_realm_law_flag = title_revocation_allowed
      • One of these

        • All of these

          • Ai rationality less than 0
          • Tyranny at most 15
        • or

          All of these

          • Ai rationality at least 0
          • Ai rationality less than 50
          • Tyranny at most 5
        • or

          All of these

          • Ai rationality at least 50
          • Tyranny at most 0
      • One of these

        • primary_title.title_capital_county = { … }
        • or

          All of these

          • primary_title.tier >= tier_kingdom
          • exists = primary_title.title_capital_county.de_jure_liege.holder
          • primary_title.title_capital_county.de_jure_liege = { … }
        • or

          Any sub realm county:
          • holder != root
          • Their province:
            • has_holding_type = castle_holding
          • this != root.primary_title.title_capital_county
          • duchy = root.primary_title.title_capital_county.duchy
          • Their holder:
            • current_military_strength < root.current_military_strength
            • NOT = { vassal_contract_has_flag = vassal_contract_cannot_revoke_titles }
            • NOT = { has_relation_friend = root }
            • NOT = { has_relation_best_friend = root }
            • NOT = { has_relation_lover = root }
            • NOT = { has_relation_soulmate = root }
            • NOT = { is_child_of = root }
            • NOT = { is_grandchild_of = root }
            • NOT = { is_great_grandchild_of = root }
      • If domain Size more than 3:
      • Their primary title is not Holy Roman Empire

      Then

      • Otherwise › 1 of 2 things will happen:
        • 50%: Nothing else happens
        • 50%: Nothing else happens
    • If has “conqueror” (a variable the game's script sets):
      • move_budget_gold = { gold = long_term_gold from = budget_long_term to = budget_war_chest }
      • move_budget_gold = { gold = short_term_gold from = budget_short_term to = budget_war_chest }
      • move_budget_gold = { gold = long_term_gold from = budget_long_term to = budget_short_term }
      • If has Treasury:
        • move_budget_treasury = { treasury = long_term_treasury from = budget_long_term to = budget_war_chest }
        • move_budget_treasury = { treasury = short_term_treasury from = budget_short_term to = budget_war_chest }
        • move_budget_treasury = { treasury = long_term_treasury from = budget_long_term to = budget_short_term }
    • Else, if has a Adventurer Government:
      • move_budget_gold = { gold = long_term_gold from = budget_long_term to = budget_short_term }
      • move_budget_gold = { gold = war_chest_gold from = budget_war_chest to = budget_short_term }
    • Otherwise:
      • If

        • Is at not War
        • is_playable_character = yes
        • If has Treasury:
          • Treasury more than 0
          • War chest treasury at least 10
        • Otherwise:
          • Gold more than 0
          • War chest gold at least 10
        • None of these

          • has_character_flag = ai_save_gold_for_revoke
          • Any targeting faction:
            • NOT = { faction_is_type = peasant_faction }
            • faction_power >= halved_faction_power_threshold
        • If government is a Tribal-type Government: Has 200
        • Not all of these

          • Any character struggle:
            • phase_has_catalyst = catalyst_winning_large_conquest_war

        Then

        • If

          Then

          • If

            Then

            • move_budget_gold = { gold = war_chest_gold from = budget_war_chest to = budget_short_term }
            • If has Treasury:
              • move_budget_treasury = { treasury = war_chest_treasury from = budget_war_chest to = budget_short_term }

            Else if

            • Their capital county’s province: Free building slots more than 0
            • ai_has_cautious_personality = yes
            • If has Treasury:
              • war_chest_treasury >= halved_ai_war_chest_treasury_maximum
            • Otherwise:
              • war_chest_gold >= halved_ai_war_chest_gold_maximum

            Then

            • move_budget_gold = { gold = excess_over_halved_ai_war_chest_gold from = budget_war_chest to = budget_short_term }
            • If has Treasury:
              • move_budget_treasury = { treasury = excess_over_halved_ai_war_chest_treasury from = budget_war_chest to = budget_short_term }

            Else if

            Then

            • move_budget_gold = { gold = war_chest_gold from = budget_war_chest to = budget_short_term }
            • If has Treasury:
              • move_budget_treasury = { treasury = war_chest_treasury from = budget_war_chest to = budget_short_term }

            Else if

            • If has Treasury:
              • war_chest_treasury > cautious_ai_minimum_war_chest_treasury
            • Otherwise:
              • war_chest_gold > cautious_ai_minimum_war_chest_gold
            • ai_has_cautious_personality = yes
          • … (more in the script below)
        • … (more in the script below)

• the game's own tooltip text · ◦ our reading of the script line · code the script where neither exists

“They” is whatever it runs on (the scope it is called in). The scripted triggers and effects it calls link to their own pages; $PARAMETERS$ stay as written: each call fills them in.

The script as written (120 lines of game script)
ai_budget_manipulation_effect = {
	# Tweaks to the War Chest AI budget - sometimes the AI will be brave enough to boom
	if = {
		limit = { is_ai = yes }
		if = { # Some special logic to make certain AI's save up gold to revoke titles in their desired domain
			limit = {
				is_at_war = no
				is_playable_character = yes
				trigger_if = {
					limit = { has_treasury = yes }
					treasury >= 50
					treasury < minimum_ai_treasury_value_for_tyranny_wars
				}
				trigger_else = {
					gold >= 50
					gold < minimum_ai_gold_value_for_tyranny_wars
				}
				NOR = {
					has_character_flag = ai_revoke_recheck_cooldown
					government_has_flag = government_is_nomadic
				}
				primary_title.tier >= tier_duchy
				years_from_game_start >= 3
				domain_size < domain_limit
				has_realm_law_flag = title_revocation_allowed
				OR = { # Tyranny tolerance is based on rationality
					AND = {
						ai_rationality < 0
						tyranny <= 15 # Don't go crazy with tyranny, just a bit is fine
					}
					AND = {
						ai_rationality >= 0
						ai_rationality < 50
						tyranny <= 5 # Don't go crazy with tyranny, just a bit is fine
					}
					AND = {
						ai_rationality >= 50
						tyranny <= 0 # Don't go crazy with tyranny, just a bit is fine
					}
				}
				OR = {
					primary_title.title_capital_county = {
						holder != root
						holder = {
							current_military_strength < root.current_military_strength
							is_vassal_or_below_of = root
							NOR = {
								vassal_contract_has_flag = vassal_contract_cannot_revoke_titles
								has_relation_friend = root
								has_relation_best_friend = root
								has_relation_lover = root
								has_relation_soulmate = root
								is_child_of = root
								is_grandchild_of = root
								is_great_grandchild_of = root
							}
						}
					}
					AND = {
						primary_title.tier >= tier_kingdom
						exists = primary_title.title_capital_county.de_jure_liege.holder
						primary_title.title_capital_county.de_jure_liege = {
							holder != root
							holder = {
								current_military_strength < root.current_military_strength
								is_vassal_or_below_of = root
								NOR = {
									vassal_contract_has_flag = vassal_contract_cannot_revoke_titles
									has_relation_friend = root
									has_relation_best_friend = root
									has_relation_lover = root
									has_relation_soulmate = root
									is_child_of = root
									is_grandchild_of = root
									is_great_grandchild_of = root
								}
							}
						}
					}
					any_sub_realm_county = {
						holder != root
						title_province = { has_holding_type = castle_holding }
						this != root.primary_title.title_capital_county
						duchy = root.primary_title.title_capital_county.duchy
						holder = {
							current_military_strength < root.current_military_strength
							NOR = {
								vassal_contract_has_flag = vassal_contract_cannot_revoke_titles
								has_relation_friend = root
								has_relation_best_friend = root
								has_relation_lover = root
								has_relation_soulmate = root
								is_child_of = root
								is_grandchild_of = root
								is_great_grandchild_of = root
							}
						}
					}
				}
				trigger_if = {
					limit = {
						domain_size > 3
					}
					NOR = {
						has_trait = generous
						has_trait = just
					}
				}
				NOT = {
					primary_title = title:e_hre
				}
			}
			if = {
				limit = {
					primary_title.title_capital_county = {
						holder != root
						holder = {
							current_military_strength < root.current_military_strength
							is_vassal_or_below_of = root
							NOT = { vassal_contract_has_flag = vassal_contract_cannot_revoke_titles }

As written in game/common/scripted_effects/00_ai_budget_effects.txt.

The first 120 of its 688 lines; the rest is in game/common/scripted_effects/00_ai_budget_effects.txt from line 5.

Where it is used

Every place in common/, events/ and history/ that calls ai_budget_manipulation_effect.

On actions (the game's own hooks) (1)

  • yearly_playable_pulse

Source: game/common/scripted_effects/00_ai_budget_effects.txt and every file of common/, events/ and history/ that calls it, Crusader Kings III 1.20.1.2.

Spotted a mistake on this page?