("battle_debrief",mnf_scale_picture|mnf_disable_all_keys,
"{s11}^^Your Casualties:{s8}{s10}^^Enemy Casualties:{s9}^^Kill count:{s12}",
"none",
[
#TOM
#### battlesize?
#### battlesize?
#### shaders
# (set_fixed_point_multiplier, 100),
# (set_shader_param_float, "@vFresnelMultiplier", shader_float_default),
#### shaders
#copy backup to main party
(try_begin),
(eq, "$auxilary_player_active", 1),
###new method, adjust the main party, by the manualy counted one
##adjust the party to pre battle
(party_get_num_companion_stacks, ":stack_num", "p_temp_casualties_3"),
(try_for_range, ":stack_no", 0, ":stack_num"),
(party_stack_get_troop_id, ":stack_troop", "p_temp_casualties_3", ":stack_no"),
(neq, ":stack_troop", "trp_player"), #player does not count
(neg|troop_is_hero, ":stack_troop"), #heroes either
(party_count_members_of_type, ":main_troop_count", "p_main_party", ":stack_troop"), #get number of troops from main
(party_count_members_of_type, ":sub_troop_count", "p_temp_casualties_3", ":stack_troop"), #get number of troops from sub
(try_begin),
(gt, ":sub_troop_count", ":main_troop_count"), #sub party has more members
(store_sub, ":amount", ":sub_troop_count", ":main_troop_count"), #calculate number of troops to adjust
(party_add_members, "p_main_party", ":stack_troop", ":amount"), #adjust number of troops in the main party
(else_try),
(lt, ":sub_troop_count", ":main_troop_count"), #sub party has less members
(store_sub, ":amount", ":main_troop_count", ":sub_troop_count"), #calculate number of troops to adjust
(party_remove_members, "p_main_party", ":stack_troop", ":amount"), #adjust number of troops in the main party
(try_end),
#wound the members, only if there are less wounded in the main party
(party_stack_get_num_wounded, ":num_wounded_sub", "p_temp_casualties_3", ":stack_no"),
(party_stack_get_num_wounded, ":num_wounded_main", "p_main_party", ":stack_no"),
(try_begin),
(gt, ":num_wounded_sub", ":num_wounded_main"), #sub has more wounded
(store_sub, ":amount", ":num_wounded_sub", ":num_wounded_main"), #calculate number of troops to wound
(party_wound_members, "p_main_party", ":stack_troop", ":amount"),
(try_end),
(try_end),
##adjust the party based on the casualties sustained on the battlefield
(party_get_num_companion_stacks, ":num_stacks", "p_player_casualties"),
(try_for_range, ":stack_no", 0, ":num_stacks"),
(party_stack_get_troop_id, ":stack_troop", "p_player_casualties", ":stack_no"),
(neq, ":stack_troop", "trp_player"), #player does not count
(neg|troop_is_hero, ":stack_troop"), #heroes either
(party_stack_get_size, ":stack_size", "p_player_casualties", ":stack_no"),
(party_stack_get_num_wounded, ":num_wounded", "p_player_casualties", ":stack_no"),
(val_sub, ":stack_size", ":num_wounded"),
(party_remove_members, "p_main_party", ":stack_troop", ":stack_size"),
(party_wound_members, "p_main_party", ":stack_troop", ":num_wounded"),
(try_end),
(party_clear, "p_temp_casualties_3"),
(assign, "$auxilary_player_active", 0),
(try_end),
#TOM
# (assign, "$g_battle_preparation_phase", 0),
# (assign, "$g_battle_preparation", -1),
(try_begin),
(eq, "$g_battle_result", 1),
(call_script, "script_change_troop_renown", "trp_player", "$battle_renown_value"),
(try_begin),
(ge, "$g_encountered_party", 0),
(party_is_active, "$g_encountered_party"),
(party_get_template_id, ":encountered_party_template", "$g_encountered_party"),
(eq, ":encountered_party_template", "pt_kingdom_caravan_party"),
(get_achievement_stat, ":number_of_village_raids", ACHIEVEMENT_THE_BANDIT, 0),
(get_achievement_stat, ":number_of_caravan_raids", ACHIEVEMENT_THE_BANDIT, 1),
(val_add, ":number_of_caravan_raids", 1),
(set_achievement_stat, ACHIEVEMENT_THE_BANDIT, 1, ":number_of_caravan_raids"),
(try_begin),
(ge, ":number_of_village_raids", 3),
(ge, ":number_of_caravan_raids", 3),
(unlock_achievement, ACHIEVEMENT_THE_BANDIT),
(try_end),
(try_end),
(try_begin),
(party_get_current_terrain, ":cur_terrain", "p_main_party"),
(eq, ":cur_terrain", rt_snow),
(get_achievement_stat, ":number_of_victories_at_snowy_lands", ACHIEVEMENT_BEST_SERVED_COLD, 0),
(val_add, ":number_of_victories_at_snowy_lands", 1),
(set_achievement_stat, ACHIEVEMENT_BEST_SERVED_COLD, 0, ":number_of_victories_at_snowy_lands"),
(try_begin),
(eq, ":number_of_victories_at_snowy_lands", 10),
(unlock_achievement, ACHIEVEMENT_BEST_SERVED_COLD),
(try_end),
(try_end),
(try_begin),
(ge, "$g_enemy_party", 0),
(party_is_active, "$g_enemy_party"),
(party_stack_get_troop_id, ":stack_troop", "$g_enemy_party", 0),
(eq, ":stack_troop", "trp_mountain_bandit"),
(get_achievement_stat, ":number_of_victories_aganist_mountain_bandits", ACHIEVEMENT_MOUNTAIN_BLADE, 0),
(val_add, ":number_of_victories_aganist_mountain_bandits", 1),
(set_achievement_stat, ACHIEVEMENT_MOUNTAIN_BLADE, 0, ":number_of_victories_aganist_mountain_bandits"),
(try_begin),
(eq, ":number_of_victories_aganist_mountain_bandits", 10),
(unlock_achievement, ACHIEVEMENT_MOUNTAIN_BLADE),
(try_end),
(try_end),
(try_begin),
(is_between, "$g_ally_party", walled_centers_begin, walled_centers_end),
(unlock_achievement, ACHIEVEMENT_NONE_SHALL_PASS),
(try_end),
(try_begin),
(eq, "$g_joined_battle_to_help", 1),
(unlock_achievement, ACHIEVEMENT_GOOD_SAMARITAN),
(try_end),
(try_end),
(assign, "$g_joined_battle_to_help", 0),
(call_script, "script_count_casualties_and_adjust_morale"),#new
(call_script, "script_encounter_calculate_fit"),
(call_script, "script_party_count_fit_regulars", "p_main_party"),
(assign, "$playerparty_postbattle_regulars", reg0),
(try_begin),
(eq, "$g_battle_result", 1),
(eq, "$g_enemy_fit_for_battle", 0),
(str_store_string, s11, "
@You were victorious!"),
# (play_track, "track_bogus"), #clear current track.
# (call_script, "script_music_set_situation_with_culture", mtf_sit_victorious),
(try_begin),
(gt, "$g_friend_fit_for_battle", 1),
(set_background_mesh, "mesh_pic_victory"),
(try_end),
(else_try),
(eq, "$g_battle_result", -1),
(ge, "$g_enemy_fit_for_battle",1),
(this_or_next|le, "$g_friend_fit_for_battle",0),
(le, "$playerparty_postbattle_regulars", 0),
(str_store_string, s11, "@Battle was lost. Your forces were utterly crushed."),
(set_background_mesh, "mesh_pic_defeat"),
(else_try),
(eq, "$g_battle_result", -1),
(str_store_string, s11, "@Your companions carry you away from the fighting."),
(troop_get_type, ":is_female", "trp_player"),
(try_begin),
(eq, ":is_female", 1),
(set_background_mesh, "mesh_pic_wounded_fem"),
(else_try),
(set_background_mesh, "mesh_pic_wounded"),
(try_end),
(else_try),
(eq, "$g_battle_result", 1),
(str_store_string, s11, "
@You have defeated the enemy."),
(try_begin),
(gt, "$g_friend_fit_for_battle", 1),
(set_background_mesh, "mesh_pic_victory"),
(try_end),
(else_try),
(eq, "$g_battle_result", 0),
(str_store_string, s11, "
@You have retreated from the fight."),
(try_end),
#NPC companion changes begin
##check for excessive casualties, more forgiving if battle result is good
(try_begin),
(gt, "$playerparty_prebattle_regulars", 9),
(store_add, ":divisor", 3, "$g_battle_result"),
(store_div, ":half_of_prebattle_regulars", "$playerparty_prebattle_regulars", ":divisor"),
(lt, "$playerparty_postbattle_regulars", ":half_of_prebattle_regulars"),
(call_script, "script_objectionable_action", tmt_egalitarian, "str_excessive_casualties"),
(try_end),
#NPC companion changes end
(call_script, "script_print_casualties_to_s0", "p_player_casualties", 0),
(str_store_string_reg, s8, s0),
(call_script, "script_print_casualties_to_s0", "p_enemy_casualties", 0),
(str_store_string_reg, s9, s0),
(call_script, "script_print_kill_count_to_s0"),
(str_store_string_reg, s12, s0),
(str_clear, s10),
(try_begin),
(eq, "$any_allies_at_the_last_battle", 1),
(call_script, "script_print_casualties_to_s0", "p_ally_casualties", 0),
(str_store_string, s10, "@^^Ally Casualties:{s0}"),
(try_end),
(try_begin),
(assign,reg20, "$killcount"),
(assign, "$killcount",0),
(try_end),
],
[
("continue",[], "Continue...",[(jump_to_menu, "$g_next_menu"),]),
]
),