building_bonus_weekly_effect = {
	#building boosts
	### if you want to add more (see /common/scripted_triggers/00_pulse_triggers.txt for all possible boost variables),
	### copy one bonus-block and change the variables accordingly
	### to get the id of a building look inside /common/buildings/00_buildings.txt
    if = {
		#does not apply to countries without the bonus variables because of performance reasons
		limit = {
			building_total_bonus_present_any = yes
		}
		
		#civ bonus
		if = {
			limit = {
				has_variable = civ_total_bonus
			}
			#getting the current total number of civs inside a country
			set_variable = { civ_total = 0 }
			every_owned_state = {
				OWNER = {
					add_to_variable = { civ_total = PREV.building_level@industrial_complex }
				}
			}
			
			#if the current total number of civs inside a country equals or exceeds the bonus number, clear the variables
			if = {
				limit = {
					OR = {
						check_variable = { civ_total = civ_total_bonus }
						check_variable = { civ_total > civ_total_bonus }
					}
				}
				clear_variable = civ_total_bonus
				clear_variable = civ_total
			}
		}
		
		#mil bonus
		if = {
			limit = {
				has_variable = mil_total_bonus
			}
			#getting the current total number of mils inside a country
			set_variable = { mil_total = 0 }
			every_owned_state = {
				OWNER = {
					add_to_variable = { mil_total = PREV.building_level@arms_factory }
				}
			}
			
			#if the current total number of mils inside a country equals or exceeds the bonus number, clear the variables
			if = {
				limit = {
					OR = {
						check_variable = { mil_total = mil_total_bonus }
						check_variable = { mil_total > mil_total_bonus }
					}
				}
				clear_variable = mil_total_bonus
				clear_variable = mil_total
			}
		}
		
		#infra bonus
		if = {
			limit = {
				has_variable = infra_total_bonus
			}
			#getting the current total number of infra inside a country
			set_variable = { infra_total = 0 }
			every_owned_state = {
				OWNER = {
					add_to_variable = { infra_total = PREV.infrastructure_level }
				}
			}
			
			#if the current total number of infra inside a country equals or exceeds the bonus number, clear the variables
			if = {
				limit = {
					OR = {
						check_variable = { infra_total = infra_total_bonus }
						check_variable = { infra_total > infra_total_bonus }
					}
				}
				clear_variable = infra_total_bonus
				clear_variable = infra_total
			}
		}

		#rail bonus
		if = {
			limit = {
				has_variable = rail_total_bonus
			}
			#getting the current total number of railways inside a country
			set_variable = { rail_total = 0 }
			every_owned_state = {
				OWNER = {
					add_to_variable = { rail_total = PREV.building_level@rail_way }
				}
			}
			
			#if the current total number of railways inside a country equals or exceeds the bonus number, clear the variables
			if = {
				limit = {
					OR = {
						check_variable = { rail_total = rail_total_bonus }
						check_variable = { rail_total > rail_total_bonus }
					}
				}
				clear_variable = rail_total_bonus
				clear_variable = rail_total
			}
		}
		
		#dock bonus
		if = {
			limit = {
				has_variable = dock_total_bonus
			}
			#getting the current total number of docks inside a country
			set_variable = { dock_total = 0 }
			every_owned_state = {
				limit = {
					is_coastal = yes
				}
				OWNER = {
					add_to_variable = { dock_total = PREV.building_level@dockyard }
				}
			}
			
			#if the current total number of docks inside a country equals or exceeds the bonus number, clear the variables
			if = {
				limit = {
					OR = {
						check_variable = { dock_total = dock_total_bonus }
						check_variable = { dock_total > dock_total_bonus }
					}
				}
				clear_variable = dock_total_bonus
				clear_variable = dock_total
			}
		}
		
		#steel mill bonus
		if = {
			limit = {
				has_variable = steel_total_bonus
			}
			#getting the current total number of steel mills inside a country
			set_variable = { steel_total = 0 }
			every_owned_state = {
				OWNER = {
					add_to_variable = { steel_total = PREV.building_level@steel_mill }
				}
			}
			
			#if the current total number of steel mills inside a country equals or exceeds the bonus number, clear the variables
			if = {
				limit = {
					OR = {
						check_variable = { steel_total = steel_total_bonus }
						check_variable = { steel_total > steel_total_bonus }
					}
				}
				clear_variable = steel_total_bonus
				clear_variable = steel_total
			}
		}
		
		#logging camp bonus
		if = {
			limit = {
				has_variable = logging_total_bonus
			}
			#getting the current total number of logging camps inside a country
			set_variable = { logging_total = 0 }
			every_owned_state = {
				OWNER = {
					add_to_variable = { logging_total = PREV.building_level@logging_camp }
				}
			}
			
			#if the current total number of logging camps inside a country equals or exceeds the bonus number, clear the variables
			if = {
				limit = {
					OR = {
						check_variable = { logging_total = logging_total_bonus }
						check_variable = { logging_total > logging_total_bonus }
					}
				}
				clear_variable = logging_total_bonus
				clear_variable = logging_total
			}
		}
		
		#farm bonus
		if = {
			limit = {
				has_variable = farm_total_bonus
			}
			#getting the current total number of farms inside a country
			set_variable = { farm_total = 0 }
			every_owned_state = {
				OWNER = {
					add_to_variable = { farm_total = PREV.building_level@farm }
				}
			}
			
			#if the current total number of farms inside a country equals or exceeds the bonus number, clear the variables
			if = {
				limit = {
					OR = {
						check_variable = { farm_total = farm_total_bonus }
						check_variable = { farm_total > farm_total_bonus }
					}
				}
				clear_variable = farm_total_bonus
				clear_variable = farm_total
			}
		}
		
		#coal mine
		if = {
			limit = {
				has_variable = coal_total_bonus
			}
			#getting the current total number of coal mines inside a country
			set_variable = { coal_total = 0 }
			every_owned_state = {
				OWNER = {
					add_to_variable = { coal_total = PREV.building_level@coal_mine }
				}
			}
			
			#if the current total number of coal mines inside a country equals or exceeds the bonus number, clear the variables
			if = {
				limit = {
					OR = {
						check_variable = { coal_total = coal_total_bonus }
						check_variable = { coal_total > coal_total_bonus }
					}
				}
				clear_variable = coal_total_bonus
				clear_variable = coal_total
			}
		}
	}
}