Counters are also powerful if you think you need to cut down on lag. You can remove the necessity of determining which faction the player is by some simple monitors to determine that at the campaign start. For instance:
Code:
monitor_event PreFactionTurnStart FactionIsLocal
and FactionType song
set_counter song_local_faction 1
set_counter jin_local_faction 0
set_counter goryeo_local_faction 0
set_counter khitans_local_faction 0
set_counter dali_local_faction 0
set_counter mongols_local_faction 0
set_counter khmer_local_faction 0
set_counter tibet_local_faction 0
set_counter daiviet_local_faction 0
set_counter xixia_local_faction 0
set_counter taira_local_faction 0
set_counter minamoto_local_faction 0
set_counter champa_local_faction 0
set_counter pagan_local_faction 0
set_counter ghurid_local_faction 0
terminate_monitor
end_monitor
This monitor will fire at the beginning and set a local faction counter. Then in future iterations where you need to check for the faction being local and being a specific faction, you can substitute the counter. This also helps nested if statements, because for if statements to work you need to use I_ conditions, as the exports of the event are not exported to the if. This script won't work as intended:
Code:
monitor_event FactionTurnStart FactionIsLocal
and I_CompareCounter exhaustion_kills_faction == 1
if FactionType song
give_everything_to_faction song slave true
end_if
end_monitor
Even though FactionTurnEnd exports faction so any "and" statements whose condition requires the faction will run, including FactionType among others, that export is not transferred to "if" statements. This is remedied by simply setting counters to act in place of the condition, like so:
Code:
;If player chooses Decline, set to Cultural
monitor_conditions I_EventCounter policy2_declined == 1
set_counter policy_timer 20
set_counter military_policy 0
set_counter economic_policy 0
set_counter cultural_policy 1
set_counter recovery_policy 0
set_counter current_policy 3
set_counter policy_change 1
inc_counter military_exhaustion_compiler -1
set_counter last_policy_delay 3
set_event_counter policy2_declined 0
historic_event cultural_policy
if I_CompareCounter song_local_faction == 1
destroy_buildings song hinterland_policy_effects false
end_if
if I_CompareCounter jin_local_faction == 1
destroy_buildings jin hinterland_policy_effects false
end_if
if I_CompareCounter goryeo_local_faction == 1
destroy_buildings goryeo hinterland_policy_effects false
end_if
if I_CompareCounter khitans_local_faction == 1
destroy_buildings khitans hinterland_policy_effects false
end_if
if I_CompareCounter dali_local_faction == 1
destroy_buildings dali hinterland_policy_effects false
end_if
if I_CompareCounter mongols_local_faction == 1
destroy_buildings mongols hinterland_policy_effects false
end_if
if I_CompareCounter khmer_local_faction == 1
destroy_buildings khmer hinterland_policy_effects false
end_if
if I_CompareCounter tibet_local_faction == 1
destroy_buildings tibet hinterland_policy_effects false
end_if
if I_CompareCounter daiviet_local_faction == 1
destroy_buildings daiviet hinterland_policy_effects false
end_if
if I_CompareCounter xixia_local_faction == 1
destroy_buildings xixia hinterland_policy_effects false
end_if
if I_CompareCounter taira_local_faction == 1
destroy_buildings taira hinterland_policy_effects false
end_if
if I_CompareCounter minamoto_local_faction == 1
destroy_buildings minamoto hinterland_policy_effects false
end_if
if I_CompareCounter champa_local_faction == 1
destroy_buildings champa hinterland_policy_effects false
end_if
if I_CompareCounter pagan_local_faction == 1
destroy_buildings pagan hinterland_policy_effects false
end_if
end_monitor