Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Medivac boost isn't a buff #206

Open
WickedFridge opened this issue Dec 2, 2024 · 2 comments
Open

Medivac boost isn't a buff #206

WickedFridge opened this issue Dec 2, 2024 · 2 comments
Labels
question Further information is requested

Comments

@WickedFridge
Copy link

When trying to check if Medivac could use their boost, I tried checking if the medivac was actually boosted, checking its buffs. I've found the Medivacspeedboost buff in the list, but when a medivac is boosted, it doesn't have any buffs.
my code reads as follow but doesn't work (as medivac.buffs is always empty) :

if (not medivac.has_buff(BuffId.MEDIVACSPEEDBOOST)):
    medivac(AbilityId.EFFECT_MEDIVACIGNITEAFTERBURNERS)
@BurnySc2
Copy link
Owner

BurnySc2 commented Dec 6, 2024

The Unit object don't update themselves. My guess is that you don't refresh the Unit object via

medivac = self.units(UnitTypeId.MEDIVAC)[0]

You can verify this by checking if medivac.position is the same - then you are using an outdated Unit object.
The unit.tag is unique so you can find the medivac in the next frame/iteration (assuming it was not destroyed) via

python-sc2/sc2/units.py

Lines 506 to 518 in aa247cc

def tags_in(self, other: Iterable[int]) -> Units:
"""Filters all units that have their tags in the 'other' set/list/dict
Example::
my_inject_queens = self.units.tags_in(self.queen_tags_assigned_to_do_injects)
# Do not use the following as it is slower because it first loops over all units to filter out if they are queens and loops over those again to check if their tags are in the list/set
my_inject_queens_slow = self.units(QUEEN).tags_in(self.queen_tags_assigned_to_do_injects)
:param other:
"""
return self.filter(lambda unit: unit.tag in other)

@BurnySc2 BurnySc2 added the question Further information is requested label Dec 6, 2024
@WickedFridge
Copy link
Author

Actually the medivac I use is different in each iteration, so I don't have an explanation as to why that is

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants