﻿#Build Pleasure Dome

mpo_pleasure_dome_decision = {
    picture = {
        reference = "gfx/interface/illustrations/event_scenes/mpo_city_steppe.dds"
    }
	decision_group_type = nomad_minor
	sort_order = 80

	is_shown = {
        always = no
		has_mpo_dlc_trigger = yes
        OR = {
	       	government_has_flag = government_is_nomadic
            has_trait = nomadic_philosophy
        }
        NOT = { has_global_variable = devised_pleasure_dome }
        #culture = {
        #    OR = {
        #        has_cultural_pillar = heritage_mongolic
        #        has_cultural_pillar = heritage_turkic
        #    }
        #}
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = mpo_pleasure_dome_no_barony_tt
			any_held_title = {
				tier = tier_barony
				title_province = {
                    has_special_building_slot = no
                }
				is_capital_barony = yes
				holder = root
				is_leased_out = no
                title_province = { geographical_region = world_steppe }
			}
		}
	}

	is_valid = {
		prestige_level >= very_high_prestige_level
		highest_held_title_tier = tier_empire
		custom_tooltip = {
			text = dominate_title_trigger_dominance_4
			OR = {
				has_realm_law = nomadic_authority_5
				has_realm_law = nomadic_authority_4
			}
		}
	}

    cost = {
        gold = 1000
        prestige = 1500
        herd = 2000
    }

    widget = {
        controller = create_holy_order
        barony_valid = {
            trigger_if = {
                limit = { exists = this }
                title_province = {
                    has_special_building_slot = no
                }
                is_capital_barony = yes
                holder = scope:ruler
                is_leased_out = no
            }
        }
    }
    effect = {
        send_interface_toast = {
            type = event_toast_effect_good
            title = mpo_pleasure_dome_slot_added.toast
            
            if = { 
                limit = { exists = scope:barony }
                custom_tooltip = {
                    text = mpo_add_pleasure_dome_effect_tt
                    scope:barony.title_province = { add_special_building = pleasure_dome }
                }
            }
        }
        custom_description_no_bullet = { text = mpo_pleasure_dome_barony_decision_tt }
        
        set_global_variable = {
            name = devised_pleasure_dome
            value = yes
        }
    }
    ai_check_interval = 60
    ai_potential = {
        is_at_war = no
		gold >= 1500
    }
    ai_will_do = {
        base = 100
    }
}

##Paiza decisions

#Starting decision, establish the system 
mpo_establish_paiza_system_decision = {
    picture = {
        reference = "gfx/interface/illustrations/event_scenes/mpo_rural_village_asian.dds"
    }
    decision_group_type = nomad_major
    sort_order = 80

    is_shown = {
		has_mpo_dlc_trigger = yes
        government_has_flag = government_is_nomadic
        NOT = { has_character_flag = established_paiza_system }
		exists = situation:the_great_steppe
		any_character_situation = {
			this = situation:the_great_steppe
		}
		OR = {
            has_realm_law = nomadic_authority_2
            has_realm_law = nomadic_authority_3
			has_realm_law = nomadic_authority_4
			has_realm_law = nomadic_authority_5
		}
    }

    is_valid = {
        culture ?= {
            has_innovation = innovation_ledger
        }
        is_independent_ruler = yes
        custom_tooltip = {
			text = mpo_establish_paiza_system_decision_is_gurkhan
			exists = situation:the_great_steppe
			this = situation:the_great_steppe.situation_top_herd
		}
		OR = {
			has_realm_law = nomadic_authority_4
			has_realm_law = nomadic_authority_5
		}    
    }

    is_valid_showing_failures_only = {
        trigger_if = {
            limit = {
                exists = global_var:global_established_paiza_system
            }
            custom_tooltip = {
                text = mpo_establish_paiza_system_decision.paiza_recently_established
                subject = global_var:global_established_paiza_system
                NAND = {  
                    global_var:global_established_paiza_system ?= {
                        is_alive = yes
                        has_realm_law = nomadic_authority_5
                    }
                }
            }
        }   
    }

    cost = {
        gold = {
            value = massive_prestige_value
        }
        prestige = {
            value = massive_prestige_value
        }
        herd = {
            value = 2000
        }
    }


    effect = {
        add_character_flag = established_paiza_system
        set_global_variable = {
            name = global_established_paiza_system
            value = root
            years = 8
        }
        custom_tooltip = mpo_establish_paiza_system_decision.grant_paiza_interaction_unlocked
        custom_tooltip = mpo_establish_paiza_system_decision.request_paiza_interaction_unlocked
        custom_tooltip = mpo_establish_paiza_system_decision.paiza_obedient
        custom_tooltip = mpo_establish_paiza_system_decision.call_for_merchants_decision_unlocked
        custom_tooltip = mpo_establish_paiza_system_decision.leverage_khan_authority_unlocked
        custom_tooltip = mpo_establish_paiza_system_decision.paiza_abuse_authority_unlocked

        if = { #populating the world with paizas
            limit = {
                is_ai = yes
            }
            ai_paiza_giveaway_effect = yes
            ai_paiza_giveaway_effect = yes
            ai_paiza_giveaway_effect = yes
            ai_paiza_giveaway_effect = yes
        }
        
        trigger_event = mpo_decisions_events.0099
    }

    ai_check_interval = 10

    ai_will_do = { 
        base = 100
    }
}

mpo_call_for_merchants_decision = {
    picture = {
        reference = "gfx/interface/illustrations/decisions/fp3_decision_tax_collector.dds"
    }
    decision_group_type = nomad_major
    sort_order = 80

    is_shown = {
		has_mpo_dlc_trigger = yes
        government_has_flag = government_is_nomadic
        has_character_flag = established_paiza_system
    }

    is_valid = {
        custom_tooltip = {
			text = mpo_call_for_merchants_decision_is_gurkhan
			exists = situation:the_great_steppe
			this = situation:the_great_steppe.situation_top_herd
		}
        OR = {
			has_realm_law = nomadic_authority_4
			has_realm_law = nomadic_authority_5
		}
        trigger_if = {
            limit = {
                is_ai = no
            }
            domicile ?= {
                has_domicile_building_or_higher = trade_yurt_04
            }
        }
        trigger_else = {
            always = yes
        }
        gold >= 800
    }

    is_valid_showing_failures_only = {
        custom_tooltip = {
            text = mpo_call_for_merchants_decision.robbed_merchants
            NOT = {
                has_character_modifier = mpo_paiza_robbed_merchants
            }
        }
    }

    cost = {
        prestige = {
            value = major_prestige_value
        }
    }

    cooldown = { years = 4 }

    effect = {
        trigger_event = mpo_decisions_events.2139
        custom_tooltip = mpo_call_for_merchants_decision.merchant_will_arrive
        custom_tooltip = mpo_call_for_merchants_decision.gold_needed
        custom_tooltip = mpo_call_for_merchants_decision.buildings
    }

    ai_check_interval = 100

    ai_will_do = {
        base = 0
        modifier = {
            add = 8
            domicile ?= {
                has_domicile_building_or_higher = merchant_yurt_01
            }
        }
        modifier = {
            add = 8
            domicile ?= {
                has_domicile_building_or_higher = herd_trade_yurt_01
            }
        }
        modifier = {
            add = 8
            domicile ?= {
                has_domicile_building_or_higher = fertility_trade_yurt_01
            }
        }       
        modifier = {
            add = 8
            domicile ?= {
                has_domicile_building_or_higher = knight_trade_yurt_01
            }
        }
        modifier = {
            add = 20
            gold >= 2400
        }
    }

    ai_potential = {
        is_at_war = no
        ai_greed >= medium_positive_ai_value
    }
}

mpo_call_for_merchants_small_decision = {
    picture = {
        reference = "gfx/interface/illustrations/decisions/fp3_decision_tax_collector.dds"
    }
    decision_group_type = nomad_minor
    sort_order = 80

    is_shown = {
        has_mpo_dlc_trigger = yes
        government_has_flag = government_is_nomadic
        NOT = {
            has_character_flag = established_paiza_system
        }   
    }

    is_valid = {
        domicile ?= {
            has_domicile_building_or_higher = trade_yurt_01
        }
        gold >= 400
    }

    is_valid_showing_failures_only = {
        custom_tooltip = {
            text = mpo_call_for_merchants_decision.robbed_merchants
            NOT = {
                has_character_modifier = mpo_paiza_robbed_merchants
            }
        }
        
    }

    cost = {
        prestige = {
            value = major_prestige_value
        }
    }

    cooldown = { years = 8 }

    effect = {
        trigger_event = mpo_decisions_events.2139
        custom_tooltip = mpo_call_for_merchants_decision.merchant_will_arrive_smol
        custom_tooltip = mpo_call_for_merchants_decision.gold_needed_smol
        custom_tooltip = mpo_call_for_merchants_decision.buildings
    }

    ai_check_interval = 100

    ai_will_do = {
        base = 0
        modifier = {
            add = 4
            domicile ?= {
                has_domicile_building_or_higher = merchant_yurt_01
            }
        }
        modifier = {
            add = 4
            domicile ?= {
                has_domicile_building_or_higher = herd_trade_yurt_01
            }
        }
        modifier = {
            add = 4
            domicile ?= {
                has_domicile_building_or_higher = fertility_trade_yurt_01
            }
        }       
        modifier = {
            add = 4
            domicile ?= {
                has_domicile_building_or_higher = knight_trade_yurt_01
            }
        }
        modifier = {
            add = 20
            gold >= 1200
        }
    }

    ai_potential = {
        is_at_war = no
        ai_greed >= medium_positive_ai_value
    }
}

mpo_abuse_authority_paiza_decision = {
    picture = {
        reference = "gfx/interface/illustrations/event_scenes/mpo_camp_steppe.dds"
    }

    decision_group_type = nomad_major
    sort_order = 80

    is_shown = {
		has_mpo_dlc_trigger = yes
        is_imprisoned = no
        any_character_artifact = {
            root = { can_benefit_from_artifact = prev }
            exists = var:paiza_patron 
            NOT = {
                root = var:paiza_patron
                var:paiza_patron = {
                    is_at_war_with = root
                }
            }                    
        }
    }

    is_valid = {
        prestige_level >= 2
        trigger_if = {
            limit = {
                has_character_flag = no_more_paiza_abuse
            }
            custom_tooltip = {
                text = mpo_abuse_authority_paiza_decision.no_more_paiza_abuse
                NOT = {
                    has_character_flag = no_more_paiza_abuse
                }
            }
        }      
    }

    is_valid_showing_failures_only = {
        custom_tooltip = {
            text = mpo_abuse_authority_paiza_decision.paiza_patron_not_topdog
            any_character_artifact = {
                root = { can_benefit_from_artifact = prev }
                exists = var:paiza_patron
                var:paiza_patron ?= {
                    is_gurkhan = yes
                }    
            }
        }
        custom_tooltip = {
            text = mpo_abuse_authority_paiza_decision.nothing_to_abuse
            location ?= {
                duchy ?= {
                    any_de_jure_county = {
                        county_ready_for_abuse_trigger = yes             
                    }
                }
            }
        }
    }

    effect = {
        trigger_event = mpo_decisions_events.0110
        show_as_tooltip = {
            mpo_abuse_authority_county_effect = yes
            random_character_artifact = {
                limit = {
                    root = { can_benefit_from_artifact = prev }
                    exists = var:paiza_patron
                }        
                var:paiza_patron ?= {
                    save_temporary_scope_as = paiza_patron
                }
                root = {
                    mpo_paiza_abuse_counter_effect = {
                        PAIZA_PATRON = scope:paiza_patron
                        PAIZA_ABUSER = root
                    }
                }   
            }       
        }
    }

    cooldown = { years = 2 }

    cost = {
        prestige = {
            value = major_prestige_value
        }
    }

    ai_check_interval = 10 

    ai_will_do = {
        base = -20

        modifier = {
            add = 10
            has_trait = greedy
        }
        modifier = {
            add = 10
            has_trait = wrathful
        }
        modifier = {
            add = 10
            has_trait = ambitious
        }
        modifier = {
            add = {
                value = max_herd
                subtract = herd
                divide = max_herd
                multiply = 10
            }
            domicile ?= {
                herd <= max_herd
            }
        }
    }
}

