
# defences

utility_component_template = {
    key = "PLNMG_IB_DEFENCE_1S"
    size = small
    icon = GFX_ship_part_shield_5 #temp
    component_set = PLNMG_IB_DEFENCE_1
    modifier = {
        ship_shield_add = @shield_S5
        ship_shield_regen_add_static = @regen_S5
        ship_armor_add = @armor_S5
        ship_hull_add = @hull_S5
    }
    ship_modifier = { damage_random_nearby_enemy_on_death = 0.5 }
    custom_tooltip = PLNMG_IB_DEFENCE_1_TT

    resources = {
        category = ship_components
        cost = {
            alloys = 34
            exotic_gases = 0.333
            rare_crystals = 0.333
        }
        upkeep = {
            energy = 0.34
            alloys = 0.068
        }
    }

    prerequisites = { tech_planetmega_dummy }
    show_tech_unlock_if = { always = no }
    potential = { can_design_plnmg_ib_defence = yes }
    should_ai_use = no
}
utility_component_template = {
    key = "PLNMG_IB_DEFENCE_1M"
    size = medium
    icon = GFX_ship_part_shield_5 #temp
    component_set = PLNMG_IB_DEFENCE_1
    modifier = {
        ship_shield_add = @shield_M5
        ship_shield_regen_add_static = @regen_M5
        ship_armor_add = @armor_M5
        ship_hull_add = @hull_M5
    }
    ship_modifier = { damage_random_nearby_enemy_on_death = 0.5 }
    custom_tooltip = PLNMG_IB_DEFENCE_1_TT

    resources = {
        category = ship_components
        cost = {
            alloys = 66
            exotic_gases = 0.666
            rare_crystals = 0.666
        }
        upkeep = {
            energy = 0.46
            alloys = 0.132
        }
    }

    prerequisites = { tech_planetmega_dummy }
    show_tech_unlock_if = { always = no }
    potential = { can_design_plnmg_ib_defence = yes }
    should_ai_use = no
}
utility_component_template = {
    key = "PLNMG_IB_DEFENCE_1L"
    size = large
    icon = GFX_ship_part_shield_5 #temp
    component_set = PLNMG_IB_DEFENCE_1
    modifier = {
        ship_shield_add = @shield_L5
        ship_shield_regen_add_static = @regen_L5
        ship_armor_add = @armor_L5
        ship_hull_add = @hull_L5
    }
    ship_modifier = { damage_random_nearby_enemy_on_death = 0.5 }
    custom_tooltip = PLNMG_IB_DEFENCE_1_TT

    resources = {
        category = ship_components
        cost = {
            alloys = 133
            exotic_gases = 1.333
            rare_crystals = 1.333
        }
        upkeep = {
            energy = 1.32
            alloys = 0.284
        }
    }

    prerequisites = { tech_planetmega_dummy }
    show_tech_unlock_if = { always = no }
    potential = { can_design_plnmg_ib_defence = yes }
    should_ai_use = no
}

utility_component_template = {
    key = "PLNMG_IB_DEFENCE_2S"
    size = small
    icon = GFX_ship_part_behemoth_armor #temp
    component_set = PLNMG_IB_DEFENCE_2
    modifier = {
        ship_shield_add = @shield_S6
        ship_shield_regen_add_static = @regen_S6
        ship_armor_add = @armor_S6
        ship_hull_add = @hull_S6
    }
    ship_modifier = { damage_random_nearby_enemy_on_death = 1 }
    custom_tooltip = PLNMG_IB_DEFENCE_2_TT

    resources = {
        category = ship_components
        cost = {
            alloys = 50
            exotic_gases = 0.5
            rare_crystals = 0.5
        }
        upkeep = {
            energy = 0.5
            alloys = 0.1
        }
    }

    prerequisites = { tech_planetmega_dummy }
    show_tech_unlock_if = { always = no }
    potential = { can_design_plnmg_ib_defence = yes }
    should_ai_use = no
}
utility_component_template = {
    key = "PLNMG_IB_DEFENCE_2M"
    size = medium
    icon = GFX_ship_part_behemoth_armor #temp
    component_set = PLNMG_IB_DEFENCE_2
    modifier = {
        ship_shield_add = @shield_M6
        ship_shield_regen_add_static = @regen_M6
        ship_armor_add = @armor_M6
        ship_hull_add = @hull_M6
    }
    ship_modifier = { damage_random_nearby_enemy_on_death = 1 }
    custom_tooltip = PLNMG_IB_DEFENCE_2_TT

    resources = {
        category = ship_components
        cost = {
            alloys = 95
            exotic_gases = 0.888
            rare_crystals = 0.888
        }
        upkeep = {
            energy = 0.95
            alloys = 0.18
        }
    }

    prerequisites = { tech_planetmega_dummy }
    show_tech_unlock_if = { always = no }
    potential = { can_design_plnmg_ib_defence = yes }
    should_ai_use = no
}
utility_component_template = {
    key = "PLNMG_IB_DEFENCE_2L"
    size = large
    icon = GFX_ship_part_behemoth_armor #temp
    component_set = PLNMG_IB_DEFENCE_2
    modifier = {
        ship_shield_add = @shield_L6
        ship_shield_regen_add_static = @regen_L6
        ship_armor_add = @armor_L6
        ship_hull_add = @hull_L6
    }
    ship_modifier = { damage_random_nearby_enemy_on_death = 1 }
    custom_tooltip = PLNMG_IB_DEFENCE_2_TT

    resources = {
        category = ship_components
        cost = {
            alloys = 188
            exotic_gases = 1.332
            rare_crystals = 1.332
        }
        upkeep = {
            energy = 1.88
            alloys = 0.376
        }
    }

    prerequisites = { tech_planetmega_dummy }
    show_tech_unlock_if = { always = no }
    potential = { can_design_plnmg_ib_defence = yes }
    should_ai_use = no
}

### aux

utility_component_template = {
    key = "PLNMG_RICNT_COMP"
    size = aux
    icon = "GFX_ship_part_boarding_cables"
    icon_frame = 1
    power = -75
    resources = {
        category = ship_components
        cost = {
            alloys = 75
        }
    }

    # not displayed, so custom tooltip is needed to explain
    ship_modifier = {
        plnmg_ricnt_ship_times_add = 1
        ship_steal_defeated_ship_chance = 0.01
        fleet_capture_defeated_leader_chance = 0.001
    }
    triggered_ship_modifier = {
        potential = { controller? = { is_variable_set = var_plnmg_reincarnation_count } }
        plnmg_ricnt_ship_times_add = 1
        ship_steal_defeated_ship_chance = 0.01
        fleet_capture_defeated_leader_chance = 0.001
        mult = controller.var_plnmg_reincarnation_count
    }

    custom_tooltip = "PLNMG_RICNT_COMP_TOOLTIP"
    prerequisites = { tech_planetmega_reincarnation }
    potential = {
        #not = { has_component = PLNMG_RICNT_COMP }
        from = { is_ai = no }
    }
    component_set = "PLNMG_RICNT_COMP"
    should_ai_use = no
    ai_weight = { weight = 0 }
}

### special utility components

utility_component_template = {
    key = "PLNMG_MAGINOT_NEXUS_STB_COMP"
    size = medium
    icon = "GFX_ship_part_aura_range"
    icon_frame = 1
    power = 0

    custom_tooltip = plnmg_maginot_nexus_stb_comp_tt
    triggered_ship_modifier = {
        potential = { owner? = { has_active_tradition = tr_pm_granchor_swap_3_orbit_deter } }
        ship_fire_rate_mult = 0.35
        ship_weapon_damage = 0.20
        ship_tracking_add = 10
    }

    friendly_aura = {
        name = "aura_plnmg_maginot_nexus_dsc"
        system_wide = yes
        stack_info = {
            id = friendly_plnmg_maginot_nexus_dsc_aura
            priority = 10
        }
        limit = { is_space_citadel_ship_size = yes }
        modifier = {
            ship_fire_rate_mult = 0.15
            ship_weapon_damage = 0.15
            ship_tracking_add = 5
            ship_weapon_range_mult = 5
            ship_engagement_range_mult = 5
            ship_damage_reduction_mult = 0.05
            ship_target_weight_mult = 1
        }
    }
}

utility_component_template = {
    key = "COMP_PLNMG_EG_CATAPULT"
    size = aux
    icon = "GFX_arkship_exodus_jump"
    icon_frame = 1
    power = 0
    hidden = yes

    custom_tooltip = sm_planetmega_eg_catapult_tt
    #scripted_action = {  }

    potential = { is_arkship_tier_3 = yes }
    # prerequisites = { "tech_planetmega_transfer" }
    # show_tech_unlock_if = { is_nomadic = yes }
    component_set = "COMP_PLNMG_EG_CATAPULT"

    ai_weight = { weight = @advanced_cloaking_weight }
}

utility_component_template = {
    key = "COMP_PLNMG_EXCAVATOR"
    size = aux
    icon = "GFX_arkship_planetary_refinery"
    icon_frame = 1
    power = 0
    hidden = yes

    custom_tooltip = sm_planetmega_ca_excavator_tt
    #scripted_action = {  }

    potential = { is_arkship_tier_3 = yes }
    # prerequisites = { "tech_planetmega_colossus" }
    # show_tech_unlock_if = { is_nomadic = yes }
    component_set = "COMP_PLNMG_EXCAVATOR"

    ai_weight = { weight = @advanced_cloaking_weight }
}
