Exemple #1
0
 public override bool Stop()
 {
     ClearAggroList();
     ListDefensiveTarget.Clear();
     return(base.Stop());
 }
Exemple #2
0
        /// <summary>
        /// [Ganrod] Nidel: Find and get random target in radius for Defensive spell, like 1.90 EU off servers.
        /// <para>Get target only if:</para>
        /// <para>- same realm (based on ServerRules)</para>
        /// <para>- don't have effect</para>
        /// <para>- is alive</para>
        /// </summary>
        /// <param name="spell"></param>
        /// <returns></returns>
        public GameLiving GetDefensiveTarget(Spell spell)
        {
            foreach (GamePlayer player in Body.GetPlayersInRadius((ushort)spell.Range, Body.CurrentRegion.IsDungeon ? false : true))
            {
                if (GameServer.ServerRules.IsAllowedToAttack(Body, player, true))
                {
                    continue;
                }

                if (!player.IsAlive)
                {
                    continue;
                }

                if (LivingHasEffect(player, spell))
                {
                    if (ListDefensiveTarget.Contains(player))
                    {
                        ListDefensiveTarget.Remove(player);
                    }
                    continue;
                }

                if (player == GetPlayerOwner())
                {
                    return(player);
                }

                ListDefensiveTarget.Add(player);
            }
            foreach (GameNPC npc in Body.GetNPCsInRadius((ushort)spell.Range, Body.CurrentRegion.IsDungeon ? false : true))
            {
                if (GameServer.ServerRules.IsAllowedToAttack(Body, npc, true))
                {
                    continue;
                }

                if (!npc.IsAlive)
                {
                    continue;
                }

                if (LivingHasEffect(npc, spell))
                {
                    if (ListDefensiveTarget.Contains(npc))
                    {
                        ListDefensiveTarget.Remove(npc);
                    }
                    continue;
                }

                if (npc == Body)
                {
                    return(Body);
                }

                if (npc == GetLivingOwner())
                {
                    return(npc);
                }

                ListDefensiveTarget.Add(npc);
            }
            // Get one random target.
            return(ListDefensiveTarget.Count > 0 ? ListDefensiveTarget[Util.Random(ListDefensiveTarget.Count - 1)] : null);
        }