Ejemplo n.º 1
0
        /// <summary>
        /// [true] if explodable else [false]
        /// </summary>
        /// <param name="powderKeg">the powder keg</param>
        /// <param name="useParrley">if set to <c>true</c> [useParrley] else melee.</param>
        /// <returns></returns>
        private bool IsPowderKegExplodable(PowderKeg powderKeg, bool useParrley)
        {
            if (useParrley && powderKeg.Minion.Distance(Player) > Q.Range)
            {
                return(false);
            }

            if (!useParrley && powderKeg.Minion.Distance(Player) > Orbwalking.GetRealAutoAttackRange(powderKeg.Minion))
            {
                return(false);
            }

            if (powderKeg.Minion.Health <= 1f)
            {
                return(true);
            }

            var travelTime     = useParrley ? GetParrleyTravelTime(powderKeg.Minion) : Player.AttackDelay;
            var activationTime = powderKeg.ActivationTime;
            var remainder      = activationTime - Environment.TickCount - travelTime;

            return(remainder <= 0);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Finds the closest powder keg.
        /// </summary>
        /// <param name="keg">The keg.</param>
        /// <param name="useParrley">if set to <c>true</c> [use parrley].</param>
        /// <param name="explodable">if set to <c>true</c> [explodable].</param>
        /// <returns></returns>
        private PowderKeg FindClosestPowderKeg(PowderKeg keg, bool useParrley, bool explodable)
        {
            var powderKeg = _powderKegs
                            .OrderBy(k => k.Minion.Distance(keg.Minion))
                            .FirstOrDefault(k => k.Minion.Distance(keg.Minion) <= PowderKegLinkRadius);

            if (powderKeg == null)
            {
                return(null);
            }

            if (!explodable)
            {
                return(powderKeg);
            }

            if (IsPowderKegExplodable(powderKeg, useParrley))
            {
                return(powderKeg);
            }

            return(FindClosestLinkedPowderKeg(powderKeg, useParrley, true, null));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Recursive call to find the closest linked powder keg.
        /// </summary>
        /// <param name="powderKeg">The powder keg.</param>
        /// <param name="useParrley">if set to <c>true</c> [use parrley].</param>
        /// <param name="explodable">if set to <c>true</c> [explodable].</param>
        /// <param name="blacklistPowderKegs">The blacklist powder kegs.</param>
        /// <returns></returns>
        private Tuple<float, PowderKeg, bool> RecursiveClosestLinkedPowderKeg(PowderKeg powderKeg, bool useParrley, bool explodable, ICollection<int> blacklistPowderKegs)
        {
            blacklistPowderKegs.Add(powderKeg.NetworkId);

            var linkedPowderKegs = _powderKegs
                .Where(k => !blacklistPowderKegs.Contains(k.NetworkId) && k.Minion.Distance(powderKeg.Minion) <= PowderKegLinkRadius)
                .OrderBy(k => k.Minion.Distance(Player))
                .ToList();

            if (!linkedPowderKegs.Any())
            {
                return null;
            }

            Tuple<float, PowderKeg, bool> closest = null;

            foreach (var keg in linkedPowderKegs)
            {
                // If we want explodable powder kegs return the closest first instance
                if (explodable)
                {
                    if (IsPowderKegExplodable(keg, useParrley))
                    {
                        return new Tuple<float, PowderKeg, bool>(keg.Minion.Distance(Player), keg, true);
                    }
                }

                // Get the closest linked powder keg
                var closestPowderKeg = RecursiveClosestLinkedPowderKeg(keg, useParrley, explodable, blacklistPowderKegs);
                if (closestPowderKeg == null)
                {
                    continue;
                }

                // Check if the closest powder keg is explodable
                if (explodable && closestPowderKeg.Item3)
                {
                    return closestPowderKeg;
                }

                // If closer than closest version update
                if (closest == null || closest.Item1 < closestPowderKeg.Item1)
                {
                    closest = closestPowderKeg;
                }
            }

            return explodable ? null : closest;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// [true] if explodable else [false]
        /// </summary>
        /// <param name="powderKeg">the powder keg</param>
        /// <param name="useParrley">if set to <c>true</c> [useParrley] else melee.</param>
        /// <returns></returns>
        private bool IsPowderKegExplodable(PowderKeg powderKeg, bool useParrley)
        {
            if (useParrley && powderKeg.Minion.Distance(Player) > Q.Range)
            {
                return false;
            }

            if (!useParrley && powderKeg.Minion.Distance(Player) > Orbwalking.GetRealAutoAttackRange(powderKeg.Minion))
            {
                return false;
            }

            if (powderKeg.Minion.Health <= 1f)
            {
                return true;
            }

            var travelTime = useParrley ? GetParrleyTravelTime(powderKeg.Minion) : Player.AttackDelay;
            var activationTime = powderKeg.ActivationTime;
            var remainder = activationTime - Environment.TickCount - travelTime;

            return remainder <= 0;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Called when [GameObject OnCreate]
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void GameObject_OnCreate(GameObject sender, EventArgs args)
        {
            var minion = sender as Obj_AI_Minion;
            if (minion == null || !minion.CharData.BaseSkinName.ToLower().Contains("gangplankbarrel"))
            {
                return;
            }

            var powderKeg = new PowderKeg(minion, GetPowderKegActivationTime(Environment.TickCount));
            _powderKegs.Add(powderKeg);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Finds the closest powder keg.
        /// </summary>
        /// <param name="keg">The keg.</param>
        /// <param name="useParrley">if set to <c>true</c> [use parrley].</param>
        /// <param name="explodable">if set to <c>true</c> [explodable].</param>
        /// <returns></returns>
        private PowderKeg FindClosestPowderKeg(PowderKeg keg, bool useParrley, bool explodable)
        {
            var powderKeg = _powderKegs
                .OrderBy(k => k.Minion.Distance(keg.Minion))
                .FirstOrDefault(k => k.Minion.Distance(keg.Minion) <= PowderKegLinkRadius);

            if (powderKeg == null)
            {
                return null;
            }

            if (!explodable)
            {
                return powderKeg;
            }

            if (IsPowderKegExplodable(powderKeg, useParrley))
            {
                return powderKeg;
            }

            return FindClosestLinkedPowderKeg(powderKeg, useParrley, true, null);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Finds the closest linked powder keg.
        /// </summary>
        /// <param name="powderKeg">The powder keg.</param>
        /// <param name="useParrley">if set to <c>true</c> [use parrley].</param>
        /// <param name="explodable">if set to <c>true</c> [explodable].</param>
        /// <param name="blacklistPowderKegs">The blacklist powder kegs.</param>
        /// <returns></returns>
        private PowderKeg FindClosestLinkedPowderKeg(PowderKeg powderKeg, bool useParrley, bool explodable, IList<int> blacklistPowderKegs)
        {
            if (blacklistPowderKegs == null)
            {
                blacklistPowderKegs = new List<int>();
            }

            blacklistPowderKegs.Add(powderKeg.NetworkId);

            var closest = RecursiveClosestLinkedPowderKeg(powderKeg, useParrley, explodable, blacklistPowderKegs);

            return closest != null ? closest.Item2 : null;
        }