0% found this document useful (0 votes)
97 views18 pages

00 Scripted Effects

The document contains code for a game that modifies how countries behave in certain situations. It includes: 1) Code to convert 5 civilian factories to military factories in random states owned by the player. 2) Code that changes a country's strategies to be more protective and allied with neighboring democratic nations if it is democratic in Germany. 3) Code to print variables to a log file to analyze a country's strategies and alliances.

Uploaded by

朱奥晗
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
97 views18 pages

00 Scripted Effects

The document contains code for a game that modifies how countries behave in certain situations. It includes: 1) Code to convert 5 civilian factories to military factories in random states owned by the player. 2) Code that changes a country's strategies to be more protective and allied with neighboring democratic nations if it is democratic in Germany. 3) Code to print variables to a log file to analyze a country's strategies and alliances.

Uploaded by

朱奥晗
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 18

# Example:

#
# example_effect = {
# add_political_power = 66
# add_popularity = {
# ideology = fascism
# popularity = 0.33
# }
# }
#
#
# In a script file:
#
# effect = {
# example_effect = yes
# }
#

#####################################
### emergency_factory_conversion ####
#####################################

#This is going to give misleading and ugly tooltips. Making it nice will take
effort. TODO_WTT_CD make nice or ignore and remove comment. Easiest solution is
just making a custom tooltip that says "5 civilian factories will be converted to
military factories" and ignore telling the player the states where it will happen.

replace_civ_with_arms_factories = {

random_owned_controlled_state = {
limit = {
is_fully_controlled_by = ROOT
industrial_complex > 0
}
remove_building = {
type = industrial_complex
level = 1
}
add_building_construction = {
type = arms_factory
level = 1
instant_build = yes
}
}

random_owned_controlled_state = {
limit = {
is_fully_controlled_by = ROOT
industrial_complex > 0
}
remove_building = {
type = industrial_complex
level = 1
}
add_building_construction = {
type = arms_factory
level = 1
instant_build = yes
}
}

random_owned_controlled_state = {
limit = {
is_fully_controlled_by = ROOT
industrial_complex > 0
}
remove_building = {
type = industrial_complex
level = 1
}
add_building_construction = {
type = arms_factory
level = 1
instant_build = yes
}
}

random_owned_controlled_state = {
limit = {
is_fully_controlled_by = ROOT
industrial_complex > 0
}
remove_building = {
type = industrial_complex
level = 1
}
add_building_construction = {
type = arms_factory
level = 1
instant_build = yes
}
}

random_owned_controlled_state = {
limit = {
is_fully_controlled_by = ROOT
industrial_complex > 0
}
remove_building = {
type = industrial_complex
level = 1
}
add_building_construction = {
type = arms_factory
level = 1
instant_build = yes
}
}
}

#Country scope
ROOT_inherit_current_scope_wars_effect = {
custom_effect_tooltip = ROOT_inherit_current_scope_wars_effect
hidden_effect = {
every_country = {
limit = {
has_defensive_war_with = PREV
}
ROOT = { declare_war_on = { target = PREV type = annex_everything
} }
}
every_country = {
limit = {
has_offensive_war_with = PREV
}
declare_war_on = { target = ROOT type = annex_everything }
}
}
}

# Add AI strategies in case of Central European Alliance


GER_democratic_nations_ai_strategies = {
# Reduce Contain against SOV
add_ai_strategy = {
type = contain
id = "SOV"
value = -800
}
add_ai_strategy = {
type = contain
id = "ITA"
value = -800
}
# Poland
add_ai_strategy = {
type = protect
id = "POL"
value = -200
}
add_ai_strategy = {
type = ignore
id = "POL"
value = 200
}
add_ai_strategy = {
type = befriend
id = "POL"
value = -200
}
add_ai_strategy = {
type = alliance
id = "POL"
value = -200
}
# Finland
add_ai_strategy = {
type = protect
id = "FIN"
value = -200
}
add_ai_strategy = {
type = ignore
id = "FIN"
value = 200
}
add_ai_strategy = {
type = befriend
id = "FIN"
value = -200
}
add_ai_strategy = {
type = alliance
id = "FIN"
value = -200
}
# Estonia
add_ai_strategy = {
type = protect
id = "EST"
value = -200
}
add_ai_strategy = {
type = ignore
id = "EST"
value = 200
}
add_ai_strategy = {
type = befriend
id = "EST"
value = -200
}
add_ai_strategy = {
type = alliance
id = "EST"
value = -200
}
# Latvia
add_ai_strategy = {
type = protect
id = "LAT"
value = -200
}
add_ai_strategy = {
type = ignore
id = "LAT"
value = 200
}
add_ai_strategy = {
type = befriend
id = "LAT"
value = -200
}
add_ai_strategy = {
type = alliance
id = "LAT"
value = -200
}
# Lithuania
add_ai_strategy = {
type = protect
id = "LIT"
value = -200
}
add_ai_strategy = {
type = ignore
id = "LIT"
value = 200
}
add_ai_strategy = {
type = befriend
id = "LIT"
value = -200
}
add_ai_strategy = {
type = alliance
id = "LIT"
value = -200
}
# Romania
add_ai_strategy = {
type = protect
id = "ROM"
value = -200
}
add_ai_strategy = {
type = ignore
id = "ROM"
value = 200
}
add_ai_strategy = {
type = befriend
id = "ROM"
value = -200
}
add_ai_strategy = {
type = alliance
id = "ROM"
value = -200
}
# Norway
add_ai_strategy = {
type = ignore
id = "NOR"
value = 200
}
add_ai_strategy = {
type = protect
id = "NOR"
value = -200
}
add_ai_strategy = {
type = befriend
id = "NOR"
value = -200
}
add_ai_strategy = {
type = alliance
id = "NOR"
value = -200
}
# Sweden
add_ai_strategy = {
type = ignore
id = "SWE"
value = 200
}
add_ai_strategy = {
type = protect
id = "SWE"
value = -200
}
add_ai_strategy = {
type = befriend
id = "SWE"
value = -200
}
add_ai_strategy = {
type = alliance
id = "SWE"
value = -200
}
# Denmark
add_ai_strategy = {
type = ignore
id = "DEN"
value = 200
}
add_ai_strategy = {
type = protect
id = "DEN"
value = -200
}
add_ai_strategy = {
type = befriend
id = "DEN"
value = -200
}
add_ai_strategy = {
type = alliance
id = "DEN"
value = -200
}
# Netherlands
add_ai_strategy = {
type = ignore
id = "HOL"
value = 200
}
add_ai_strategy = {
type = protect
id = "HOL"
value = -200
}
add_ai_strategy = {
type = befriend
id = "HOL"
value = -200
}
add_ai_strategy = {
type = alliance
id = "HOL"
value = -200
}
# Belgium
add_ai_strategy = {
type = ignore
id = "BEL"
value = 200
}
add_ai_strategy = {
type = protect
id = "BEL"
value = -200
}
add_ai_strategy = {
type = befriend
id = "BEL"
value = -200
}
add_ai_strategy = {
type = alliance
id = "BEL"
value = -200
}
# Luxemburg
add_ai_strategy = {
type = ignore
id = "LUX"
value = 200
}
add_ai_strategy = {
type = protect
id = "LUX"
value = -200
}
add_ai_strategy = {
type = befriend
id = "LUX"
value = -200
}
add_ai_strategy = {
type = alliance
id = "LUX"
value = -200
}
# Austria
add_ai_strategy = {
type = ignore
id = "AUS"
value = 200
}
add_ai_strategy = {
type = protect
id = "AUS"
value = -200
}
add_ai_strategy = {
type = befriend
id = "AUS"
value = -200
}
add_ai_strategy = {
type = alliance
id = "AUS"
value = -200
}
# Hungary
add_ai_strategy = {
type = ignore
id = "HUN"
value = 200
}
add_ai_strategy = {
type = protect
id = "HUN"
value = -200
}
add_ai_strategy = {
type = befriend
id = "HUN"
value = -200
}
add_ai_strategy = {
type = alliance
id = "HUN"
value = -200
}
# Czechoslovakia
add_ai_strategy = {
type = ignore
id = "CZE"
value = 200
}
add_ai_strategy = {
type = protect
id = "CZE"
value = -200
}
add_ai_strategy = {
type = befriend
id = "CZE"
value = -200
}
add_ai_strategy = {
type = alliance
id = "CZE"
value = -200
}
# Yugoslavia
add_ai_strategy = {
type = ignore
id = "YUG"
value = 200
}
add_ai_strategy = {
type = protect
id = "YUG"
value = -200
}
add_ai_strategy = {
type = befriend
id = "YUG"
value = -200
}
add_ai_strategy = {
type = alliance
id = "YUG"
value = -200
}
}

print_variable_log_effect = {
print_variables = {
file = variables_yug
append = yes
}
}

get_best_alliance_match_democratic_effect = { #arguably a trigger, but it does


stuff so we keep it in here. If this is your first time seeing this, welcome to my
personal hell.
if = {
limit = {
any_other_country = {
is_faction_leader = yes
is_major = yes
has_government = democratic
not = { has_war_with = ROOT }
set_temp_variable = { ROOT.best_leader = this }
set_temp_variable = { ROOT.best_leader_score = 0 }
}
}
}
if = {
limit = {
all_other_country = {
is_faction_leader = yes
is_major = yes
has_government = democratic
not = { has_war_with = ROOT }
set_temp_variable = { this.leader_score =
num_of_factories }
add_to_temp_variable = { this.leader_score = num_battalions
}
all_of_scopes = {
array = allies
add_to_temp_variable = { PREV.leader_score =
num_of_factories }
add_to_temp_variable = { PREV.leader_score =
num_battalions }
}
if = {
limit = {
capital_scope = {
is_on_continent = ROOT
}
}
multiply_temp_variable = { leader_score = 2 }
}
if = {
limit = {
any_neighbor_country = { tag = ROOT }
}
multiply_temp_variable = { leader_score = 1.25 }
}
if = {
limit = {
check_variable = { ROOT.best_leader_score <
leader_score }
set_temp_variable = { ROOT.best_leader = this }
set_temp_variable = { ROOT.best_leader_score =
leader_score }
}
}
}
}
}
}

get_best_alliance_match_fascism_effect = { #arguably a trigger, but it does stuff


so we keep it in here. If this is your first time seeing this, welcome to my
personal hell.
if = {
limit = {
any_other_country = {
is_faction_leader = yes
is_major = yes
has_government = fascism
not = { has_war_with = ROOT }
set_temp_variable = { ROOT.best_leader = this }
set_temp_variable = { ROOT.best_leader_score = 0 }
}
}
}
if = {
limit = {
all_other_country = {

is_faction_leader = yes
is_major = yes
has_government = fascism
not = { has_war_with = ROOT }

set_temp_variable = { this.leader_score =
num_of_factories }
add_to_temp_variable = { this.leader_score = num_battalions
}
all_of_scopes = {
array = allies
add_to_temp_variable = { PREV.leader_score =
num_of_factories }
add_to_temp_variable = { PREV.leader_score =
num_battalions }
}
if = {
limit = {
capital_scope = {
is_on_continent = ROOT
}
}
multiply_temp_variable = { this.leader_score = 2 }
}
if = {
limit = {
any_neighbor_country = { tag = ROOT }
}
multiply_temp_variable = { this.leader_score = 1.25 }
}
if = {
limit = {
check_variable = { ROOT.best_leader_score <
this.leader_score }
}
set_temp_variable = { ROOT.best_leader = this }
set_temp_variable = { ROOT.best_leader_score =
this.leader_score }
}
}
}
}
}

get_best_alliance_match_communism_effect = { #arguably a trigger, but it does stuff


so we keep it in here. If this is your first time seeing this, welcome to my
personal hell.
if = {
limit = {
any_other_country = {
is_faction_leader = yes
is_major = yes
has_government = communism
not = { has_war_with = ROOT }
set_temp_variable = { ROOT.best_leader = this }
set_temp_variable = { ROOT.best_leader_score = 0 }
}
}
}
if = {
limit = {
all_other_country = {
is_faction_leader = yes
is_major = yes
has_government = communism
not = { has_war_with = ROOT }
set_temp_variable = { this.leader_score =
num_of_factories }
add_to_temp_variable = { this.leader_score = num_battalions
}
all_of_scopes = {
array = allies
add_to_temp_variable = { PREV.leader_score =
num_of_factories }
add_to_temp_variable = { PREV.leader_score =
num_battalions }
}
if = {
limit = {
capital_scope = {
is_on_continent = ROOT
}
}
multiply_temp_variable = { leader_score = 2 }
}
if = {
limit = {
any_neighbor_country = { tag = ROOT }
}
multiply_temp_variable = { leader_score = 1.25 }
}
if = {
limit = {
check_variable = { ROOT.best_leader_score <
leader_score }
set_temp_variable = { ROOT.best_leader = this }
set_temp_variable = { ROOT.best_leader_score =
leader_score }
}
}
}
}
}
}

remove_naval_treaty_effect = {
if = {
limit = {
has_idea = MTG_naval_treaty_adherent
}
remove_ideas = MTG_naval_treaty_adherent
}
else_if = {
limit = {
has_idea = MTG_naval_treaty_cheating
}
remove_ideas = MTG_naval_treaty_cheating
}
else_if = {
limit = {
has_idea = MTG_naval_treaty_adherent_reduced
}
remove_ideas = MTG_naval_treaty_adherent_reduced
}
else_if = {
limit = {
has_idea = MTG_naval_treaty_cheating_reduced
}
remove_ideas = MTG_naval_treaty_cheating_reduced
}
set_country_flag = MTG_naval_treaty_abandoned
}

civil_war_anti_exploiter_punitive_action = {
# Anti-exploiter punitive brigades! BET YA DIDN'T SEE THAT COMING DID YA?!
if = {
limit = {
has_army_size = {
size < 1
}
}
division_template = {
name = "Anti-Exploit Punitive Brigade"
priority = 1
division_names_group = ENG_MAR_01
is_locked = yes
regiments = {
infantry = { x = 0 y = 0 }
infantry = { x = 0 y = 1 }
infantry = { x = 0 y = 2 }

infantry = { x = 1 y = 0 }
infantry = { x = 1 y = 1 }
infantry = { x = 1 y = 2 }

infantry = { x = 2 y = 0 }
artillery_brigade = { x = 2 y = 1 }
artillery_brigade = { x = 2 y = 2 }
}
support = {
engineer = { x = 0 y = 0 }
recon = { x = 0 y = 1 }
artillery = { x = 0 y = 2 }
}
}
random_state = {
limit = {
is_capital = yes
is_fully_controlled_by = PREV
}
create_unit = {
division = "division_template = \"Anti-Exploit Punitive
Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
owner = PREV
}
create_unit = {
division = "division_template = \"Anti-Exploit Punitive
Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
owner = PREV
}
create_unit = {
division = "division_template = \"Anti-Exploit Punitive
Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
owner = PREV
}
create_unit = {
division = "division_template = \"Anti-Exploit Punitive
Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
owner = PREV
}
}
random_state = {
limit = {
is_in_home_area = yes
is_fully_controlled_by = PREV
}
create_unit = {
division = "division_template = \"Anti-Exploit Punitive
Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
owner = PREV
}
create_unit = {
division = "division_template = \"Anti-Exploit Punitive
Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
owner = PREV
}
create_unit = {
division = "division_template = \"Anti-Exploit Punitive
Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
owner = PREV
}
create_unit = {
division = "division_template = \"Anti-Exploit Punitive
Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
owner = PREV
}
}
random_state = {
limit = {
is_in_home_area = yes
is_fully_controlled_by = PREV
}
create_unit = {
division = "division_template = \"Anti-Exploit Punitive
Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
owner = PREV
}
create_unit = {
division = "division_template = \"Anti-Exploit Punitive
Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
owner = PREV
}
create_unit = {
division = "division_template = \"Anti-Exploit Punitive
Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
owner = PREV
}
create_unit = {
division = "division_template = \"Anti-Exploit Punitive
Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
owner = PREV
}
}
random_state = {
limit = {
is_in_home_area = yes
is_fully_controlled_by = PREV
}
create_unit = {
division = "division_template = \"Anti-Exploit Punitive
Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
owner = PREV
}
create_unit = {
division = "division_template = \"Anti-Exploit Punitive
Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
owner = PREV
}
create_unit = {
division = "division_template = \"Anti-Exploit Punitive
Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
owner = PREV
}
create_unit = {
division = "division_template = \"Anti-Exploit Punitive
Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
owner = PREV
}
}
random_state = {
limit = {
is_in_home_area = yes
is_fully_controlled_by = PREV
}
create_unit = {
division = "division_template = \"Anti-Exploit Punitive
Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
owner = PREV
}
create_unit = {
division = "division_template = \"Anti-Exploit Punitive
Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
owner = PREV
}
create_unit = {
division = "division_template = \"Anti-Exploit Punitive
Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
owner = PREV
}
create_unit = {
division = "division_template = \"Anti-Exploit Punitive
Brigade\" start_experience_factor = 1 start_equipment_factor = 1"
owner = PREV
}
}
}
}

clear_sabotaged_resources_if_necesary = {
if = {
limit = {
not = {
has_dynamic_modifier = {
modifier = sabotaged_resources
}
}
}

clear_variable = sabotaged_oil
clear_variable = sabotaged_aluminium
clear_variable = sabotaged_rubber
clear_variable = sabotaged_tungsten
clear_variable = sabotaged_steel
clear_variable = sabotaged_chromium
}
}
remove_from_allowed_party = {
if = {
limit = { has_government = democratic }
set_temp_variable = { allowed_party_democratic = 0 }
}
else_if = {
limit = { has_government = fascism }
set_temp_variable = { allowed_party_fascism = 0 }
}
else_if = {
limit = { has_government = communism }
set_temp_variable = { allowed_party_communism = 0 }
}
else_if = {
limit = { has_government = neutrality }
set_temp_variable = { allowed_party_neutrality = 0 }
}
}

#expectes a temp variable country_to_initiate which should contain original_tag to


instantiate as a collabration government
instantiate_collaboration_government = {
custom_effect_tooltip = compliance_80_effect_tooltip
hidden_effect = {
set_variable = { collaboration_formed@var:country_to_initiate = 1 }

if = {
# if country_to_initiate does not exist, simply release it as a
puppet
limit = {
var:country_to_initiate = {
exists = no
}
}
var:country_to_initiate = { set_variable =
{ collaboration_formed_by = PREV } }
release_autonomy = {
target = country_to_initiate
autonomy_state = autonomy_collaboration_government
freedom_level = 0.5
release_non_owned_controlled = yes
}
}
else = {
# if country_to_initiate exists, create a dynamic country as our
new puppet

create_dynamic_country = {
original_tag = country_to_initiate

set_variable = { collaboration_formed_by = PREV }


set_temp_variable = { new_country = this }

PREV = {
every_controlled_state = {
limit = { occupied_country_tag =
country_to_initiate }

var:new_country = {
transfer_state = PREV
}
}

puppet = new_country

set_autonomy = {
target = new_country
autonomy_state =
autonomy_collaboration_government
freedom_level = 0.5
}
}
}
}
}
}

abandon_colony_tag = {
if = {
limit = {
is_subject = yes
}
if = {
limit = {
original_tag = CAN
}
if = {
limit = { NOT = { has_dlc = "Together for Victory" } }
set_cosmetic_tag = CAN_ALY
}
else = {
set_cosmetic_tag = CAN_UK
}
}
else_if = {
limit = {
original_tag = RAJ
}
set_cosmetic_tag = RAJ_UK
}
else_if = {
limit = {
original_tag = MAL
}
set_cosmetic_tag = MAL_UK
}
else_if = {
limit = {
original_tag = INS
}
set_cosmetic_tag = INS_HOL
}
}
else = {
if = {
limit = {
OR = {
has_cosmetic_tag = united_polynesia
has_cosmetic_tag = MAJ_UNIFIED
}
}
}
else = {
drop_cosmetic_tag = yes
}
}
}

on_daily = {

#on_daily_USA = {
# # you can specify an on daily action for a specific country
#}

You might also like