Skip to content

Conversation

@lL1l1
Copy link
Contributor

@lL1l1 lL1l1 commented Jun 17, 2025

Issue

  • Fixes the sim side of an issue reported on Discord where using the "Build T2 support factory" hotkey you can build the support factory as a unit instead of an upgrade.
    Spawn uab0102 and give the following order to reproduce the bug:
IssueBlueprintCommandToUnits(GetSelectedUnits(), "UNITCOMMAND_BuildFactory", 'uab0202', 1, false)

Description of the proposed changes

  • Add the appropriate UpgradeOnlyCategory for all 60 factories.
  • Move the UpgradeOnlyCategory logic into CheckBuildRestrictions, as that is the only place where it is needed since it only matters for FactoryBuild and BuildMobile orders. This simplifies the logic overall.
  • Fix the factory and structure units not returning when the base class's OnStartBuild reports a failure. In particular this fixed errors when the factory was ordered to build (not upgrade) a factory upgrade and UpgradeOnlyCategory logic was not in CheckBuildRestrictions.

Testing done on the proposed changes

Test hives again since the logic added by #6709 was changed. Use xrb0104.

import("/lua/ui/game/commandmode.lua").StartCommandMode('build', {name = 'xrb0204'})

Test that factories cannot factory build their own upgrades. Use uab0102.

IssueBlueprintCommandToUnits(GetSelectedUnits(), "UNITCOMMAND_BuildFactory", 'uab0202', 1, false)

Checklist

lL1l1 added 7 commits June 16, 2025 22:33
1. it didn't work
2. we will use UpgradeOnlyCategory
Regex find: `((\s+)BuildableCategory\s*=\s*\{(?:\n.*)*?("BUILTBY.*STRUCTURE.*",)(?:\n.*)*?\2\},)`
Regex replace: `$1$2UpgradeOnlyCategory = {$2\t$3$2},`

60 files replaced. There are 4 factions * 3 fac types * (2 support tiers + 3 HQ tiers) = 60 replacements expected.

I don't know why T3 Factories have a T3 structure build possibility, but it's best to have it upgrade-only just in case imo.
@lL1l1 lL1l1 added the area: sim Area that is affected by the Simulation of the Game label Jun 17, 2025
@4z0t
Copy link
Member

4z0t commented Jul 17, 2025

Some mods will still have this issue. I suggest generating this field based on UpgradesFrom and UpgradesFromBase.

@lL1l1
Copy link
Contributor Author

lL1l1 commented Sep 8, 2025

Doing that would restrict the possibility of a unit that can upgrade into + build copies of its upgrade.

@lL1l1
Copy link
Contributor Author

lL1l1 commented Sep 8, 2025

Ideally the construction UI has an "upgrade into unit" button and a "build unit" button. The real issue is that it abuses the BuildableCategories to identify upgrades, and that blueprint setup causes side effects. Iirc you can upgrade into a unit if it has the correct UpgradesFrom fields, even if its not in the buildable categories.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: sim Area that is affected by the Simulation of the Game

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants