on_actions = {
    on_startup = {

        #Gamerule Setups
        effect = {
            ROOT = {
                set_variable = {global.days_since_start = 0}
                set_variable = {daysince = 0}
            }
            if = {
                limit = {
                    has_game_rule = { 
                        rule = war_start_date 
                        option = SIX_MONTH_WAR
                    }
                }
                ROOT = {
                    set_variable = {war_date_time = 181}
                    set_variable = {global.days_to_war = war_date_time}
                }
            }
            else_if = {
                limit = {
                    has_game_rule = { 
                        rule = war_start_date 
                        option = TWELVE_MONTH_WAR
                    }
                }
                ROOT = {
                    set_variable = {war_date_time = 365}
                    set_variable = {global.days_to_war = war_date_time}
                }
            }
            else_if = {
                limit = {
                    has_game_rule = { 
                        rule = war_start_date 
                        option = EIGHTEEN_MONTH_WAR
                    }
                }
                ROOT = {
                    set_variable = {war_date_time = 546}
                    set_variable = {global.days_to_war = war_date_time}
                }
            }
            else = {
                ROOT = {
                    set_variable = {war_date_time = 730}
                    set_variable = {global.days_to_war = war_date_time}
                }
            }


            if = {
                limit = {
                    has_game_rule = { 
                        rule = game_speed_setting 
                        option = REDUCED_SPEED
                    }
                }
                every_country = {
                    add_ideas = reduced_speed_idea
                }                
            }
            else_if = {
                limit = {
                    has_game_rule = { 
                        rule = game_speed_setting 
                        option = TWENTY_FIVE_SPEED
                    }
                }
                every_country = {
                    add_ideas = twenty_five_speed_idea
                }
            }
            else_if = {
                limit = {
                    has_game_rule = { 
                        rule = game_speed_setting 
                        option = FIFTY_SPEED
                    }
                }
                every_country = {
                    add_ideas = fifty_speed_idea
                }
            }
            else_if = {
                limit = {
                    has_game_rule = { 
                        rule = game_speed_setting 
                        option = SEVENTY_FIVE_SPEED
                    }
                }
                every_country = {
                    add_ideas = seventy_five_speed_idea
                }
            }
            else_if = {
                limit = {
                    has_game_rule = { 
                        rule = game_speed_setting 
                        option = HUNDRED_SPEED
                    }
                }
                every_country = {
                    add_ideas = one_hundred_speed_idea
                }
            }
			CYM =  {
				if = {
					limit = {
						#CYM = {
							isOneVOne = yes
						#}
					}
					log = "One versus one setup commencing"
					main_annex_major_island = yes
				}
				else_if = {
					limit = {
						#CYM = {
							isThreeFFA = yes
						#}
					}
					log = "Three FFA setup"
					VAR = {
						load_oob  = "VAR_Start"
						var_add_pop = yes
						var_add_industry = yes
						var_add_resources = yes
						var_annex_islands = yes
					}
					
				}
				else_if = {
					limit = {
						isTwoVOne = yes
					}
					log = "Two Versus One setup"
					VAR = {
						load_oob  = "VAR_Start"
						var_add_pop = yes
						var_add_industry = yes
						var_add_resources = yes
						var_annex_islands = yes
						country_event = oevent.500
					}
					
				}
			}
			

        }

        #War setups
        effect = {

            #Startup event
            every_country = {
                country_event = oevent.5000
                activate_mission = war_dec_time_expr
            }
            every_country = {
                limit = {is_ai = yes}
                add_ideas = ai_efficiency_buff
			}
        }
        effect = {
           EDS = {
               country_event = oevent.1#Initialize vars
               country_event = oevent.100#Kickoff the war timer event
           }
        }

        

        
    }

	on_monthly_VAR = {
		effect = {
			drain_thralls = yes
		}
	}

	on_state_control_changed = {
		effect = {
			if = {
				limit = {
					FROM.FROM = {
						OR = {
							state = 148
							state = 149
							state = 150
							state = 151
						}
					}
					
					VAR = {
						has_completed_focus = var_arms_levies
					}
				}

				if = {
					limit = {
						ROOT = {
							tag = VAR
						}
					}
					add_offsite_building = {
						type = arms_factory 
						level = 3
					}
				}
				
				if = {
					limit = {
						FROM ={
							tag = VAR
						}
					}
					VAR = {
						add_offsite_building = {
							type = arms_factory 
							level = -3
						}
					}
				}

			}



		}
	}

    on_weekly = {
        effect ={
            every_country = {
                limit = {is_ai = yes}
                add_ideas = ai_efficiency_buff
            }
        }
    }

    on_daily = {
        effect = {
            add_to_variable = {daysince = 1}
            set_variable = {global.days_since_start = daysince}
            set_variable = {global.days_to_war = global.war_date_time}
            subtract_from_variable = {global.days_to_war = global.days_since_start}

            #add_to_variable = {global.days_since_start = 1}
            #set_variable = {global.days_to_war = global.war_date_time}
            #subtract_from_variable = {global.days_to_war = global.days_since_start}
            
        }       
    }
}