(
"total_victory", 0,
"You shouldn't be reading this... {s9}",
"none",
[
# We exploit the menu condition system below.
# The conditions should make sure that always another screen or menu is called.
(assign, ":break", 0),
(try_begin),
(eq, "$routed_party_added", 0), #new
(assign, "$routed_party_added", 1),
#add new party to map (routed_warriors)
(call_script, "script_add_routed_party"),
(end_try),
(try_begin),
(check_quest_active, "qst_track_down_bandits"),
(neg|check_quest_succeeded, "qst_track_down_bandits"),
(neg|check_quest_failed, "qst_track_down_bandits"),
(quest_get_slot, ":quest_party", "qst_track_down_bandits", slot_quest_target_party),
(party_is_active, ":quest_party"),
(party_get_attached_to, ":quest_party_attached"),
(this_or_next|eq, ":quest_party", "$g_enemy_party"),
(eq, ":quest_party_attached", "$g_enemy_party"),
(call_script, "script_succeed_quest", "qst_track_down_bandits"),
(try_end),
(try_begin),
(gt, "$g_private_battle_with_troop", 0),
(troop_slot_eq, "$g_private_battle_with_troop", slot_troop_leaded_party, "$g_encountered_party"),
(assign, "$g_private_battle_with_troop", 0),
##diplomacy start+
#g_disable_condescending_comments is also used to track the "enhanced/diminished prejudice" setting
(try_begin),
(eq, "$g_disable_condescending_comments", 0),
(assign, "$g_disable_condescending_comments", 1),
(else_try),
(eq, "$g_disable_condescending_comments", 2),
(assign, "$g_disable_condescending_comments", 3),
##diplomacy end+
(try_end),
(try_end),
#new - begin
(party_get_num_companion_stacks, ":num_stacks", "p_collective_enemy"),
(try_for_range, ":i_stack", 0, ":num_stacks"),
(party_stack_get_troop_id, ":stack_troop", "p_collective_enemy", ":i_stack"),
(is_between, ":stack_troop", lords_begin, lords_end),
(troop_is_wounded, ":stack_troop"),
(party_add_members, "p_total_enemy_casualties", ":stack_troop", 1),
(try_end),
#new - end
(try_begin),
# Talk to ally leader
(eq, "$thanked_by_ally_leader", 0),
(assign, "$thanked_by_ally_leader", 1),
(gt, "$g_ally_party", 0),
#(store_add, ":total_str_without_player", "$g_starting_strength_ally_party", "$g_starting_strength_enemy_party"),
(store_add, ":total_str_without_player", "$g_starting_strength_friends", "$g_starting_strength_enemy_party"),
(val_sub, ":total_str_without_player", "$g_starting_strength_main_party"),
(store_sub, ":ally_strength_without_player", "$g_starting_strength_friends", "$g_starting_strength_main_party"),
(store_mul, ":ally_advantage", ":ally_strength_without_player", 100),
(val_add, ":total_str_without_player", 1),
(val_div, ":ally_advantage", ":total_str_without_player"),
#Ally advantage=50 means battle was evenly matched
(store_sub, ":enemy_advantage", 100, ":ally_advantage"),
(store_mul, ":faction_reln_boost", ":enemy_advantage", "$g_starting_strength_enemy_party"),
(val_div, ":faction_reln_boost", 3000),
(val_min, ":faction_reln_boost", 4),
(store_mul, "$g_relation_boost", ":enemy_advantage", ":enemy_advantage"),
(val_div, "$g_relation_boost", 700),
(val_clamp, "$g_relation_boost", 0, 20),
(party_get_num_companion_stacks, ":num_ally_stacks", "$g_ally_party"),
(gt, ":num_ally_stacks", 0),
(store_faction_of_party, ":ally_faction","$g_ally_party"),
(call_script, "script_change_player_relation_with_faction", ":ally_faction", ":faction_reln_boost"),
(party_stack_get_troop_id, ":ally_leader", "$g_ally_party"),
(party_stack_get_troop_dna, ":ally_leader_dna", "$g_ally_party", 0),
(try_begin),
(troop_is_hero, ":ally_leader"),
(troop_get_slot, ":hero_relation", ":ally_leader", slot_troop_player_relation),
(assign, ":rel_boost", "$g_relation_boost"),
(try_begin),
(lt, ":hero_relation", -5),
(val_div, ":rel_boost", 3),
(try_end),
(call_script,"script_change_player_relation_with_troop", ":ally_leader", ":rel_boost"),
(try_end),
(assign, "$talk_context", tc_ally_thanks),
(call_script, "script_setup_troop_meeting", ":ally_leader", ":ally_leader_dna"),
(else_try),
# Talk to enemy leaders
(assign, ":break", 0),
(party_get_num_companion_stacks, ":num_stacks", "p_total_enemy_casualties"), #p_encountered changed to total_enemy_casualties
(try_for_range, ":stack_no", "$last_defeated_hero", ":num_stacks"), #May 31 bug note -- this now returns some heroes in victorious party as well as in the other party
(eq, ":break", 0),
(party_stack_get_troop_id, ":stack_troop", "p_total_enemy_casualties", ":stack_no"),
(party_stack_get_troop_dna, ":stack_troop_dna", "p_total_enemy_casualties", ":stack_no"),
(troop_is_hero, ":stack_troop"),
(store_troop_faction, ":defeated_faction", ":stack_troop"),
#steve post 0912 changes begin - removed, this is duplicated elsewhere in game menus
#(call_script, "script_add_log_entry", logent_lord_defeated_by_player, "trp_player", -1, ":stack_troop", ":defeated_faction"),
(try_begin),
(store_relation, ":relation", ":defeated_faction", "fac_player_faction"),
(ge, ":relation", 0),
(str_store_troop_name, s4, ":stack_troop"),
(try_begin),
(eq, "$cheat_mode", 1),
(display_message, "@{!}{s4} skipped in p_total_enemy_casualties capture queue because is friendly"),
(try_end),
(else_try),
(try_begin),
(party_stack_get_troop_id, ":party_leader", "$g_encountered_party", 0),
(is_between, ":party_leader", active_npcs_begin, active_npcs_end),
(troop_slot_eq, ":party_leader", slot_troop_occupation, slto_kingdom_hero),
(store_sub, ":kingdom_hero_id", ":party_leader", active_npcs_begin),
(get_achievement_stat, ":was_he_defeated_player_before", ACHIEVEMENT_BARON_GOT_BACK, ":kingdom_hero_id"),
(eq, ":was_he_defeated_player_before", 1),
(unlock_achievement, ACHIEVEMENT_BARON_GOT_BACK),
(try_end),
(store_add, "$last_defeated_hero", ":stack_no", 1),
(call_script, "script_remove_troop_from_prison", ":stack_troop"),
(troop_set_slot, ":stack_troop", slot_troop_leaded_party, -1),
(call_script, "script_cf_check_hero_can_escape_from_player", ":stack_troop"),
(str_store_troop_name, s1, ":stack_troop"),
(str_store_faction_name, s3, ":defeated_faction"),
(str_store_string, s17, "@{s1} of {s3} managed to escape."),
(display_log_message, "@{!}{s17}"),
(jump_to_menu, "mnu_enemy_slipped_away"),
(assign, ":break", 1),
(else_try),
(store_add, "$last_defeated_hero", ":stack_no", 1),
(call_script, "script_remove_troop_from_prison", ":stack_troop"),
(troop_set_slot, ":stack_troop", slot_troop_leaded_party, -1),
(assign, "$talk_context", tc_hero_defeated),
(call_script, "script_setup_troop_meeting", ":stack_troop", ":stack_troop_dna"),
(assign, ":break", 1),
(try_end),
(try_end),
(eq, ":break", 1),
(else_try),
# Talk to freed heroes
(assign, ":break", 0),
(party_get_num_prisoner_stacks, ":num_prisoner_stacks", "p_collective_enemy"),
(try_for_range, ":stack_no", "$last_freed_hero", ":num_prisoner_stacks"),
(eq, ":break", 0),
(party_prisoner_stack_get_troop_id, ":stack_troop", "p_collective_enemy", ":stack_no"),
(troop_is_hero, ":stack_troop"),
(party_prisoner_stack_get_troop_dna, ":stack_troop_dna", "p_collective_enemy", ":stack_no"),
(store_add, "$last_freed_hero", ":stack_no", 1),
(assign, "$talk_context", tc_hero_freed),
(call_script, "script_setup_troop_meeting", ":stack_troop", ":stack_troop_dna"),
(assign, ":break", 1),
(try_end),
(eq, ":break", 1),
(else_try),
(eq, "$capture_screen_shown", 0),
(assign, "$capture_screen_shown", 1),
(party_clear, "p_temp_party"),
(assign, "$g_move_heroes", 0),
#(call_script, "script_party_prisoners_add_party_companions", "p_temp_party", "p_collective_enemy"),
#p_total_enemy_casualties deki yarali askerler p_temp_party'e prisoner olarak eklenecek.
(call_script, "script_party_add_wounded_members_as_prisoners", "p_temp_party", "p_total_enemy_casualties"),
(call_script, "script_party_add_party_prisoners", "p_temp_party", "p_collective_enemy"),
(try_begin),
(call_script, "script_party_calculate_strength", "p_collective_friends_backup",0),
(assign,":total_initial_strength", reg(0)),
(gt, ":total_initial_strength", 0),
#(gt, "$g_ally_party", 0),
(call_script, "script_party_calculate_strength", "p_main_party_backup",0),
(assign,":player_party_initial_strength", reg(0)),
# move ally_party_initial_strength/(player_party_initial_strength + ally_party_initial_strength) prisoners to ally party.
# First we collect the share of prisoners of the ally party and distribute those among the allies.
(store_sub, ":ally_party_initial_strength", ":total_initial_strength", ":player_party_initial_strength"),
#(call_script, "script_party_calculate_strength", "p_ally_party_backup"),
#(assign,":ally_party_initial_strength", reg(0)),
#(store_add, ":total_initial_strength", ":player_party_initial_strength", ":ally_party_initial_strength"),
(store_mul, ":ally_share", ":ally_party_initial_strength", 1000),
(val_div, ":ally_share", ":total_initial_strength"),
(assign, "$pin_number", ":ally_share"), #we send this as a parameter to the script.
(party_clear, "p_temp_party_2"),
(call_script, "script_move_members_with_ratio", "p_temp_party", "p_temp_party_2"),
#TODO: This doesn't handle prisoners if our allies joined battle after us.
(try_begin),
(gt, "$g_ally_party", 0),
(distribute_party_among_party_group, "p_temp_party_2", "$g_ally_party"),
(try_end),
#next if there's anything left, we'll open up the party exchange screen and offer them to the player.
(try_end),
(party_get_num_companions, ":num_rescued_prisoners", "p_temp_party"),
(party_get_num_prisoners, ":num_captured_enemies", "p_temp_party"),
(store_add, ":total_capture_size", ":num_rescued_prisoners", ":num_captured_enemies"),
(gt, ":total_capture_size", 0),
(change_screen_exchange_with_party, "p_temp_party"),
(else_try),
(eq, "$loot_screen_shown", 0),
(assign, "$loot_screen_shown", 1),
# (try_begin),
# (gt, "$g_ally_party", 0),
# (call_script, "script_party_add_party", "$g_ally_party", "p_temp_party"), #Add remaining prisoners to ally TODO: FIX it.
# (else_try),
# (party_get_num_attached_parties, ":num_quick_attachments", "p_main_party"),
# (gt, ":num_quick_attachments", 0),
# (party_get_attached_party_with_rank, ":helper_party", "p_main_party", 0),
# (call_script, "script_party_add_party", ":helper_party", "p_temp_party"), #Add remaining prisoners to our reinforcements
# (try_end),
(troop_clear_inventory, "trp_temp_troop"),
(call_script, "script_party_calculate_loot", "p_total_enemy_casualties"), #p_encountered_party_backup changed to total_enemy_casualties
(gt, reg0, 0),
(troop_sort_inventory, "trp_temp_troop"),
##diplomacy start+
#Here: we jump to rubik's autoloot from CC if applicable instead of using the standard loot screen
(try_begin),
(call_script, "script_cf_dplmc_player_party_meets_autoloot_conditions"),
(assign, "$dplmc_return_menu", "mnu_total_victory"),
(jump_to_menu, "mnu_dplmc_manage_loot_pool"),
(else_try),
#Old behavior:
(change_screen_loot, "trp_temp_troop"),
(try_end),
##diplomacy end+
(else_try),
#finished all
(try_begin),
(le, "$g_ally_party", 0),
(end_current_battle),
(try_end),
(call_script, "script_party_give_xp_and_gold", "p_total_enemy_casualties"), #p_encountered_party_backup changed to total_enemy_casualties
(try_begin),
(eq, "$g_enemy_party", 0),
(display_message,"str_error_string"),
(try_end),
(try_begin),
(party_is_active, "$g_ally_party"),
(call_script, "script_battle_political_consequences", "$g_enemy_party", "$g_ally_party"),
(else_try),
(call_script, "script_battle_political_consequences", "$g_enemy_party", "p_main_party"),
(try_end),
(call_script, "script_event_player_defeated_enemy_party", "$g_enemy_party"),
(call_script, "script_clear_party_group", "$g_enemy_party"),
(try_begin),
(eq, "$g_next_menu", -1),
#NPC companion changes begin
(call_script, "script_post_battle_personality_clash_check"),
#NPC companion changes end
#Post 0907 changes begin
(party_stack_get_troop_id, ":enemy_leader", "p_encountered_party_backup",0),
(try_begin),
(is_between, ":enemy_leader", active_npcs_begin, active_npcs_end),
(neg|is_between, "$g_encountered_party", centers_begin, centers_end),
(store_troop_faction, ":enemy_leader_faction", ":enemy_leader"),
(try_begin),
(eq, "$g_ally_party", 0),
(call_script, "script_add_log_entry", logent_lord_defeated_by_player, "trp_player", -1, ":enemy_leader", ":enemy_leader_faction"),
(try_begin),
(eq, "$cheat_mode", 1),
(display_message, "@{!}Victory comment. Player was alone"),
(try_end),
(else_try),
(ge, "$g_strength_contribution_of_player", 40),
(call_script, "script_add_log_entry", logent_lord_defeated_by_player, "trp_player", -1, ":enemy_leader", ":enemy_leader_faction"),
(try_begin),
(eq, "$cheat_mode", 1),
(display_message, "@{!}Ordinary victory comment. The player provided at least 40 percent forces."),
(try_end),
(else_try),
(gt, "$g_starting_strength_enemy_party", 1000),
(call_script, "script_get_closest_center", "p_main_party"),
(assign, ":battle_of_where", reg0),
(call_script, "script_add_log_entry", logent_player_participated_in_major_battle, "trp_player", ":battle_of_where", -1, ":enemy_leader_faction"),
(try_begin),
(eq, "$cheat_mode", 1),
(display_message, "@{!}Player participation comment. The enemy had at least 1k starting strength."),
(try_end),
(else_try),
(eq, "$cheat_mode", 1),
(display_message, "@{!}No victory comment. The battle was small, and the player provided less than 40 percent of allied strength"),
(try_end),
(try_end),
#Post 0907 changes end
(val_add, "$g_total_victories", 1),
(leave_encounter),
(change_screen_return),
(else_try),
(try_begin), #my kingdom
##diplomacy begin
(eq, "$g_next_menu", "mnu_dplmc_town_riot_removed"),
(jump_to_menu, "$g_next_menu"),
(else_try),
##diplomacy end
#(change_screen_return),
(eq, "$g_next_menu", "mnu_castle_taken"),
(call_script, "script_add_log_entry", logent_castle_captured_by_player, "trp_player", "$g_encountered_party", -1, "$g_encountered_party_faction"),
(store_current_hours, ":hours"),
(faction_set_slot, "$players_kingdom", slot_faction_ai_last_decisive_event, ":hours"),
(try_begin), #player took a walled center while he is a vassal of npc kingdom.
##diplomacy start+ Handle player is co-ruler of NPC faction
(assign, ":is_coruler", 0),
(is_between, "$players_kingdom", npc_kingdoms_begin, npc_kingdoms_end),
(call_script, "script_dplmc_get_troop_standing_in_faction", "trp_player", "$players_kingdom"),
(ge, reg0, DPLMC_FACTION_STANDING_LEADER_SPOUSE),
(assign, ":is_coruler", 1),
(assign, "$g_center_taken_by_player_faction", "$g_encountered_party"),
(faction_get_slot, ":faction_leader", "fac_player_supporters_faction", slot_faction_leader),
(try_begin),
(eq, ":faction_leader", "trp_player"),
(assign, ":faction_leader", heroes_end),
(try_for_range, ":troop_no", heroes_begin, ":faction_leader"),
(this_or_next|troop_slot_eq, slot_troop_spouse, "trp_player"),
(troop_slot_eq, "trp_player", slot_troop_spouse, ":troop_no"),
(neg|troop_slot_ge, ":faction_leader", slot_troop_prisoner_of_party, 0),#Not a prisoner
(neg|troop_slot_ge, ":faction_leader", slot_troop_occupation, slto_retirement),#Not retired, exiled, dead
(assign, ":faction_leader", ":troop_no"),#assign and break the loop
(try_end),
(try_end),
(is_between, ":faction_leader", heroes_begin, heroes_end),#Not the player, and not a bogus value
(neg|troop_slot_ge, ":faction_leader", slot_troop_prisoner_of_party, 0),#Not a prisoner
(neg|troop_slot_ge, ":faction_leader", slot_troop_occupation, slto_retirement),#Not retired, exiled, dead
(change_screen_return),
(start_map_conversation, ":faction_leader", -1),
(else_try),
#player took a walled center while he is a vassal of npc kingdom.
(neq, ":is_coruler", 1),
##diplomacy end+
(is_between, "$players_kingdom", npc_kingdoms_begin, npc_kingdoms_end),
(jump_to_menu, "$g_next_menu"),
(else_try), #player took a walled center while he is a vassal of rebels.
(eq, "$players_kingdom", "fac_player_supporters_faction"),
(assign, "$g_center_taken_by_player_faction", "$g_encountered_party"),
(neg|faction_slot_eq, "fac_player_supporters_faction", slot_faction_leader, "trp_player"),
(faction_get_slot, ":faction_leader", "fac_player_supporters_faction", slot_faction_leader),
(change_screen_return),
(start_map_conversation, ":faction_leader", -1),
(else_try), #player took a walled center for player's kingdom
##diplomacy start+ Handle player is co-ruler of faction
(this_or_next|eq, ":is_coruler", 1),
##diplomacy end+
(neg|is_between, "$players_kingdom", npc_kingdoms_begin, npc_kingdoms_end),
(assign, "$g_center_taken_by_player_faction", "$g_encountered_party"),
(assign, "$talk_context", tc_give_center_to_fief),
(change_screen_return),
(assign, ":best_troop", "trp_swadian_sharpshooter"),
##diplomacy start+
#Trivial aesthetic change, change the default troop to be appropriate to the
#culture of the player kingdom (instead of defaulting always to a Swadian troop).
(assign, ":players_culture", "$players_kingdom"),
(try_begin),
#If not the co-ruler of an NPC kingdom, use the player faction culture.
(neg|is_between, "$players_kingdom", npc_kingdoms_begin, npc_kingdoms_end),
(assign, ":best_troop", "trp_mercenary_crossbowman"),#<- while we're at it, use a mercenary default
(assign, ":players_culture", "$g_player_culture"),
(this_or_next|is_between, ":players_culture", npc_kingdoms_begin, npc_kingdoms_end),
(is_between, ":players_culture", cultures_begin, cultures_end),
(else_try),
#If not the co-ruler of an NPC kingdom, and there wasn't a valid player faction
#culture, try to use the faction of the player's court.
(neg|is_between, "$players_kingdom", npc_kingdoms_begin, npc_kingdoms_end),
(is_between, "$g_player_court", centers_begin, centers_end),
(party_slot_ge, "$g_player_court", slot_center_original_faction, 1),
(party_get_slot, ":players_culture", "$g_player_court", slot_center_original_faction),
(try_end),
(try_begin),
#Resolve from kingdom to culture if necessary
(is_between, ":players_culture", kingdoms_begin, kingdoms_end),
(faction_get_slot, ":players_culture", ":players_culture", slot_faction_culture),
(try_end),
(try_begin),
#If the final result is a culture, get the best troop if valid
(is_between, ":players_culture", cultures_begin, cultures_end),
(neq, ":players_culture", "fac_culture_1"),
(faction_get_slot, reg0, ":players_culture", slot_faction_guard_troop),
(ge, reg0, soldiers_begin),
(assign, ":best_troop", reg0),
(try_end),
##diplomacy end+
(assign, ":maximum_troop_score", 0),
(party_get_num_companion_stacks, ":num_stacks", "p_main_party"),
(try_for_range, ":stack_no", 0, ":num_stacks"),
(party_stack_get_troop_id, ":stack_troop", "p_main_party", ":stack_no"),
(neq, ":stack_troop", "trp_player"),
(party_stack_get_size, ":stack_size", "p_main_party", ":stack_no"),
(party_stack_get_num_wounded, ":num_wounded", "p_main_party", ":stack_no"),
(troop_get_slot, ":num_routed", "p_main_party", slot_troop_player_routed_agents),
(assign, ":continue", 0),
(try_begin),
(neg|troop_is_hero, ":stack_troop"),
(store_add, ":agents_which_cannot_speak", ":num_wounded", ":num_routed"),
(gt, ":stack_size", ":agents_which_cannot_speak"),
(assign, ":continue", 1),
(else_try),
(troop_is_hero, ":stack_troop"),
(neg|troop_is_wounded, ":stack_troop"),
(assign, ":continue", 1),
(try_end),
(eq, ":continue", 1),
(try_begin),
(troop_is_hero, ":stack_troop"),
(troop_get_slot, ":troop_renown", ":stack_troop", slot_troop_renown),
(store_mul, ":troop_score", ":troop_renown", 100),
(val_add, ":troop_score", 1000),
(else_try),
(store_character_level, ":troop_level", ":stack_troop"),
(assign, ":troop_score", ":troop_level"),
(try_end),
(try_begin),
(gt, ":troop_score", ":maximum_troop_score"),
(assign, ":maximum_troop_score", ":troop_score"),
(assign, ":best_troop", ":stack_troop"),
(party_stack_get_troop_dna, ":best_troop_dna", "p_main_party", ":stack_no"),
(try_end),
(try_end),
(start_map_conversation, ":best_troop", ":best_troop_dna"),
(try_end),
(try_end),
(try_end),
(try_end),
],
[
("continue",[],"Continue...",[]),
]
),