TL;DR| how do I make a refugee from a pop with a specific flag?
As the title says, I've tagged pops with a flag. Through an event, I want to make them refugees. However, with the current code I created, the game crashes, BUT only under a specific circumstance:
is it mayve the refugee effect that I should edit or is something else not correct in here?
As the title says, I've tagged pops with a flag. Through an event, I want to make them refugees. However, with the current code I created, the game crashes, BUT only under a specific circumstance:
- if there is NO pop present which is NOT the same as the founder species, and that non-founder species pop has the flag --> no crash
- if there is a pop present which is NOT the same as the founder species, and that non-founder species pop has the flag --> crash
Code:
#xenophobe being xenophobe
country_event = {
id = wagho_event.182
title = wagho_event.182.name
(...)
option = { #bio
name = wagho_event.182.0
custom_tooltip = wagho_event.182.tooltip
trigger = {
OR = {
has_ethic = ethic_fanatic_xenophobe
has_ethic = ethic_xenophobe
}
}
hidden_effect = {
event_target:wagho_riot_planet = {
while = {
limit = {
any_owned_pop = {
has_pop_flag = wagho_event_pop_infected
wagho_event_trigger_is_immune = no
NOT = { is_same_species = owner.species }
}
}
random_owned_pop = {
limit = {
has_pop_flag = wagho_event_pop_infected
NOT = { is_same_species = owner.species }
}
if = {
limit = { is_valid_refugee_pop = yes }
save_event_target_as = refugee_pop #Must be saved for refugee_pop_effect to work
refugee_pop_effect = yes
root = {
add_event_chain_counter = {
event_chain = wagho_event_count
counter = wagho_event_infected_pop_count
amount = -1
}
}
root = {
subtract_variable = {
which = wagho_report_infected
value = 1
}
}
}
else = {
kill_pop = yes
root = {
add_event_chain_counter = {
event_chain = wagho_event_count
counter = wagho_event_killed_pop_count
amount = 1
}
add_event_chain_counter = {
event_chain = wagho_event_count
counter = wagho_event_infected_pop_count
amount = -1
}
}
root = {
change_variable = {
which = wagho_report_killed
value = 1
}
subtract_variable = {
which = wagho_report_infected
value = 1
}
}