Server.Mobiles.MageAI.FindDispelTarget C# (CSharp) Méthode

FindDispelTarget() public méthode

public FindDispelTarget ( bool activeOnly ) : Mobile
activeOnly bool
Résultat Mobile
		public Mobile FindDispelTarget( bool activeOnly )
		{
			if( m_Mobile.Deleted || m_Mobile.Int < 95 || CanDispel( m_Mobile ) || m_Mobile.AutoDispel )
				return null;

			if( activeOnly )
			{
				List<AggressorInfo> aggressed = m_Mobile.Aggressed;
				List<AggressorInfo> aggressors = m_Mobile.Aggressors;

				Mobile active = null;
				double activePrio = 0.0;

				Mobile comb = m_Mobile.Combatant;

				if( comb != null && !comb.Deleted && comb.Alive && !comb.IsDeadBondedPet && m_Mobile.InRange( comb, 12 ) && CanDispel( comb ) )
				{
					active = comb;
					activePrio = m_Mobile.GetDistanceToSqrt( comb );

					if( activePrio <= 2 )
						return active;
				}

				for( int i = 0; i < aggressed.Count; ++i )
				{
					AggressorInfo info = aggressed[ i ];
					Mobile m = info.Defender;

					if( m != comb && m.Combatant == m_Mobile && m_Mobile.InRange( m, 12 ) && CanDispel( m ) )
					{
						double prio = m_Mobile.GetDistanceToSqrt( m );

						if( active == null || prio < activePrio )
						{
							active = m;
							activePrio = prio;

							if( activePrio <= 2 )
								return active;
						}
					}
				}

				for( int i = 0; i < aggressors.Count; ++i )
				{
					AggressorInfo info = aggressors[ i ];
					Mobile m = info.Attacker;

					if( m != comb && m.Combatant == m_Mobile && m_Mobile.InRange( m, 12 ) && CanDispel( m ) )
					{
						double prio = m_Mobile.GetDistanceToSqrt( m );

						if( active == null || prio < activePrio )
						{
							active = m;
							activePrio = prio;

							if( activePrio <= 2 )
								return active;
						}
					}
				}

				return active;
			}
			else
			{
				Map map = m_Mobile.Map;

				if( map != null )
				{
					Mobile active = null, inactive = null;
					double actPrio = 0.0, inactPrio = 0.0;

					Mobile comb = m_Mobile.Combatant;

					if( comb != null && !comb.Deleted && comb.Alive && !comb.IsDeadBondedPet && CanDispel( comb ) )
					{
						active = inactive = comb;
						actPrio = inactPrio = m_Mobile.GetDistanceToSqrt( comb );
					}

					foreach( Mobile m in m_Mobile.GetMobilesInRange( 12 ) )
					{
						if( m != m_Mobile && CanDispel( m ) )
						{
							double prio = m_Mobile.GetDistanceToSqrt( m );

							if( !activeOnly && ( inactive == null || prio < inactPrio ) )
							{
								inactive = m;
								inactPrio = prio;
							}

							if( ( m_Mobile.Combatant == m || m.Combatant == m_Mobile ) && ( active == null || prio < actPrio ) )
							{
								active = m;
								actPrio = prio;
							}
						}
					}

					return active != null ? active : inactive;
				}
			}

			return null;
		}