-
Notifications
You must be signed in to change notification settings - Fork 335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Standardize factory alt behavior #4177
base: master
Are you sure you want to change the base?
Standardize factory alt behavior #4177
Conversation
if isFactory[unitDefID] and buildOpts[unitDefID][-cmdID] then | ||
factoryExists = true | ||
if not cmdOpts.internal then | ||
cmdOpts.coded = cmdOpts.coded + CMD.OPT_INTERNAL -- prevent repeating command |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I slightly dislike using INTERNAL over ALT but I suppose that ship had already sailed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What could be done to prevent this? I assume the factory will repeat commands, unless it has INTERNAL in the params.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can skip factories who are on repeat (since they already handle Alt correctly) and then for the remaining non-repeat ones you don't need to add internal since they won't repeat anyway.
spGiveOrderToUnit(unitID, CMD_INSERT, {currentCmdID and 1 or 0, cmdID, cmdOpts.coded}, {"ctrl", "alt"}) | ||
end | ||
end | ||
return factoryExists |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory this makes any fac in selection eat the entire order for all the other units. Sounds fine though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It only does this if the unit is in the build options, so when it's relevant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but if you have a factory and a mobile unit who both have the same buildoption. Consider:
Beyond-All-Reason/units/Legion/Bots/T2 Bots/leginfestor.lua
Lines 43 to 44 in 9bb196c
buildoptions = { | |
[1] = "leginfestor" |
[9] = "leginfestor", |
What happens if you have both selected and give a mobile build order while holding alt? Right now it looks like it's going to drop the mobile order but insert it in the factory instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a weird one: in this case the factory already eats the command (in current master), even without alt (in both buildmenus). I would fix this in a future PR.
if not cmdOpts.internal then | ||
cmdOpts.coded = cmdOpts.coded + CMD.OPT_INTERNAL -- prevent repeating command | ||
end | ||
local currentCmdID, targetID = spGetUnitWorkerTask(unitID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what happens if there is a unit in queue but the factory isn't actually building it (opening animation, area blocked, etc). There may be a minor behaviour difference compared to native engine insert. Sounds fine though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Factories get extremely glitchy when wait is issued and insert is used, where I also found bugs. I would wait to avoid this bugs before merging.
Work done
Alt-queued units in factories will now always be queued after the current unit that is being built, even when not in repeat mode.
Addresses Issue(s)
Test steps