namespace = prices_marcin

country_event = {
	id = prices_marcin.1
	title = prices_marcin.1.t
	desc = prices_marcin.1.d
	picture = TRADE_GOODS_PLANTATION_GOODS_IN_WAREHOUSE_eventPicture

	
	fire_only_once = yes
	major = yes

	trigger = {
		is_year = 1516
		culture_group = germanic
		NOT = { has_global_flag = beerislove }
	}
	
	mean_time_to_happen = {
		months = 1
	}
	
	
	option = {
		name = prices_marcin.1.a
		ai_chance = { factor = 100 }
		change_price = {
			trade_goods = beer
			key = REIN
			value = 0.20
			duration = -1
		}
		set_global_flag = beerislove
	}
}


country_event = {
	id = prices_marcin.3
	title = prices_marcin.3.t
	desc = prices_marcin.3.d
	picture = TRADEGOODS_eventPicture

	fire_only_once = yes
	
	major = yes

	trigger = {
		AND = {
			OR = {
				any_subject_country = {
					is_colonial_nation = yes
					any_owned_province = {
						trade_goods = potato
					}
				}
				any_owned_province = {
					trade_goods = potato
					continent = new_world
				}
				any_owned_province = {
					trade_goods = potato
					continent = north_america
				}
				any_owned_province = {
					trade_goods = potato
					continent = south_america
				}
			}
			capital_scope = { continent = europe }
			NOT = { has_global_flag = potatoislove }
		}
	}
	
	mean_time_to_happen = {
		months = 1
	}
	
	option = {
		name = prices_marcin.3.a
		ai_chance = { factor = 100 }
		custom_tooltip = potato_tooltip
		hidden_effect = {
			every_province = {
				limit = {
					AND = {
						OR = {	
							trade_goods = livestock
							trade_goods = grain
						}
						continent = europe 
					}
				}
				
				random = { 
					chance = 20

					change_trade_goods = potato
				}			
				
			}
		}
		set_global_flag = potatoislove
		add_years_of_income  = 0.15
		add_prestige = 20
	}
}


province_event = {
	id = prices_marcin.5
	title = flavor_jap.60.t
	desc = flavor_jap.60.d
	picture = COURT_eventPicture
	
	hidden = yes
	fire_only_once = yes
	
	trigger = {
		province_id = 4183 # Iwami
		trade_goods = gold
	}
	
	mean_time_to_happen = {
		months = 1
	}
	
	option = { 
		name = flavor_jap.60.a
		change_trade_goods = silver
		ai_chance = { factor = 100 }
	}
}

country_event = {
	id = prices_marcin.4
	title = prices_marcin.4.t
	desc = prices_marcin.4.d
	picture = TRADEGOODS_eventPicture

	fire_only_once = yes
	
	major = yes

	trigger = {
		dip_tech = 16
		cheese = 2
		NOT = { has_global_flag = cheeseislove }
		OR = {
			culture_group = latin
			culture_group = french
		}
	}
	
	mean_time_to_happen = {
		months = 1
	}
	
	option = {
		name = prices_marcin.4.a
		ai_chance = { factor = 100 }
		change_price = {
			trade_goods = cheese
			key = CHEESE_ART
			value = 0.10
			duration = -1
		}
		add_years_of_income  = 0.15
		add_prestige = 20
		set_global_flag = cheeseislove
	}
}

country_event = {
	id = prices_marcin.7
	title = prices_marcin.7.t
	desc = prices_marcin.7.d
	picture = TRADEGOODS_eventPicture

	fire_only_once = yes

	trigger = {
		owns = 4740
		is_year = 1510
		NOT = { has_global_flag = como_silk }
		
		4740 = {
			NOT = { trade_goods = silk }
			NOT = { has_province_flag = has_latent_good }
		}
	}
	
	mean_time_to_happen = {
		months = 1
	}
	
	option = {
		name = prices_marcin.7.a
		ai_chance = { factor = 75 }
		4740 = {
			change_trade_goods = silk
		}
		ROOT = {
			add_treasury = -100
		}
		
		set_global_flag = como_silk
		
	}
	
	option = {
		name = prices_marcin.7.b
		ai_chance = { factor = 25 }
		set_global_flag = como_silk
		add_prestige = -5
	}
}


province_event = {
	id = prices_marcin.8
	title = prices_marcin.8.t
	desc = prices_marcin.8.d
	picture = TRADEGOODS_eventPicture

	is_triggered_only = yes

	trigger = {
	}
	
	
	option = {
		name = prices_marcin.8.a
		ai_chance = { factor = 100 }
	}
	
	immediate = {
		set_variable = {    
			which = Dev_Cost
			value = 0
		}
		export_to_variable = {
			variable_name = Local_Dev_Cost 
			value = modifier:local_development_cost
			who = ROOT
		}
				
		export_to_variable = {
			variable_name = Global_Dev_Cost
			value =  modifier:development_cost
			who = owner
		}
		
		change_variable = { 
			which = Local_Dev_Cost 
			which = Global_Dev_Cost
		}
		
		multiply_variable = {
			which = Local_Dev_Cost
			value = 50
		}
	
		change_variable = { 
			which = Local_Dev_Cost
			value = 50
		}
		
		change_variable = { 
			which = Dev_Cost
			which = Local_Dev_Cost
		}
		
		while = {
			limit = {
				check_variable = {
					which = Dev_Cost
					value = 1
				}
			}
			change_variable = { 
				which = Dev_Cost
				value = -1
			}
			owner = {
				add_dip_power = -1
			}
		}
	}
}


province_event = {
	id = prices_marcin.9
	title = prices_marcin.9.t
	desc = prices_marcin.9.d
	picture = TRADEGOODS_eventPicture

	is_triggered_only = yes

	trigger = {
	}
	
	
	option = {
		name = prices_marcin.9.a
		ai_chance = { factor = 100 }
	}
	
	immediate = {
		set_variable = {    
			which = Dev_Cost
			value = 0
		}
		export_to_variable = {
			variable_name = Local_Dev_Cost 
			value = modifier:local_development_cost
			who = ROOT
		}
				
		export_to_variable = {
			variable_name = Global_Dev_Cost
			value =  modifier:development_cost
			who = owner
		}
		
		change_variable = { 
			which = Local_Dev_Cost 
			which = Global_Dev_Cost
		}
		
		multiply_variable = {
			which = Local_Dev_Cost
			value = 50
		}
	
		change_variable = { 
			which = Local_Dev_Cost
			value = 50
		}
		
		change_variable = { 
			which = Dev_Cost
			which = Local_Dev_Cost
		}
		
		while = {
			limit = {
				check_variable = {
					which = Dev_Cost
					value = 1
				}
			}
			change_variable = { 
				which = Dev_Cost
				value = -1
			}
			owner = {
				add_adm_power = -1
			}
		}
	}
}

country_event = {
	id = prices_marcin.10
	title = prices_marcin.10.t
	desc = prices_marcin.10.d
	picture = TRADEGOODS_eventPicture

	fire_only_once = yes
	
	major = yes

	trigger = {
		AND = {
			OR = {
				any_subject_country = {
					is_colonial_nation = yes
					any_owned_province = {
						trade_goods = tomato
					}
				}
				any_owned_province = {
					trade_goods = tomato
					continent = new_world
				}
				any_owned_province = {
					trade_goods = tomato
					continent = north_america
				}
				any_owned_province = {
					trade_goods = tomato
					continent = south_america
				}
			}
			capital_scope = { continent = europe }
			NOT = { has_global_flag = tomatoislove }
		}
	}
	
	mean_time_to_happen = {
		months = 1
	}
	
	option = {
		name = prices_marcin.3.a
		ai_chance = { factor = 100 }
		custom_tooltip = tomato_tooltip
		hidden_effect = {
			every_province = {
				limit = {
					AND = {
						OR = {	
							trade_goods = livestock
							trade_goods = grain
							trade_goods = wine
						}
						
						OR = {
							region = france_region
							region = italy_region
							region = balkan_region
							region = iberia_region
						}
					}
				}
				
				random = { 
					chance = 20

					change_trade_goods = tomato
				}			
				
			}
		}
		set_global_flag = tomatoislove
		add_years_of_income  = 0.15
		add_prestige = 20
	}
}

province_event = {
	id = prices_marcin.12
	title = prices_marcin.12.t
	desc = prices_marcin.12.d
	picture = TRADE_GOODS_METALS_AND_MINING_EQUIPENT_eventPicture

	hidden = yes
	is_triggered_only = yes
	
	trigger = {
	}
	
	option = {
		name = prices_marcin.12.a
		ai_chance = { factor = 100 }
	}
	
	immediate = {
		every_country = { 
			limit = {
				OR = {
					trading_bonus = {
						trade_goods = indigo
						value = yes
					}
					
					trading_bonus = {
						trade_goods = llama
						value = yes
					}

					trading_bonus = {
						trade_goods = camel
						value = yes
					}
				}
			}
			
			if = {
				limit = {	
					trading_bonus = {
						trade_goods = indigo
						value = yes
					}
				}
				
				set_country_flag = indigo_here
				
				every_owned_province = {
					if = {
						limit = {
							AND = {
								OR = {
									trade_goods = cloth 
								}
								NOT = { has_province_modifier = indigo_leader_new }
								owner = {
									trading_bonus = {
										trade_goods = indigo
										value = yes
									}
								}
							}
						}
						
						add_province_modifier = { 
							name = indigo_leader_new
							duration = -1
						}
					}
				}
			}
			
			if = {
				limit = {	
					trading_bonus = {
						trade_goods = llama
						value = yes
					}
				}
				
				add_country_modifier = { 
					name = lama_tradegood
					duration = -1  
				}
				
				set_country_flag = llama_here
				
				every_owned_province = {
					if = {
						limit = {
							AND = {
								OR = {
									has_terrain = mountain
									has_terrain = hills
									has_terrain = highlands
								}
								NOT = { has_province_modifier = llama_leader_new }
								owner = {
									trading_bonus = {
										trade_goods = llama
										value = yes
									}
								}
							}
						}
						
						add_province_modifier = { 
							name = llama_leader_new
							duration = -1
						}
					}
				}
			}
	
			if = {
				limit = {	
					trading_bonus = {
						trade_goods = camel
						value = yes
					}
				}
				
				set_country_flag = camel_here
				
				every_owned_province = {
					if = {
						limit = {
							AND = {
								OR = {
									has_climate = arid
								}
								NOT = { has_province_modifier = camel_leader_new }
								owner = {
									trading_bonus = {
										trade_goods = camel
										value = yes
									}
								}
							}
						}
						
						add_province_modifier = { 
							name = camel_leader_new
							duration = -1
						}
					}
				}
			}
		}
			
		every_country = { 
			limit = {
				OR = {
					AND = {
						has_country_flag = indigo_here
						trading_bonus = {
							trade_goods = indigo
							value = no
						}
					}
					
					AND = {
						has_country_flag = llama_here
						trading_bonus = {
							trade_goods = llama
							value = no
						}
					}
					
					AND = {
						has_country_flag = camel_here
						trading_bonus = {
							trade_goods = camel
							value = no
						}
					}

				}
			}
			
			if = {
				limit = { has_country_flag = indigo_here }
				clr_country_flag = indigo_here
			
				every_owned_province = {
					limit = {
						has_province_modifier = indigo_leader_new
					}	
					
					remove_province_modifier = indigo_leader_new 
				}
			}
			
			if = {
				limit = { has_country_flag = llama_here }
				clr_country_flag = llama_here
				
				remove_country_modifier = lama_tradegood 

				every_owned_province = {
					limit = {
						has_province_modifier = llama_leader_new
					}	
					
					remove_province_modifier = llama_leader_new 
				}
			}
			
			if = {
				limit = { has_country_flag = camel_here }
				clr_country_flag = camel_here
			
				every_owned_province = {
					limit = {
						has_province_modifier = camel_leader_new
					}	
					
					remove_province_modifier = camel_leader_new 
				}
			}
			
			
		}
	}
}

province_event = {
	id = prices_marcin.13
	title = prices_marcin.13.t
	desc = prices_marcin.13.d
	picture = TRADE_GOODS_METALS_AND_MINING_EQUIPENT_eventPicture

	hidden = yes
	is_triggered_only = yes
	
	trigger = {
	}
	
	option = {
		name = prices_marcin.13.a
		ai_chance = { factor = 100 }
	}
	
	immediate = {
		1 = {
			province_event = { id = prices_marcin.12 days = 1 }
			province_event = { id = prices_marcin.13 days = 365 }
		}
	}
	
}

province_event = {
	id = prices_marcin.14
	title = prices_marcin.14.t
	desc = prices_marcin.14.d
	picture = TRADE_GOODS_METALS_AND_MINING_EQUIPENT_eventPicture

	hidden = yes
	is_triggered_only = yes
	
	trigger = {
	}
	
	option = {
		name = prices_marcin.14.a
		ai_chance = { factor = 100 }
	}
	
	immediate = {
		every_country = { 
			limit = {
				OR = {
					trading_bonus = {
						trade_goods = metalworking
						value = yes
					}
					
					num_of_owned_provinces_with = {
						value = 1
						trade_goods = metalworking
					}
				}
			}
		
			set_country_flag = metalworking_here
			
			every_owned_province = {

				if = {
					limit = {
						any_neighbor_province = { 
							trade_goods = metalworking
							owned_by = owner
						}
						NOT = { has_province_modifier = metalworking_modifier_new }
					}
					
					add_province_modifier = { 
						name = metalworking_modifier_new
						duration = -1
					}
					
				}
				
				
				if = {
					limit = {
						AND = {
							NOT = {
								any_neighbor_province = { 
									trade_goods = metalworking 
									owned_by = owner
								}
							}
							has_province_modifier = metalworking_modifier_new
						}						
					}
					
					remove_province_modifier = metalworking_modifier_new 
					
				}
			}
		}
			
		every_country = { 
			limit = {
				has_country_flag = metalworking_here
				trading_bonus = {
					trade_goods = metalworking
					value = no
				}
			}
			
			clr_country_flag = metalworking_here
		}	
	}
}

province_event = {
	id = prices_marcin.15
	title = prices_marcin.15.t
	desc = prices_marcin.15.d
	picture = TRADE_GOODS_METALS_AND_MINING_EQUIPENT_eventPicture

	hidden = yes
	is_triggered_only = yes
	
	trigger = {
	}
	
	option = {
		name = prices_marcin.15.a
		ai_chance = { factor = 100 }
	}
	
	immediate = {
		1 = {
			province_event = { id = prices_marcin.14 days = 120 }
			province_event = { id = prices_marcin.14 days = 240 }
			province_event = { id = prices_marcin.14 days = 360 }
			province_event = { id = prices_marcin.15 days = 365 }
		}
	}
	
}


country_event = {
	id = prices_marcin.16
	title = prices_marcin.16.t
	desc = prices_marcin.16.d
	picture = TRADE_GOODS_PLANTATION_GOODS_IN_WAREHOUSE_eventPicture

	
	fire_only_once = yes
	major = yes

	trigger = {
		capital_scope = { continent = europe }
		OR = {
			has_discovered = 4457
			has_discovered = 2030
			has_discovered = 534
			has_discovered = 540
			has_discovered = 539
			has_discovered = 561
			has_discovered = 543
		}
		any_owned_province = {
			trade_goods = indigo	
		}
		NOT = { has_global_flag = indigoislove }
	}
	
	mean_time_to_happen = {
		months = 1
	}
	
	
	option = {
		name = prices_marcin.16.a
		ai_chance = { factor = 100 }
		custom_tooltip = my_tooltip_woad
		hidden_effect = {
			every_province = { 
				limit = {
					has_province_modifier = woad_type
				}
				remove_province_modifier = woad_type 
				add_permanent_province_modifier = { 
					name = woad_type_bad
					duration = -1
				}
			
			}
			
			every_province = { 
				limit = {
					superregion = india_superregion
					trade_goods = indigo
				}
				add_permanent_province_modifier = { 
					name = indigo_india
					duration = 18250
				}
			
			}
			set_global_flag = indigoislove
		}
	}
}
##Community events

##ComradDoge
country_event = {
    id = prices_marcin.17
    title = prices_marcin.17.t
    desc = prices_marcin.17.d
    picture = TRADEGOODS_eventPicture

    fire_only_once = yes
    
    major = yes

    trigger = {
        adm_tech = 21
    }
    
    mean_time_to_happen = {
        months = 600
    }

    option = {
        name = prices_marcin.17.a
        change_price = {
            trade_goods = lumber
            key = DEFORESTATION_HAPPEN
            value = 0.5
            duration = -1
        }
    }
}
##

##Vince.bike
country_event = {
    id = prices_marcin.18
    title = prices_marcin.18.t
    desc = prices_marcin.18.d
    picture = TRADE_GOODS_PLANTATION_GOODS_IN_WAREHOUSE_eventPicture

    fire_only_once = yes
    major = yes

    trigger = {
        OR = {
            AND = {
                tag = MNG
				NOT = { num_of_cities = 40 }
				has_disaster = ming_crisis
            }
            AND = {
                is_emperor_of_china = yes
                NOT = { num_of_cities = 30 }
            }
        }
        NOT = { has_global_flag = collapse_of_the_silk_road_flag }
    }
    
    mean_time_to_happen = {
        months = 1
    }

    option = {
        name = prices_marcin.18.a    #Not the silk!
        ai_chance = { factor = 100 }
        change_price = {
            trade_goods = silk
            key = COLLAPSE_OF_THE_SILK_ROAD
            value = 0.35
            duration = -1
        }
        change_price = {
            trade_goods = chinaware
            key = COLLAPSE_OF_THE_SILK_ROAD
            value = 0.35
            duration = -1
        }
        change_price = {
            trade_goods = jade
            key = COLLAPSE_OF_THE_SILK_ROAD
            value = 0.35
            duration = -1
        }
        set_global_flag = collapse_of_the_silk_road_flag
    }
}
##


country_event = {
    id = prices_marcin.19
    title = prices_marcin.19.t
    desc = prices_marcin.19.d
    picture = TRADE_GOODS_PLANTATION_GOODS_IN_WAREHOUSE_eventPicture

    fire_only_once = yes
    major = yes

    trigger = {
		NOT = { has_global_flag = decline_of_cavalry_flag }
		always = no
    }
    
    mean_time_to_happen = {
        months = 1
    }

    option = {
        name = prices_marcin.19.a    
        ai_chance = { factor = 100 }
        change_price = {
            trade_goods = horses
            key = DECLINE_OF_CAVALRY
            value = -0.35
            duration = -1
        }
		change_price = {
            trade_goods = elephants
            key = DECLINE_OF_CAVALRY
            value = -0.35
            duration = -1
        }
        set_global_flag = decline_of_cavalry_flag
    }
}

country_event = {
    id = prices_marcin.20
    title = prices_marcin.20.t
    desc = prices_marcin.20.d
    picture = TRADE_GOODS_PLANTATION_GOODS_IN_WAREHOUSE_eventPicture

    fire_only_once = yes
    major = yes

    trigger = {
		always = no
		NOT = { has_global_flag = renaissance_architecture_boom_flag }
    }
    
    mean_time_to_happen = {
        months = 1
    }

    option = {
        name = prices_marcin.20.a    
        ai_chance = { factor = 100 }
        change_price = {
            trade_goods = marble
            key = RENAISSANCE_ARCHITECTURE_BOOM
            value = -0.35
            duration = -1
        }
        set_global_flag = renaissance_architecture_boom_flag
    }
}










