Code for threshold
(val_div, ":total_weight", 10),
(agent_get_troop_id, ":troop", ":agent_no"),
(troop_get_slot, ":weight_threshold",":troop", slot_troop_crpg_atr_str),
(troop_get_slot, ":weight_threshold_if",":troop", slot_troop_crpg_skl_ironflesh),
(val_div, ":weight_threshold", 3),
(val_add, ":weight_threshold", 1),
(val_max, ":weight_threshold", ":weight_threshold_if"),
(val_max, ":weight_threshold", 6),
(val_sub, ":total_weight", ":weight_threshold"),
(assign, ":weight_penalty", 0),
(try_begin),
(gt, ":total_weight", 0),
(set_fixed_point_multiplier, 1000),
(assign, ":weight_penalty", ":total_weight"),
(convert_to_fixed_point, ":weight_penalty"),
(assign, ":exp", 1),
(convert_to_fixed_point, ":exp"),
(val_mul, ":exp", 112),
(val_div, ":exp", 100),
(store_pow, ":weight_penalty", ":weight_penalty", ":exp"),
(convert_from_fixed_point, ":weight_penalty"),
(try_end),
Code for weight penalty:
(try_begin),
#weight penalty/1.5 as %
(assign, ":weight_penalty_percent", ":weight_penalty"),
(try_begin),
(this_or_next|eq, ":wpf_id", wpt_archery), #Ranged classes receive 1.5x the penalty of melee
(this_or_next|eq, ":wpf_id", wpt_crossbow),
(eq, ":wpf_id", wpt_throwing),
(val_mul, ":weight_penalty_percent", 3),
(else_try),
(val_mul, ":weight_penalty_percent", 2),
(try_end),
(val_div, ":weight_penalty_percent", 3),
(val_sub, ":weight_penalty_percent", 100),
(val_abs, ":weight_penalty_percent"),
(val_mul, ":new_value", ":weight_penalty_percent"),
(val_div, ":new_value", 100),
(try_end),
Then it subtracts 11*PT and checks if the final wpf is less than 1. Either I made an error somewhere or there are rounding issues. I don't really know how the game rounds values, and it doesn't deal with floating points very well.