Dentosal / python-sc2

A StarCraft II bot api client library for Python 3
MIT License
586 stars 182 forks source link

Morph archon #133

Closed ryanthompson591 closed 5 years ago

ryanthompson591 commented 6 years ago

Anyone have sample code for morphing an archon?

Is it impossible? https://github.com/Blizzard/s2client-api/issues/279

BurnySc2 commented 6 years ago

Hey, no still no reply from Blizzard on that topic.

As long as the high/dark templars cannot target another one using that ability (like similar to how a SCV repair command is given), I'm pretty sure that morphing archons will stay impossible via API without using the UI Feature layer (for clicking on the "morph archon" button). Even with the clicking, you have to actually select at least two templars first before the button is clickable. For that you'd have to move the camera to the locations of the templars too. That would be the only workaround that could work, but I haven't tested that and seems too complicated instead of waiting for a fix on blizzard's side.

BurnySc2 commented 5 years ago

Since StarCraft 2 patch 4.6.2, this works now. Using a command similar to this would morph an archons (at current state of the library):

if self.units(UnitTypeId.HIGHTEMPLAR).idle.ready.amount >= 2:
    ht1 = self.units(UnitTypeId.HIGHTEMPLAR).idle.ready.random
    ht2 = next((ht for ht in self.units(UnitTypeId.HIGHTEMPLAR).idle.ready if ht.tag != ht1.tag), None)
    if ht2:
        await self.chat_send("Sending morph command, morph archon ability value == {}".format(AbilityId.MORPH_ARCHON.value))
        from s2clientprotocol import raw_pb2 as raw_pb
        from s2clientprotocol import sc2api_pb2 as sc_pb
        command = raw_pb.ActionRawUnitCommand(
                ability_id=AbilityId.MORPH_ARCHON.value,
                unit_tags=[ht1.tag, ht2.tag],
                queue_command=False
            )
        action = raw_pb.ActionRaw(unit_command=command)
        await self._client._execute(action=sc_pb.RequestAction(
                actions=[sc_pb.Action(action_raw=action)]
            ))
if self.units(UnitTypeId.ARCHON).amount > 0:
    await self.chat_send("Archon detected!")