Conversation
client.py is appropiate place for unit unload function, most imports are already here and also many self._execute funcion are here Note: In unload example https://github.com/BurnySc2/python-sc2/blob/2e5d29671cf6ebcf78b1764c8153916b01c096ca/examples/protoss/single_unit_unload_test.py there is unit index option, which I think is unnecessary. Use scenario: we want to unload specific unit (ex. immortal out of stalkers), we iterate over transporter passengers to identify unit type or tag, so we have unit selected already which we pass to unload function, never store its index.
| self.client.unload_unit(transporter_unit, cargo_unit) | ||
| self.client.unload_unit(transporter_unit) # unloads first one |
There was a problem hiding this comment.
Why would you prefer this function to be in the client.py instead of bot_ai.py?
There was a problem hiding this comment.
bot_ai.py would be my second choice
In my first comment I list why client.py is my choice, what are arguments in favor of bot_ai.py?
| await self._execute( | ||
| action=sc_pb.RequestAction( | ||
| actions=[ | ||
| sc_pb.Action( | ||
| action_raw=raw_pb.ActionRaw( | ||
| unit_command=raw_pb.ActionRawUnitCommand(ability_id=0, unit_tags=[transporter_unit.tag]) | ||
| ) | ||
| ), | ||
| sc_pb.Action( | ||
| action_ui=ui_pb.ActionUI( | ||
| cargo_panel=ui_pb.ActionCargoPanelUnload(unit_index=unload_unit_index) | ||
| ) | ||
| ), | ||
| ] | ||
| ) | ||
| ) |
There was a problem hiding this comment.
This executes the command instantly. Is there a better way to bundle it with other unit commands?
Currently actions such as unit.move(position) and structure.train(unittype) are collected and sent once to the API at the end of the step. Is it also possible with this?
There was a problem hiding this comment.
It would be rare situation where someone use more than one unload command in same frame over a game.
The most usage I have seen is a bot that has 4 prisms and with human eye his unloads aren't synchronized.
client.py is appropiate place for unit unload function, most imports are already here and also many self._execute funcions are here
Note:
In unload example https://github.com/BurnySc2/python-sc2/blob/2e5d29671cf6ebcf78b1764c8153916b01c096ca/examples/protoss/single_unit_unload_test.py there is unit index option, which I think is unnecessary. Use scenario: we want to unload specific unit (ex. immortal out of stalkers), we iterate over transporter passengers to identify unit type or tag, so we have unit selected already which we pass to unload function, never store its index.