#For stuff that doesn't fit in a specific place, be it initialization events, global events, etc.
add_namespace = oevent

country_event = {
	id = oevent.1
	title = "Init variables"

    hidden = yes
	is_triggered_only = yes
	#fire_only_once = yes
    immediate = {
        init_variables = yes
    }
}

country_event = {
	id = oevent.5000
	title = oevent.5000
    desc = oevent.5000D
    picture = GFX_event_have_fun

	is_triggered_only = yes
    option = {
        name = oevent.5000a
    }
    option = {
        name = oevent.5000b
        country_event = oevent.5999
    }
    option = {
        name = oevent.0latest
        country_event = oevent.5991
    }
}

#update one
country_event = {
	id = oevent.5999
	title = oevent.5999
    desc = oevent.5999D
    picture = GFX_event_patch_notes

	is_triggered_only = yes
    #Done
    option = {
        name = oevent.0done
    }
    #Next
    option = {
        name = oevent.0next
        country_event = oevent.5998
    }
    #Prev
    #option = {
    #    name = oevent.0b
    #    country_event = oevent.0back
    #}
    option = {
        name = oevent.0latest
        country_event = oevent.5994
    }
}

#update two
country_event = {
	id = oevent.5998
	title = oevent.5998
    desc = oevent.5998D
    picture = GFX_event_patch_notes

	is_triggered_only = yes
    #Done
    option = {
        name = oevent.0done
    }
    #Next
    option = {
        name = oevent.0next
        country_event = oevent.5997
    }
    #Prev
    option = {
        name = oevent.0prev
        country_event = oevent.5999
    }
}

#update three
country_event = {
	id = oevent.5997
	title = oevent.5997
    desc = oevent.5997D
    picture = GFX_event_patch_notes

	is_triggered_only = yes
    #Done
    option = {
        name = oevent.0done
    }
    #Next
    option = {
        name = oevent.0next
        country_event = oevent.5996
    }
    #Prev
    option = {
        name = oevent.0prev
        country_event = oevent.5998
    }
}

#update four
country_event = {
	id = oevent.5996
	title = oevent.5996
    desc = oevent.5996D
    picture = GFX_event_patch_notes

	is_triggered_only = yes
    #Done
    option = {
        name = oevent.0done
    }
    #Next
    option = {
        name = oevent.0next
        country_event = oevent.5995
    }
    #Prev
    option = {
        name = oevent.0prev
        country_event = oevent.5997
    }
}

#update five
country_event = {
	id = oevent.5995
	title = oevent.5995
    desc = oevent.5995D
    picture = GFX_event_patch_notes

	is_triggered_only = yes
    #Done
    option = {
        name = oevent.0done
    }
    #Next
    option = {
        name = oevent.0next
        country_event = oevent.5994
    }
    #Prev
    option = {
        name = oevent.0prev
        country_event = oevent.5996
    }
}

#update six
country_event = {
	id = oevent.5994
	title = oevent.5994
    desc = oevent.5994D
    picture = GFX_event_patch_notes

	is_triggered_only = yes
    #Done
    option = {
        name = oevent.0done
    }
    #Next
    option = {
        name = oevent.0next
        country_event = oevent.5993
    }
    #Prev
    option = {
        name = oevent.0prev
        country_event = oevent.5995
    }
}


#update seven & eight
country_event = {
	id = oevent.5993
	title = oevent.5993
    desc = oevent.5993D
    picture = GFX_event_patch_notes

	is_triggered_only = yes
    #Done
    option = {
        name = oevent.0done
    }
    #Next
    option = {
        name = oevent.0next
        country_event = oevent.5992
    }
    #Prev
    option = {
        name = oevent.0prev
        country_event = oevent.5994
    }
}

#update nine
country_event = {
	id = oevent.5992
	title = oevent.5992
    desc = oevent.5992D
    picture = GFX_event_patch_notes

	is_triggered_only = yes
    #Done
    option = {
        name = oevent.0done
    }
    #Next
    option = {
        name = oevent.0next
        country_event = oevent.5991
    }
    #Prev
    option = {
        name = oevent.0prev
        country_event = oevent.5993
    }
}

#update 10 & 11.
country_event = {
	id = oevent.5991
	title = oevent.5991
    desc = oevent.5991D
    picture = GFX_event_patch_notes

	is_triggered_only = yes
    #Done
    option = {
        name = oevent.0done
    }
    #Next
    #option = {
    #    name = oevent.0next
    #    country_event = oevent.5990
    #}
    #Prev
    option = {
        name = oevent.0prev
        country_event = oevent.5992
    }
}


country_event = {
	id = oevent.10
	title = "Forceupdate factory count"

    hidden = yes
	is_triggered_only = yes
	#fire_only_once = yes
    immediate = {
        add_offsite_building = {
            type = industrial_complex 
            level = 1
        }
        country_event = oevent.11
    }
}

country_event = {
	id = oevent.11
	title = "Forceupdate factory count pt2"

    hidden = yes
	is_triggered_only = yes
	#fire_only_once = yes
    immediate = {
        add_offsite_building = {
            type = industrial_complex 
            level = -1
        }
    }
}

country_event = {
	id = oevent.100
	title = "WarChecker"

    hidden = yes
	is_triggered_only = yes
	#fire_only_once = yes
    immediate = {
        #Todo, do the check of gamerules here
        if = {
            limit = {
                has_game_rule = { 
                    rule = war_start_date 
                    option = SIX_MONTH_WAR
                }
            }
            country_event = {id = oevent.101 days = 181}
        }
        else_if = {
            limit = {
                has_game_rule = { 
                    rule = war_start_date 
                    option = TWELVE_MONTH_WAR
                }
            }
            country_event = {id = oevent.101 days = 365}
        }
        else_if = {
            limit = {
                has_game_rule = { 
                    rule = war_start_date 
                    option = EIGHTEEN_MONTH_WAR
                }
            }
            country_event = {id = oevent.101 days = 546}
        }
        else = {
            country_event = {id = oevent.101 days = 730}
        }
    }
}

country_event = {
	id = oevent.101
	title = "WarFirer"

    hidden = yes
	is_triggered_only = yes
	#fire_only_once = yes
    immediate = {
        CYM = {
            declare_war_on = {
                target = EDS
                type = annex_everything
            }
            declare_war_on = {
                target = VAR
                type = annex_everything
            }
        }
        EDS = {
            declare_war_on = {
                target = VAR
                type = annex_everything
            }
        }
    }
}

country_event = {
	id = oevent.500
	title = oevent.500
    desc = oevent.500D
    #picture = GFX_report_event_generic_factory

	is_triggered_only = yes
    #Var & Cym
    option = {
        name = oevent.500a

		VAR_ALLY_CYM = yes		

		ai_chance = {
			base = 0
		}
    }

	#Var & Eds
    option = {
        name = oevent.500b

		VAR_ALLY_EDS = yes

		ai_chance = {
			base = 0
		}
    }

	#Cym & Eds
    option = {
        name = oevent.500b

		CYM_ALLY_EDS = yes	

		ai_chance = {
			base = 0
		}
    }

	#Random
    option = {
        name = oevent.500d

		random_list = {
			10 = {
				VAR_ALLY_CYM = yes
			}
			10 = {
				VAR_ALLY_EDS = yes
			}
			10 = {
				CYM_ALLY_EDS = yes
			}
		}	

		ai_chance = {
			base = 1
		}
    }


	 
}