public static bool DrinkPotion() { var legendaryPotions = Core.Inventory.Backpack.Where(i => i.InternalName.ToLower().Contains("healthpotion_legendary_")).ToList(); if (legendaryPotions.Any()) { Core.Logger.Verbose(LogCategory.None, "Using Potion", 0); var dynamicId = legendaryPotions.First().AnnId; InventoryManager.UseItem(dynamicId); SpellHistory.RecordSpell(new TrinityPower(SNOPower.DrinkHealthPotion)); SnapShot.Record(); return(true); } var potion = InventoryManager.BaseHealthPotion; if (potion != null) { Core.Logger.Verbose(LogCategory.None, "Using Potion", 0); InventoryManager.UseItem(potion.AnnId); SpellHistory.RecordSpell(new TrinityPower(SNOPower.DrinkHealthPotion)); SnapShot.Record(); return(true); } Core.Logger.Verbose(LogCategory.None, "No Available potions!", 0); return(false); }
public static async Task <CoroutineResult> DrinkPotion() { if (!ZetaDia.IsInGame || ZetaDia.Globals.IsLoadingWorld || ZetaDia.Globals.IsPlayingCutscene || ZetaDia.IsInTown || SpellHistory.TimeSinceUse(SNOPower.DrinkHealthPotion) <= TimeSpan.FromSeconds(30) || ZetaDia.Me == null || !ZetaDia.Me.IsFullyValid() || ZetaDia.Me.IsDead || Combat.TrinityCombat.Routines.Current == null) { return(CoroutineResult.NoAction); } if (ZetaDia.Me.HitpointsCurrentPct > Combat.TrinityCombat.Routines.Current.PotionHealthPct) { return(CoroutineResult.NoAction); } if (ZetaDia.Me.IsFeared || ZetaDia.Me.IsStunned || ZetaDia.Me.IsFrozen || ZetaDia.Me.IsBlind || ZetaDia.Me.CommonData .GetAttribute <bool>(ActorAttributeType.PowerImmobilize)) { s_logger.Warning($"[{nameof(DrinkPotion)}] Can't use potion while incapacitated!"); return(CoroutineResult.NoAction); } if (ActivePotion == null) { s_logger.Warning($"[{nameof(DrinkPotion)}] No Available potions!"); return(CoroutineResult.NoAction); } s_logger.Information($"[{nameof(DrinkPotion)}] Using Potion {ActivePotion.Name}"); InventoryManager.UseItem(ActivePotion.AnnId); SpellHistory.RecordSpell(new TrinityPower(SNOPower.DrinkHealthPotion)); SnapShot.Record(); return(CoroutineResult.Done); }