Skip to content

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

@tommwa

Description

@tommwa
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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions