python-sc2 icon indicating copy to clipboard operation
python-sc2 copied to clipboard

Medivac boost isn't a buff

Open WickedFridge opened this issue 1 year ago • 2 comments

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)

WickedFridge avatar Dec 02 '24 16:12 WickedFridge

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 https://github.com/BurnySc2/python-sc2/blob/aa247cc3a89d72ef298e663627be5d57b930932a/sc2/units.py#L506-L518

BurnySc2 avatar Dec 06 '24 14:12 BurnySc2

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

WickedFridge avatar Jan 03 '25 10:01 WickedFridge