Losa10/PreTrain-HOI4-Modding-Assistant huggingface dataset:
### Entity: Scope Reference
Construct: Expressions
Source: vanilla_docs
File: documentation/script_concept_documentation.md

Doc:
## Math Expressions
```

Math expressions allow for mathematical calculations using constants, scoped variables and mathematical functions.
Using math expressions is expected to be more performant than using temporary variables for calculations.

All math expressions are based on fixed point arithmetic. For boolean operations, 0.0 is considered false and any
other value is considered true. All operators that return a boolean value will return 1.0 for true and 0.0 for false.

A list of math functions can be found [here](script_math_functions.md).
### Entity: Scripted Trigger
Component: EAI_MILITARY_north_summer_season
Constructs: check_variable
Source: game
File: common/scripted_triggers/EAI_MILITARY_strategy_triggers.txt

Code:
EAI_MILITARY_north_summer_season = {
	OR = {
		check_variable = {
			global.EAI_calendar_month = 5
		} {
			global.EAI_calendar_month = 6
		} {
			global.EAI_calendar_month = 7
		} {
			global.EAI_calendar_month = 8
		} {
			global.EAI_calendar_month = 9
		}
	}
}
### Entity: Country History
Country: UZB
Component: UZB_technology
Constructs: set_technology
Source: game
File: history/countries/UZB - Uzbekistan.txt

Code:
# Starting Technologies for UZB
set_technology = {
	infantry_weapons = 1
}
### Entity: National Focus
Tree: pol_focus
Component: POL_demand_LIT_pavel
Constructs: has_completed_focus, prerequisite, has_war, limit, has_government, has_war_with, completion_reward, allow_branch
Source: game
File: common/national_focus/poland.txt

Code:
focus = {
	id = POL_demand_LIT_pavel
	icon = GFX_goal_demand_sudetenland
	prerequisite = {
		focus = POL_restore_bermontians POL_invite_exiled_nobility
	}
	relative_position_id = POL_restore_bermontians
	will_lead_to_war_with = LIT
	x = 0
	y = 1
	cost = 10
	ai_will_do = {
		factor = 2.5
	}
	allow_branch = {
		has_dlc = No Step Back
		if = {
			limit = {
				has_game_rule = {
					rule = obsolete_focus_branches_visibility
					option = HIDE
				}
			}
			NOT = {
				OR = {
					has_completed_focus = POL_organize_the_peasants_strike POL_restore_the_sejm POL_complete_april_constitution POL_nationalist_constitution
				}
			}
		}
	}
	available_if_capitulated = no
	available = {
		is_subject = no
		IF = {
			limit = {
				has_completed_focus = POL_romanov
			}
			has_government = neutrality
		}
		ELSE = {
			has_government = fascism
		}
		LIT = {
			exists = yes
			has_capitulated = no
			is_subject = no
			NOT = {
				has_war_with = ROOT
			} {
				is_in_faction_with = ROOT
			}
		}
		784 = {
			owns_or_subject_of = yes
		}
		has_army_manpower = {
			size = > 399999
		}
	}
	bypass = {
		OR = {
			LIT = {
				OR = {
					exists = no
					has_capitulated = yes
					is_subject = yes
					has_war_with = ROOT
					is_in_faction_with = ROOT
				}
			}
			784 = {
				owns_or_subject_of = no
			}
		}
	}
	search_filters = {
		FOCUS_FILTER_ANNEXATION
	}
	completion_reward = {
		if = {
			limit = {
				LIT = {
					has_war = no
				}
			}
			LIT = {
				country_event = {
					id = poland.15
					days = 5
				}
			}
		}
		else = {
			11 = {
				add_claim_by = POL
			}
			814 = {
				add_claim_by = POL
			}
			815 = {
				add_claim_by = POL
			}
			189 = {
				add_claim_by = POL
			}
			create_wargoal = {
				type = annex_everything
				target = LIT
			}
		}
	}
}
### Entity: AI Strategy
Component: GER_upgrade_the_blitz
Constructs: has_war_with, is_historical_focus_on, has_capitulated
Source: game
File: common/ai_strategy/GER.txt

Code:
GER_upgrade_the_blitz = {
	allowed = {
		original_tag = GER
	}
	enable = {
		is_historical_focus_on = yes
		has_war_with = ENG
		ENG = {
			controls_state = 126
		}
		FRA = {
			has_capitulated = yes
		}
		NOT = {
			has_war_with = SOV
		} {
			focus_progress = {
				focus = GER_war_with_the_ussr
				progress = > 0.01
			}
		}
		date = > 1940.3.1 < 1940.11.1
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = strategic_air_importance
		id = 1
		value = 10000
	}
}
### Entity: National Focus
Tree: mon_focus
Component: MON_foreign_air_equipment_coordination
Constructs: prerequisite, add_ideas, completion_reward, unlock_decision_tooltip
Source: game
File: common/national_focus/mongolia.txt

Code:
focus = {
	id = MON_foreign_air_equipment_coordination
	icon = GFX_goal_HOL_standardize_plane_designs
	prerequisite = {
		focus = MON_situational_aerial_presence MON_capital_operations_focus
	}
	x = 1
	y = 1
	relative_position_id = MON_situational_aerial_presence
	cost = 10
	ai_will_do = {
		factor = 10
	}
	completion_reward = {
		air_experience = 10
		add_ideas = MON_air_equipment_manufacturers_coordination_idea
		unlock_decision_tooltip = MON_obtain_plane_schematics
	}
	search_filters = {
		FOCUS_FILTER_AIR_XP FOCUS_FILTER_RESEARCH
	}
}
### Entity: AI Strategy
Component: r56_latin_armerica_nice_demo_boy_stays_home_unless_something_goes_wrong
Constructs: has_government, has_war_with, is_major, is_in_faction_with
Source: game
File: common/ai_strategy/r56_default.txt

Code:
r56_latin_armerica_nice_demo_boy_stays_home_unless_something_goes_wrong = {
	allowed = {
		OR = {
			original_tag = ARG VEN ECU PRU BOL CHL PAR URG BRA COS PAN NIC HON ELS GUA CUB HAI DOM JAM COL
		}
	}
	enable = {
		ROOT = {
			AND = {
				exists = yes
				has_government = democratic
				OR = {
					is_in_faction_with = ENG USA
				}
				any_enemy_country = {
					is_major = yes
				}
			}
		}
		OR = {
			USA = {
				exists = yes
				has_government = democratic
				is_in_faction_with = ROOT
				surrender_progress = < 0.02
				has_war_with = GER
			}
			ENG = {
				exists = yes
				has_government = democratic
				is_in_faction_with = ROOT
				surrender_progress = < 0.02
				has_war_with = GER
			}
		}
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = dont_defend_ally_borders
		id = USA
		value = 125
	} {
		type = dont_defend_ally_borders
		id = ENG
		value = 125
	} {
		type = area_priority
		id = north_america
		value = 175
	} {
		type = area_priority
		id = south_america
		value = 175
	} {
		type = area_priority
		id = europe
		value = 10
	} {
		type = area_priority
		id = asia
		value = 0
	} {
		type = area_priority
		id = middle_east
		value = 0
	} {
		type = area_priority
		id = suez
		value = 0
	} {
		type = area_priority
		id = africa
		value = 10
	} {
		type = area_priority
		id = pacific
		value = 10
	} {
		type = area_priority
		id = oceania
		value = 0
	}
}
### Entity: Idea
Component: r56_LUX_red_army_2
Constructs: has_government
Source: game
File: common/ideas/r56_luxembourg.txt

Code:
r56_LUX_red_army_2 = {
	name = r56_LUX_red_army
	picture = MEX_revolutionary_army
	cancel = {
		NOT = {
			has_government = communism
		}
	}
	modifier = {
		army_core_defence_factor = 0.15
		army_core_attack_factor = 0.075
		army_morale_factor = 0.05
		conscription = 0.035
	}
}
### Entity: Scripted Effect
Component: BUL_zveno_high_loyalty_decrease_effect
Constructs: add_to_variable
Source: game
File: common/scripted_effects/BUL_scripted_effects.txt

Code:
BUL_zveno_high_loyalty_decrease_effect = {
	custom_effect_tooltip = BUL_zveno_tt BUL_high_loyalty_decrease_tt
	add_to_variable = {
		BUL_zveno_loyalty = BUL_faction_high_decrease
	}
	clamp_variable = {
		var = BUL_zveno_loyalty
		min = 0
		max = 100
	}
}
### Entity: Character
Component: pc_for_foreign_affairs_litvinov
Source: game
File: common/country_leader/00_traits.txt

Code:
pc_for_foreign_affairs_litvinov = {
	random = no
	sprite = 13
	opinion_gain_monthly_factor = 0.15
	enemy_justify_war_goal_time = 0.15
	request_lease_tension = -0.2
	democratic_acceptance = 40
}
### Entity: National Focus
Tree: saf_focus
Component: SAF_Union_of_the_African_People
Constructs: prerequisite, limit, has_country_flag, completion_reward, cancel_if_invalid, has_dlc, set_rule, create_faction_from_template
Source: game
File: common/national_focus/south_africa.txt

Code:
focus = {
	id = SAF_Union_of_the_African_People
	icon = GFX_goal_anschluss
	prerequisite = {
		focus = SAF_anti_colonialist_crusade
	}
	x = 4
	y = 4
	relative_position_id = SAF_empower_the_workers
	cost = 10
	ai_will_do = {
		factor = 1
	}
	available = {
		NOT = {
			has_country_flag = britain_enforced_our_loyalty
		}
	}
	bypass = {

	}
	cancel_if_invalid = yes
	continue_if_invalid = no
	available_if_capitulated = no
	search_filters = {
		FOCUS_FILTER_POLITICAL
	}
	completion_reward = {
		IF = {
			limit = {
				has_dlc = No Compromise, No Surrender
			}
			set_rule = {
				can_create_factions = yes
			}
			create_faction_from_template = faction_template_SAF_faction_uotap
			add_faction_initiative = 1
		}
		ELSE = {
			set_rule = {
				can_create_factions = yes
			}
			create_faction = SAF_faction_uotap
		}
		hidden_effect = {
			news_event = {
				hours = 6
				id = news.264
			}
		}
	}
}
### Entity: AI Strategy
Component: EAI_BUILDING_construction_MIC_17
Constructs: has_country_flag
Source: game
File: common/ai_strategy/EAI_BUILDING_construction_strategies.txt

Code:
EAI_BUILDING_construction_MIC_17 = {
	enable = {
		has_country_flag = {
			flag = EAI_BUILDING_build_num_MIC
			value = 17
		}
	}
	abort_when_not_enabled = yes
	ai_strategy = {
		type = building_target
		id = arms_factory
		value = 17
	}
}
### Entity: National Focus
Tree: sov_focus
Component: SOV_workers_culture
Constructs: has_completed_focus, prerequisite, limit, add_ideas, has_government, completion_reward, complete_tooltip, modify_timed_idea
Source: game
File: common/national_focus/soviet_old.txt

Code:
focus = {
	id = SOV_workers_culture
	icon = GFX_goal_workers_support
	prerequisite = {
		focus = SOV_third_five_year_plan_old
	}
	x = 2
	y = 1
	cost = 10
	ai_will_do = {
		factor = 5
	}
	available = {
		has_government = communism
	}
	bypass = {
		NOT = {
			has_government = communism
		}
	}
	complete_tooltip = {
		add_ideas = workers_culture
		modify_timed_idea = {
			idea = SOV_revolutionized_industry_1
			days = 10
		} {
			idea = SOV_revolutionized_industry_2
			days = 10
		}
	}
	completion_reward = {
		add_ideas = workers_culture
		if = {
			limit = {
				has_completed_focus = SOV_Invest_in_Engineering_old
			}
			add_timed_idea = {
				idea = SOV_engineering_push
				days = 30
			}
		}
		modify_timed_idea = {
			idea = SOV_revolutionized_industry_1
			days = 10
		} {
			idea = SOV_revolutionized_industry_2
			days = 10
		}
	}
	search_filters = {
		FOCUS_FILTER_INDUSTRY
	}
}
### Entity: Idea
Component: army_dominant
Constructs: industrial_capacity_factory, is_controlled_by, removal_cost, research_bonus
Source: game
File: common/ideas/add_director.txt

Code:
army_dominant = {
	level = 5
	cost = 10
	available = {
		ROOT = {
			any_owned_state = {
				is_controlled_by = ROOT
				dockyard = > 0
			}
		}
	}
	removal_cost = -1
	picture = jap_interservice_rivalry_army_dominant
	research_bonus = {
		naval_equipment = -0.2
		infantry_weapons = 0.1
		air_equipment = 0.1
		armor = 0.1
	}
	modifier = {
		production_speed_arms_factory_factor = 0.3
		production_speed_dockyard_factor = -0.3
		industrial_capacity_factory = 0.3
		industrial_capacity_dockyard = -0.3
	}
}
### Entity: Decision
Component: CHI_the_sinofication_of_china
Source: game
File: common/decisions/categories/r56_warlord_decision_categories.txt

Code:
CHI_the_sinofication_of_china = {
	priority = 101
	icon = GFX_decision_category_generic_crisis
	visible_when_empty = no
	allowed = {
		OR = {
			original_tag = XSM GXC YUN SIK KHM SHX SIC XIC GDC HBC SND
		}
	}
	visible = {

	}
}
### Entity: National Focus
Tree: ast_focus
Component: AST_second_australian_imperial_force
Constructs: prerequisite, completion_reward, add_to_variable
Source: game
File: common/national_focus/australia_taog.txt

Code:
focus = {
	id = AST_second_australian_imperial_force
	icon = GFX_focus_AST_second_australian_imperial_force
	prerequisite = {
		focus = AST_permanant_military_forces
	} {
		focus = AST_invoke_the_1903_defence_act
	}
	relative_position_id = AST_permanant_military_forces
	overlay = GFX_focus_fast_overlay_conscription
	dynamic = yes
	x = 1
	y = 2
	cost = 10
	available = {

	}
	bypass = {

	}
	available_if_capitulated = no
	completion_reward = {
		custom_effect_tooltip = AST_australian_military_forces_spirit_tt generic_skip_one_line_tt generic_skip_one_line_tt AST_expeditionary_leader_plural generic_skip_one_line_tt AST_conscription_law_so_far
		add_to_variable = {
			AST_australian_military_forces_spirit_army_non_core_attack_factor = 0.025
			tooltip = army_non_core_attack_factor_tt
		} {
			AST_australian_military_forces_spirit_army_non_core_defence_factor = 0.05
			tooltip = army_non_core_defence_factor_tt
		}
		show_unit_leaders_tooltip = AST_alan_vasey AST_george_wootten
		hidden_effect = {
			AST_conscription_level_scripted_effect = yes
		}
	}
	search_filters = {
		FOCUS_FILTER_MANPOWER FOCUS_FILTER_MILITARY_CHARACTER
	}
}
### Entity: Event
Component: wtt_political_warlord_support.3
Constructs: is_triggered_only
Source: game
File: events/WTT_china_political_power_struggle.txt

Code:
country_event = {
	id = wtt_political_warlord_support.3
	title = wtt_political_warlord_support.3.t
	desc = wtt_political_warlord_support.3.desc
	picture = GFX_report_event_generic_read_write
	is_triggered_only = yes
	option = {
		name = wtt_political_warlord_support.3.a
	}
}
### Entity: Character
Component: AUS_alfred_jansa
Constructs: has_completed_focus, has_government, has_civil_war
Source: game
File: common/characters/AUS.txt

Code:
AUS_alfred_jansa = {
	name = AUS_alfred_jansa
	portraits = {
		army = {
			large = GFX_portrait_AUS_alfred_jansa
			small = GFX_portrait_AUS_alfred_jansa_small
		}
	}
	advisor = {
		slot = army_chief
		idea_token = AUS_alfred_jansa
		allowed = {
			original_tag = AUS
		}
		available = {
			has_completed_focus = AUS_follow_the_jansa_plan
		}
		visible = {
			NOT = {
				OR = {
					has_completed_focus = AUS_establish_bohme_plan
					original_tag = GER
				}
			}
		}
		traits = {
			army_chief_defensive_2
		}
		cost = 100
		ai_will_do = {
			base = 5
		}
	}
	field_marshal = {
		traits = {
			organizer thorough_planner war_hero
		}
		skill = 3
		attack_skill = 2
		defense_skill = 4
		planning_skill = 3
		logistics_skill = 2
		legacy_id = -1
		visible = {
			OR = {
				AND = {
					has_civil_war = yes
					OR = {
						has_government = democratic communism
					}
				}
				has_civil_war = no
			}
			NOT = {
				original_tag = GER
			}
		}
	}
}
### Entity: Order of Battle
Component: air_wing_797
Source: game
File: history/units/TUR_1939_air_bba.txt

Code:
air_wings = {
	797 = {
		small_plane_cas_airframe_1 = {
			owner = TUR
			amount = 32
			creator = USA
			version_name = YA-19
		}
		small_plane_airframe_1 = {
			owner = TUR
			amount = 60
			creator = FRA
			version_name = M.S. 406
		}
	}
}
### Entity: Event
Component: bftb_turkey.108
Constructs: is_triggered_only, every_owned_state, limit, add_stability, add_dynamic_modifier, clear_global_event_target, is_core_of, add_resistance
Source: game
File: events/BFTB_Turkey.txt

Code:
country_event = {
	id = bftb_turkey.108
	title = bftb_turkey.108.t
	desc = bftb_turkey.108.desc
	picture = GFX_report_event_tur_turkish_soldiers
	is_triggered_only = yes
	option = {
		name = bftb_turkey.108.a
		event_target:TUR_kurdish_state_event_target = {
			TUR_integrate_kurdish_state_forced_effect = yes
			add_dynamic_modifier = {
				modifier = conscription_exemptions_granted
			}
		}
		hidden_effect = {
			clear_global_event_target = TUR_kurdish_state_event_target
		}
	} {
		name = bftb_turkey.108.b
		add_stability = -0.05
		every_owned_state = {
			limit = {
				is_core_of = KUR
			}
			add_resistance = 10
		}
		hidden_effect = {
			clear_global_event_target = TUR_kurdish_state_event_target
		}
	}
}
### Entity: Idea
Component: CZE_sokol_movement_2
Constructs: has_government, removal_cost
Source: game
File: common/ideas/czechoslovakia_old.txt

Code:
CZE_sokol_movement_2 = {
	picture = generic_manpower_bonus
	allowed = {
		always = no
	}
	allowed_civil_war = {
		OR = {
			has_government = democratic neutrality
		}
	}
	removal_cost = -1
	modifier = {
		conscription = 0.005
	}
}
### Entity: National Focus
Tree: rut_focus
Component: RUT_military_modernization
Constructs: prerequisite, limit, completion_reward, add_research_slot
Source: game
File: common/national_focus/ruthenia.txt

Code:
focus = {
	id = RUT_military_modernization
	icon = GFX_focus_research
	prerequisite = {
		focus = RUT_special_forces
	} {
		focus = RUT_modern_artillery
	} {
		focus = RUT_armor_effort
	} {
		focus = RUT_modern_tactics_effort
	}
	relative_position_id = RUT_carpathian_sich
	x = 0
	y = 4
	cost = 10
	ai_will_do = {
		factor = 40
	}
	available = {

	}
	available_if_capitulated = yes
	completion_reward = {
		if = {
			limit = {
				NOT = {
					amount_research_slots = > 4
				}
			}
			add_research_slot = 1
		}
	}
	search_filters = {
		FOCUS_FILTER_RESEARCH
	}
}
### Entity: Faction
Component: faction_goal_control_the_chinese_capitals
Constructs: limit, complete_effect, add_faction_power_projection, add_faction_initiative, every_collection_element, has_completed_goal
Source: game
File: common/factions/goals/faction_goals_medium_term.txt

Code:
faction_goal_control_the_chinese_capitals = {
	name = control_the_chinese_capitals_goal_name
	description = control_the_chinese_capitals_goal_desc
	category = medium_term
	group = FOCUS_FILTER_ANNEXATION
	allowed = {

	}
	visible = {
		FROM = {
			original_tag = JAP
		}
	}
	completed = {
		608 = {
			is_controlled_by_ROOT_or_ally = yes
		}
		1035 = {
			is_controlled_by_ROOT_or_ally = yes
		}
		592 = {
			is_controlled_by_ROOT_or_ally = yes
		}
	}
	complete_effect = {
		add_faction_power_projection = 100
		custom_effect_tooltip = generic_skip_one_line_tt THE_FACTION_LEADER generic_skip_one_line_tt
		add_faction_initiative = 1
		every_collection_element = {
			input = {
				input = game:scope
				operators = {
					faction_members
				}
				name = ALL_FACTION_MEMBERS
			}
			custom_effect_tooltip = ALL_FACTION_MEMBERS
			IF = {
				limit = {
					NOT = {
						has_completed_goal = faction_goal_control_the_chinese_capitals
					}
				}
				army_experience = 50
				air_experience = 25
				navy_experience = 25
			}
		}
	}
	ai_will_do = {
		base = 1
		modifier = {
			add = 9
			date = < 1941.1.1
		}
	}
}
### Entity: Idea
Component: r56_LUX_republican_humanism
Constructs: has_government, democratic_drift, communism_drift
Source: game
File: common/ideas/r56_luxembourg.txt

Code:
r56_LUX_republican_humanism = {
	picture = generic_victors_of_ww1
	cancel = {
		has_government = neutrality
	}
	modifier = {
		democratic_drift = 0.05
		communism_drift = 0.03
		stability_weekly = 0.001
	}
}
### Entity: Idea
Component: idea_RAJ_bhoodan_movement
Constructs: industrial_capacity_factory, production_speed_buildings_factor, removal_cost
Source: game
File: common/ideas/british_raj_goe.txt

Code:
idea_RAJ_bhoodan_movement = {
	picture = SOV_third_five_year_plan_civilian
	allowed = {
		original_tag = RAJ
	}
	allowed_civil_war = {
		always = yes
	}
	removal_cost = -1
	name = RAJ_bhoodan_movement
	modifier = {
		production_speed_buildings_factor = 0.1
		production_factory_start_efficiency_factor = 0.15
		production_factory_efficiency_gain_factor = 0.05
		production_factory_max_efficiency_factor = 0.1
		industrial_capacity_factory = -0.06
		consumer_goods_factor = 0.1
		stability_weekly = 0.003
	}
}
### Entity: Game Rule
Component: SWE_ai_behavior
Constructs: allow_achievements
Source: game
File: common/game_rules/00_game_rules.txt

Code:
SWE_ai_behavior = {
	name = SWE_AI_BEHAVIOR
	group = RULE_GROUP_AI_BEHAVIOR
	required_dlc = Arms Against Tyranny
	default = {
		name = DEFAULT
		text = RULE_OPTION_DEFAULT
		desc = RULE_OPTION_DEFAULT_AI_DESC
	}
	option = {
		name = HISTORICAL
		text = RULE_OPTION_HISTORICAL
		desc = RULE_HISTORICAL_SWE_AI_DESC
		allow_achievements = yes
	} {
		name = SWE_DEMOCRATIC_DEM_ALT
		text = RULE_OPTION_SWE_DEM_ALT
		desc = RULE_OPTION_SWE_DEM_ALT_DESC
		allow_achievements = no
	} {
		name = SWE_DEMOCRATIC_NORDIC_DEFENCE_COUNCIL
		text = RULE_OPTION_SWE_DEMOCRATIC_NORDIC_DEFENCE_COUNCIL
		desc = RULE_OPTION_SWE_DEMOCRATIC_NORDIC_DEFENCE_COUNCIL_DESC
		allow_achievements = no
	} {
		name = SWE_COMMUNISM
		text = RULE_OPTION_SWE_COMMUNISM
		desc = RULE_OPTION_SWE_COMMUNISM_DESC
		allow_achievements = no
	} {
		name = SWE_FASCIST_INDEPENDENT
		text = RULE_OPTION_SWE_FASCIST_INDEPENDENT
		desc = RULE_OPTION_SWE_FASCIST_INDEPENDENT_DESC
		allow_achievements = no
	} {
		name = SWE_FASCIST_PUPPET
		text = RULE_OPTION_SWE_FASCIST_PUPPET
		desc = RULE_OPTION_SWE_FASCIST_PUPPET_DESC
		allow_achievements = no
	} {
		name = SWE_FASCIST_PUPPET_BACKSTABBER
		text = RULE_OPTION_SWE_FASCIST_PUPPET_BACKSTABBER
		desc = RULE_OPTION_SWE_FASCIST_PUPPET_BACKSTABBER_DESC
		allow_achievements = no
	} {
		name = SWE_UNALIGNED
		text = RULE_OPTION_SWE_UNALIGNED
		desc = RULE_OPTION_SWE_UNALIGNED_DESC
		allow_achievements = no
	} {
		name = RANDOM
		text = RULE_OPTION_RANDOM
		desc = RULE_OPTION_RANDOM_AI_DESC
		allow_achievements = no
	}
}
### Entity: Scripted Effect
Component: EAI_BUILDING_REFINERY_general_building_target_modifiers
Constructs: has_war, limit, has_country_flag, set_temp_variable, check_variable, add_to_temp_variable
Source: game
File: common/scripted_effects/EAI_CONSTRUCTION_NORMAL_strategies.txt

Code:
EAI_BUILDING_REFINERY_general_building_target_modifiers = {
	set_temp_variable = {
		EAI_BUILDING_target_num_REF = EAI_BUILDING_num_REF
	}
	if = {
		limit = {
			check_variable = {
				EAI_BUILDING_num_CIC = > 50
			} {
				EAI_fuel_produced = < @EAI_FUEL_PRODUCED_TO_MAX_CONSUMED_RATIO_TO_BUILD_REF
			} {
				EAI_fuel_reserve = < @EAI_FUEL_RESERVE_DAYS_TO_BUILD_REF
			}
			has_war = yes
			set_temp_variable = {
				EAI_refineries_needed_for_fuel = EAI_max_fuel_consumption_estimate
			} {
				EAI_fuel_produced = resource_produced@oil
			} {
				EAI_fuel_reserve = fuel_k
			} {
				EAI_max_fuel_consumption_estimate_k = EAI_max_fuel_consumption_estimate
			}
			add_to_temp_variable = {
				EAI_fuel_produced = resource_imported@oil
			}
			subtract_from_temp_variable = {
				EAI_fuel_produced = resource_exported@oil
			}
			multiply_temp_variable = {
				EAI_fuel_produced = 48
			}
			if = {
				limit = {
					check_variable = {
						EAI_max_fuel_consumption_estimate = > 0
					}
				}
				divide_temp_variable = {
					EAI_fuel_produced = EAI_max_fuel_consumption_estimate
				}
			} {
				limit = {
					check_variable = {
						EAI_max_fuel_consumption_estimate_k = > 0
					}
				}
				divide_temp_variable = {
					EAI_fuel_reserve = EAI_max_fuel_consumption_estimate_k
				}
			}
			else = {
				always = no
			} {
				always = no
			}
		}
		add_to_temp_variable = {
			EAI_BUILDING_target_num_REF = 1
		}
		if = {
			limit = {
				has_country_flag = EAI_building_logging
			}
			log = Needs more refineries if producing too little fuel compared to max consumption AND fuel reserve days at max consumption is low
		}
	} {
		limit = {
			check_variable = {
				EAI_rubber_resource_shortage = 3
			}
		}
		add_to_temp_variable = {
			EAI_BUILDING_target_num_REF = 1
		}
		if = {
			limit = {
				has_country_flag = EAI_building_logging
			}
			log = There has been a rubber shortage for a while, build REF
		}
	}
}