From 4cbc4b8e12259726f632a3330a5aaef9fb1a5761 Mon Sep 17 00:00:00 2001 From: lL1l1 <82986251+lL1l1@users.noreply.github.com> Date: Fri, 12 Jun 2026 15:14:19 -0700 Subject: [PATCH 1/7] Debug logging of Mercy's prio You can reload the weapon.lua file to reload the initial prio parsing --- lua/sim/weapon.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/sim/weapon.lua b/lua/sim/weapon.lua index 8f584618a07..7eb998b9838 100644 --- a/lua/sim/weapon.lua +++ b/lua/sim/weapon.lua @@ -37,6 +37,7 @@ local DebugWeaponComponent = import("/lua/sim/weapons/components/debugweaponcomp ---@return EntityCategory[] local function ParsePriorities() + LOG("Parsing prios init") local idlist = EntityCategoryGetUnitList(categories.ALLUNITS) local finalPriorities = {} local StringFind = string.find @@ -55,10 +56,13 @@ local function ParsePriorities() end for _, priority in priorities do if not finalPriorities[priority] then + local log = priority == "(ALLUNITS - SPECIALLOWPRI)" if StringFind(priority, '%(', 1, true) then finalPriorities[priority] = ParseEntityCategoryProperly(priority) + if log then LOG("ParseEntityCategoryProperly", priority, repr(EntityCategoryGetUnitList(finalPriorities[priority]))) end else finalPriorities[priority] = ParseEntityCategory(priority) + if log then LOG("ParseEntityCategory", priority, repr(EntityCategoryGetUnitList(finalPriorities[priority]))) end end end end From 56a1611b1d3f2725d6e1768ad694c18c6fdfd995 Mon Sep 17 00:00:00 2001 From: lL1l1 <82986251+lL1l1@users.noreply.github.com> Date: Fri, 12 Jun 2026 15:16:19 -0700 Subject: [PATCH 2/7] Fix "proper" expressions not being parsed in default prios The bug is that the third argument `plain` being `true` disables the pattern matching facilities so the escape character `%` becomes an actual matched character, which causes the string from target priorities to not match. I also regex searched all files with `find\(.*, true\)` and didn't find any other instances of this mistake. --- lua/sim/weapon.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/sim/weapon.lua b/lua/sim/weapon.lua index 7eb998b9838..9a2a56901f6 100644 --- a/lua/sim/weapon.lua +++ b/lua/sim/weapon.lua @@ -57,7 +57,7 @@ local function ParsePriorities() for _, priority in priorities do if not finalPriorities[priority] then local log = priority == "(ALLUNITS - SPECIALLOWPRI)" - if StringFind(priority, '%(', 1, true) then + if StringFind(priority, '(', 1, true) then finalPriorities[priority] = ParseEntityCategoryProperly(priority) if log then LOG("ParseEntityCategoryProperly", priority, repr(EntityCategoryGetUnitList(finalPriorities[priority]))) end else From 3be6f706ef3e9829c16ca57fffae3936a8a8bcdd Mon Sep 17 00:00:00 2001 From: lL1l1 <82986251+lL1l1@users.noreply.github.com> Date: Fri, 12 Jun 2026 15:20:38 -0700 Subject: [PATCH 3/7] Revert debug logging --- lua/sim/weapon.lua | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lua/sim/weapon.lua b/lua/sim/weapon.lua index 9a2a56901f6..13408dc9632 100644 --- a/lua/sim/weapon.lua +++ b/lua/sim/weapon.lua @@ -37,7 +37,6 @@ local DebugWeaponComponent = import("/lua/sim/weapons/components/debugweaponcomp ---@return EntityCategory[] local function ParsePriorities() - LOG("Parsing prios init") local idlist = EntityCategoryGetUnitList(categories.ALLUNITS) local finalPriorities = {} local StringFind = string.find @@ -56,13 +55,10 @@ local function ParsePriorities() end for _, priority in priorities do if not finalPriorities[priority] then - local log = priority == "(ALLUNITS - SPECIALLOWPRI)" if StringFind(priority, '(', 1, true) then finalPriorities[priority] = ParseEntityCategoryProperly(priority) - if log then LOG("ParseEntityCategoryProperly", priority, repr(EntityCategoryGetUnitList(finalPriorities[priority]))) end else finalPriorities[priority] = ParseEntityCategory(priority) - if log then LOG("ParseEntityCategory", priority, repr(EntityCategoryGetUnitList(finalPriorities[priority]))) end end end end From 8816c274edd1d42cd06e5eb591b5f5dc6e3fcb14 Mon Sep 17 00:00:00 2001 From: lL1l1 <82986251+lL1l1@users.noreply.github.com> Date: Fri, 12 Jun 2026 15:47:12 -0700 Subject: [PATCH 4/7] Clean up overdefined torp bomber priorities --- units/UAA0204/UAA0204_unit.bp | 10 +++++----- units/UEA0204/UEA0204_unit.bp | 10 +++++----- units/URA0204/URA0204_unit.bp | 10 +++++----- units/XAA0306/XAA0306_unit.bp | 12 ++++++------ units/XSA0204/XSA0204_unit.bp | 10 +++++----- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/units/UAA0204/UAA0204_unit.bp b/units/UAA0204/UAA0204_unit.bp index a28f0cb8351..1f533f1593c 100644 --- a/units/UAA0204/UAA0204_unit.bp +++ b/units/UAA0204/UAA0204_unit.bp @@ -235,12 +235,12 @@ UnitBlueprint{ RateOfFire = 10/100, --10/integer interval in ticks TargetPriorities = { "CRUISER", - "(NAVAL * TECH2 * SHIELD)", - "(STRUCTURE * DEFENSE * ANTIAIR)", - "(TECH3 * NAVAL * CARRIER)", + "NAVAL TECH2 SHIELD", + "STRUCTURE DEFENSE ANTIAIR", + "TECH3 NAVAL CARRIER", "SUBMERSIBLE", - "NAVAL * TECH2", - "NAVAL * TECH3", + "NAVAL TECH2", + "NAVAL TECH3", "MOBILE", "(STRUCTURE * DEFENSE - ANTIMISSILE)", "ALLUNITS", diff --git a/units/UEA0204/UEA0204_unit.bp b/units/UEA0204/UEA0204_unit.bp index 702122dd086..b18280284dd 100644 --- a/units/UEA0204/UEA0204_unit.bp +++ b/units/UEA0204/UEA0204_unit.bp @@ -243,12 +243,12 @@ UnitBlueprint{ RateOfFire = 10/100, --10/integer interval in ticks TargetPriorities = { "CRUISER", - "(NAVAL * TECH2 * SHIELD)", - "(STRUCTURE * DEFENSE * ANTIAIR)", - "(TECH3 * NAVAL * CARRIER)", + "NAVAL TECH2 SHIELD", + "STRUCTURE DEFENSE ANTIAIR", + "TECH3 NAVAL CARRIER", "SUBMERSIBLE", - "NAVAL * TECH2", - "NAVAL * TECH3", + "NAVAL TECH2", + "NAVAL TECH3", "MOBILE", "(STRUCTURE * DEFENSE - ANTIMISSILE)", "ALLUNITS", diff --git a/units/URA0204/URA0204_unit.bp b/units/URA0204/URA0204_unit.bp index 9fda9ee3be5..8834d318e0b 100644 --- a/units/URA0204/URA0204_unit.bp +++ b/units/URA0204/URA0204_unit.bp @@ -242,12 +242,12 @@ UnitBlueprint{ RateOfFire = 10/100, --10/integer interval in ticks TargetPriorities = { "CRUISER", - "(NAVAL * TECH2 * SHIELD)", - "(STRUCTURE * DEFENSE * ANTIAIR)", - "(TECH3 * NAVAL * CARRIER)", + "NAVAL TECH2 SHIELD", + "STRUCTURE DEFENSE ANTIAIR", + "TECH3 NAVAL CARRIER", "SUBMERSIBLE", - "NAVAL * TECH2", - "NAVAL * TECH3", + "NAVAL TECH2", + "NAVAL TECH3", "MOBILE", "(STRUCTURE * DEFENSE - ANTIMISSILE)", "ALLUNITS", diff --git a/units/XAA0306/XAA0306_unit.bp b/units/XAA0306/XAA0306_unit.bp index f57cbf067fd..e8471e540c2 100644 --- a/units/XAA0306/XAA0306_unit.bp +++ b/units/XAA0306/XAA0306_unit.bp @@ -235,15 +235,15 @@ UnitBlueprint{ RateOfFire = 10/100, --10/integer interval in ticks TargetPriorities = { "CRUISER", - "(NAVAL * TECH2 * SHIELD)", - "(TECH3 * STRUCTURE * DEFENSE * ANTIAIR)", - "(TECH3 * NAVAL * CARRIER)", + "NAVAL TECH2 SHIELD", + "TECH3 STRUCTURE DEFENSE ANTIAIR", + "TECH3 NAVAL CARRIER", "(SUBMERSIBLE - TECH1)", - "(NAVAL * TECH2)", - "(NAVAL * TECH3)", + "NAVAL TECH2", + "NAVAL TECH3", "SUBMERSIBLE", "MOBILE", - "(STRUCTURE * DEFENSE * ANTIAIR)", + "STRUCTURE DEFENSE ANTIAIR", "(STRUCTURE * DEFENSE - ANTIMISSILE)", "ALLUNITS", }, diff --git a/units/XSA0204/XSA0204_unit.bp b/units/XSA0204/XSA0204_unit.bp index 754442a5860..a0dccf07474 100644 --- a/units/XSA0204/XSA0204_unit.bp +++ b/units/XSA0204/XSA0204_unit.bp @@ -234,12 +234,12 @@ UnitBlueprint{ RateOfFire = 10/100, --10/integer interval in ticks TargetPriorities = { "CRUISER", - "(NAVAL * TECH2 * SHIELD)", - "(STRUCTURE * DEFENSE * ANTIAIR)", - "(TECH3 * NAVAL * CARRIER)", + "NAVAL TECH2 SHIELD", + "STRUCTURE DEFENSE ANTIAIR", + "TECH3 NAVAL CARRIER", "SUBMERSIBLE", - "NAVAL * TECH2", - "NAVAL * TECH3", + "NAVAL TECH2", + "NAVAL TECH3", "MOBILE", "(STRUCTURE * DEFENSE - ANTIMISSILE)", "ALLUNITS", From 0dc3e4758ff0f6949a3a8b04608dc9ebfc6b8415 Mon Sep 17 00:00:00 2001 From: lL1l1 <82986251+lL1l1@users.noreply.github.com> Date: Fri, 12 Jun 2026 15:56:25 -0700 Subject: [PATCH 5/7] Log all proper prios and their weapons --- lua/sim/weapon.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lua/sim/weapon.lua b/lua/sim/weapon.lua index 13408dc9632..e581e95b69e 100644 --- a/lua/sim/weapon.lua +++ b/lua/sim/weapon.lua @@ -35,6 +35,19 @@ local DebugWeaponComponent = import("/lua/sim/weapons/components/debugweaponcomp ---@field Buffs BlueprintBuff[] # Active buffs for the weapon ---@field __index WeaponDamageTable +local properPrios = {} + +local function getStr(id, weapon) + local bp = __blueprints[id] + local descAndName = string.format('%s %s', LOC(bp.Description), LOC(bp.General.UnitName) or '') + return string.format('%-8s %-12s %-45s%-35s' + , bp.FactionCategory + , bp.TechCategory + , descAndName + , weapon.BlueprintId + ) +end + ---@return EntityCategory[] local function ParsePriorities() local idlist = EntityCategoryGetUnitList(categories.ALLUNITS) @@ -57,13 +70,19 @@ local function ParsePriorities() if not finalPriorities[priority] then if StringFind(priority, '(', 1, true) then finalPriorities[priority] = ParseEntityCategoryProperly(priority) + properPrios[priority] = { getStr(id, weapon) } else finalPriorities[priority] = ParseEntityCategory(priority) end + else + if properPrios[priority] then + table.insert(properPrios[priority], getStr(id, weapon)) + end end end end end + _ALERT(repr(properPrios)) return finalPriorities end From 4f43313774c4cc7bc3753415747eab4283b0bd7a Mon Sep 17 00:00:00 2001 From: lL1l1 <82986251+lL1l1@users.noreply.github.com> Date: Fri, 12 Jun 2026 16:38:25 -0700 Subject: [PATCH 6/7] Revert "Log all proper prios and their weapons" This reverts commit 0dc3e4758ff0f6949a3a8b04608dc9ebfc6b8415. --- lua/sim/weapon.lua | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/lua/sim/weapon.lua b/lua/sim/weapon.lua index e581e95b69e..13408dc9632 100644 --- a/lua/sim/weapon.lua +++ b/lua/sim/weapon.lua @@ -35,19 +35,6 @@ local DebugWeaponComponent = import("/lua/sim/weapons/components/debugweaponcomp ---@field Buffs BlueprintBuff[] # Active buffs for the weapon ---@field __index WeaponDamageTable -local properPrios = {} - -local function getStr(id, weapon) - local bp = __blueprints[id] - local descAndName = string.format('%s %s', LOC(bp.Description), LOC(bp.General.UnitName) or '') - return string.format('%-8s %-12s %-45s%-35s' - , bp.FactionCategory - , bp.TechCategory - , descAndName - , weapon.BlueprintId - ) -end - ---@return EntityCategory[] local function ParsePriorities() local idlist = EntityCategoryGetUnitList(categories.ALLUNITS) @@ -70,19 +57,13 @@ local function ParsePriorities() if not finalPriorities[priority] then if StringFind(priority, '(', 1, true) then finalPriorities[priority] = ParseEntityCategoryProperly(priority) - properPrios[priority] = { getStr(id, weapon) } else finalPriorities[priority] = ParseEntityCategory(priority) end - else - if properPrios[priority] then - table.insert(properPrios[priority], getStr(id, weapon)) - end end end end end - _ALERT(repr(properPrios)) return finalPriorities end From e9f217a26c4a36768df9806dda557b2a7d7a67ca Mon Sep 17 00:00:00 2001 From: lL1l1 <82986251+lL1l1@users.noreply.github.com> Date: Fri, 12 Jun 2026 16:40:28 -0700 Subject: [PATCH 7/7] Create fix.7138.md --- changelog/snippets/fix.7138.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/snippets/fix.7138.md diff --git a/changelog/snippets/fix.7138.md b/changelog/snippets/fix.7138.md new file mode 100644 index 00000000000..2bcef635343 --- /dev/null +++ b/changelog/snippets/fix.7138.md @@ -0,0 +1 @@ +- (#7138) Fix default target priorities that use parentheses to enable richer category parsing using normal category parsing instead.