
tr_pm_granchor_adopt = {
    possible = {
        or = {
            num_tradition_categories > 0
            can_early_build_planetmega = yes
            # has_civic = civic_planetmega_rationalist
        }
    }
    custom_tooltip = tr_pm_granchor_adopt_tt
    unlocks_agenda = agenda_planetmega_granchor
}
tr_pm_granchor_finish = {
    modifier = {
        planetmega_space_need_mult = -0.05
        ascension_perks_add = 1
    }
}

tr_pm_granchor_swap_1 = {
    on_enabled = {
        hidden_effect = {
            set_country_flag = pm_granchor_swap1_enabled
            country_event = { id = planetmega_global.51 }
        }
    }
    custom_tooltip = tr_pm_granchor_swap_1_desc

    tradition_swap = {
        name = tr_pm_granchor_swap_1_pmm
        inherit_name = no
        inherit_icon = no
        inherit_effects = no
        trigger = {
            has_country_flag = pm_granchor_swap1_enabled
            has_technology = tech_zero_point_power
        }
        inline_script = traditions/tr_pm_granchor_pmm_core
        weight = {
            set = 1
            modifier = {
                add = pm_granchor_pmm_core_weight
                is_variable_set = pm_granchor_pmm_core_weight
            }
            modifier = {
                mult = 1000
                is_variable_set = pm_granchor_swap1_forced_index
                check_variable = { which = pm_granchor_swap1_forced_index value = 1 }
            }
        }
    }
    tradition_swap = {
        name = tr_pm_granchor_swap_1_qt
        inherit_name = no
        inherit_icon = no
        inherit_effects = no
        trigger = {
            has_country_flag = pm_granchor_swap1_enabled
            has_technology = tech_fe_lab_1
        }
        inline_script = traditions/tr_pm_granchor_qt_reconst
        weight = {
            set = 1
            modifier = {
                add = pm_granchor_qt_reconst_weight
                is_variable_set = pm_granchor_qt_reconst_weight
            }
            modifier = {
                mult = 1000
                is_variable_set = pm_granchor_swap1_forced_index
                check_variable = { which = pm_granchor_swap1_forced_index value = 2 }
            }
        }
    }
    tradition_swap = {
        name = tr_pm_granchor_swap_1_eg
        inherit_name = no
        inherit_icon = no
        inherit_effects = no
        trigger = {
            always = no
            # has_country_flag = pm_granchor_swap1_enabled
            # has_technology = tech_planetmega_transfer
        }
        inline_script = traditions/tr_pm_granchor_eg_ext
        weight = {
            set = 1
            modifier = {
                add = pm_granchor_eg_weight
                is_variable_set = pm_granchor_eg_weight
            }
            modifier = {
                mult = 1000
                is_variable_set = pm_granchor_swap1_forced_index
                check_variable = { which = pm_granchor_swap1_forced_index value = 3 }
            }
        }
    }

    ai_weight = { weight = 1000 }
}
tr_pm_granchor_pmm_core = {
    possible = { always = no }
    inline_script = traditions/tr_pm_granchor_pmm_core
}
tr_pm_granchor_qt_reconst = {
    possible = { always = no }
    inline_script = traditions/tr_pm_granchor_qt_reconst
}
tr_pm_granchor_eg_ext = {
    possible = { always = no }
    inline_script = traditions/tr_pm_granchor_eg_ext
}

tr_pm_granchor_dynexp_1 = {
    #custom_tooltip_with_modifiers = tr_pm_granchor_dynexp_1_desc
    modifier = {
        ground_megastructure_build_speed_mult = 0.1
        planet_building_build_speed_mult = 0.25
        ground_megastructure_build_cap_add = 3
    }
    ai_weight = { weight = 1000 }
}

tr_pm_granchor_swap_3 = {
    possible = { has_tr_pm_granchor_swap_1 = yes }
    on_enabled = {
        hidden_effect = {
            set_country_flag = pm_granchor_swap3_enabled
            country_event = { id = planetmega_global.52 }
        }
    }
    custom_tooltip = tr_pm_granchor_swap_3_desc

    tradition_swap = {
        name = tr_pm_granchor_swap_3_autodef
        inherit_name = no
        inherit_icon = no
        inherit_effects = no
        trigger = {
            has_country_flag = pm_granchor_swap3_enabled
            has_planetmega_nanotech = yes
        }
        inline_script = traditions/tr_pm_granchor_autodef
        weight = {
            set = 1
            modifier = {
                add = pm_granchor_autodef_weight
                is_variable_set = pm_granchor_autodef_weight
            }
            modifier = {
                mult = 1000
                is_variable_set = pm_granchor_swap3_forced_index
                check_variable = { which = pm_granchor_swap3_forced_index value = 1 }
            }
        }
    }
    tradition_swap = {
        name = tr_pm_granchor_swap_3_orbit_deter
        inherit_name = no
        inherit_icon = no
        inherit_effects = no
        trigger = {
            has_country_flag = pm_granchor_swap3_enabled
            has_technology = tech_planetmega_active_defense
        }
        custom_tooltip = tr_pm_granchor_orbit_deter_desc
        weight = {
            set = 1
            modifier = {
                add = pm_granchor_orbit_deter_weight
                is_variable_set = pm_granchor_orbit_deter_weight
            }
            modifier = {
                mult = 1000
                is_variable_set = pm_granchor_swap3_forced_index
                check_variable = { which = pm_granchor_swap3_forced_index value = 2 }
            }
        }
    }

    ai_weight = { weight = 1000 }
}
tr_pm_granchor_autodef = {
    possible = { always = no }
    inline_script = traditions/tr_pm_granchor_autodef
}
tr_pm_granchor_orbit_deter = {
    possible = { always = no }
    custom_tooltip = tr_pm_granchor_orbit_deter_desc
}

tr_pm_granchor_reshaper = {
    possible = {
        has_tradition = tr_pm_granchor_dynexp_1
        has_tr_pm_granchor_swap_1 = yes
        #has_technology = tech_planetmega_transfer_prereq
    }
    custom_tooltip_with_modifiers = tr_pm_granchor_reshaper_desc
    modifier = {
        terraform_speed_mult = 0.25
    }
    ai_weight = { weight = 1000 }
}

tr_pm_granchor_swap_5 = {
    possible = { has_tradition = tr_pm_granchor_dynexp_1 }
    on_enabled = {
        hidden_effect = {
            set_country_flag = pm_granchor_swap5_enabled
            country_event = { id = planetmega_global.53 }
        }
    }
    custom_tooltip = tr_pm_granchor_swap_5_desc

    tradition_swap = {
        name = tr_pm_granchor_swap_5_dynexp_2
        inherit_name = no
        inherit_icon = no
        inherit_effects = no
        trigger = {
            has_country_flag = pm_granchor_swap5_enabled
            has_technology = tech_planetmega_advanced
        }
        inline_script = traditions/tr_pm_granchor_dynexp_2
        weight = {
            set = 1
            modifier = {
                add = pm_granchor_dynexp_2_weight
                is_variable_set = pm_granchor_dynexp_2_weight
            }
            modifier = {
                mult = 1000
                is_variable_set = pm_granchor_swap5_forced_index
                check_variable = { which = pm_granchor_swap5_forced_index value = 1 }
            }
        }
    }
    tradition_swap = {
        name = tr_pm_granchor_swap_5_alter_dim_const
        inherit_name = no
        inherit_icon = no
        inherit_effects = no
        trigger = {
            has_country_flag = pm_granchor_swap5_enabled
            is_planetmega_psionic = yes
        }
        inline_script = traditions/tr_pm_granchor_alter_dim_const
        weight = {
            set = 1
            modifier = {
                add = pm_granchor_alter_dim_const_weight
                is_variable_set = pm_granchor_alter_dim_const_weight
            }
            modifier = {
                mult = 1000
                is_variable_set = pm_granchor_swap5_forced_index
                check_variable = { which = pm_granchor_swap5_forced_index value = 2 }
            }
        }
    }
    tradition_swap = {
        name = tr_pm_granchor_swap_5_lively_use
        inherit_name = no
        inherit_icon = no
        inherit_effects = no
        trigger = { has_country_flag = pm_granchor_swap5_enabled }
        inline_script = traditions/tr_pm_granchor_lively_use
        weight = {
            set = 2
            modifier = {
                mult = 10000
                is_variable_set = pm_granchor_swap5_forced_index
                check_variable = { which = pm_granchor_swap5_forced_index value = 3 }
            }
        }
    }

    ai_weight = { weight = 1000 }
}
tr_pm_granchor_dynexp_2 = {
    possible = { always = no }
    inline_script = traditions/tr_pm_granchor_dynexp_2
}
tr_pm_granchor_alter_dim_const = {
    possible = { always = no }
    inline_script = traditions/tr_pm_granchor_alter_dim_const
}
tr_pm_granchor_lively_use = {
    possible = { always = no }
    inline_script = traditions/tr_pm_granchor_lively_use
}
