ability = {
	jap_last_stand = {
		name = ABILITY_LAST_STAND
		desc = ABILITY_LAST_STAND_DESC
		
		sound_effect = command_power_ability_offensive
		
		type = army_leader
		
		allowed = {
			is_leading_army_group = no
			is_border_war = no
			OWNER = {
				OR = {
					has_completed_focus = JAP_warrior_spirit
					has_completed_focus = SPA_cultivate_fanaticism
				}
			}
		}
		
		cost = 0.2
		duration = 168
		cooldown = 168
		
		one_time_effect = {
			add_temporary_buff_to_units = {
				combat_offense = 0.15
				combat_defense = -0.05
				org_damage_multiplier = -0.25
				str_damage_multiplier = 0.25
			    war_support_reduction_on_damage = 0.25
				cannot_retreat_while_defending = 1.0
				
				days = 5
				tooltip = ABILITY_LAST_STAND_TOOLTIP
			}
		}
		
		ai_will_do = {
			factor = -1
			modifier = {
				FROM = {
					has_war_support > 0.4
				}
				
				check_variable = { num_units_defensive_combats > 6 }
				
				set_temp_variable = { temp = avg_defensive_combat_status }
				check_variable = { temp < 0.40 }
				check_variable = { ai_random > temp }
				
				add = 2
			}
		}
	}
}