﻿gbf_commander_event = {
	type = commander

	is_valid = {
		exists = root
	}
	
	chance = {
		base = 600

		modifier = {
			add = {
				value = martial
				multiply = 10
				max = 400
			}
		}

		modifier = {
			factor = 1.5
			has_trait = brave
		}

		modifier = {
			factor = 0.75
			has_trait = craven
		}

		modifier = {
			factor = 0.6
			is_ai = yes
			has_trait_xp = {
			    trait = gbf_commander
				value >= 45
			}
		}

		modifier = {
			factor = 0.7
			has_trait_xp = {
			    trait = gbf_commander
				value >= 50
			}
		}

		modifier = {
			factor = {
				value = scope:combat_side.enemy_side.side_strength
				divide = scope:combat_side.side_strength
				max = 2 # 2倍兵力时获得最大增益 - 2倍的经验值
				min = 1 # 防止bug
			}
			scope:combat_side.side_strength < scope:combat_side.enemy_side.side_strength
			scope:combat_side.side_strength > 50
		}

	}
	
	effect = {
		root = {
		    if = {
		        limit = {has_trait = gbf_commander}
		        add_trait_xp = {
                    trait = gbf_commander
                    value = { 1 3 }
                }
		    }
		    else = {
		        add_trait = gbf_commander
		    }
		}
	}
}