Dentosal / python-sc2

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

Can't get _game data for `LURKER` or `LURKERDEN` #207

Closed Lambdanaut closed 5 years ago

Lambdanaut commented 5 years ago

It seems that self._game_data.units doesn't provide any data for constants.LURKER(id of 911) or constants.LURKERDEN(id of 901)

I found this bug while attempting to run can_afford on LURKER and LURKERDEN

>>> self.can_afford(constants.LURKERDEN) 

Traceback (most recent call last):
File "/Users/username/.pyenv/versions/3.6.5/lib/python3.6/site-packages/sc2/bot_ai.py", line 262, in can_afford    
    unit = self._game_data.units[item_id.value]
KeyError: 901

It seems that this bug is also keeping me from building Lurkers and Lurker Dens

Traceback (most recent call last):
  File "/Users/jthomas/.pyenv/versions/3.6.5/lib/python3.6/site-packages/sc2/main.py", line 63, in _play_game_ai
    await ai.on_step(iteration)
  File "/Users/jthomas/git/lambdanaut-sc2/lambdanaut/bot.py", line 1316, in on_step
    await self.build_manager.run()
  File "/Users/jthomas/git/lambdanaut-sc2/lambdanaut/bot.py", line 613, in run
    await self.create_build_target(current_build_target)
  File "/Users/jthomas/git/lambdanaut-sc2/lambdanaut/bot.py", line 485, in create_build_target
    self.bot.actions.append(hydralisk_dens.random.build(build_target))
  File "/Users/jthomas/.pyenv/versions/3.6.5/lib/python3.6/site-packages/sc2/unit.py", line 500, in build
    return self(self._game_data.units[unit.value].creation_ability.id, *args, **kwargs)
KeyError: 901
BurnySc2 commented 5 years ago

Hey, have you tried using these instead?

https://github.com/Dentosal/python-sc2/blob/889ab5097f8d0ece6d376d6d19e1ddac8044f051/sc2/ids/unit_typeid.py#L508-L511

The normal lurker IDs might be campaign or coop related.

Lambdanaut commented 5 years ago

That works! Thanks Burny 👍 :)