ggtracker / ggtracker/sc2reader

SelectionTracker does not take "control group stealing" into account

Open
#183 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
169
Forks
152
PR merge metrics
No merged PRs in 30d

Description

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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in sc2reader/events/game.py by tracing update_types 3, 4, and 5, then inspect the SelectionTracker in sc2reader/engine/plugins/selection.py while replaying the linked example. Done means control-group stealing updates the affected groups and current selection so the reproduced create-steal and add-steal commands produce the stated group contents.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.