Zero-K icon indicating copy to clipboard operation
Zero-K copied to clipboard

add guard selection rank override.

Open amnykon opened this issue 1 year ago • 9 comments

Adds an selection rank option for "Units issued a guard command are reduced to this selection rank."

amnykon avatar May 20 '24 22:05 amnykon

Update PR to address Sprunk's comments.

amnykon avatar May 21 '24 02:05 amnykon

The PR lacks a description so I went looking for one.

desc = "Units issued a guard command will be treated as a different selection rank.", desc = "Units issued a guard command are treated as this selection rank, if override is enabled.",

I thought "this seems marginally more useful as an upper bound, rather than a strict override".

But then

if WG.Orbit and WG.Orbit.IsSelectionOverrideSet and WG.Orbit.IsUnitGuarding(unitID) and (rank > WG.Orbit.SelectionOverrideRank) then
	rank = WG.Orbit.SelectionOverrideRank
end

So just make the description accurate?

GoogleFrog avatar May 21 '24 11:05 GoogleFrog

Hold up.

Why was the orbit widget modified at all? This should be a setting under selection rank, and it should work on guard regardless of whether the orbit widget is enabled. The WG-ness of the check for a guard command is redundant, as it doesn't do anything with the local state or data of the orbit widget. This entire PR should be in the selection rank widget, because the new option does nothing with selection rank disabled, and should do basically everything with orbit disabled.

GoogleFrog avatar May 21 '24 11:05 GoogleFrog

updated to address GoogleFrog's comments, and removed the bool option since guardRankoverrideOption set at 3 is the same as having it off.

amnykon avatar May 21 '24 23:05 amnykon

Removing the tickbox option is nice too. But now, shouldn't the default be 3?

GoogleFrog avatar May 22 '24 08:05 GoogleFrog

Updated default value to 3. As I just returned my new laptop due to too many crashes and boot issues, I am not able to currently test this change; however, it's simple enough that it should work, as long as the comma is still there.

amnykon avatar May 22 '24 18:05 amnykon

I have yet had a chance to test, but I suspect the code has a bug. OnChanged doesn't call when the value is read as the default from settings, and the default is 3. However, the local value is 0, so guard selection rank will be applied until the player toggles it from 3 then back. I would remove guardSelectionOverrideRank to prevent this and future bugs like it, just use options.<setting>.value.

GoogleFrog avatar May 23 '24 08:05 GoogleFrog

Updated to remove the extra local var, and fixed a camel case. like I said, I returned my laptop so please test this before merging it. As the funds for my new laptop is allocated elsewhere, I cannot test until ~ December...

amnykon avatar May 24 '24 03:05 amnykon

Tested, seems to work.

sprunk avatar May 27 '24 01:05 sprunk