﻿defend = {
    texture = "gfx/interface/icons/commander_order_icons/defend.dds"
	
	military_type = army
	behavior = defend
    is_basic_order_type = yes

    visible = {
		has_role = general
	}

    possible = {
		has_role = general
    }

    modifier = {
		unit_defense_mult = 0.1
    }

	entity_animation = "defend"
	clicksound = "event:/SFX/UI/Military/order_general_front_defend"
	experience = 0.1 # This much extra experience per week while executing Order
	
	ai_weight = {
		value = 1
	}
}


defend_dig_in = {
    texture = "gfx/interface/icons/commander_order_icons/zw_defend_adamant_defense.dds"
    
    military_type = army
    behavior = defend

    visible = {
		has_role = general
	}

    possible = {
            has_role = general
    	OR = {
    		has_trait = basic_defensive_strategist
            has_trait = experienced_defensive_strategist
            has_trait = expert_defensive_strategist
    	}
    }

    modifier = {
        unit_defense_mult = 0.1
        unit_supply_consumption_mult = -0.1
        character_battle_condition_dug_in_mult = 1
    }

    entity_animation = "defend"
    clicksound = "event:/SFX/UI/Military/order_general_front_defend"
    experience = 0.1 # This much extra experience per week while executing Order


    ai_weight = {
        value = 2
    }
}

defend_desperate_charge = {
    texture = "gfx/interface/icons/commander_order_icons/zw_defend_counter_charge.dds"
    
    military_type = army
    behavior = defend

    visible = {
		has_role = general
	}

    possible = {
        has_role = general
        has_trait = brave
        trigger_if = {
            limit = {
                has_role = general
            }
            OR = {
                commander_military_formation ?= {
                    formation_army_unit_type_fraction = {
                        target = unit_type:combat_unit_type_hussars
                        value >= 0.5
                    }
                }
                commander_military_formation ?= {
                    formation_army_unit_type_fraction = {
                        target = unit_type:combat_unit_type_dragoons
                        value >= 0.5
                    }
                }
                commander_military_formation ?= {
                    formation_army_unit_type_fraction = {
                        target = unit_type:combat_unit_type_cuirassiers
                        value >= 0.5
                    }
                }
                commander_military_formation ?= {
                    formation_army_unit_type_fraction = {
                        target = unit_type:combat_unit_type_lancers
                        value >= 0.5
                    }
                }
            }
        }
    }

    modifier = {
        unit_kill_rate_add = 0.25
        unit_morale_damage_mult = 0.25
        battle_casualties_mult = 0.1
        character_battle_condition_surprise_maneuver_mult = 0.5
        character_battle_condition_aggressive_maneuver_mult = 0.5
    }

    entity_animation = "defend"
    clicksound = "event:/SFX/UI/Military/order_general_front_defend"
    experience = 0.1 # This much extra experience per week while executing Order

    ai_weight = {
        value = 2
    }
}

defend_last_stand = {
    texture = "gfx/interface/icons/commander_order_icons/zw_defend_last_stand.dds"
    
    military_type = army
    behavior = defend

    visible = {
		has_role = general
	}

    possible = {
          has_role = general
        OR = {
            has_trait = stalwart_defender
            has_trait = trench_rat
            has_trait = defense_in_depth_specialist
        }
    }

    modifier = {
        battle_casualties_mult = 0.05
        unit_defense_mult = 0.15
    }

    entity_animation = "defend"
    clicksound = "event:/SFX/UI/Military/order_general_front_defend"
    experience = 0.1 # This much extra experience per week while executing Order

    ai_weight = {
        value = 2
    }
}

defend_guerilla_warfare = {
    texture = "gfx/interface/icons/commander_order_icons/zw_defend_delaying_tatics.dds"
    
    military_type = army
    behavior = defend

    visible = {
		has_role = general
	}

    possible = {
        has_role = general
        OR = {
            has_trait = pillager
            has_trait = cruel
            has_trait = wrathful
            has_trait = bandit
        }
        trigger_if = {
            limit = {
                has_role = general
            }
            OR = {
                commander_military_formation ?= {
                    formation_army_unit_type_fraction = {
                        target = unit_type:combat_unit_type_irregular_infantry
                        value >= 0.8
                    }
                }
                commander_military_formation ?= {
                    formation_army_unit_type_fraction = {
                        target = unit_type:combat_unit_type_skirmish_infantry
                        value >= 0.8
                    }
                }
                commander_military_formation ?= {
                    formation_army_unit_type_fraction = {
                        target = unit_type:combat_unit_type_squad_infantry
                        value >= 0.8
                    }
                }
            }
        }
    }

    modifier = {
        unit_defense_mult = 0.1
        unit_morale_loss_mult = 0.15
        character_battle_condition_camouflaged_mult = 2
        character_battle_condition_surprise_maneuver_mult = 1
    #    unit_enemy_devastation_mult = 1 ## add enemy devastation mult
    #   unit_enemy_ocupation_mult = 0.3 ## add a new trigger for reducing the amount of occupied territory gets
    }

    entity_animation = "defend"
    clicksound = "event:/SFX/UI/Military/order_general_front_defend"
    experience = 0.1 # This much extra experience per week while executing Order
	
	ai_weight = {
		value = 2
	}
}

