Example #1
0
        public bool TryToHeal()
        {
            if (this.m_Mobile.Summoned)
                return false;
            else if (DateTime.UtcNow < this.m_NextHealTime)
                return false;

            int diff = this.m_Mobile.HitsMax - this.m_Mobile.Hits;
            diff = ((this.m_Mobile.HitsMax * (100 - diff)) / 100);
            diff = 100 - diff;

            if ((int)(Utility.RandomDouble() * 100.0) > diff)
                return false;

            Spell spell = null;
            this.m_NextHealTime = DateTime.UtcNow + TimeSpan.FromSeconds(20);

            if (this.m_CanUseMagery)
            {
                if (this.m_Mobile.Poisoned)
                    spell = new CureSpell(this.m_Mobile, null);

                spell = new GreaterHealSpell(this.m_Mobile, null);

                if (spell == null)
                    spell = new HealSpell(this.m_Mobile, null);
            }
            else if (this.m_CanUseNecromancy)
            {
                this.m_Mobile.UseSkill(SkillName.SpiritSpeak);
                this.m_NextHealTime = DateTime.UtcNow + TimeSpan.FromSeconds(10);
            }
            else if (this.m_CanUseChivalry)
            {
                if (this.m_Mobile.Poisoned)
                    spell = new CleanseByFireSpell(this.m_Mobile, null);
                else
                    spell = new CloseWoundsSpell(this.m_Mobile, null);
            }
            else if (this.m_CanUseMystic)
            {
                spell = new CleansingWindsSpell(this.m_Mobile, null);
            }
            else if (this.m_Mobile.Skills[SkillName.Healing].Value > 10.0)
            {
                int delay = (int)(5.0 + (0.5 * ((120 - this.m_Mobile.Dex) / 10)));
                new BandageContext(this.m_Mobile, this.m_Mobile, TimeSpan.FromSeconds(delay), false);
                this.m_NextHealTime = DateTime.UtcNow + TimeSpan.FromSeconds(delay + 1);
                return true;
            }

            if (spell != null)
                spell.Cast();

            return true;
        }
Example #2
0
		public override bool DoActionCombat()
		{
			bool ret = base.DoActionCombat();
			
			if ( m_Mobile.Spell == null && DateTime.Now > m_NextCastTime )
			{
				Spell spell = null;
				
				if ( m_Mobile.Poisoned ) // Top cast priority is cure
				{
					m_Mobile.DebugSay( "I am going to cure myself" );

					spell = new CleanseByFireSpell( m_Mobile, null );
				}
				else if ( FindDispelTarget( true ) != null )
				{
					m_Mobile.DebugSay( "I am going to area dispel" );

					spell = new DispelEvilSpell( m_Mobile, null );					
				}
				else
				{
					spell = ChooseSpell( m_Mobile.Combatant );
				}
				
				if ( spell != null )
					spell.Cast();
					
				TimeSpan delay;

				if ( spell is DispelEvilSpell )
					delay = TimeSpan.FromSeconds( m_Mobile.ActiveSpeed );
				else
					delay = GetDelay();
					
				m_NextCastTime = DateTime.Now + delay;
			}			

			return ret;
		}
Example #3
0
 public InternalTarget(CleanseByFireSpell owner) : base(Core.ML ? 10 : 12, false, TargetFlags.Beneficial)
 {
     m_Owner = owner;
 }
Example #4
0
 public InternalTarget(CleanseByFireSpell owner)
     : base(Core.ML ? 10 : 12, false, TargetFlags.Beneficial)
 {
     this.m_Owner = owner;
 }
Example #5
0
 public InternalTarget(CleanseByFireSpell owner)
     : base(10, false, TargetFlags.Beneficial)
 {
     this.m_Owner = owner;
 }
        public virtual Spell ChooseSpell( Mobile c )
        {
            if ( !SmartAI )
            {
                if ( !m_Mobile.Summoned && ScaleByHealing( HealChance ) > Utility.RandomDouble() )
                {
                    if ( m_Mobile.Hits < (m_Mobile.HitsMax - 50) )
                        new CloseWoundsSpell( m_Mobile, null ).Cast();
                    else if ( m_Mobile.Hits < (m_Mobile.HitsMax - 10) )
                        new CloseWoundsSpell( m_Mobile, null ).Cast();
                }

                return GetRandomSpell();
            }

            Spell spell = null;

            int healChance = (m_Mobile.Hits == 0 ? m_Mobile.HitsMax : (m_Mobile.HitsMax / m_Mobile.Hits));

            if ( m_Mobile.Summoned )
                healChance = 0;

            switch ( Utility.Random( 5 + healChance ) )
            {
                case 0: // Heal  myself
                {
                    if ( !m_Mobile.Summoned )
                    {
                        if ( m_Mobile.Hits < (m_Mobile.HitsMax - 50) )
                            new CloseWoundsSpell( m_Mobile, null ).Cast();
                        else if ( m_Mobile.Hits < (m_Mobile.HitsMax - 10) )
                            new CloseWoundsSpell( m_Mobile, null ).Cast();
                    }

                    break;
                }
                case 1: // Clean myself from Poison
                {
                    if ( m_Mobile.Poisoned )
                        spell = new CleanseByFireSpell( m_Mobile, null );

                    break;
                }
                case 2: // Select a random paladin spell to allow me to do some damage
                {
                    spell = GetRandomSpell();

                    break;
                }
                case 3: // Set up a combo of spell attacks
                {
                    if ( m_Mobile.Mana < 30 && m_Mobile.Mana > 15 )
                    {
                        if ( c.Paralyzed )
                        {
                            m_Mobile.DebugSay( "I am going to meditate" );

                            m_Mobile.UseSkill( SkillName.Meditation );
                        }
                        else if ( !c.Paralyzed ) //Not very paladin like, but.. I cant think of anything right now.
                        {
                            if ( Utility.Random( 2 ) == 0 )
                            {
                                m_Combo = 2;
                                spell = new EnemyOfOneSpell( m_Mobile, null );
                            }
                        }
                    }
                    else if ( m_Mobile.Mana > 30 && m_Mobile.Mana < 80 )
                    {
                        if ( Utility.Random( 2 ) == 0 )
                        {
                            m_Combo = 0;
                            spell = new DispelEvilSpell( m_Mobile, null ); //Necros are gonna hate this one :P
                        }
                        else
                        {
                            m_Combo = 1;
                            spell = new HolyLightSpell( m_Mobile, null ); //Blind them evil doers!!!
                        }

                    }
                     break;
                }
                case 4: //Combo to hurt them like crazy, fury + enemy of one ...pitty i cant think how to make it do a 3 spell combo
                {
                    if ( m_Mobile.Mana > 80 ) //Needs lotsa mana... so make pallys loaded in mana
                    {
                        if ( Utility.Random( 2 ) == 0 && !c.Paralyzed && !c.Frozen )
                        {
                            m_Combo = 0;
                            spell = new DivineFurySpell( m_Mobile, null );
                        }
                        else
                        {
                            m_Combo = 1;
                            spell = new EnemyOfOneSpell( m_Mobile, null );
                        }
                    }
                    break;
                }

            }

            return spell;
        }
        public override bool DoActionCombat()
        {
            Mobile c = m_Mobile.Combatant;
            m_Mobile.Warmode = true;

            if ( c == null || c.Deleted || !c.Alive || c.IsDeadBondedPet || !m_Mobile.CanSee( c ) || !m_Mobile.CanBeHarmful( c, false ) || c.Map != m_Mobile.Map )
            {
                // Our combatant is deleted, dead, hidden, or we cannot hurt them
                // Try to find another combatant

                if ( AcquireFocusMob( m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true ) )
                {
                    if ( m_Mobile.Debug )
                        m_Mobile.DebugSay( "Something happened to my combatant, so I am going to fight {0}", m_Mobile.FocusMob.Name );

                    m_Mobile.Combatant = c = m_Mobile.FocusMob;
                    m_Mobile.FocusMob = null;
                }
                else
                {
                    m_Mobile.DebugSay( "Something happened to my combatant, and nothing is around. I am on guard." );
                    Action = ActionType.Guard;
                    return true;
                }
            }

            if ( !m_Mobile.InLOS( c ) )
            {
                if ( AcquireFocusMob( m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true ) )
                {
                    m_Mobile.Combatant = c = m_Mobile.FocusMob;
                    m_Mobile.FocusMob = null;
                }
            }

            if ( SmartAI && !m_Mobile.StunReady && m_Mobile.Skills[SkillName.Swords].Value >= 80.0 && m_Mobile.Skills[SkillName.Anatomy].Value >= 80.0 )
                EventSink.InvokeStunRequest( new StunRequestEventArgs( m_Mobile ) );

            if ( !m_Mobile.InRange( c, m_Mobile.RangePerception ) )
            {
                // They are somewhat far away, can we find something else?

                if ( AcquireFocusMob( m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true ) )
                {
                    m_Mobile.Combatant = m_Mobile.FocusMob;
                    m_Mobile.FocusMob = null;
                }
                else if ( !m_Mobile.InRange( c, m_Mobile.RangePerception * 3 ) )
                {
                    m_Mobile.Combatant = null;
                }

                c = m_Mobile.Combatant;

                if ( c == null )
                {
                    m_Mobile.DebugSay( "My combatant has fled, so I am on guard" );
                    Action = ActionType.Guard;

                    return true;
                }
            }

            if ( !m_Mobile.Controlled && !m_Mobile.Summoned )
            {
                if ( m_Mobile.Hits < m_Mobile.HitsMax * 20/100 )
                {
                    // We are low on health, should we flee?

                    bool flee = false;

                    if ( m_Mobile.Hits < c.Hits )
                    {
                        // We are more hurt than them

                        int diff = c.Hits - m_Mobile.Hits;

                        flee = ( Utility.Random( 0, 100 ) > (10 + diff) ); // (10 + diff)% chance to flee
                    }
                    else
                    {
                        flee = Utility.Random( 0, 100 ) > 10; // 10% chance to flee
                    }

                    if ( flee )
                    {
                        if ( m_Mobile.Debug )
                            m_Mobile.DebugSay( "I am going to flee from {0}", c.Name );

                        Action = ActionType.Flee;
                        return true;
                    }
                }
            }

            if ( m_Mobile.Spell == null && DateTime.Now > m_NextCastTime && m_Mobile.InRange( c, 12 ) )
            {
                // We are ready to cast a spell

                Spell spell = null;
                Mobile toDispel = FindDispelTarget( true );

                if ( m_Mobile.Poisoned ) // Top cast priority is cure
                {
                    spell = new CleanseByFireSpell( m_Mobile, null );
                }
                else if ( toDispel != null ) // Paladins cant dispel... but its useful.. I know.. Im cheating players this way...
                {
                    spell = DoDispel( toDispel );
                }
                else if ( SmartAI && m_Combo != -1 ) // We are doing a spell combo
                {
                    spell = DoCombo( c );
                }
                else if ( SmartAI && (c.Spell is HealSpell || c.Spell is GreaterHealSpell) && !c.Poisoned ) // They are going to heal with a spell... disrupt it the only way we can...
                {
                    spell = new DivineFurySpell( m_Mobile, null ); // ... by going nuts on them.
                }
                else if ( SmartAI && ( c.Spell is BloodOathSpell || c.Spell is EvilOmenSpell || c.Spell is StrangleSpell || c.Spell is CurseSpell || c.Spell is WeakenSpell || c.Spell is ClumsySpell ) ) //Are we cursed by a necro or a mage?
                {
                    spell = new RemoveCurseSpell( m_Mobile, null ); // Lets get rid of the curse then.
                }
                else
                {
                    spell = ChooseSpell( c );
                }

                // Now we have a spell picked
                // Move first before casting

                if ( SmartAI && toDispel != null )
                {
                    if ( m_Mobile.InRange( toDispel, 10 ) )
                        RunFrom( toDispel );
                    else if ( !m_Mobile.InRange( toDispel, 12 ) )
                        RunTo( toDispel );
                }
                else
                {
                    RunTo( c );
                }

                if ( spell != null && spell.Cast() )
                {
                    TimeSpan delay;

                    if ( SmartAI || ( spell is DispelSpell ) )
                    {
                        delay = TimeSpan.FromSeconds( m_Mobile.ActiveSpeed );
                    }
                    else
                    {
                        double del = ScaleByChivalry( 3.0 );
                        double min = 6.0 - (del * 0.75);
                        double max = 6.0 - (del * 1.25);

                        delay = TimeSpan.FromSeconds( min + ((max - min) * Utility.RandomDouble()) );
                    }

                    m_NextCastTime = DateTime.Now + delay;
                }
            }
            else if ( m_Mobile.Spell == null || !m_Mobile.Spell.IsCasting )
            {
                RunTo( c );
            }

            return true;
        }
Example #8
0
 public InternalTarget( CleanseByFireSpell owner )
     : base(12, false, TargetFlags.Beneficial)
 {
     m_Owner = owner;
 }
Example #9
0
 public InternalTarget(CleanseByFireSpell owner) : base(owner.SpellRange, false, TargetFlags.Beneficial)
 {
     m_Owner = owner;
 }