(party_get_num_companion_stacks, ":num_stacks",":enemy_party"),
(assign, ":last_stack", ":num_stacks"),
(try_for_range, ":unused", 0, ":num_stacks"),
(assign, ":best_stack", -1),
(assign, ":best_level", -1),
(try_for_range, ":cur_stack", 0, ":last_stack"),
(party_stack_get_troop_id, ":cur_troop", ":enemy_party", ":cur_stack"),
(neg|troop_is_hero, ":cur_troop"),
(store_character_level, ":troop_level", ":cur_troop"),
(gt, ":troop_level", ":best_level"),
(assign, ":best_level", ":troop_level"),
(assign, ":best_stack", ":cur_stack"),
(try_end),
(try_begin),
(gt, ":best_stack", -1),
(party_stack_get_troop_id, ":stack_troop", ":enemy_party", ":best_stack"),
(party_stack_get_size, ":stack_size", ":enemy_party", ":best_stack"),
(party_remove_members, ":enemy_party", ":stack_troop", ":stack_size"),
(party_add_members, ":enemy_party", ":stack_troop", ":stack_size"),
(val_sub, ":last_stack", 1),
(try_end),
(try_end),