Medivac boost isn't a buff
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)
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
Actually the medivac I use is different in each iteration, so I don't have an explanation as to why that is