public static bool IsKnownAndReady(this SpellData spell, int remainingTimeInMs = 0)
 {
     return(spell.IsKnown() && spell.IsReady(remainingTimeInMs));
 }
Esempio n. 2
0
        public static async Task <bool> Raise(
            SpellData spell,
            bool SwiftcastRes,
            bool SlowcastRes,
            bool ResOutOfCombat,
            // isSwiftcast, continue
            Func <bool, Task <bool> > extensions = null
            )
        {
            if (!Globals.InParty)
            {
                return(false);
            }

            if (!spell.IsKnown())
            {
                return(false);
            }

            if (Core.Me.CurrentMana < spell.Cost)
            {
                return(false);
            }

            var deadList = Group.DeadAllies.Where(u => u.CurrentHealth == 0 &&
                                                  !u.HasAura(Auras.Raise) &&
                                                  u.Distance(Core.Me) <= 30 &&
                                                  u.IsVisible &&
                                                  u.InLineOfSight() &&
                                                  u.IsTargetable)
                           .OrderByDescending(r => r.GetResurrectionWeight());

            var deadTarget = deadList.FirstOrDefault();

            if (deadTarget == null)
            {
                return(false);
            }

            if (Globals.PartyInCombat)
            {
                if (SwiftcastRes && Spells.Swiftcast.IsKnownAndReady())
                {
                    // Prevent burning switftcast if no mana to actually rez.
                    if (!ActionManager.CanCast(spell, deadTarget))
                    {
                        return(false);
                    }

                    if (await Swiftcast())
                    {
                        while (Core.Me.HasAura(Auras.Swiftcast))
                        {
                            if (extensions != null && !await extensions.Invoke(true))
                            {
                                return(false);
                            }
                            if (await spell.CastAura(deadTarget, Auras.Raise))
                            {
                                return(true);
                            }
                            await Coroutine.Yield();
                        }
                    }
                }
            }

            if (Globals.PartyInCombat && SlowcastRes || !Globals.PartyInCombat && ResOutOfCombat)
            {
                if (extensions != null && !await extensions.Invoke(false))
                {
                    return(false);
                }
                return(await spell.CastAura(deadTarget, Auras.Raise));
            }

            return(false);
        }