I was thinking rather than primary and secondary attacks, we could have a list of them in the unit's template in order of preference. We'd include matching classes because e.g. spearman might want the order: melee against units, then capture anything, then melee anything (structures). This seems more general than DPS, since how else would we decide between melee and capture? Ranged attacks could first match Unit+!Siege, for example. It seems like we could include heal too rather than treat that as a separate state. We could modify (usually through stances, but maybe sometimes with hotkeys) an attack by matching types of attack (e.g. don't capture) or classes of targets (e.g. ignore structures). When figuring out if we can attack or the best attack against a unit, we could just go through the attacks one by one and see if it has the right properties depending on the type (damage receiver, capturable, healable) and matches the right classes. When searching for new targets we could go through the attacks one by one using the relevant range queries.