Reworked fallback from rating sortings. Renamed melee potential to solo combat potential. Added group combat potential.

develop
Mikhail 2023-08-27 17:52:09 +03:00
parent 6fcbf48c84
commit c91a02ca6a
2 changed files with 180 additions and 112 deletions

@ -26,12 +26,22 @@ skill they have in crossbows or general ranged combat.
If sorted by "leadership", then the citizen is sorted according to the highest If sorted by "leadership", then the citizen is sorted according to the highest
skill they have in leader, teacher, or military tactics. skill they have in leader, teacher, or military tactics.
If sorting is done by "melee potential" citizens are arranged based on their If sorting is done by "mental stability" citizens are arranged based on their
melee potential rating. This rating is a heuristic measure that takes into mental stability rating. This rating is a measure that takes into account
facets and values of an individual and correlates to better stress values.
It is designed to be higher for more stress-resistant citizens.
If sorting is done by "solo combat potential" citizens are arranged based on their
solo combat potential rating. This rating is a measure that takes into
account genetic predispositions in physical and mental attributes, as account genetic predispositions in physical and mental attributes, as
well as body size. Dwarves (and other humanoid creatures) with bigger rating well as body size. Dwarves (and other humanoid creatures) with bigger rating
are expected to be more effective in melee combat against opponents of are expected to be more effective in melee combat against strong opponents.
similar skill levels.
If sorting is done by "group combat potential" citizens are arranged based on their
group combat potential rating. Similar with solo combat rating except this rating
taking into account efficiency in a fight against multiple opponents. This rating
is valid only for dwarves because it considers martial trance which only dwarves
are capable of.
If sorting is done by "ranged potential" citizens are arranged based on their If sorting is done by "ranged potential" citizens are arranged based on their
ranged potential rating. This rating is a statistical measure that takes into ranged potential rating. This rating is a statistical measure that takes into
@ -39,11 +49,6 @@ account genetic predispositions in physical and mental attributes.
Dwarves (and other humanoid creatures) with bigger rating are expected to be Dwarves (and other humanoid creatures) with bigger rating are expected to be
more effective in ranged combat. more effective in ranged combat.
If sorting is done by "mental stability" citizens are arranged based on their
mental stability rating. This rating is a measure that takes into account
facets and values of an individual and correlates to better stress values.
It is designed to be higher for more stress-resistant citizens.
You can search for a dwarf by name by typing in the Search field. You can also You can search for a dwarf by name by typing in the Search field. You can also
type in the name of any job skill (military-related or not) and dwarves with type in the name of any job skill (military-related or not) and dwarves with
any experience in that skill will be shown. For example, to only see citizens any experience in that skill will be shown. For example, to only see citizens

@ -205,9 +205,82 @@ local function make_sort_by_skill_asc(sort_skill)
end end
end end
-- Statistical rating that is bigger for dwarves that are mentally stable
local function mental_stability(unit)
local ALTRUISM = unit.status.current_soul.personality.traits.ALTRUISM
local ANXIETY_PROPENSITY = unit.status.current_soul.personality.traits.ANXIETY_PROPENSITY
local BRAVERY = unit.status.current_soul.personality.traits.BRAVERY
local CHEER_PROPENSITY = unit.status.current_soul.personality.traits.CHEER_PROPENSITY
local CURIOUS = unit.status.current_soul.personality.traits.CURIOUS
local DISCORD = unit.status.current_soul.personality.traits.DISCORD
local DUTIFULNESS = unit.status.current_soul.personality.traits.DUTIFULNESS
local EMOTIONALLY_OBSESSIVE = unit.status.current_soul.personality.traits.EMOTIONALLY_OBSESSIVE
local HUMOR = unit.status.current_soul.personality.traits.HUMOR
local LOVE_PROPENSITY = unit.status.current_soul.personality.traits.LOVE_PROPENSITY
local PERSEVERENCE = unit.status.current_soul.personality.traits.PERSEVERENCE
local POLITENESS = unit.status.current_soul.personality.traits.POLITENESS
local PRIVACY = unit.status.current_soul.personality.traits.PRIVACY
local STRESS_VULNERABILITY = unit.status.current_soul.personality.traits.STRESS_VULNERABILITY
local TOLERANT = unit.status.current_soul.personality.traits.TOLERANT
local CRAFTSMANSHIP = setbelief.getUnitBelief(unit, df.value_type['CRAFTSMANSHIP'])
local FAMILY = setbelief.getUnitBelief(unit, df.value_type['FAMILY'])
local HARMONY = setbelief.getUnitBelief(unit, df.value_type['HARMONY'])
local INDEPENDENCE = setbelief.getUnitBelief(unit, df.value_type['INDEPENDENCE'])
local KNOWLEDGE = setbelief.getUnitBelief(unit, df.value_type['KNOWLEDGE'])
local LEISURE_TIME = setbelief.getUnitBelief(unit, df.value_type['LEISURE_TIME'])
local NATURE = setbelief.getUnitBelief(unit, df.value_type['NATURE'])
local SKILL = setbelief.getUnitBelief(unit, df.value_type['SKILL'])
-- Calculate the rating using the defined variables
local rating = (CRAFTSMANSHIP * -0.01) + (FAMILY * -0.09) + (HARMONY * 0.05)
+ (INDEPENDENCE * 0.06) + (KNOWLEDGE * -0.30) + (LEISURE_TIME * 0.24)
+ (NATURE * 0.27) + (SKILL * -0.21) + (ALTRUISM * 0.13)
+ (ANXIETY_PROPENSITY * -0.06) + (BRAVERY * 0.06)
+ (CHEER_PROPENSITY * 0.41) + (CURIOUS * -0.06) + (DISCORD * 0.14)
+ (DUTIFULNESS * -0.03) + (EMOTIONALLY_OBSESSIVE * -0.13)
+ (HUMOR * -0.05) + (LOVE_PROPENSITY * 0.15) + (PERSEVERENCE * -0.07)
+ (POLITENESS * -0.14) + (PRIVACY * 0.03) + (STRESS_VULNERABILITY * -0.20)
+ (TOLERANT * -0.11)
return rating
end
local function sort_by_mental_stability_desc(unit_id_1, unit_id_2)
if unit_id_1 == unit_id_2 then return 0 end
local unit1 = df.unit.find(unit_id_1)
local unit2 = df.unit.find(unit_id_2)
if not unit1 then return -1 end
if not unit2 then return 1 end
local rating1 = mental_stability(unit1)
local rating2 = mental_stability(unit2)
if rating1 == rating2 then
-- sorting by stress is opposite
-- more mental stable dwarves should have less stress
return sort_by_stress_asc(unit_id_1, unit_id_2)
end
return utils.compare(rating2, rating1)
end
local function sort_by_mental_stability_asc(unit_id_1, unit_id_2)
if unit_id_1 == unit_id_2 then return 0 end
local unit1 = df.unit.find(unit_id_1)
local unit2 = df.unit.find(unit_id_2)
if not unit1 then return -1 end
if not unit2 then return 1 end
local rating1 = mental_stability(unit1)
local rating2 = mental_stability(unit2)
if rating1 == rating2 then
return sort_by_stress_desc(unit_id_1, unit_id_2)
end
return utils.compare(rating1, rating2)
end
-- Statistical rating that is bigger for more potent dwarves in long run melee military training -- Statistical rating that is bigger for more potent dwarves in long run melee military training
-- Rating considers fighting solo opponents
-- Wounds are not considered! -- Wounds are not considered!
local function melee_potential(unit) local function solo_combat_potential(unit)
-- Physical attributes -- Physical attributes
local strength = unit.body.physical_attrs.STRENGTH.max_value local strength = unit.body.physical_attrs.STRENGTH.max_value
local agility = unit.body.physical_attrs.AGILITY.max_value local agility = unit.body.physical_attrs.AGILITY.max_value
@ -220,154 +293,130 @@ local function melee_potential(unit)
local spatialSense = unit.status.current_soul.mental_attrs.SPATIAL_SENSE.max_value local spatialSense = unit.status.current_soul.mental_attrs.SPATIAL_SENSE.max_value
local kinestheticSense = unit.status.current_soul.mental_attrs.KINESTHETIC_SENSE.max_value local kinestheticSense = unit.status.current_soul.mental_attrs.KINESTHETIC_SENSE.max_value
-- Melee potential rating -- solo combat potential rating
local rating = strength*5.8 + kinestheticSense*3.7 + bodySize*2 + agility*2 + endurance*1.8 local rating = strength*5.8 + kinestheticSense*3.7 + bodySize*2 + agility*2 + endurance*1.8
+ willpower*1.5 * spatialSense*1.5 + toughness*1.5 + willpower*1.5 * spatialSense*1.5 + toughness*1.5
return rating return rating
end end
local function sort_by_melee_potential_desc(unit_id_1, unit_id_2) local function sort_by_solo_combat_potential_desc(unit_id_1, unit_id_2)
if unit_id_1 == unit_id_2 then return 0 end if unit_id_1 == unit_id_2 then return 0 end
local unit1 = df.unit.find(unit_id_1) local unit1 = df.unit.find(unit_id_1)
local unit2 = df.unit.find(unit_id_2) local unit2 = df.unit.find(unit_id_2)
if not unit1 then return -1 end if not unit1 then return -1 end
if not unit2 then return 1 end if not unit2 then return 1 end
local rating1 = melee_potential(unit1) local rating1 = solo_combat_potential(unit1)
local rating2 = melee_potential(unit2) local rating2 = solo_combat_potential(unit2)
if rating1 == rating2 then if rating1 == rating2 then
return sort_by_name_desc(unit_id_1, unit_id_2) return sort_by_mental_stability_desc(unit_id_1, unit_id_2)
end end
return utils.compare(rating2, rating1) return utils.compare(rating2, rating1)
end end
local function sort_by_melee_potential_asc(unit_id_1, unit_id_2) local function sort_by_solo_combat_potential_asc(unit_id_1, unit_id_2)
if unit_id_1 == unit_id_2 then return 0 end if unit_id_1 == unit_id_2 then return 0 end
local unit1 = df.unit.find(unit_id_1) local unit1 = df.unit.find(unit_id_1)
local unit2 = df.unit.find(unit_id_2) local unit2 = df.unit.find(unit_id_2)
if not unit1 then return -1 end if not unit1 then return -1 end
if not unit2 then return 1 end if not unit2 then return 1 end
local rating1 = melee_potential(unit1) local rating1 = solo_combat_potential(unit1)
local rating2 = melee_potential(unit2) local rating2 = solo_combat_potential(unit2)
if rating1 == rating2 then if rating1 == rating2 then
return sort_by_name_asc(unit_id_1, unit_id_2) return sort_by_mental_stability_asc(unit_id_1, unit_id_2)
end end
return utils.compare(rating1, rating2) return utils.compare(rating1, rating2)
end end
-- Statistical rating that is bigger for more potent dwarves in long run ranged military training -- Statistical rating that is bigger for more potent dwarves in long run melee military training
-- Rating considers fighting group of opponents
-- Wounds are not considered! -- Wounds are not considered!
local function ranged_potential(unit) local function group_combat_potential(unit)
-- Physical attributes -- Physical attributes
local agility = unit.body.physical_attrs.AGILITY.max_value local strength = unit.body.physical_attrs.STRENGTH.max_value
local toughness = unit.body.physical_attrs.TOUGHNESS.max_value
local endurance = unit.body.physical_attrs.ENDURANCE.max_value local endurance = unit.body.physical_attrs.ENDURANCE.max_value
local bodySize = unit.body.size_info.size_base
-- Mental attributes -- Mental attributes
local focus = unit.status.current_soul.mental_attrs.FOCUS.max_value
local willpower = unit.status.current_soul.mental_attrs.WILLPOWER.max_value
local spatialSense = unit.status.current_soul.mental_attrs.SPATIAL_SENSE.max_value local spatialSense = unit.status.current_soul.mental_attrs.SPATIAL_SENSE.max_value
local kinestheticSense = unit.status.current_soul.mental_attrs.KINESTHETIC_SENSE.max_value local kinestheticSense = unit.status.current_soul.mental_attrs.KINESTHETIC_SENSE.max_value
-- Ranged potential formula -- group combat potential rating
local rating = agility*3.9 + kinestheticSense*3 + spatialSense*2.9 + toughness*0.9 local rating = strength*8.3 + endurance*3 + bodySize*2.8 + kinestheticSense*0.6 + spatialSense*0.4
+ focus*0.7 + endurance*0.7 + willpower*0.6
return rating return rating
end end
local function sort_by_ranged_potential_desc(unit_id_1, unit_id_2) local function sort_by_group_combat_potential_desc(unit_id_1, unit_id_2)
if unit_id_1 == unit_id_2 then return 0 end if unit_id_1 == unit_id_2 then return 0 end
local unit1 = df.unit.find(unit_id_1) local unit1 = df.unit.find(unit_id_1)
local unit2 = df.unit.find(unit_id_2) local unit2 = df.unit.find(unit_id_2)
if not unit1 then return -1 end if not unit1 then return -1 end
if not unit2 then return 1 end if not unit2 then return 1 end
local rating1 = ranged_potential(unit1) local rating1 = group_combat_potential(unit1)
local rating2 = ranged_potential(unit2) local rating2 = group_combat_potential(unit2)
if rating1 == rating2 then if rating1 == rating2 then
return sort_by_name_desc(unit_id_1, unit_id_2) return sort_by_mental_stability_desc(unit_id_1, unit_id_2)
end end
return utils.compare(rating2, rating1) return utils.compare(rating2, rating1)
end end
local function sort_by_ranged_potential_asc(unit_id_1, unit_id_2) local function sort_by_group_combat_potential_asc(unit_id_1, unit_id_2)
if unit_id_1 == unit_id_2 then return 0 end if unit_id_1 == unit_id_2 then return 0 end
local unit1 = df.unit.find(unit_id_1) local unit1 = df.unit.find(unit_id_1)
local unit2 = df.unit.find(unit_id_2) local unit2 = df.unit.find(unit_id_2)
if not unit1 then return -1 end if not unit1 then return -1 end
if not unit2 then return 1 end if not unit2 then return 1 end
local rating1 = ranged_potential(unit1) local rating1 = group_combat_potential(unit1)
local rating2 = ranged_potential(unit2) local rating2 = group_combat_potential(unit2)
if rating1 == rating2 then if rating1 == rating2 then
return sort_by_name_asc(unit_id_1, unit_id_2) return sort_by_mental_stability_asc(unit_id_1, unit_id_2)
end end
return utils.compare(rating1, rating2) return utils.compare(rating1, rating2)
end end
-- Statistical rating that is bigger for dwarves that are mentally stable -- Statistical rating that is bigger for more potent dwarves in long run ranged military training
local function mental_stability(unit) -- Wounds are not considered!
local ALTRUISM = unit.status.current_soul.personality.traits.ALTRUISM local function ranged_potential(unit)
local ANXIETY_PROPENSITY = unit.status.current_soul.personality.traits.ANXIETY_PROPENSITY -- Physical attributes
local BRAVERY = unit.status.current_soul.personality.traits.BRAVERY local agility = unit.body.physical_attrs.AGILITY.max_value
local CHEER_PROPENSITY = unit.status.current_soul.personality.traits.CHEER_PROPENSITY local toughness = unit.body.physical_attrs.TOUGHNESS.max_value
local CURIOUS = unit.status.current_soul.personality.traits.CURIOUS local endurance = unit.body.physical_attrs.ENDURANCE.max_value
local DISCORD = unit.status.current_soul.personality.traits.DISCORD
local DUTIFULNESS = unit.status.current_soul.personality.traits.DUTIFULNESS
local EMOTIONALLY_OBSESSIVE = unit.status.current_soul.personality.traits.EMOTIONALLY_OBSESSIVE
local HUMOR = unit.status.current_soul.personality.traits.HUMOR
local LOVE_PROPENSITY = unit.status.current_soul.personality.traits.LOVE_PROPENSITY
local PERSEVERENCE = unit.status.current_soul.personality.traits.PERSEVERENCE
local POLITENESS = unit.status.current_soul.personality.traits.POLITENESS
local PRIVACY = unit.status.current_soul.personality.traits.PRIVACY
local STRESS_VULNERABILITY = unit.status.current_soul.personality.traits.STRESS_VULNERABILITY
local TOLERANT = unit.status.current_soul.personality.traits.TOLERANT
local CRAFTSMANSHIP = setbelief.getUnitBelief(unit, df.value_type['CRAFTSMANSHIP'])
local FAMILY = setbelief.getUnitBelief(unit, df.value_type['FAMILY'])
local HARMONY = setbelief.getUnitBelief(unit, df.value_type['HARMONY'])
local INDEPENDENCE = setbelief.getUnitBelief(unit, df.value_type['INDEPENDENCE'])
local KNOWLEDGE = setbelief.getUnitBelief(unit, df.value_type['KNOWLEDGE'])
local LEISURE_TIME = setbelief.getUnitBelief(unit, df.value_type['LEISURE_TIME'])
local NATURE = setbelief.getUnitBelief(unit, df.value_type['NATURE'])
local SKILL = setbelief.getUnitBelief(unit, df.value_type['SKILL'])
-- Calculate the rating using the defined variables -- Mental attributes
local rating = (CRAFTSMANSHIP * -0.01) + (FAMILY * -0.09) + (HARMONY * 0.05) local focus = unit.status.current_soul.mental_attrs.FOCUS.max_value
+ (INDEPENDENCE * 0.06) + (KNOWLEDGE * -0.30) + (LEISURE_TIME * 0.24) local willpower = unit.status.current_soul.mental_attrs.WILLPOWER.max_value
+ (NATURE * 0.27) + (SKILL * -0.21) + (ALTRUISM * 0.13) local spatialSense = unit.status.current_soul.mental_attrs.SPATIAL_SENSE.max_value
+ (ANXIETY_PROPENSITY * -0.06) + (BRAVERY * 0.06) local kinestheticSense = unit.status.current_soul.mental_attrs.KINESTHETIC_SENSE.max_value
+ (CHEER_PROPENSITY * 0.41) + (CURIOUS * -0.06) + (DISCORD * 0.14)
+ (DUTIFULNESS * -0.03) + (EMOTIONALLY_OBSESSIVE * -0.13)
+ (HUMOR * -0.05) + (LOVE_PROPENSITY * 0.15) + (PERSEVERENCE * -0.07)
+ (POLITENESS * -0.14) + (PRIVACY * 0.03) + (STRESS_VULNERABILITY * -0.20)
+ (TOLERANT * -0.11)
-- Ranged potential formula
local rating = agility*3.9 + kinestheticSense*3 + spatialSense*2.9 + toughness*0.9
+ focus*0.7 + endurance*0.7 + willpower*0.6
return rating return rating
end end
local function sort_by_ranged_potential_desc(unit_id_1, unit_id_2)
local function sort_by_mental_stability_desc(unit_id_1, unit_id_2)
if unit_id_1 == unit_id_2 then return 0 end if unit_id_1 == unit_id_2 then return 0 end
local unit1 = df.unit.find(unit_id_1) local unit1 = df.unit.find(unit_id_1)
local unit2 = df.unit.find(unit_id_2) local unit2 = df.unit.find(unit_id_2)
if not unit1 then return -1 end if not unit1 then return -1 end
if not unit2 then return 1 end if not unit2 then return 1 end
local rating1 = mental_stability(unit1) local rating1 = ranged_potential(unit1)
local rating2 = mental_stability(unit2) local rating2 = ranged_potential(unit2)
if rating1 == rating2 then if rating1 == rating2 then
return sort_by_name_desc(unit_id_1, unit_id_2) return sort_by_mental_stability_desc(unit_id_1, unit_id_2)
end end
return utils.compare(rating2, rating1) return utils.compare(rating2, rating1)
end end
local function sort_by_mental_stability_asc(unit_id_1, unit_id_2) local function sort_by_ranged_potential_asc(unit_id_1, unit_id_2)
if unit_id_1 == unit_id_2 then return 0 end if unit_id_1 == unit_id_2 then return 0 end
local unit1 = df.unit.find(unit_id_1) local unit1 = df.unit.find(unit_id_1)
local unit2 = df.unit.find(unit_id_2) local unit2 = df.unit.find(unit_id_2)
if not unit1 then return -1 end if not unit1 then return -1 end
if not unit2 then return 1 end if not unit2 then return 1 end
local rating1 = mental_stability(unit1) local rating1 = ranged_potential(unit1)
local rating2 = mental_stability(unit2) local rating2 = ranged_potential(unit2)
if rating1 == rating2 then if rating1 == rating2 then
return sort_by_name_asc(unit_id_1, unit_id_2) return sort_by_mental_stability_asc(unit_id_1, unit_id_2)
end end
return utils.compare(rating1, rating2) return utils.compare(rating1, rating2)
end end
@ -402,7 +451,7 @@ SquadAssignmentOverlay.ATTRS{
default_pos={x=-33, y=40}, default_pos={x=-33, y=40},
default_enabled=true, default_enabled=true,
viewscreens='dwarfmode/UnitSelector/SQUAD_FILL_POSITION', viewscreens='dwarfmode/UnitSelector/SQUAD_FILL_POSITION',
frame={w=74, h=9}, frame={w=84, h=9},
frame_style=gui.FRAME_PANEL, frame_style=gui.FRAME_PANEL,
frame_background=gui.CLEAR_PEN, frame_background=gui.CLEAR_PEN,
} }
@ -441,12 +490,14 @@ function SquadAssignmentOverlay:init()
{label='spear skill'..CH_UP, value=SORT_FNS.sort_by_spear_asc, pen=COLOR_YELLOW}, {label='spear skill'..CH_UP, value=SORT_FNS.sort_by_spear_asc, pen=COLOR_YELLOW},
{label='crossbow skill'..CH_DN, value=SORT_FNS.sort_by_crossbow_desc, pen=COLOR_GREEN}, {label='crossbow skill'..CH_DN, value=SORT_FNS.sort_by_crossbow_desc, pen=COLOR_GREEN},
{label='crossbow skill'..CH_UP, value=SORT_FNS.sort_by_crossbow_asc, pen=COLOR_YELLOW}, {label='crossbow skill'..CH_UP, value=SORT_FNS.sort_by_crossbow_asc, pen=COLOR_YELLOW},
{label='melee potential'..CH_DN, value=sort_by_melee_potential_desc, pen=COLOR_GREEN},
{label='melee potential'..CH_UP, value=sort_by_melee_potential_asc, pen=COLOR_YELLOW},
{label='ranged potential'..CH_DN, value=sort_by_ranged_potential_desc, pen=COLOR_GREEN},
{label='ranged potential'..CH_UP, value=sort_by_ranged_potential_asc, pen=COLOR_YELLOW},
{label='mental stability'..CH_DN, value=sort_by_mental_stability_desc, pen=COLOR_GREEN}, {label='mental stability'..CH_DN, value=sort_by_mental_stability_desc, pen=COLOR_GREEN},
{label='mental stability'..CH_UP, value=sort_by_mental_stability_asc, pen=COLOR_YELLOW}, {label='mental stability'..CH_UP, value=sort_by_mental_stability_asc, pen=COLOR_YELLOW},
{label='solo combat potential'..CH_DN, value=sort_by_solo_combat_potential_desc, pen=COLOR_GREEN},
{label='solo combat potential'..CH_UP, value=sort_by_solo_combat_potential_asc, pen=COLOR_YELLOW},
{label='group combat potential'..CH_DN, value=sort_by_group_combat_potential_desc, pen=COLOR_GREEN},
{label='group combat potential'..CH_UP, value=sort_by_group_combat_potential_asc, pen=COLOR_YELLOW},
{label='ranged potential'..CH_DN, value=sort_by_ranged_potential_desc, pen=COLOR_GREEN},
{label='ranged potential'..CH_UP, value=sort_by_ranged_potential_asc, pen=COLOR_YELLOW},
}, },
initial_option=SORT_FNS.sort_by_any_melee_desc, initial_option=SORT_FNS.sort_by_any_melee_desc,
on_change=self:callback('refresh_list', 'sort'), on_change=self:callback('refresh_list', 'sort'),
@ -530,7 +581,7 @@ function SquadAssignmentOverlay:init()
}, },
widgets.CycleHotkeyLabel{ widgets.CycleHotkeyLabel{
view_id='sort_axe', view_id='sort_axe',
frame={t=2, l=2, w=4}, frame={t=2, l=0, w=4},
options={ options={
{label='axe', value=sort_noop}, {label='axe', value=sort_noop},
{label='axe'..CH_DN, value=SORT_FNS.sort_by_axe_desc, pen=COLOR_GREEN}, {label='axe'..CH_DN, value=SORT_FNS.sort_by_axe_desc, pen=COLOR_GREEN},
@ -541,7 +592,7 @@ function SquadAssignmentOverlay:init()
}, },
widgets.CycleHotkeyLabel{ widgets.CycleHotkeyLabel{
view_id='sort_sword', view_id='sort_sword',
frame={t=2, l=9, w=6}, frame={t=2, l=7, w=6},
options={ options={
{label='sword', value=sort_noop}, {label='sword', value=sort_noop},
{label='sword'..CH_DN, value=SORT_FNS.sort_by_sword_desc, pen=COLOR_GREEN}, {label='sword'..CH_DN, value=SORT_FNS.sort_by_sword_desc, pen=COLOR_GREEN},
@ -552,7 +603,7 @@ function SquadAssignmentOverlay:init()
}, },
widgets.CycleHotkeyLabel{ widgets.CycleHotkeyLabel{
view_id='sort_mace', view_id='sort_mace',
frame={t=2, l=18, w=5}, frame={t=2, l=16, w=5},
options={ options={
{label='mace', value=sort_noop}, {label='mace', value=sort_noop},
{label='mace'..CH_DN, value=SORT_FNS.sort_by_mace_desc, pen=COLOR_GREEN}, {label='mace'..CH_DN, value=SORT_FNS.sort_by_mace_desc, pen=COLOR_GREEN},
@ -563,7 +614,7 @@ function SquadAssignmentOverlay:init()
}, },
widgets.CycleHotkeyLabel{ widgets.CycleHotkeyLabel{
view_id='sort_hammer', view_id='sort_hammer',
frame={t=2, l=25, w=7}, frame={t=2, l=23, w=7},
options={ options={
{label='hammer', value=sort_noop}, {label='hammer', value=sort_noop},
{label='hammer'..CH_DN, value=SORT_FNS.sort_by_hammer_desc, pen=COLOR_GREEN}, {label='hammer'..CH_DN, value=SORT_FNS.sort_by_hammer_desc, pen=COLOR_GREEN},
@ -574,7 +625,7 @@ function SquadAssignmentOverlay:init()
}, },
widgets.CycleHotkeyLabel{ widgets.CycleHotkeyLabel{
view_id='sort_spear', view_id='sort_spear',
frame={t=2, l=36, w=6}, frame={t=2, l=34, w=6},
options={ options={
{label='spear', value=sort_noop}, {label='spear', value=sort_noop},
{label='spear'..CH_DN, value=SORT_FNS.sort_by_spear_desc, pen=COLOR_GREEN}, {label='spear'..CH_DN, value=SORT_FNS.sort_by_spear_desc, pen=COLOR_GREEN},
@ -585,7 +636,7 @@ function SquadAssignmentOverlay:init()
}, },
widgets.CycleHotkeyLabel{ widgets.CycleHotkeyLabel{
view_id='sort_crossbow', view_id='sort_crossbow',
frame={t=2, l=45, w=9}, frame={t=2, l=43, w=9},
options={ options={
{label='crossbow', value=sort_noop}, {label='crossbow', value=sort_noop},
{label='crossbow'..CH_DN, value=SORT_FNS.sort_by_crossbow_desc, pen=COLOR_GREEN}, {label='crossbow'..CH_DN, value=SORT_FNS.sort_by_crossbow_desc, pen=COLOR_GREEN},
@ -595,37 +646,48 @@ function SquadAssignmentOverlay:init()
on_change=self:callback('refresh_list', 'sort_crossbow'), on_change=self:callback('refresh_list', 'sort_crossbow'),
}, },
widgets.CycleHotkeyLabel{ widgets.CycleHotkeyLabel{
view_id='sort_melee_potential', view_id='sort_mental_stability',
frame={t=4, l=2, w=16}, frame={t=4, l=0, w=17},
options={
{label='mental stability', value=sort_noop},
{label='mental stability'..CH_DN, value=sort_by_mental_stability_desc, pen=COLOR_GREEN},
{label='mental stability'..CH_UP, value=sort_by_mental_stability_asc, pen=COLOR_YELLOW},
},
option_gap=0,
on_change=self:callback('refresh_list', 'sort_mental_stability'),
},
widgets.CycleHotkeyLabel{
view_id='sort_solo_combat_potential',
frame={t=4, l=18, w=22},
options={ options={
{label='melee potential', value=sort_noop}, {label='solo combat potential', value=sort_noop},
{label='melee potential'..CH_DN, value=sort_by_melee_potential_desc, pen=COLOR_GREEN}, {label='solo combat potential'..CH_DN, value=sort_by_solo_combat_potential_desc, pen=COLOR_GREEN},
{label='melee potential'..CH_UP, value=sort_by_melee_potential_asc, pen=COLOR_YELLOW}, {label='solo combat potential'..CH_UP, value=sort_by_solo_combat_potential_asc, pen=COLOR_YELLOW},
}, },
option_gap=0, option_gap=0,
on_change=self:callback('refresh_list', 'sort_melee_potential'), on_change=self:callback('refresh_list', 'sort_solo_combat_potential'),
}, },
widgets.CycleHotkeyLabel{ widgets.CycleHotkeyLabel{
view_id='sort_ranged_potential', view_id='sort_group_combat_potential',
frame={t=4, l=21, w=17}, frame={t=4, l=41, w=23},
options={ options={
{label='ranged potential', value=sort_noop}, {label='group combat potential', value=sort_noop},
{label='ranged potential'..CH_DN, value=sort_by_ranged_potential_desc, pen=COLOR_GREEN}, {label='group combat potential'..CH_DN, value=sort_by_group_combat_potential_desc, pen=COLOR_GREEN},
{label='ranged potential'..CH_UP, value=sort_by_ranged_potential_asc, pen=COLOR_YELLOW}, {label='group combat potential'..CH_UP, value=sort_by_group_combat_potential_asc, pen=COLOR_YELLOW},
}, },
option_gap=0, option_gap=0,
on_change=self:callback('refresh_list', 'sort_ranged_potential'), on_change=self:callback('refresh_list', 'sort_group_combat_potential'),
}, },
widgets.CycleHotkeyLabel{ widgets.CycleHotkeyLabel{
view_id='sort_mental_stability', view_id='sort_ranged_potential',
frame={t=4, l=41, w=17}, frame={t=4, l=65, w=17},
options={ options={
{label='mental stability', value=sort_noop}, {label='ranged potential', value=sort_noop},
{label='mental stability'..CH_DN, value=sort_by_mental_stability_desc, pen=COLOR_GREEN}, {label='ranged potential'..CH_DN, value=sort_by_ranged_potential_desc, pen=COLOR_GREEN},
{label='mental stability'..CH_UP, value=sort_by_mental_stability_asc, pen=COLOR_YELLOW}, {label='ranged potential'..CH_UP, value=sort_by_ranged_potential_asc, pen=COLOR_YELLOW},
}, },
option_gap=0, option_gap=0,
on_change=self:callback('refresh_list', 'sort_mental_stability'), on_change=self:callback('refresh_list', 'sort_ranged_potential'),
}, },
} }
}, },
@ -704,9 +766,10 @@ local SORT_WIDGET_NAMES = {
'sort_hammer', 'sort_hammer',
'sort_spear', 'sort_spear',
'sort_crossbow', 'sort_crossbow',
'sort_melee_potential',
'sort_ranged_potential',
'sort_mental_stability', 'sort_mental_stability',
'sort_solo_combat_potential',
'sort_group_combat_potential',
'sort_ranged_potential',
} }
function SquadAssignmentOverlay:refresh_list(sort_widget, sort_fn) function SquadAssignmentOverlay:refresh_list(sort_widget, sort_fn)