("give_special_loot", [
(store_script_param_1, ":party"), #Party_id
(assign, ":total_gain", 0),
(party_get_num_companion_stacks, ":num_stacks",":party"),
(try_for_range, ":i_stack", 0, ":num_stacks"),
(party_stack_get_troop_id, ":stack_troop",":party",":i_stack"),
(store_character_level, ":level", ":stack_troop"),
(store_mul, ":gain", ":level", ":level"),
(try_begin),
(neg|troop_is_hero, ":stack_troop"),
(party_stack_get_size, ":stack_size",":party",":i_stack"),
(store_mul, ":stack_gain", ":gain", ":stack_size"),
(else_try),
(store_mul, ":stack_gain", ":gain", 2), # heroes count twice
(try_end),
(val_add, ":total_gain", ":stack_gain"),
(try_end),
(val_div, ":total_gain", 100),
(val_max, ":total_gain", 20),
(val_sub, ":total_gain", 20),
(assign, ":special_item_in_loot", 0),
(store_mul, ":upper_range", "$num_unique_items_given", 250),
(val_add, ":upper_range", 3000),
(store_random_in_range, ":r", 0, ":upper_range"),
(try_begin),
(lt, ":r", ":total_gain"),
(store_random_in_range, ":r", 0, 14),
# First special item is always the one you can use the best
(try_begin),
(eq, "$num_unique_items_given", 0),
(store_proficiency_level, ":one_handed_skill", "trp_player", wpt_one_handed_weapon),
(store_proficiency_level, ":two_handed_skill", "trp_player", wpt_two_handed_weapon),
(store_proficiency_level, ":polearm_skill", "trp_player", wpt_polearm),
(store_proficiency_level, ":archery_skill", "trp_player", wpt_archery),
###################################################################################
# Modified Unique Item Drops for Band of Warriors Expanded by NCrawler
###################################################################################
(store_proficiency_level, ":firearm_skill", "trp_player", wpt_firearm),
(try_begin),
(ge, ":firearm_skill", ":one_handed_skill"),
(ge, ":firearm_skill", ":two_handed_skill"),
(ge, ":firearm_skill", ":polearm_skill"),
(ge, ":firearm_skill", ":archery_skill"),
(assign, ":r", 16), #rifled musket
(else_try),
###################################################################################
# End Modified Unique Item Drops for Band of Warriors Expanded by NCrawler
###################################################################################
(ge, ":archery_skill", ":one_handed_skill"),
(ge, ":archery_skill", ":two_handed_skill"),
(ge, ":archery_skill", ":polearm_skill"),
(assign, ":r", 15), #silver bow
(else_try),
(ge, ":polearm_skill", ":one_handed_skill"),
(ge, ":polearm_skill", ":two_handed_skill"),
(assign, ":r", 7), #kushana
(else_try),
(ge, ":two_handed_skill", ":one_handed_skill"),
(assign, ":r", 2), #durendal
(else_try),
(assign, ":r", 4), #caliburn
(try_end),
(try_end),...