SOV_unit_production = {
	allowed = {
		original_tag = SOV
	}
	enable = {
		always = yes
	}
	abort = {
		always = no
	}

	ai_strategy = {
		type = role_ratio
		id = garrison
		value = 1
	}

	ai_strategy = {
		type = role_ratio
		id = paratroopers
		value = 0
	}

	ai_strategy = {
		type = role_ratio
		id = mountaineers
		value = 2
	}

	ai_strategy = {
		type = role_ratio
		id = marines
		value = 0
	}

	ai_strategy = {
		type = role_ratio
		id = cavalry
		value = 0
	}

	ai_strategy = {
		type = role_ratio
		id = motorized
		value = 1
	}

	ai_strategy = {
		type = role_ratio
		id = mechanized
		value = 0
	}

	ai_strategy = {
		type = role_ratio
		id = armor
		value = 5
	}

	ai_strategy = {
		type = role_ratio
		id = infantry
		value = 40 #because doctrine 70
	}

	#Air unit factors
	ai_strategy = {
		type = unit_ratio
		id = fighter
		value = 40
	}

	ai_strategy = {
		type = unit_ratio
		id = cas
		value = 2 #because doctrine this = 15
	}

	ai_strategy = {
		type = unit_ratio
		id = tactical_bomber
		value = 5
	}

	ai_strategy = {
		type = unit_ratio
		id = strategic_bomber
		value = -50 # we can add a strategy later to increase this once Germany is beaten
	}

	ai_strategy = {
		type = unit_ratio
		id = naval_bomber
		value = 4
	}


	# Naval unit factors
	ai_strategy = {
		type = unit_ratio
		id = capital_ship
		value = 1
	}
	ai_strategy = {
		type = unit_ratio
		id = carrier
		value = 1
	}
	ai_strategy = {
		type = unit_ratio
		id = submarine
		value = 30
	}

	ai_strategy = {
		type = unit_ratio
		id = screen_ship
		value = 20
	}

	ai_strategy = {
		type = unit_ratio
		id = convoy
		value = 20
	}

	ai_strategy = {
		type = equipment_production_factor
		id = fighter
		value = 25
	}

	ai_strategy = {
		type = equipment_production_factor
		id = tactical_bomber
		value = -20
	}

	ai_strategy = {
		type = equipment_production_factor
		id = naval_bomber
		value = -100
	}

	ai_strategy = {
		type = equipment_production_factor
		id = infantry
		value = 15
	}

	ai_strategy = {
		type = equipment_production_factor
		id = artillery
		value = 100
	}

	ai_strategy = {
		type = equipment_production_min_factories
		id = artillery
		value = 4
	}

	ai_strategy = {
		type = equipment_production_factor
		id = armor
		value = 5
	}
}

SOV_anti_armor = {
	allowed = {
		original_tag = SOV
	}
	enable = {
		ai_wants_divisions > 5 #Decreasing the amount of motorized the AI wants

		any_enemy_country = {
			ROOT = {
				estimated_intel_max_armor = {
					tag = PREV
					value > 25
				}
			}
		}
	}
	abort = {
		ai_wants_divisions < 6 #Decreasing the amount of motorized the AI wants
	}

	ai_strategy = {
		type = role_ratio
		id = motorized
		value = 5
	}
}

southern_thrust = {
	enable = {
		tag = SOV
		has_completed_focus = SOV_ultimatum_middle_east
		OR = {
			country_exists = AFG
			country_exists = PER
			country_exists = IRQ
			country_exists = TUR
		}
	}
	abort = {
		NOT = {
			country_exists = AFG
			country_exists = PER
			country_exists = IRQ
			country_exists = TUR
		}
		NOT = {
			TUR = {
				is_subject = yes
			}
			AFG = {
				is_subject = yes
			}
			PER = {
				is_subject = yes
			}
			IRQ = {
				is_subject = yes
			}
		}
	}

	ai_strategy = {
		type = antagonize
		id = "PER"
		value = 100
	}
	ai_strategy = {
		type = antagonize
		id = "AFG"
		value = 100
	}
	ai_strategy = {
		type = antagonize
		id = "IRQ"
		value = 50
	}
	ai_strategy = {
		type = antagonize
		id = "TUR"
		value = 200 # Gotta get Istanbul :)
	}
}

#Do not attack turkey if they're protected
ignore_turkey = {
    enable = {
        tag = SOV
        has_wargoal_against = TUR
        OR = {
            any_country = {
                OR = {
                    is_in_faction_with = GER
                    is_in_faction_with = ENG
                    is_major = yes
                }
                has_guaranteed = TUR
            }
            any_country = {
                is_major = yes
                is_in_faction_with = TUR
            }
            any_country = {
                OR = {
                    tag = TUR
                    is_in_faction_with = TUR
                }
                has_idea = anti_soviet_pact
            }
        }
    }
    abort = {
        OR = {
            NOT = {
                OR = {
                    any_country = {
                        OR = {
                            is_in_faction_with = GER
                            is_in_faction_with = ENG
                            is_major = yes
                        }
                        has_guaranteed = TUR
                    }
                    any_country = {
                        is_major = yes
                        is_in_faction_with = TUR
                    }
                    any_country = {
                        OR = {
                            tag = TUR
                            is_in_faction_with = TUR
                        }
                        has_idea = anti_soviet_pact
					}
					TUR = {
						OR = {
							if = {
								limit = {
									is_in_faction = yes
									NOT = {
										any_country = {
											has_guaranteed = TUR
										}
									}
								}
								alliance_strength_ratio < 0.8
							}
							has_war_with = SOV
						}
					}
				}
			}
			TUR = {
				OR = {
					if = {
						limit = {
							is_in_faction = yes
							NOT = {
								any_country = {
									has_guaranteed = TUR
								}
							}
						}
						#set_temp_variable = { total_faction_strength = 0 }
						#any_of = {
						#	array = TUR.faction_members
						#	value = current
						#	index = i

						#	add_to_temp_variable = {
						#		var = total_faction_strength
						#		value = current.num_divisions
						#	}
						#	check_variable = {
						#		var = SOV.num_divisions
						#		value = total_faction_strength
						#		compare = greater_than
						#	}
						#}
						#print_variables = {
						#	file = log_file
						#	text = header_text
						#	append = yes
						#	print_global = yes
						#	var_list = { SOV.num_divisions total_faction_strength TUR.faction_members }
						#}
					}
					has_war_with = SOV
				}
			}
            NOT = {
                has_wargoal_against = TUR
            }
            date > 1944.01.01
        }
    }

	ai_strategy = {
		type = ignore
		id = "TUR"
		value = 1000
	}

	ai_strategy = {
		type = ignore_claim
		id = "TUR"
		value = 1000
	}

	ai_strategy = {
		type = declare_war
		id = "TUR"
		value = -1000
	}

	ai_strategy = {
		type = area_priority
		id = middle_east
		value = -150
	}
}

#Do not attack afghanistan if they're protected
ignore_afghanistan = {
    enable = {
        tag = SOV
        has_wargoal_against = AFG
        OR = {
            any_country = {
                OR = {
                    is_in_faction_with = GER
                    is_in_faction_with = ENG
                    is_major = yes
                }
                has_guaranteed = AFG
            }
            any_country = {
                is_major = yes
                is_in_faction_with = AFG
            }
            any_country = {
                OR = {
                    tag = AFG
                    is_in_faction_with = AFG
                }
                has_idea = anti_soviet_pact
            }
        }
    }
    abort = {
        OR = {
            NOT = {
                OR = {
                    any_country = {
                        OR = {
                            is_in_faction_with = GER
                            is_in_faction_with = ENG
                            is_major = yes
                        }
                        has_guaranteed = AFG
                    }
                    any_country = {
                        is_major = yes
                        is_in_faction_with = AFG
                    }
                    any_country = {
                        OR = {
                            tag = AFG
                            is_in_faction_with = AFG
                        }
                        has_idea = anti_soviet_pact
					}
					AFG = {
						OR = {
							if = {
								limit = {
									NOT = {
										any_country = {
											has_guaranteed = AFG
										}
									}
								}
								alliance_strength_ratio < 0.8
							}
							has_war_with = SOV
						}
					}
                }
            }
            NOT = {
                has_wargoal_against = AFG
            }
            date > 1944.01.01
        }
    }

    ai_strategy = {
        type = ignore
        id = "AFG"
        value = 1000
    }

    ai_strategy = {
        type = declare_war
        id = "AFG"
        value = -1000
    }

    ai_strategy = {
        type = area_priority
        id = middle_east
        value = -150
    }
}

#Do not attack Iran if they're protected
ignore_persia = {
    enable = {
        tag = SOV
        has_wargoal_against = PER
        OR = {
            any_country = {
                OR = {
                    is_in_faction_with = GER
                    is_in_faction_with = ENG
                    is_major = yes
                }
                has_guaranteed = PER
            }
            any_country = {
                is_major = yes
                is_in_faction_with = PER
            }
            any_country = {
                OR = {
                    tag = PER
                    is_in_faction_with = PER
                }
                has_idea = anti_soviet_pact
            }
        }
    }
    abort = {
        OR = {
            NOT = {
                OR = {
                    any_country = {
                        OR = {
                            is_in_faction_with = GER
                            is_in_faction_with = ENG
                            is_major = yes
                        }
                        has_guaranteed = PER
                    }
                    any_country = {
                        is_major = yes
                        is_in_faction_with = PER
                    }
                    any_country = {
                        OR = {
                            tag = PER
                            is_in_faction_with = PER
                        }
                        has_idea = anti_soviet_pact
					}
					PER = {
						OR = {
							if = {
								limit = {
									NOT = {
										any_country = {
											has_guaranteed = PER
										}
									}
								}
								alliance_strength_ratio < 0.8
							}
							has_war_with = SOV
						}
					}
                }
            }
            NOT = {
                has_wargoal_against = PER
            }
            date > 1944.01.01
        }
    }

    ai_strategy = {
        type = ignore
        id = "PER"
        value = 1000
    }

    ai_strategy = {
        type = declare_war
        id = "PER"
        value = -1000
    }

    ai_strategy = {
        type = area_priority
        id = middle_east
        value = -150
    }
}

#Do not attack iraq if they're protected
ignore_iraq = {
    enable = {
        tag = SOV
        has_wargoal_against = IRQ
        OR = {
            any_country = {
                OR = {
                    is_in_faction_with = GER
                    is_in_faction_with = ENG
                    is_major = yes
                }
                has_guaranteed = IRQ
            }
            any_country = {
                is_major = yes
                is_in_faction_with = IRQ
            }
            any_country = {
                OR = {
                    tag = IRQ
                    is_in_faction_with = IRQ
                }
                has_idea = anti_soviet_pact
            }
        }
    }
    abort = {
        OR = {
            NOT = {
                OR = {
                    any_country = {
                        OR = {
                            is_in_faction_with = GER
                            is_in_faction_with = ENG
                            is_major = yes
                        }
                        has_guaranteed = IRQ
                    }
                    any_country = {
                        is_major = yes
                        is_in_faction_with = IRQ
                    }
                    any_country = {
                        OR = {
                            tag = IRQ
                            is_in_faction_with = IRQ
                        }
                        has_idea = anti_soviet_pact
					}
					IRQ = {
						OR = {
							if = {
								limit = {
									NOT = {
										any_country = {
											has_guaranteed = IRQ
										}
									}
								}
								alliance_strength_ratio < 0.8
							}
							has_war_with = SOV
						}
					}
                }
            }
            NOT = {
                has_wargoal_against = IRQ
            }
            date > 1944.01.01
        }
    }

	ai_strategy = {
		type = ignore
		id = "IRQ"
		value = 1000
	}

	ai_strategy = {
		type = declare_war
		id = "IRQ"
		value = -1000
	}

	ai_strategy = {
		type = area_priority
		id = middle_east
		value = -150
	}
}

claims_on_poland = {
	enable = {
		tag = SOV
		has_completed_focus = SOV_russian_expansion
		country_exists = POL
	}
	abort = {
		OR = {
			NOT = {
				country_exists = POL
			}
			is_in_faction_with = POL
			POL = {
				is_subject_of = ROOT
			}
			has_non_aggression_pact_with = POL
			has_country_leader = {
				character = SOV_Ivan_nikolaevich
				ruling_only = yes
			}
		}
	}

	ai_strategy = {
		type = antagonize
		id = "POL"
		value = 200
	}
}

#Do not attack poland if they're protected
ignore_poland = {
	enable = {
        tag = SOV
        has_wargoal_against = POL
        OR = {
            any_country = {
                OR = {
                    is_in_faction_with = GER
                    is_in_faction_with = ENG
                    is_major = yes
                }
                has_guaranteed = POL
            }
            any_country = {
                is_major = yes
                is_in_faction_with = POL
            }
            any_country = {
                OR = {
                    tag = POL
                    is_in_faction_with = POL
                }
                has_idea = anti_soviet_pact
            }
        }
    }
    abort = {
        OR = {
            NOT = {
                OR = {
                    any_country = {
                        OR = {
                            is_in_faction_with = GER
                            is_in_faction_with = ENG
                            is_major = yes
                        }
                        has_guaranteed = POL
                    }
                    any_country = {
                        is_major = yes
                        is_in_faction_with = POL
                    }
                    any_country = {
                        OR = {
                            tag = POL
                            is_in_faction_with = POL
                        }
                        has_idea = anti_soviet_pact
					}
					POL = {
						OR = {
							if = {
								limit = {
									NOT = {
										any_country = {
											has_guaranteed = POL
										}
									}
								}
								alliance_strength_ratio < 0.8
							}
							has_war_with = SOV
						}
					}
                }
            }
            NOT = {
                has_wargoal_against = POL
            }
            date > 1944.01.01
        }
    }

	ai_strategy = {
		type = ignore
		id = "POL"
		value = 350
	}

	ai_strategy = {
		type = ignore_claim
		id = "POL"
		value = 100
	}

	ai_strategy = {
		type = declare_war
		id = "POL"
		value = -1000
	}
}

claims_on_baltic = {
	enable = {
		tag = SOV
		has_completed_focus = SOV_russian_expansion
		OR = {
			country_exists = LAT
			country_exists = LIT
			country_exists = EST
		}
	}
	abort = {
		OR = {
			NOT = {
				country_exists = LAT
				country_exists = LIT
				country_exists = EST
			}
			has_country_leader = {
				character = SOV_Ivan_nikolaevich
				ruling_only = yes
			}
		}
	}

	ai_strategy = {
		type = antagonize
		id = "LAT"
		value = 200
	}
	ai_strategy = {
		type = antagonize
		id = "LIT"
		value = 200
	}
	ai_strategy = {
		type = antagonize
		id = "EST"
		value = 200
	}
}

#Do not attack lithuania if they're protected
ignore_lithuania = {
	enable = {
        tag = SOV
        has_wargoal_against = LIT
        OR = {
            any_country = {
                OR = {
                    is_in_faction_with = GER
                    is_in_faction_with = ENG
                    is_major = yes
                }
                has_guaranteed = LIT
            }
            any_country = {
                is_major = yes
                is_in_faction_with = LIT
            }
            any_country = {
                OR = {
                    tag = LIT
                    is_in_faction_with = LIT
                }
                has_idea = anti_soviet_pact
            }
        }
    }
    abort = {
        OR = {
            NOT = {
                OR = {
                    any_country = {
                        OR = {
                            is_in_faction_with = GER
                            is_in_faction_with = ENG
                            is_major = yes
                        }
                        has_guaranteed = LIT
                    }
                    any_country = {
                        is_major = yes
                        is_in_faction_with = LIT
                    }
                    any_country = {
                        OR = {
                            tag = LIT
                            is_in_faction_with = LIT
                        }
                        has_idea = anti_soviet_pact
					}
					LIT = {
						OR = {
							if = {
								limit = {
									NOT = {
										any_country = {
											has_guaranteed = LIT
										}
									}
								}
								alliance_strength_ratio < 0.8
							}
							has_war_with = SOV
						}
					}
                }
            }
            NOT = {
                has_wargoal_against = LIT
            }
            date > 1944.01.01
        }
    }

	ai_strategy = {
		type = ignore
		id = "LIT"
		value = 350
	}

	ai_strategy = {
		type = declare_war
		id = "LIT"
		value = -1000
	}

	ai_strategy = {
		type = ignore_claim
		id = "LIT"
		value = 1
	}
}

#Do not attack latvia if they're protected
ignore_latvia = {
	enable = {
        tag = SOV
        has_wargoal_against = LAT
        OR = {
            any_country = {
                OR = {
                    is_in_faction_with = GER
                    is_in_faction_with = ENG
                    is_major = yes
                }
                has_guaranteed = LAT
            }
            any_country = {
                is_major = yes
                is_in_faction_with = LAT
            }
            any_country = {
                OR = {
                    tag = LAT
                    is_in_faction_with = LAT
                }
                has_idea = anti_soviet_pact
            }
        }
    }
    abort = {
        OR = {
            NOT = {
                OR = {
                    any_country = {
                        OR = {
                            is_in_faction_with = GER
                            is_in_faction_with = ENG
                            is_major = yes
                        }
                        has_guaranteed = LAT
                    }
                    any_country = {
                        is_major = yes
                        is_in_faction_with = LAT
                    }
                    any_country = {
                        OR = {
                            tag = LAT
                            is_in_faction_with = LAT
                        }
                        has_idea = anti_soviet_pact
					}
					LAT = {
						OR = {
							if = {
								limit = {
									NOT = {
										any_country = {
											has_guaranteed = LAT
										}
									}
								}
								alliance_strength_ratio < 0.8
							}
							has_war_with = SOV
						}
					}
                }
            }
            NOT = {
                has_wargoal_against = LAT
            }
            date > 1944.01.01
        }
    }

	ai_strategy = {
		type = ignore
		id = "LAT"
		value = 350
	}

	ai_strategy = {
		type = declare_war
		id = "LAT"
		value = -1000
	}

	ai_strategy = {
		type = ignore_claim
		id = "LAT"
		value = 1
	}
}

#Do not attack Estonia if they're protected
ignore_estonia = {
	enable = {
        tag = SOV
        has_wargoal_against = EST
        OR = {
            any_country = {
                OR = {
                    is_in_faction_with = GER
                    is_in_faction_with = ENG
                    is_major = yes
                }
                has_guaranteed = EST
            }
            any_country = {
                is_major = yes
                is_in_faction_with = EST
            }
            any_country = {
                OR = {
                    tag = EST
                    is_in_faction_with = EST
                }
                has_idea = anti_soviet_pact
            }
        }
    }
    abort = {
        OR = {
            NOT = {
                OR = {
                    any_country = {
                        OR = {
                            is_in_faction_with = GER
                            is_in_faction_with = ENG
                            is_major = yes
                        }
                        has_guaranteed = EST
                    }
                    any_country = {
                        is_major = yes
                        is_in_faction_with = EST
                    }
                    any_country = {
                        OR = {
                            tag = EST
                            is_in_faction_with = EST
                        }
                        has_idea = anti_soviet_pact
					}
					EST = {
						OR = {
							if = {
								limit = {
									NOT = {
										any_country = {
											has_guaranteed = EST
										}
									}
								}
								alliance_strength_ratio < 0.8
							}
							has_war_with = SOV
						}
					}
                }
            }
            NOT = {
                has_wargoal_against = EST
            }
            date > 1944.01.01
        }
    }

	ai_strategy = {
		type = ignore
		id = "EST"
		value = 350
	}

	ai_strategy = {
		type = declare_war
		id = "EST"
		value = -1000
	}

	ai_strategy = {
		type = ignore_claim
		id = "EST"
		value = 1
	}
}

claims_on_finland = {
	enable = {
		tag = SOV
		has_completed_focus = SOV_red_finland
		country_exists = FIN
	}
	abort = {
		OR = {
			NOT = {
				country_exists = FIN
			}
			FIN = {
				has_government = ROOT
			}
			controls_state = 146 #Karelija
		}
	}

	ai_strategy = {
		type = antagonize
		id = "FIN"
		value = 200
	}
}

#Do not attack Finland if they're protected
ignore_finland = {
	enable = {
        tag = SOV
        has_wargoal_against = FIN
        OR = {
            any_country = {
                OR = {
                    is_in_faction_with = GER
                    is_in_faction_with = ENG
                    is_major = yes
                }
                has_guaranteed = FIN
            }
            any_country = {
                is_major = yes
                is_in_faction_with = FIN
            }
            any_country = {
                OR = {
                    tag = FIN
                    is_in_faction_with = FIN
                }
                has_idea = anti_soviet_pact
            }
        }
    }
    abort = {
        OR = {
            NOT = {
                OR = {
                    any_country = {
                        OR = {
                            is_in_faction_with = GER
                            is_in_faction_with = ENG
                            is_major = yes
                        }
                        has_guaranteed = FIN
                    }
                    any_country = {
                        is_major = yes
                        is_in_faction_with = FIN
                    }
                    any_country = {
                        OR = {
                            tag = FIN
                            is_in_faction_with = FIN
                        }
                        has_idea = anti_soviet_pact
					}
					FIN = {
						OR = {
							if = {
								limit = {
									NOT = {
										any_country = {
											has_guaranteed = FIN
										}
									}
								}
								alliance_strength_ratio < 0.8
							}
							has_war_with = SOV
						}
					}
                }
            }
            NOT = {
                has_wargoal_against = FIN
            }
            date > 1944.01.01
        }
    }

	ai_strategy = {
		type = ignore
		id = "FIN"
		value = 350
	}

	ai_strategy = {
		type = declare_war
		id = "FIN"
		value = -1000
	}

	ai_strategy = {
		type = ignore_claim
		id = "FIN"
		value = 1
	}
}

claims_on_romania = {
	enable = {
		tag = SOV
		has_completed_focus = SOV_russian_expansion
		country_exists = ROM
	}
	abort = {
		NOT = {
			country_exists = ROM
		}
	}

	ai_strategy = {
		type = antagonize
		id = "ROM"
		value = 200
	}
}

#Do not attack romania if they're protected
ignore_romania = {
	enable = {
        tag = SOV
        has_wargoal_against = ROM
        OR = {
            any_country = {
                OR = {
                    is_in_faction_with = GER
                    is_in_faction_with = ENG
                    is_major = yes
                }
                has_guaranteed = ROM
            }
            any_country = {
                is_major = yes
                is_in_faction_with = ROM
            }
            any_country = {
                OR = {
                    tag = ROM
                    is_in_faction_with = ROM
                }
                has_idea = anti_soviet_pact
            }
        }
    }
    abort = {
        OR = {
            NOT = {
                OR = {
                    any_country = {
                        OR = {
                            is_in_faction_with = GER
                            is_in_faction_with = ENG
                            is_major = yes
                        }
                        has_guaranteed = ROM
                    }
                    any_country = {
                        is_major = yes
                        is_in_faction_with = ROM
                    }
                    any_country = {
                        OR = {
                            tag = ROM
                            is_in_faction_with = ROM
                        }
                        has_idea = anti_soviet_pact
					}
					ROM = {
						OR = {
							if = {
								limit = {
									NOT = {
										any_country = {
											has_guaranteed = ROM
										}
									}
								}
								alliance_strength_ratio < 0.8
							}
							has_war_with = SOV
						}
					}
                }
            }
            NOT = {
                has_wargoal_against = ROM
            }
            date > 1944.01.01
        }
    }

	ai_strategy = {
		type = ignore
		id = "ROM"
		value = 350
	}

	ai_strategy = {
		type = declare_war
		id = "ROM"
		value = -1000
	}

	ai_strategy = {
		type = ignore_claim
		id = "ROM"
		value = 1
	}
}

claims_on_china = {
	enable = {
		tag = SOV
		OR = {
			has_completed_focus = SOV_force_chinese_unification
			has_completed_focus = SOV_one_china
		}
		if = {
			limit = {
				country_exists = PRC
			}
			country_exists = PRC
		}
		else = {
			country_exists = SIK
		}
	}
	abort = {
		if = {
			limit = {
				country_exists = PRC
			}
			NOT = {
				country_exists = PRC
			}
		}
		else = {
			NOT = {
				country_exists = SIK
			}
		}
	}

	ai_strategy = {
		type = antagonize
		id = "PRC"
		value = 200
	}
	ai_strategy = {
		type = antagonize
		id = "SIK"
		value = 200
	}
}

japan_ally = {
	enable = {
		tag = SOV
		SOV = {
			has_country_flag = SOV_ally_japan
		}
		country_exists = JAP
	}
	abort = {
		NOT = { country_exists = JAP }
	}

	ai_strategy = {
		type = befriend
		id = "JAP"
		value = 200
	}
	ai_strategy = {
		type = alliance
		id = "JAP"
		value = 200
	}
}

japan_refuse_south = {
	enable = {
		tag = SOV
		SOV = {
			has_country_flag = SOV_japan_not_south
		}
		country_exists = JAP
	}
	abort = {
		SOV = {
			has_war = yes
		}
	}

	ai_strategy = {
		type = antagonize
		id = "JAP"
		value = 50
	}
}

germany_ally = {
	enable = {
		tag = SOV
		OR = {
			has_country_flag = replaced_maisky
			GER = { has_completed_focus = GER_alliance_with_the_ussr }
		}
		country_exists = GER
	}
	abort = {
		NOT = { country_exists = GER }
	}

	ai_strategy = {
		type = befriend
		id = "GER"
		value = 100
	}
	ai_strategy = {
		type = alliance
		id = "GER"
		value = 50
	}
}

germany_enemy = {
	enable = {
		tag = SOV
		country_exists = GER
		OR = {
			has_completed_focus = SOV_officially_join_war
			date > 1942.1.1
			has_war_with = GER
		}
	}
	abort = {
		NOT = { country_exists = GER }
	}

	ai_strategy = {
		type = antagonize
		id = "GER"
		value = 200
	}
}

spanish_civil_war_SOV = {
	enable = {
		original_tag = SOV
		has_government = communism
		has_global_flag = spanish_civil_war
		NOT = { has_dlc = "La Resistance" }
		NOT = { has_global_flag = scw_over }
	}

	abort = {
		OR = {
			SPR = { has_civil_war = no }
			has_global_flag = scw_over
		}
	}

	ai_strategy = {
		type = befriend
		id = "SPR"
		value = 100
	}
}

spanish_civil_war_SOV_resistance = {
	enable = {
		original_tag = SOV
		has_government = communism
		country_exists = SPD
		has_dlc = "La Resistance"
		has_global_flag = spanish_civil_war
		NOT = { has_global_flag = scw_over }
	}

	abort = {
		has_global_flag = scw_over
	}

	ai_strategy = {
		type = befriend
		id = "SPD"
		value = 10
	}
	ai_strategy = {
		type = support
		id = "SPD"
		value = 100
	}
	ai_strategy = {
		type = send_volunteers_desire
		id = "SPD"
		value = 100
	}
}

SOV_template_design_1 = {
	allowed = {
		original_tag = SOV
	}
	enable = {
		date < 1940.1.1
	}
	abort = {
		date > 1940.1.1
	}

	ai_strategy = {
		type = template_prio
		id = motorized
		value = 10
	}

	ai_strategy = {
		type = template_prio
		id = cavalry
		value = -100
	}

	ai_strategy = {
		type = template_prio
		id = light_armor
		value = 50
	}

	ai_strategy = {
		type = template_prio
		id = medium_armor
		value = -10
	}

	ai_strategy = {
		type = template_prio
		id = heavy_armor
		value = -50
	}

	ai_strategy = {
		type = template_prio
		id = paratroopers
		value = -50
	}

	ai_strategy = {
		type = template_prio
		id = infantry
		value = 50
	}
}

SOV_template_design_2 = {
	allowed = {
		original_tag = SOV
	}
	enable = {
		date > 1940.1.1
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = template_prio
		id = mechanized
		value = 20
	}

	ai_strategy = {
		type = template_prio
		id = cavalry
		value = -100
	}

	ai_strategy = {
		type = template_prio
		id = light_armor
		value = 10
	}

	ai_strategy = {
		type = template_prio
		id = medium_armor
		value = 50
	}

	ai_strategy = {
		type = template_prio
		id = modern_armor
		value = 60
	}

	ai_strategy = {
		type = template_prio
		id = heavy_armor
		value = 20
	}

	ai_strategy = {
		type = template_prio
		id = paratroopers
		value = -50
	}

	ai_strategy = {
		type = template_prio
		id = infantry
		value = 10
	}
}

SOV_pp_spending = {
	enable = {
		original_tag = SOV
		has_manpower < 100000
		has_political_power < 200
	}
	abort = {
		OR = {
			has_manpower > 100000
			has_political_power > 200
			date > 1944.1.1
		}
	}

	ai_strategy = { # dont burn PP on admirals if you need manpower laws
		type = pp_spend_priority
		id = admiral
		value = -100
	}
}

#Stop the peasants before it's too late
SOV_stop_peasants = {
	enable = {
		original_tag = SOV
		date > 1943.1.1
		has_political_power < 100
		OR = {
			has_idea = SOV_Unhappy_peasants1
			has_idea = SOV_Unhappy_peasants2
			has_idea = SOV_Unhappy_peasants3
			has_idea = SOV_Unhappy_peasants4
			has_idea = SOV_Unhappy_peasants5
			has_idea = SOV_Unhappy_peasants6
		}
	}
	abort = {
		OR = {
			NOT = {
				has_idea = SOV_Unhappy_peasants1
				has_idea = SOV_Unhappy_peasants2
				has_idea = SOV_Unhappy_peasants3
				has_idea = SOV_Unhappy_peasants4
				has_idea = SOV_Unhappy_peasants5
				has_idea = SOV_Unhappy_peasants6
			}
			has_political_power > 100
		}
	}

	ai_strategy = {
		type = pp_spend_priority
		id = SOV_unhappy_peasants
		value = 1000
	}
}

SOV_play_nice_with_ribbentrop_pact = {
	enable = {
		tag = SOV
		has_global_flag = sov_yes_pact
		GER = { has_war_with = POL }
		date < 1941.1.1
	}
	abort = {
		OR ={
			GER = { has_war_with = SOV }
			NOT = { GER = { has_war_with = POL } }
			date > 1941.1.1
		}
	}

	# respect the spirit of the law ;)
	ai_strategy = {
		type = send_volunteers_desire
		id = "POL"
		value = -100
	}
}

SOV_naval_role_ratios_historical = {
	allowed = {
		has_dlc = "Man the Guns"
		original_tag = SOV
	}

	enable = {
		always = yes
	}
	abort_when_not_enabled = yes

	ai_strategy = {
		type = role_ratio
		id = naval_capital_bb
		value = -25
	}

	ai_strategy = {
		type = role_ratio
		id = naval_capital_bc
		value = -100
	}

	ai_strategy = {
		type = role_ratio
		id = naval_carrier
		value = -5
	}

	ai_strategy = {
		type = role_ratio
		id = naval_submarine
		value = 150
	}

	ai_strategy = {
		type = role_ratio
		id = naval_screen
		value = 150
	}

	ai_strategy = {
		type = role_ratio
		id = naval_cruiser_light
		value = 15
	}

	ai_strategy = {
		type = role_ratio
		id = naval_cruiser_heavy
		value = -15
	}

	ai_strategy = {
		type = role_ratio
		id = naval_mine_sweeper
		value = 15
	}

	ai_strategy = {
		type = role_ratio
		id = naval_mine_layer
		value = 80
	}
}


SOV_dont_upgrade_to_weapons_2_too_early = {
	enable = {
		original_tag = SOV
		OR = {
			date < "1943.1.1" # stock up on lots of rifles, we got the manpower
			AND = {
				date > "1943.8.1"
				surrender_progress < 0.1 # if we arent losing badly its ok now
			}
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = production_upgrade_desire_offset
		id = infantry_equipment_2
		value = -100
	}
}

#Not so sure
SOV_home_land_is_safe = {
	enable = {
		original_tag = SOV
		NOT = {
			country_exists = SOJ
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = garrison
		value = -10
	}
}

SOV_the_nkvd_is_all_the_intel_we_need = {
	enable = {
		tag = SOV
		has_government = communism
		has_dlc = "La Resistance"
		num_of_civilian_factories < 90
		num_of_civilian_factories > 35
	}
	abort = {
		OR = {
			num_of_civilian_factories > 90
		}
	}
	ai_strategy = {
		type = intelligence_agency_usable_factories
		value = -20
	}
}

SOV_dont_mess_with_volunteers_for_european_democratic_nations = { # Reverse strategy

	reversed = yes

	allowed = {
		original_tag = SOV
	}

	enable = {
		has_government = democratic
		SOV = {
			has_government = communism
		}
		NOT = {
			original_tag = SPR
		}

		capital_scope = {
			is_on_continent = europe # lets not mess with europe
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = send_volunteers_desire
		id = "SOV"
		value = -500
	}
}

#Help the Korean revolution
send_volunteers_revolutions_korea = {
	enable = {
		tag = SOV
		has_government = communism
		KOR = {
			has_country_flag = liberated_by_sov
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = befriend
		id = "KOR"
		value = 500
	}
	ai_strategy = {
		type = support
		id = "KOR"
		value = 500
	}
	ai_strategy = {
		type = send_volunteers_desire
		id = "KOR"
		value = 500
	}
}

#Help the Indochinese revolution
send_volunteers_revolutions_korea = {
	enable = {
		tag = SOV
		has_government = communism
		OR = {
			VIN = {
				has_country_flag = liberated_by_sov
			}
			LAO = {
				has_country_flag = liberated_by_sov
			}
			CAM = {
				has_country_flag = liberated_by_sov
			}
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = befriend
		id = "VIN"
		value = 500
	}
	ai_strategy = {
		type = support
		id = "VIN"
		value = 500
	}
	ai_strategy = {
		type = send_volunteers_desire
		id = "VIN"
		value = 500
	}

	ai_strategy = {
		type = befriend
		id = "LAO"
		value = 500
	}
	ai_strategy = {
		type = support
		id = "LAO"
		value = 500
	}
	ai_strategy = {
		type = send_volunteers_desire
		id = "LAO"
		value = 500
	}

	ai_strategy = {
		type = befriend
		id = "CAM"
		value = 500
	}
	ai_strategy = {
		type = support
		id = "CAM"
		value = 500
	}
	ai_strategy = {
		type = send_volunteers_desire
		id = "CAM"
		value = 500
	}
}

#Help the Tibetan revolution
send_volunteers_revolutions_korea = {
	enable = {
		tag = SOV
		has_government = communism
		TIB = {
			has_country_flag = liberated_by_sov
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = befriend
		id = "TIB"
		value = 500
	}
	ai_strategy = {
		type = support
		id = "TIB"
		value = 500
	}
	ai_strategy = {
		type = send_volunteers_desire
		id = "TIB"
		value = 500
	}
}

#Help the Moroccan revolution
send_volunteers_revolutions_korea = {
	enable = {
		tag = SOV
		has_government = communism
		MOR = {
			has_country_flag = liberated_by_sov
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = befriend
		id = "MOR"
		value = 500
	}
	ai_strategy = {
		type = support
		id = "MOR"
		value = 500
	}
	ai_strategy = {
		type = send_volunteers_desire
		id = "MOR"
		value = 500
	}
}

#Help the Egyptian revolution
send_volunteers_revolutions_korea = {
	enable = {
		tag = SOV
		has_government = communism
		EGY = {
			has_country_flag = liberated_by_sov
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = befriend
		id = "EGY"
		value = 500
	}
	ai_strategy = {
		type = support
		id = "EGY"
		value = 500
	}
	ai_strategy = {
		type = send_volunteers_desire
		id = "EGY"
		value = 500
	}
}

#Help the Ethiopian revolution
send_volunteers_revolutions_korea = {
	enable = {
		tag = SOV
		has_government = communism
		ETH = {
			has_country_flag = liberated_by_sov
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = befriend
		id = "ETH"
		value = 500
	}
	ai_strategy = {
		type = support
		id = "ETH"
		value = 500
	}
	ai_strategy = {
		type = send_volunteers_desire
		id = "ETH"
		value = 500
	}
}

#Help the Balkan revolution
send_volunteers_revolutions_korea = {
	enable = {
		tag = SOV
		has_government = communism
		OR = {
			SER = {
				has_country_flag = liberated_by_sov
			}
			CRO = {
				has_country_flag = liberated_by_sov
			}
			SLV = {
				has_country_flag = liberated_by_sov
			}
			BOS = {
				has_country_flag = liberated_by_sov
			}
			MNT = {
				has_country_flag = liberated_by_sov
			}
			MAC = {
				has_country_flag = liberated_by_sov
			}
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = befriend
		id = "SER"
		value = 500
	}
	ai_strategy = {
		type = support
		id = "SER"
		value = 500
	}
	ai_strategy = {
		type = send_volunteers_desire
		id = "SER"
		value = 500
	}

	ai_strategy = {
		type = befriend
		id = "CRO"
		value = 500
	}
	ai_strategy = {
		type = support
		id = "CRO"
		value = 500
	}
	ai_strategy = {
		type = send_volunteers_desire
		id = "CRO"
		value = 500
	}

	ai_strategy = {
		type = befriend
		id = "SLV"
		value = 500
	}
	ai_strategy = {
		type = support
		id = "SLV"
		value = 500
	}
	ai_strategy = {
		type = send_volunteers_desire
		id = "SLV"
		value = 500
	}

	ai_strategy = {
		type = befriend
		id = "BOS"
		value = 500
	}
	ai_strategy = {
		type = support
		id = "BOS"
		value = 500
	}
	ai_strategy = {
		type = send_volunteers_desire
		id = "BOS"
		value = 500
	}

	ai_strategy = {
		type = befriend
		id = "MNT"
		value = 500
	}
	ai_strategy = {
		type = support
		id = "MNT"
		value = 500
	}
	ai_strategy = {
		type = send_volunteers_desire
		id = "MNT"
		value = 500
	}

	ai_strategy = {
		type = befriend
		id = "MAC"
		value = 500
	}
	ai_strategy = {
		type = support
		id = "MAC"
		value = 500
	}
	ai_strategy = {
		type = send_volunteers_desire
		id = "MAC"
		value = 500
	}
}

#Help the British revolution
send_volunteers_revolutions_korea = {
	enable = {
		tag = SOV
		has_government = communism
		OR = {
			WLS = {
				has_country_flag = liberated_by_sov
			}
			SCO = {
				has_country_flag = liberated_by_sov
			}
			NIR = {
				has_country_flag = liberated_by_sov
			}
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = befriend
		id = "WLS"
		value = 500
	}
	ai_strategy = {
		type = support
		id = "WLS"
		value = 500
	}
	ai_strategy = {
		type = send_volunteers_desire
		id = "WLS"
		value = 500
	}

	ai_strategy = {
		type = befriend
		id = "SCO"
		value = 500
	}
	ai_strategy = {
		type = support
		id = "SCO"
		value = 500
	}
	ai_strategy = {
		type = send_volunteers_desire
		id = "SCO"
		value = 500
	}

	ai_strategy = {
		type = befriend
		id = "NIR"
		value = 500
	}
	ai_strategy = {
		type = support
		id = "NIR"
		value = 500
	}
	ai_strategy = {
		type = send_volunteers_desire
		id = "NIR"
		value = 500
	}
}

#Help the Iberian revolution
send_volunteers_revolutions_korea = {
	enable = {
		tag = SOV
		has_government = communism
		OR = {
			CAT = {
				has_country_flag = liberated_by_sov
			}
			NAV = {
				has_country_flag = liberated_by_sov
			}
			GLC = {
				has_country_flag = liberated_by_sov
			}
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = befriend
		id = "CAT"
		value = 500
	}
	ai_strategy = {
		type = support
		id = "CAT"
		value = 500
	}
	ai_strategy = {
		type = send_volunteers_desire
		id = "CAT"
		value = 500
	}

	ai_strategy = {
		type = befriend
		id = "NAV"
		value = 500
	}
	ai_strategy = {
		type = support
		id = "NAV"
		value = 500
	}
	ai_strategy = {
		type = send_volunteers_desire
		id = "NAV"
		value = 500
	}

	ai_strategy = {
		type = befriend
		id = "GLC"
		value = 500
	}
	ai_strategy = {
		type = support
		id = "GLC"
		value = 500
	}
	ai_strategy = {
		type = send_volunteers_desire
		id = "GLC"
		value = 500
	}
}

#The revolutions are thankful to the Motherland
SOV_we_love_the_motherland = {
	enable = {
		has_country_flag = liberated_by_sov
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = befriend
		id = "SOV"
		value = 2000
	}
	ai_strategy = {
		type = support
		id = "SOV"
		value = 2000
	}
	ai_strategy = {
		type = send_volunteers_desire
		id = "SOV"
		value = 2000
	}
}

#Stop spending pp to buy useless generals :(
SOV_spend_more_political_advisors = {
	enable = {
		tag = SOV
		date > 1941.1.1 #Should be enough for the AI to take the ultimatum decisions
		amount_taken_ideas = {
			amount < 8
			slots = {
				political_advisor
			}
		}
	}
	abort = {
		OR = {
			amount_taken_ideas = {
				amount > 8
				slots = {
					political_advisor
				}
			}
			SOV = {
				has_idea = SOV_Russian_sphere_investments
			}
		}
	}

	ai_strategy = {
		type = pp_spend_priority
		id = political_advisor
		value = 300
	}
	ai_strategy = {
		type = pp_spend_priority
		id = general
		value = -500
	}
}

#Don't need to justify manually when we have ultimatums
ignore_claims_we_have_ultimatums = {
	enable = {
		tag = SOV
		has_completed_focus = SOV_russian_expansion
	}

	abort = {
		date > 1944.1.1
	}

	ai_strategy = {
		type = ignore_claim
		id = "FIN"
		value = 1
	}
	ai_strategy = {
		type = ignore_claim
		id = "ROM"
		value = 1
	}
	ai_strategy = {
		type = ignore_claim
		id = "LAT"
		value = 1
	}
	ai_strategy = {
		type = ignore_claim
		id = "EST"
		value = 1
	}
	ai_strategy = {
		type = ignore_claim
		id = "LIT"
		value = 1
	}
	ai_strategy = {
		type = ignore_claim
		id = "POL"
		value = 1
	}
}

#Focus on European front if we are at war with European major
focus_on_europe = {
	enable = {
		tag = SOV
		date > 1940.1.1
		any_country = {
			has_war_with = SOV
			is_major = yes
			capital_scope = {
				is_on_continent = europe
			}
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = area_priority
		id = europe
		value = 300
	}
}

#AI will be more likely to fire the revolutions operations
fire_the_revolutions_operations = {
	enable = {
		tag = SOV
		has_completed_focus = SOV_liberation_of_the_workers
		OR = {
			has_completed_focus = SOV_asian_revolution
			has_completed_focus = SOV_european_revolution
			has_completed_focus = SOV_african_revolution
		}
		stockpile_ratio = {
			archetype = infantry_equipment
			ratio > 0.1
		}
		stockpile_ratio = {
			archetype = support_equipment
			ratio > 0.05
		}
		stockpile_ratio = {
			archetype = artillery_equipment
			ratio > 0.01
		}
		num_of_operatives > 1
		NOT = {
			surrender_progress > 0.25
		}
	}

	abort = {
		OR = {
			has_country_flag = SOV_liberated_korea
			has_country_flag = SOV_liberated_tibet
			has_country_flag = SOV_liberated_indochina
			has_country_flag = SOV_liberated_morocco
			has_country_flag = SOV_liberated_ethiopia
			has_country_flag = SOV_liberated_egypt
			has_country_flag = SOV_liberated_uk
			has_country_flag = SOV_liberated_iberia
			has_country_flag = SOV_liberated_balkan
			surrender_progress > 0.25
		}
	}

	ai_strategy = {
		type = operative_mission
		mission = build_intel_network
		value = 1000
		state = 525 #Korea
		state = 671 #Indochina
		state = 757 #Tibet
		state = 271 #Ethiopia
		state = 446 #Egypt
		state = 461 #Morocco
		state = 165 #Iberia
		state = 121 #UK
		state = 107 #Balkan
	}

	ai_strategy = {
		type = operative_operation
		operation = SOV_liberate_korea
		value = 5000
	}

	ai_strategy = {
		type = operative_operation
		operation = SOV_uprising_indochina
		value = 5000
	}

	ai_strategy = {
		type = operative_operation
		operation = SOV_free_tibet
		value = 5000
	}

	ai_strategy = {
		type = operative_operation
		operation = SOV_free_ethiopia
		value = 5000
	}

	ai_strategy = {
		type = operative_operation
		operation = SOV_uprising_morroco
		value = 5000
	}

	ai_strategy = {
		type = operative_operation
		operation = SOV_liberate_cairo
		value = 5000
	}

	ai_strategy = {
		type = operative_operation
		operation = SOV_disolve_yugoslavia
		value = 5000
	}

	ai_strategy = {
		type = operative_operation
		operation = SOV_divide_british_isle
		value = 5000
	}

	ai_strategy = {
		type = operative_operation
		operation = SOV_liberate_iberia
		value = 5000
	}
}

#AI will be more likely to steal US Nuclear tech
fire_the_revolutions_operations = {
	enable = {
		tag = SOV
		has_completed_focus = SOV_spying_on_the_american
		num_of_operatives > 2
	}

	abort = {
		has_country_flag = SOV_stole_us_nuclear
	}

	ai_strategy = {
		type = operation_equipment_priority
		value = 100
	}

	ai_strategy = {
		type = operative_mission
		mission = build_intel_network
		value = 1000
		mission_target = USA
		num_operatives = 3
		state = 361
		state = 362
		state = 360
	}

	ai_strategy = {
		type = operative_operation
		operation = SOV_spy_nuclear_technology
		value = 5000
		operation_target = USA
	}
}

#Garrison territory if enemy can naval invade like crazy
SOV_home_land_is_not_safe = {
	enable = {
		tag = SOV
		NOT = {
			has_war_with = SOJ
		}
		OR = {
			has_war_with = ENG
			has_war_with = USA
			has_war_with = JAP
			any_country = {
				has_navy_size = {
					size > 50
				}
				stockpile_ratio = {
					archetype = convoy
					ratio > 100
				}
				has_war_with = SOV
			}
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = garrison
		value = 60
	}
}

#Prevent Portugal from bringing the Soviets against Germany in 1937
SOV_stop_portugal_suicide = {
	enable = {
		tag = SOV
		has_government = communism
		POR = {
			has_government = communism
		}
	}

	abort = {
		OR = {
			any_country = {
				is_major = yes
				has_war_with = SOV
				has_government = fascism
			}
			date > 1940.1.1
		}
	}

	ai_strategy = {
		type = alliance
		id = "POR"
		value = -5000
	}

	ai_strategy = {
		type = dont_join_wars_with
		id = POR
		target_country = GER
		value = 5000
	}

	ai_strategy = {
		type = dont_join_wars_with
		id = POR
		target_country = ITA
		value = 5000
	}

	ai_strategy = {
		type = dont_join_wars_with
		id = POR
		target_country = JAP
		value = 5000
	}
}

#Do not attack Xibei San Ma if they're protected
ignore_xibei = {
	enable = {
		OR = {
			tag = SOV
			tag = PRC
			tag = SIK
		}
		SOV = {
			OR = {
				has_completed_focus = SOV_force_chinese_unification
				has_completed_focus = SOV_one_china
			}
		}
		has_wargoal_against = XSM
        OR = {
            any_country = {
                OR = {
                    is_in_faction_with = GER
                    is_in_faction_with = ENG
                    is_major = yes
                }
                has_guaranteed = XSM
            }
            any_country = {
                is_major = yes
                is_in_faction_with = XSM
            }
            any_country = {
                OR = {
                    tag = XSM
                    is_in_faction_with = XSM
                }
                has_idea = anti_soviet_pact
            }
        }
	}
    abort = {
        OR = {
            NOT = {
                OR = {
                    any_country = {
                        OR = {
                            is_in_faction_with = GER
                            is_in_faction_with = ENG
                            is_major = yes
                        }
                        has_guaranteed = XSM
                    }
                    any_country = {
                        is_major = yes
                        is_in_faction_with = XSM
                    }
                    any_country = {
                        OR = {
                            tag = XSM
                            is_in_faction_with = XSM
                        }
                        has_idea = anti_soviet_pact
					}
					XSM = {
						OR = {
							if = {
								limit = {
									NOT = {
										any_country = {
											has_guaranteed = XSM
										}
									}
								}
								alliance_strength_ratio < 0.8
							}
							has_war_with = SOV
						}
					}
                }
            }
            NOT = {
                has_wargoal_against = XSM
            }
            date > 1943.08.05
        }
    }

	ai_strategy = {
		type = ignore
		id = "XSM"
		value = 350
	}

	ai_strategy = {
		type = declare_war
		id = "XSM"
		value = -1000
	}
}

#Do not attack China if they're protected
ignore_china = {
	enable = {
		OR = {
			tag = SOV
			tag = PRC
			tag = SIK
		}
		SOV = {
			OR = {
				has_completed_focus = SOV_force_chinese_unification
				has_completed_focus = SOV_one_china
			}
		}
		has_wargoal_against = CHI
        OR = {
            any_country = {
                OR = {
                    is_in_faction_with = GER
                    is_in_faction_with = ENG
                    is_major = yes
                }
                has_guaranteed = CHI
            }
            any_country = {
                is_major = yes
                is_in_faction_with = CHI
            }
            any_country = {
                OR = {
                    tag = CHI
                    is_in_faction_with = CHI
                }
                has_idea = anti_soviet_pact
            }
        }
	}
    abort = {
        OR = {
            NOT = {
                OR = {
                    any_country = {
                        OR = {
                            is_in_faction_with = GER
                            is_in_faction_with = ENG
                            is_major = yes
                        }
                        has_guaranteed = CHI
                    }
                    any_country = {
                        is_major = yes
                        is_in_faction_with = CHI
                    }
                    any_country = {
                        OR = {
                            tag = CHI
                            is_in_faction_with = CHI
                        }
                        has_idea = anti_soviet_pact
					}
					CHI = {
						OR = {
							if = {
								limit = {
									NOT = {
										any_country = {
											has_guaranteed = CHI
										}
									}
								}
								alliance_strength_ratio < 0.8
							}
							has_war_with = SOV
						}
					}
                }
            }
            NOT = {
                has_wargoal_against = CHI
            }
            date > 1943.08.05
        }
    }

	ai_strategy = {
		type = ignore
		id = "CHI"
		value = 350
	}

	ai_strategy = {
		type = declare_war
		id = "CHI"
		value = -1000
	}
}

#Do not attack Shanxi if they're protected
ignore_shanxi = {
	enable = {
		OR = {
			tag = SOV
			tag = PRC
			tag = SIK
		}
		SOV = {
			OR = {
				has_completed_focus = SOV_force_chinese_unification
				has_completed_focus = SOV_one_china
			}
		}
		has_wargoal_against = SHX
        OR = {
            any_country = {
                OR = {
                    is_in_faction_with = GER
                    is_in_faction_with = ENG
                    is_major = yes
                }
                has_guaranteed = SHX
            }
            any_country = {
                is_major = yes
                is_in_faction_with = SHX
            }
            any_country = {
                OR = {
                    tag = SHX
                    is_in_faction_with = SHX
                }
                has_idea = anti_soviet_pact
            }
        }
	}
    abort = {
        OR = {
            NOT = {
                OR = {
                    any_country = {
                        OR = {
                            is_in_faction_with = GER
                            is_in_faction_with = ENG
                            is_major = yes
                        }
                        has_guaranteed = SHX
                    }
                    any_country = {
                        is_major = yes
                        is_in_faction_with = SHX
                    }
                    any_country = {
                        OR = {
                            tag = SHX
                            is_in_faction_with = SHX
                        }
                        has_idea = anti_soviet_pact
					}
					SHX = {
						OR = {
							if = {
								limit = {
									NOT = {
										any_country = {
											has_guaranteed = SHX
										}
									}
								}
								alliance_strength_ratio < 0.8
							}
							has_war_with = SOV
						}
					}
                }
            }
            NOT = {
                has_wargoal_against = SHX
            }
            date > 1943.08.05
        }
    }

	ai_strategy = {
		type = ignore
		id = "SHX"
		value = 350
	}

	ai_strategy = {
		type = declare_war
		id = "SHX"
		value = -1000
	}
}

#Do not attack Yunnan if they're protected
ignore_yunnan = {
	enable = {
		OR = {
			tag = SOV
			tag = PRC
			tag = SIK
		}
		SOV = {
			OR = {
				has_completed_focus = SOV_force_chinese_unification
				has_completed_focus = SOV_one_china
			}
		}
		has_wargoal_against = YUN
        OR = {
            any_country = {
                OR = {
                    is_in_faction_with = GER
                    is_in_faction_with = ENG
                    is_major = yes
                }
                has_guaranteed = YUN
            }
            any_country = {
                is_major = yes
                is_in_faction_with = YUN
            }
            any_country = {
                OR = {
                    tag = YUN
                    is_in_faction_with = YUN
                }
                has_idea = anti_soviet_pact
            }
        }
	}
    abort = {
        OR = {
            NOT = {
                OR = {
                    any_country = {
                        OR = {
                            is_in_faction_with = GER
                            is_in_faction_with = ENG
                            is_major = yes
                        }
                        has_guaranteed = YUN
                    }
                    any_country = {
                        is_major = yes
                        is_in_faction_with = YUN
                    }
                    any_country = {
                        OR = {
                            tag = YUN
                            is_in_faction_with = YUN
                        }
                        has_idea = anti_soviet_pact
					}
					YUN = {
						OR = {
							if = {
								limit = {
									NOT = {
										any_country = {
											has_guaranteed = YUN
										}
									}
								}
								alliance_strength_ratio < 0.8
							}
							has_war_with = SOV
						}
					}
                }
            }
            NOT = {
                has_wargoal_against = YUN
            }
            date > 1943.08.05
        }
    }

	ai_strategy = {
		type = ignore
		id = "YUN"
		value = 350
	}

	ai_strategy = {
		type = declare_war
		id = "YUN"
		value = -1000
	}
}

#Do not attack Guangxi Clique if they're protected
ignore_guangxi = {
	enable = {
		OR = {
			tag = SOV
			tag = PRC
			tag = SIK
		}
		SOV = {
			OR = {
				has_completed_focus = SOV_force_chinese_unification
				has_completed_focus = SOV_one_china
			}
		}
		has_wargoal_against = GXC
        OR = {
            any_country = {
                OR = {
                    is_in_faction_with = GER
                    is_in_faction_with = ENG
                    is_major = yes
                }
                has_guaranteed = GXC
            }
            any_country = {
                is_major = yes
                is_in_faction_with = GXC
            }
            any_country = {
                OR = {
                    tag = GXC
                    is_in_faction_with = GXC
                }
                has_idea = anti_soviet_pact
            }
        }
	}
    abort = {
        OR = {
            NOT = {
                OR = {
                    any_country = {
                        OR = {
                            is_in_faction_with = GER
                            is_in_faction_with = ENG
                            is_major = yes
                        }
                        has_guaranteed = GXC
                    }
                    any_country = {
                        is_major = yes
                        is_in_faction_with = GXC
                    }
                    any_country = {
                        OR = {
                            tag = GXC
                            is_in_faction_with = GXC
                        }
                        has_idea = anti_soviet_pact
					}
					GXC = {
						OR = {
							if = {
								limit = {
									NOT = {
										any_country = {
											has_guaranteed = GXC
										}
									}
								}
								alliance_strength_ratio < 0.8
							}
							has_war_with = SOV
						}
					}
                }
            }
            NOT = {
                has_wargoal_against = GXC
            }
            date > 1943.08.05
        }
    }

	ai_strategy = {
		type = ignore
		id = "GXC"
		value = 350
	}

	ai_strategy = {
		type = declare_war
		id = "GXC"
		value = -1000
	}
}

#Do not attack the Japanese Puppets if they're protected
ignore_japanese_puppets = {
	enable = {
		OR = {
			tag = SOV
			tag = PRC
			tag = SIK
		}
		SOV = {
			OR = {
				has_completed_focus = SOV_force_chinese_unification
				has_completed_focus = SOV_one_china
			}
		}
		has_wargoal_against = MEN
		has_wargoal_against = MAN
		OR = {
			MEN = {
				is_subject = yes
			}
			MAN = {
				is_subject = yes
			}
		}
	}

	abort = {
		OR = {
			date > 1943.08.05
			NOT = {
				MEN = {
					is_subject = yes
				}
				MAN = {
					is_subject = yes
				}
			}
			MAN = {
				OR = {
					if = {
						limit = {
							NOT = {
								any_country = {
									has_guaranteed = MAN
								}
							}
						}
						alliance_strength_ratio < 0.8
					}
					has_war_with = SOV
				}
			}
		}
	}

	ai_strategy = {
		type = ignore
		id = "MEN"
		value = 350
	}

	ai_strategy = {
		type = declare_war
		id = "MEN"
		value = -1000
	}

	ai_strategy = {
		type = ignore
		id = "MAN"
		value = 350
	}

	ai_strategy = {
		type = declare_war
		id = "MAN"
		value = -1000
	}
}

#Do not focus on planes if the enemy outnumbers you at least 2 to 1 and produce AA instead
SOV_stop_plane_production = {
	allowed = {
		original_tag = SOV
	}

	enable = {
		original_tag = SOV
		has_war = yes
		set_temp_variable = { plane_count_sov_by_2 = SOV.num_deployed_planes }
		multiply_temp_variable = { plane_count_sov_by_2 = 2 }
		check_variable = {
			var = plane_count_sov_by_2
			value = plane_count_enemy_sov
			compare = less_than
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = equipment_production_factor
		id = anti_air
		value = 50
	}

	ai_strategy = {
		type = air_factory_balance
		value = -100
	}

	ai_strategy = {
		type = equipment_production_factor
		id = fighter
		value = -25
	}

	ai_strategy = {
		type = equipment_production_factor
		id = tactical_bomber
		value = -25
	}

	ai_strategy = {
		type = equipment_production_factor
		id = strategic_bomber
		value = -50
	}

	ai_strategy = {
		type = role_ratio
		id = anti_air
		value = 10
	}
}

#Build less guns if stockpile is too high
SOV_stockpile_less_tanks_guns = {
	allowed = {
		original_tag = SOV
	}

	enable = {
		tag = SOV
		OR = {
			stockpile_ratio = {
				archetype = infantry_equipment
				ratio > 1.5
			}
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = equipment_stockpile_surplus_ratio
		value = -100
	}
}

#Build more of the equipment needed (mostly artillery and medium tanks)
SOV_build_more_needed_equipment_artillery = {
	allowed = {
		original_tag = SOV
	}

	enable = {
		tag = SOV
		date > 1940.01.01
		stockpile_ratio = {
			archetype = artillery_equipment
			ratio < 0.75
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = equipment_production_min_factories
		id = artillery
		value = 20
	}

	ai_strategy = {
		type = equipment_production_factor
		id = artillery
		value = 40
	}
}

SOV_build_more_needed_equipment_medium_tanks = {
	allowed = {
		original_tag = SOV
	}

	enable = {
		tag = SOV
		date > 1940.01.01
		stockpile_ratio = {
			archetype = medium_tank_chassis
			ratio < 0.75
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = equipment_production_min_factories
		id = armor
		value = 20
	}

	ai_strategy = {
		type = equipment_production_factor
		id = armor
		value = 20
	}
}

#Seriously stop
SOV_stop_prospecting_resources = {
	allowed = {
		original_tag = SOV
	}

	enable = {
		NOT = {
			amount_taken_ideas = {
				amount < 8
				slots = {
					political_advisor
				}
			}
		}
	}

	abort = {
		amount_taken_ideas = {
			amount < 8
			slots = {
				political_advisor
			}
		}
	}

	ai_strategy = {
		type = pp_spend_priority
		id = prospect_for_resources
		value = -10000
	}

	ai_strategy = {
		type = pp_spend_priority
		id = advisors
		value = 500
	}
}

#Agreement members will not try to stop SOV
SOV_dont_contain_root_russian_agreement = {
	enable = {
		has_idea = SOV_Root_russian_pact
	}

	abort = {
		NOT = {
			has_idea = SOV_Root_russian_pact
		}
	}

	ai_strategy = {
		type = contain
		id = "SOV"
		value = -1000
	}

	ai_strategy = {
		type = alliance
		id = "SOV"
		value = -20
	}

	ai_strategy = {
		type = dont_join_wars_with
		id = "SOV"
		value = -150
	}
}

#SOV Will not help any country who's at war with people who signed the agreement
SOV_respect_root_russian_agreement_sov = {

	reversed = yes

	allowed = {
		original_tag = SOV
	}

	enable = {
		any_of_scopes = {
			array = enemies
			has_idea = SOV_Root_russian_pact
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = support
		id = "SOV"
		value = -1000
	}

	ai_strategy = {
		type = alliance
		id = "SOV"
		value = -1000
	}

	ai_strategy = {
		type = send_volunteers_desire
		id = "SOV"
		value = -1000
	}
}

#SOV Will try to not mess with agreement members
SOV_do_not_mess_agreement_sov = {

	reversed = yes

	allowed = {
		original_tag = SOV
	}

	enable = {
		has_idea = SOV_Root_russian_pact
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = contain
		id = "SOV"
		value = -1000
	}

	ai_strategy = {
		type = alliance
		id = "SOV"
		value = -20
	}
}

prepare_fight_russia_from = {
	enable = {
		OR = {
			has_country_flag = is_target_of_SOV_fascist
			has_country_flag = is_target_of_SOV_democratic
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = prepare_for_war
		id = "SOV"
		value = 100
	}
}

prepare_fight_from_russia = {
	reversed = yes

	enable = {
		OR = {
			has_country_flag = is_target_of_SOV_fascist
			has_country_flag = is_target_of_SOV_democratic
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = prepare_for_war
		id = "SOV"
		value = 100
	}
}

SOV_spend_pp_for_concession = {
	enable = {
		tag = SOV
		SOV = {
			OR = {
				has_idea = SOV_Communist_resistance2
				has_idea = SOV_Communist_resistance4
				has_idea = SOV_Communist_resistance5
				has_idea = SOV_Communist_resistance6
				has_idea = SOV_Communist_resistance7
			}
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = pp_spend_priority
		id = decision
		value = 999
	}

	ai_strategy = {
		type = pp_spend_priority
		id = advisors
		value = -500
	}
}

SOV_keep_political_power_partisan = {
	enable = {
		tag = SOV
		SOV = {
			has_idea = SOV_Communist_resistance3
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = pp_spend_priority
		id = decision
		value = 999
	}

	ai_strategy = {
		type = pp_spend_priority
		id = advisors
		value = -500
	}
}

SOV_keep_political_power_reintegration = {
	enable = {
		tag = SOV
		SOV = {
			has_government = neutrality
		}
		OR = {
			UKR = {
				is_subject_of = SOV
			}
			BLR = {
				is_subject_of = SOV
			}
			ARM = {
				is_subject_of = SOV
			}
			GEO = {
				is_subject_of = SOV
			}
			AZR = {
				is_subject_of = SOV
			}
			KAZ = {
				is_subject_of = SOV
			}
			TMS = {
				is_subject_of = SOV
			}
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = pp_spend_priority
		id = decision
		value = 999
	}

	ai_strategy = {
		type = pp_spend_priority
		id = advisors
		value = -500
	}
}

SOV_keep_political_power_investment = {
	enable = {
		tag = SOV
		SOV = {
			has_government = democratic
			has_idea = SOV_Russian_sphere_investments
		}
	}

	abort = {
		SOV = {
			NOT = {
				has_idea = SOV_Russian_sphere_investments
			}
		}
	}

	ai_strategy = {
		type = pp_spend_priority
		id = decision
		value = 999
	}

	ai_strategy = {
		type = pp_spend_priority
		id = advisors
		value = -500
	}
}

SOV_keep_political_power_perpetual_liberty = {
	enable = {
		tag = SOV
		SOV = {
			has_government = democratic
			has_completed_focus = SOV_perpetual_defense_liberty
		}
		any_country = {
			is_major = no
			is_neighbor_of = SOV
		}
	}

	abort = {
		NOT = {
			any_country = {
				is_major = yes
				is_neighbor_of = SOV
			}
		}
		SOV = {
			has_country_flag = is_changing_foreign_government
		}
	}

	ai_strategy = {
		type = pp_spend_priority
		id = decision
		value = 999
	}

	ai_strategy = {
		type = pp_spend_priority
		id = advisors
		value = -500
	}
}

SOV_send_volunteers_second_civil_war_white_guard = {

	enable = {
		is_major = yes
		NOT = {
			has_government = SOJ
			original_tag = SOV
		}
		has_global_flag = second_russian_civil_war_in_progress
		has_country_flag = help_whiteguard_during_russian_civil_war
		country_exists = SOJ
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = send_volunteers_desire
		id = "SOV"
		value = 100
	}

	ai_strategy = {
		type = send_lend_lease_desire
		id = SOV
		value = 100
	}
}

#Do not guarantee any fucking country while being democratic Russia
SOV_no_guarantee_democratic_russia = {
	enable = {
		original_tag = SOV
		SOV = {
			has_government = democratic
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = pp_spend_priority
		id = guarantee
		value = -999
	}
}

#Do not join or invite other countries if not ready - Democratic Russia
SOV_no_alliance_russia_democratic = {
	enable = {
		NOT = {
			original_tag = SOV
		}
		SOV = {
			has_government = democratic
			NOT = {
				has_completed_focus = SOV_keep_expanding_russian_sphere
				has_completed_focus = SOV_reform_entente
			}
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = alliance
		id = SOV
		value = -500
	}
}

#Improve relations with minor communist countries that can be invited to the International
SOV_invite_minor_communist_boost_opinion = {
	reversed = yes

	enable = {
		has_government = communism
		NOT = {
			is_in_faction_with = ROOT
			has_civil_war = yes
		}
		is_major = no
		NOT = {
			tag = SLV
			tag = CRO
			tag = BOS
			tag = SER
			tag = MNT
			tag = MAC
			tag = CAT
			tag = NAV
			tag = GLC
			tag = SCO
			tag = WLS
			tag = NIR
			tag = KOR
			tag = VIN
			tag = CAM
			tag = LAO
			tag = TIB
			tag = ETH
			tag = MOR
			tag = EGY
			has_idea = SOV_Communist_influence_international_1
			has_idea = SOV_Communist_influence_international_2
			has_idea = SOV_Communist_influence_international_3
			has_idea = SOV_Supporters_fourth_international
		}
	}

	enable_reverse = {
		SOV = {
			has_completed_focus = SOV_communist_minorities_europe
			has_government = communism
			is_subject = no
			is_faction_leader = yes
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = befriend
		id = "SOV"
		value = 100
	}
}

#Send volunteers to White Guard if they accept to help them
SOV_send_volunteers_second_civil_war_white_guard_accept_help_foreign = {
	enable = {
		has_country_flag = help_whiteguard_during_russian_civil_war
		NOT = {
			has_government = communism
			original_tag = SOV
		}
		SOV = {
			has_global_flag = second_russian_civil_war_in_progress
		}
		country_exists = SOJ
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = send_volunteers_desire
		id = "SOV"
		value = 600
	}
}

#Japan Become Friendly Towards White Guard if they Have Idea thanks to Sakhalin
SOV_japan_non_agression_pact = {

	enable = {
		has_idea = SOV_Japan_non_agression_pact_sakhalin
		NOT = {
			original_tag = SOV
		}
		country_exists = SOV
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = befriend
		id = "SOV"
		value = 50
	}

	ai_strategy = {
		type = conquer
		id = "SOV"
		value = -25
	}

	ai_strategy = {
		type = antagonize
		id = "SOV"
		value = -25
	}
}

#Italy Becomes Friendly Towards White Guard if they Have Idea diplomatic relation
SOV_italy_diplomatic_relations = {

	enable = {
		has_idea = SOV_Russian_italian_diplomacy_neutral
		NOT = {
			tag = SOV
		}
		country_exists = SOV
		country_exists = ITA
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = befriend
		id = "SOV"
		value = 50
	}

	ai_strategy = {
		type = conquer
		id = "SOV"
		value = -25
	}

	ai_strategy = {
		type = antagonize
		id = "SOV"
		value = -25
	}
}

SOV_save_pp_for_scw = {

	allowed = {
		original_tag = SOV
	}

    enable = {
		original_tag = SOV
        is_subject = no
        OR = {
			has_completed_focus = SOV_terrible_fate
			focus_progress = {
				focus = SOV_terrible_fate
				progress > 0.01
			}
			AND = {
				OR = {
					has_country_flag = RUS_AI_VLADIMIR_KIRILLOVICH_NEUTRALITY_BEHAVIOR
					has_country_flag = RUS_AI_ANASTASIA_NIKOLAEVNA_NEUTRALITY_BEHAVIOR
					has_country_flag = RUS_AI_ANDREY_VLASOV_NEUTRALITY_BEHAVIOR
					has_country_flag = RUS_AI_PAVEL_BERMONDT_AVALOV_NEUTRALITY_BEHAVIOR
					has_country_flag = RUS_AI_KONSTANTIN_RODZAEVSKY_FASCIST_BEHAVIOR
					has_country_flag = RUS_AI_ANASTASY_VONSYATSKY_FASCIST_BEHAVIOR
				}
				date < 1936.05.01
			}
		}
		NOT = {
			has_completed_focus = SOV_right_to_believe
			has_completed_focus = SOV_second_civil_war
		}
	}

	abort = {
		OR = {
            is_subject = yes
            exists = no
            has_completed_focus = SOV_right_to_believe
			has_completed_focus = SOV_second_civil_war
        }
	}

    ai_strategy = {
		type = pp_spend_priority
		id = political_advisor
		value = -9999
	}

    ai_strategy = {
		type = pp_spend_priority
		id = admiral
		value = -9999
	}

	ai_strategy = {
		type = pp_spend_priority
		id = general
		value = -9999
	}

    ai_strategy = {
		type = pp_spend_priority
		id = guarantee
		value = -9999
	}

	ai_strategy = {
		type = pp_spend_priority
		id = relation
		value = -9999
	}
}

SOV_focus_on_your_enemies = {

    reversed = yes

	enable = {
		has_global_flag = second_russian_civil_war_in_progress
        NOT = {
            has_war_with = SOV
        }
	}

	enable_reverse = {
		tag = SOV
        has_global_flag = second_russian_civil_war_in_progress
        sov_in_scw = yes
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = conquer
		id = SOV
		value = -9999
	}

	ai_strategy = {
		type = antagonize
		id = SOV
		value = -9999
	}

	ai_strategy = {
		type = declare_war
		id = SOV
		value = -9999
	}

    ai_strategy = {
		type = ignore
		id = SOV
		value = 9999
	}
}

SOV_focus_only_scw  = {

	allowed = {
		original_tag = SOV
	}

	reversed = yes

	enable = {
		has_global_flag = second_russian_civil_war_in_progress
		has_war_with = SOV
	}

	enable_reverse = {
		tag = SOV
		has_global_flag = second_russian_civil_war_in_progress
		sov_in_scw = yes
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = front_control

		priority = 1000

		tag = SOV

		ordertype = front
		execute_order = yes
		manual_attack = yes
	}

	ai_strategy = {
		type = front_unit_request

		tag = SOV

		value = 9999
	}
}

SOV_destroy_TAN_scw = {

	allowed = {
		original_tag = SOV
	}

	enable = {
		has_global_flag = second_russian_civil_war_in_progress
		sov_in_scw = yes
		soj_in_scw = yes
		TAN = {
			has_capitulated = no
			has_war_with = SOV
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = front_control

		priority = 800

		tag = TAN
		ordertype = front
		execution_type = rush_weak
		execute_order = yes
		manual_attack = yes
	}
}

SOV_destroy_MON_scw = {

	allowed = {
		original_tag = SOV
	}

	enable = {
		has_global_flag = second_russian_civil_war_in_progress
		sov_in_scw = yes
		soj_in_scw = yes
		MON = {
			has_capitulated = no
			has_war_with = SOV
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = front_control

		priority = 800

		tag = MON
		ordertype = front
		execution_type = rush_weak
		execute_order = yes
		manual_attack = yes
	}
}

SOV_chill_scw  = {

	allowed = {
		original_tag = SOV
	}

	enable = {
		has_global_flag = second_russian_civil_war_in_progress
		date < 1939.3.1 #Just attack at this point
		sov_in_scw = yes
		soj_in_scw = yes
		OR = {
			has_manpower < 100000
			AND = {
				set_temp_variable = { sov_gun_deficit = var:sov.num_target_equipment_in_armies_k@infantry_equipment }
				subtract_from_temp_variable = { sov_gun_deficit = var:sov.num_equipment_in_armies_k@infantry_equipment }
				set_temp_variable = { soj_gun_deficit = var:soj.num_target_equipment_in_armies_k@infantry_equipment }
				subtract_from_temp_variable = { soj_gun_deficit = var:soj.num_equipment_in_armies_k@infantry_equipment }
				check_variable = {
					var = sov_gun_deficit
					value = soj_gun_deficit
					compare = greater_than
				}
				if = {
					limit = {
						check_variable = {
							var = sov_gun_deficit
							value = 10
							compare = less_than
						}
					}
					check_variable = {
						var = sov.num_divisions
						value = var:soj.num_divisions
						compare = less_than
					}
				}
			}
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = front_control

		priority = 5000

		tag = SOJ

		execute_order = no
		manual_attack = yes
	}
}

SOV_protect_caucasus_until_connected = {

	allowed = {
		original_tag = SOV
	}

	enable = {
		has_global_flag = second_russian_civil_war_in_progress
		sov_in_scw = yes
		date < 1939.3.1
		any_controlled_state = {
			OR = {
				state = 237
				state = 238
				state = 218
				state = 234
				state = 235
				state = 232
				state = 821
				state = 828
				state = 827
				state = 233
			}
			is_in_home_area = no
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = front_control

		priority = 9999

		state_trigger = {
			OR = {
				state = 237
				state = 238
				state = 218
				state = 234
				state = 235
				state = 232
				state = 821
				state = 828
				state = 827
				state = 233
			}
			is_in_home_area = no
		}

		ordertype = front
		execution_type = careful
		execute_order = no
		manual_attack = yes
	}
}

SOV_do_not_waste_pp = {

	allowed = {
		original_tag = SOV
	}

	enable = {
		has_political_power < 500
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = pp_spend_priority
		id = guarantee
		value = -9999
	}

	ai_strategy = {
		type = pp_spend_priority
		id = relation
		value = -9999
	}
}

SOV_unit_buffer_for_asian_threat = {
	allowed = {
		original_tag = SOV
	}
	enable = {
		surrender_progress < 0.75
		OR = {
			controls_state = 564
			controls_state = 563
			controls_state = 566
			controls_state = 567
			controls_state = 561
			controls_state = 657
			controls_state = 408
			controls_state = 409
		}
		any_country = {
			OR = {
				has_war_with = SOV
				has_wargoal_against = SOV
				is_justifying_wargoal_against = SOV
			}
			is_neighbor_of = SOV
			capital_scope = {
				is_on_continent = asia
			}
		}
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = put_unit_buffers

		# ratio of total armeis in country to be buffered
		ratio = 0.1

		# you can specify an order id. ratio of same orders ids will be share same ratio
		#order_id = 2

		# states to put garrison orders (if no state is friendly, strat is invalid)
		states = {
			564
			563
			566
			567
			561
			657
			408
			409
		}

		# ai areas that the orders will use these buffers in
		area = asia

		# by default if you have orders in target areas, the buffer will request less units.
		# you can override this to disable the feature
		subtract_invasions_from_need = no
		subtract_fronts_from_need = no
	}
}

SOV_destroy_PRT_military_junta = {

	allowed = {
		original_tag = SOV
	}

	enable = {
		country_exists = PRT
		has_war_with = PRT
	}

	abort_when_not_enabled = yes

	ai_strategy = {
		type = front_control

		priority = 800

		tag = PRT
		ordertype = front
		execution_type = rush_weak
		execute_order = yes
		manual_attack = yes
		ratio = 0.1
	}
}