(24, [
(try_for_parties, ":party_no"),
(party_is_active, ":party_no"),
(party_get_num_companion_stacks, ":cap", ":party_no"),
(gt, ":cap", 0),
(str_store_party_name, s0, ":party_no"), #not necessary
(try_for_range, ":outer_stack", 0, ":cap"),
(party_stack_get_troop_id, ":troop", ":party_no", ":outer_stack"),
(gt, ":troop", 0),
(neg|is_between, ":troop", companions_begin, companions_end),
(party_stack_get_size, ":size", ":party_no", ":outer_stack"),
(party_stack_get_num_wounded, ":wounded", ":party_no", ":outer_stack"),
(val_sub, ":size", ":wounded"),
(gt, ":size", 0),
(troop_get_skill_level, ":xp", "skl_trainer", ":troop"),
(gt, ":xp", 0),
(assign, ":total_xp", 0), #just debugging
(try_begin), #too lazy to type out all the xp levels - see module_skills and parse accordingly
(try_end), #if you leave this as-is, regular troops will only give xp=trainer level
(val_mul, ":xp", ":size"),
(store_troop_level, ":level", ":troop"),
(try_for_range, ":inner_stack", 0, ":cap"),
(neq, ":inner_stack", ":outer_stack"),
(party_stack_get_troop_id, ":troop_no", ":party_no", ":inner_stack"),
(store_troop_level, ":lvl", ":troop_no"),
(gt, ":level", ":lvl"),
(party_add_xp_to_stack, ":party_no", ":inner_stack", ":xp"),
(val_add, ":total_xp", ":xp"), #accumulates xp total for each trainer stack
(try_end),
#this section displays how much xp
(gt, ":total_xp", 0),
(assign, reg1, ":size"),
(try_begin),
(eq, ":size", 1),
(str_store_troop_name, s1, ":troop"),
(assign, reg1, 0),
(else_try),
(assign, reg1, ":size"),
(str_store_troop_name_plural, s1, ":troop"),
(try_end),
(assign, reg0, ":total_xp"),
(display_message, "@Total experience gained by {s0} through {reg1?{reg1} {s1}:{s1}}'s training: {reg0}"),
#which isn't really necessary
(try_end),
(try_end),
]),