Skip to content
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

SelectionTracker does not take "control group stealing" into account #183

Open
tommwa opened this issue Apr 2, 2023 · 2 comments
Open

Comments

@tommwa
Copy link

tommwa commented Apr 2, 2023

Explanation of what "control group stealing" is Many years ago (I believe with the LOTV release) they added the functionality to "steal" units between control groups. It works exactly like the usual Add / Create except that all of the selected units are also simultaneously removed from all other control groups.

In the hotkey menu in StarCraft this is called "{Create/Add to} Control Group X and Take Away Units" and the buttons for it is found under Menu - Options - Hotkeys - Global - Control Groups.

In the file https://github.com/ggtracker/sc2reader/blob/upstream/sc2reader/events/game.py there are some comments of confusion related to this issue related to "update_type".

def create_control_group_event(frame, pid, data):
    update_type = data["control_group_update"]
    if update_type == 0:
        return SetControlGroupEvent(frame, pid, data)
    elif update_type == 1:
        return AddToControlGroupEvent(frame, pid, data)
    elif update_type == 2:
        return GetControlGroupEvent(frame, pid, data)
    elif update_type == 3:
        # TODO: What could this be?!?
        return ControlGroupEvent(frame, pid, data)
    else:
        # No idea what this is but we're seeing update_types of 4 and 5 in 3.0
        return ControlGroupEvent(frame, pid, data)

From my basic testing, update_type == 4 is related to create-steal and update_type == 5 is related to add-steal. When units are removed from other control groups in this way, they also trigger another event of update_type == 3.

The SelectionTracker https://github.com/ggtracker/sc2reader/blob/upstream/sc2reader/engine/plugins/selection.py does not currently handle these update_types 3, 4 and 5 since they are simply "ControlGroupEvent".

That said, it is a bit more complicated because in sc2reader, a single "steal" command in-game generates a series of 4-5 events, including some SelectionEvent.

To reproduce the issue + details

I simply started a game and performed all of the types of commands.

  1. "created" 1 scv to control group 1
  2. "add" the command center to group 1
  3. "create-steal" command center to group 8
  4. "add-steal" all scvs to group 8

At the end the player.selection incorrectly contains 1 scv in group 1 and the rest are empty. The correct result is that group 1 is empty and group 8 and the current selection contains the command center and all scvs. The replay can be found at https://drop.sc/replay/23379541

Notice how the single create-steal command creates 5 events by sc2reader:

00.39	FightingFrog    ControlGroupEvent
00.39	FightingFrog    GetControlGroupEvent
00.39	FightingFrog    SelectionEvent[]
00.39	FightingFrog    SetControlGroupEvent
00.39	FightingFrog    SelectionEvent['CommandCenter [2CC0001]']

What are your thoughts on this?

@StoicLoofah
Copy link
Collaborator

StoicLoofah commented Aug 21, 2023

THis is addressed in #187

@dlithio
Copy link
Contributor

dlithio commented Aug 21, 2023

I think the only change required to get the SelectionTracker working is to properly handle the new control group event DeleteControlGroupEvent. When this event is registered on a control group it means that everything in the control group is removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants