#SoD INVASION BEGIN
####################################################################################################################################
(24,
[
(store_current_day, ":cur_day"),
(store_random_in_range, ":village_no", "p_castle_23", "p_town_6"),
(eq, ":cur_day", 3),
#CHEAT TEST REMOVE ME
## (call_script, "script_change_troop_renown", "trp_player", 20000),
## (try_for_range, ":troop_new", "trp_ief_velites", "trp_ief_deserter"),
## (party_add_members, "p_main_party", ":troop_new", 10),
## (try_end),
#CHEAT TEST REMOVE ME
(troop_set_faction, "trp_kingdom_7_lord", "fac_kingdom_7"),
(faction_set_slot, "fac_kingdom_7", slot_faction_state, sfs_active),
(call_script, "script_create_kingdom_hero_party", "trp_kingdom_7_lord", ":village_no"),
(party_add_members, "trp_kingdom_7_lord", "trp_georian_muszkieter", 100),
# (call_script, "script_create_kingdom_hero_party", "trp_knight_7_1", ":village_no"),
# (call_script, "script_create_kingdom_hero_party", "trp_knight_7_2", ":village_no"),
# (call_script, "script_create_kingdom_hero_party", "trp_knight_7_3", ":village_no"),
# (call_script, "script_create_kingdom_hero_party", "trp_knight_7_4", ":village_no"),
# (call_script, "script_create_kingdom_hero_party", "trp_knight_7_5", ":village_no"),
# (call_script, "script_create_kingdom_hero_party", "trp_knight_7_6", ":village_no"),
# (call_script, "script_create_kingdom_hero_party", "trp_knight_7_7", ":village_no"),
# (call_script, "script_create_kingdom_hero_party", "trp_knight_7_8", ":village_no"),
(troop_set_slot, "trp_kingdom_7_lord", slot_troop_wealth, 100000),
(call_script, "script_diplomacy_start_war_between_kingdoms", "fac_kingdom_7", "fac_kingdom_1", 1),
(call_script, "script_diplomacy_start_war_between_kingdoms", "fac_kingdom_7", "fac_kingdom_2", 1),
(call_script, "script_diplomacy_start_war_between_kingdoms", "fac_kingdom_7", "fac_kingdom_3", 1),
(call_script, "script_diplomacy_start_war_between_kingdoms", "fac_kingdom_7", "fac_kingdom_4", 1),
(call_script, "script_diplomacy_start_war_between_kingdoms", "fac_kingdom_7", "fac_kingdom_5", 1),
(call_script, "script_diplomacy_start_war_between_kingdoms", "fac_kingdom_7", "fac_kingdom_6", 1),
(try_for_range, ":troop_no", "trp_knight_7_1", "trp_kingdom_1_pretender"),
(troop_slot_eq, ":troop_no", slot_troop_occupation, slto_kingdom_hero),
#(troop_slot_eq, ":troop_no", slot_troop_is_prisoner, 0),
(neg|troop_slot_ge, ":troop_no", slot_troop_prisoner_of_party, 0),
(neg|troop_slot_ge, ":troop_no", slot_troop_leaded_party, 1),
(call_script, "script_create_kingdom_hero_party", ":troop_no", ":village_no"),
(troop_set_slot, ":troop_no", slot_troop_wealth, 40000),
(try_end),
# (jump_to_menu, "mnu_dk_invasion_start_warning"),
]),
#(24,
# [
# (store_current_day, ":cur_day"),
# (eq, ":cur_day", 4),
####################################################################################################################################
#SoD INVASION END
####################################################################################################################################
# Check if a faction is defeated every day
####################################################################################################################################
# Check if a faction is defeated every day
(24,
[
(assign, ":num_active_factions", 0),
(try_for_range, ":cur_kingdom", kingdoms_begin, "fac_kingdoms_end"),
(faction_set_slot, ":cur_kingdom", slot_faction_number_of_parties, 0),
(try_end),
(try_for_parties, ":cur_party"),
(store_faction_of_party, ":party_faction", ":cur_party"),
(is_between, ":party_faction", kingdoms_begin, "fac_kingdoms_end"),
(this_or_next|is_between, ":cur_party", centers_begin, centers_end),
(party_slot_eq, ":cur_party", slot_party_type, spt_kingdom_hero_party),
(faction_get_slot, ":kingdom_num_parties", ":party_faction", slot_faction_number_of_parties),
(val_add, ":kingdom_num_parties", 1),
(faction_set_slot, ":party_faction", slot_faction_number_of_parties, ":kingdom_num_parties"),
(try_end),
(try_for_range, ":cur_kingdom", kingdoms_begin, "fac_kingdoms_end"),
## (try_begin),
## (eq, "$cheat_mode", 1),
## (str_store_faction_name, s1, ":cur_kingdom"),
## (faction_get_slot, reg1, ":cur_kingdom", slot_faction_number_of_parties),
## (display_message, "@Number of parties belonging to {s1}: {reg1}"),
## (try_end),
(faction_slot_eq, ":cur_kingdom", slot_faction_state, sfs_active),
(val_add, ":num_active_factions", 1),
(faction_slot_eq, ":cur_kingdom", slot_faction_number_of_parties, 0),
(assign, ":faction_removed", 0),
(try_begin),
(eq, ":cur_kingdom", "fac_player_supporters_faction"),
(try_begin),
(le, "$supported_pretender", 0),
(faction_set_slot, ":cur_kingdom", slot_faction_state, sfs_inactive),
(assign, ":faction_removed", 1),
(try_end),
(else_try),
(neq, "$players_kingdom", ":cur_kingdom"),
(faction_set_slot, ":cur_kingdom", slot_faction_state, sfs_defeated),
(try_for_parties, ":cur_party"),
(store_faction_of_party, ":party_faction", ":cur_party"),
(eq, ":party_faction", ":cur_kingdom"),
(party_get_slot, ":home_center", ":cur_party", slot_party_home_center),
(store_faction_of_party, ":home_center_faction", ":home_center"),
(party_set_faction, ":cur_party", ":home_center_faction"),
(try_end),
(assign, ":kingdom_pretender", -1),
(try_for_range, ":cur_pretender", pretenders_begin, pretenders_end),
(troop_slot_eq, ":cur_pretender", slot_troop_original_faction, ":cur_kingdom"),
(assign, ":kingdom_pretender", ":cur_pretender"),
(try_end),
(try_begin),
(is_between, ":kingdom_pretender", pretenders_begin, pretenders_end),
(neq, ":kingdom_pretender", "$supported_pretender"),
(troop_set_slot, ":kingdom_pretender", slot_troop_cur_center, 0), #remove pretender from the world
(try_end),
(assign, ":faction_removed", 1),
(try_begin),
(eq, "$players_oath_renounced_against_kingdom", ":cur_kingdom"),
(assign, "$players_oath_renounced_against_kingdom", 0),
(assign, "$players_oath_renounced_given_center", 0),
(assign, "$players_oath_renounced_begin_time", 0),
(call_script, "script_add_notification_menu", "mnu_notification_oath_renounced_faction_defeated", ":cur_kingdom", 0),
(try_end),
#This menu must be at the end because faction banner will change after this menu if the player's supported pretender's original faction is cur_kingdom
(call_script, "script_add_notification_menu", "mnu_notification_faction_defeated", ":cur_kingdom", 0),
(try_end),
(try_begin),
(eq, ":faction_removed", 1),
(val_sub, ":num_active_factions", 1),
#(call_script, "script_store_average_center_value_per_faction"),
(try_end),
(try_for_range, ":cur_kingdom_2", kingdoms_begin, "fac_kingdoms_end"),
(call_script, "script_update_faction_notes", ":cur_kingdom_2"),
(try_end),
(try_end),
(try_begin),
(eq, ":num_active_factions", 1),
(try_for_range, ":cur_kingdom", kingdoms_begin, "fac_kingdoms_end"),
(faction_slot_eq, ":cur_kingdom", slot_faction_state, sfs_active),
(call_script, "script_add_notification_menu", "mnu_notification_one_faction_left", ":cur_kingdom", 0),
(try_end),
(try_end),
]),
####################################################################################################################################