
#ship scope

sv_plnmg_total_ship_hp = {
    add = trigger:has_max_armor_hp
    mult = trigger:has_armor_percentage
    add = trigger:has_shield_hp
    add = trigger:has_hp
    min = 1
}

# WARNING: specially for planetmega.1110
former_ship_ricnt_revival_count = {
    base = 1
    modifier = {
        prevprev = { is_variable_set = ship_ricnt_revival_count }
        add = prevprev.ship_ricnt_revival_count
    }
}

#planet scope

sv_plnmg_itss_recharge_cost_mult = {
    #this = event_target:fire_launcher_of_@from e.g. shooter planet
    complex_trigger_modifier = {
        potential = {
            solar_system = {
                not = { is_same_value = root.solar_system }
                or = {
                    not = { exists = owner }
                    owner = { not = { is_same_value = prevprev.owner } }
                }
            }
        }
        trigger = distance_to_empire
        parameters = {
            who = from
            type = euclidean
            use_bypasses = no
        }
        mode = set
        mult = @plntITSS_distanceFactor
    }
    min = 1
    square_root = yes
    max = 100
    modifier = {
        exists = owner
        mult = owner.value:sv_colossus_recharge_cost_mult
    }
    mult = value:scripted_modifier_mult|MODIFIER|planetmega_itss_recharge_cost_mult|
    round_to = 0.02
    min = 0
    max = 100
}

sv_plnmg_itss_fleet_recharge_cost_mult = {
    complex_trigger_modifier = {
        potential = {
            solar_system = {
                not = { is_same_value = root.solar_system }
                or = {
                    not = { exists = owner }
                    owner = { not = { is_same_value = prevprev.owner } }
                }
            }
        }
        trigger = distance_to_empire
        parameters = {
            who = from
            type = euclidean
            use_bypasses = no
        }
        mode = set
        mult = @plntITSS_distanceFactor
    }
    min = 1
    square_root = yes
    max = 100
    modifier = {
        exists = owner
        mult = owner.value:sv_colossus_recharge_cost_mult
    }
    mult = value:scripted_modifier_mult|MODIFIER|planetmega_itss_recharge_cost_mult|
    round_to = 0.02
    min = 0
    max = 100
    mult = root.trigger:fleet_size
}

# country scope

sv_colossus_recharge_cost_mult = {
    base = 1
    #divide = value:count_plnmg_colossus_recharge_facility
    modifier = {
        has_any_plnmg_aeg_supportive_structure = yes
        divide = modifier:planetmega_aeg_support_base
    }
    modifier = {
        has_any_plnmg_aeg_supportive_structure = no
        mult = 10
    }
    max = 1
    min = 0.01
}

# sv_colossus_recharge_cost_mult = {
#     set = num_plnmg_colossus_fired_count
#     square = yes
#     mult = value:sv_plnmg_crc_plnt_factor
#     round = yes
#     max = value:sv_plnmg_crc_max_resource
# }
sv_plnmg_crc_plnt_factor = {
    base = 1
    complex_trigger_modifier = {
        trigger = count_owned_colony
        parameters = { limit = { has_deposit = d_plnmg_colossus_assist } }
        mode = divide
    }
    complex_trigger_modifier = {
        trigger = count_owned_colony
        parameters = { limit = { has_deposit = d_plnmg_colossus_assist } }
        mode = add
        mult = 0.02
    }
}
sv_plnmg_crc_max_resource = {
    base = 50000
    add = modifier:country_resource_max_add
    add = modifier:country_resource_max_energy_add
}

# count_plnmg_colossus_recharge_facility = {
#     modifier = {
#         check_modifier_value = { modifier = planetmega_ca_oc_enc_modifier value > 0 }
#         subtract = modifier:planetmega_ca_oc_enc_modifier
#     }
#     mult = 10
#     complex_trigger_modifier = {
#         trigger = count_owned_colony
#         parameters = { limit = { has_deposit = d_plnmg_colossus_assist } }
#         mode = add
#     }
#     complex_trigger_modifier = {
#         trigger = count_starbase_buildings
#         parameters = {
#             type = colossus_assist_orbital_accessory
#             include_being_constructed = no
#         }
#         mode = add
#         mult = 0.1
#     }
#     complex_trigger_modifier = {
#         trigger = count_owned_megastructure
#         parameters = {
#             limit = {
#                 or = {
#                     is_megastructure_type = planetmega_colossus_assistant_2
#                     is_megastructure_type = planetmega_colossus_assistant_restored
#                 }
#             }
#         }
#         mode = add
#         mult = 10
#     }
#     complex_trigger_modifier = {
#         trigger = count_owned_megastructure
#         parameters = { limit = { is_megastructure_type = planetmega_colossus_assistant_1 } }
#         mode = add
#         mult = 3
#     }
# }
# sv_plnmg_ca_oc_enc_modifier_mult = {
#     add = modifier:planetmega_ca_oc_enc_modifier
#     mult = 10
# }

plnmg_pmhs_perf_enhance_ps_res_mult = {
    base = 1
    modifier = {
        is_variable_set = eaten_planet_sizes
        add = eaten_planet_sizes
    }
    min = 2
}

plnmg_raid_goods_mult = {
    add = trigger:free_jobs
    # modifier = {
    #     mult = from.PR_var_plnt_MAN
    #     from = {
    #         is_variable_set = PR_var_plnt_MAN
    #         check_variable = { which = PR_var_plnt_MAN value > 0 }
    #     }
    # }
}

# WARNING: Specially for planetmega.1110
sv_plnmg_ricnt_energy_cost_mult = {
    base = 1
    modifier = {
        fromfrom = { is_variable_set = ship_ricnt_revival_count }
        add = fromfrom.ship_ricnt_revival_count
    }
    complex_trigger_modifier = {
        trigger = ship_size_multiplier
        trigger_scope = fromfrom
        mode = mult
    }
    modifier = {
        is_variable_set = var_plnmg_reincarnation_count
        divide = var_plnmg_reincarnation_count
    }
    min = 1
    max = 1000
}
