Fixes casting checks
This commit is contained in:
parent
7ea00fbf4f
commit
03dd5f1926
431 changed files with 5616 additions and 6250 deletions
|
|
@ -10,49 +10,49 @@ namespace Server.Mobiles
|
|||
public BerserkAI(BaseCreature m) : base (m)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public override bool DoActionWander()
|
||||
{
|
||||
m_Mobile.DebugSay( "I have No Combatant" );
|
||||
|
||||
if( AcquireFocusMob( m_Mobile.RangePerception, FightMode.Closest, false, true, true) )
|
||||
|
||||
if ( AcquireFocusMob( m_Mobile.RangePerception, FightMode.Closest, false, true, true) )
|
||||
{
|
||||
if ( m_Mobile.Debug )
|
||||
m_Mobile.DebugSay( "I have detected " + m_Mobile.FocusMob.Name + " and I will attack" );
|
||||
|
||||
m_Mobile.Combatant = m_Mobile.FocusMob;
|
||||
Action = ActionType.Combat;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
base.DoActionWander();
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public override bool DoActionCombat()
|
||||
{
|
||||
if( m_Mobile.Combatant == null || m_Mobile.Combatant.Deleted )
|
||||
if ( m_Mobile.Combatant == null || m_Mobile.Combatant.Deleted )
|
||||
{
|
||||
m_Mobile.DebugSay("My combatant is deleted");
|
||||
Action = ActionType.Guard;
|
||||
return true;
|
||||
}
|
||||
|
||||
if( WalkMobileRange( m_Mobile.Combatant, 1, true, m_Mobile.RangeFight, m_Mobile.RangeFight ) )
|
||||
if ( WalkMobileRange( m_Mobile.Combatant, 1, true, m_Mobile.RangeFight, m_Mobile.RangeFight ) )
|
||||
{
|
||||
// Be sure to face the combatant
|
||||
m_Mobile.Direction = m_Mobile.GetDirectionTo( m_Mobile.Combatant.Location );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( m_Mobile.Combatant != null )
|
||||
if ( m_Mobile.Combatant != null )
|
||||
{
|
||||
if ( m_Mobile.Debug )
|
||||
m_Mobile.DebugSay("I am still not in range of " + m_Mobile.Combatant.Name);
|
||||
|
||||
if( (int) m_Mobile.GetDistanceToSqrt( m_Mobile.Combatant ) > m_Mobile.RangePerception + 1 )
|
||||
if ( (int) m_Mobile.GetDistanceToSqrt( m_Mobile.Combatant ) > m_Mobile.RangePerception + 1 )
|
||||
{
|
||||
if ( m_Mobile.Debug )
|
||||
m_Mobile.DebugSay( "I have lost " + m_Mobile.Combatant.Name );
|
||||
|
|
@ -62,10 +62,10 @@ namespace Server.Mobiles
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public override bool DoActionGuard()
|
||||
{
|
||||
if ( AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, true, true ) )
|
||||
|
|
|
|||
|
|
@ -25,10 +25,10 @@ namespace Server.Mobiles
|
|||
|
||||
public override bool Think()
|
||||
{
|
||||
if( m_Mobile.Deleted )
|
||||
if ( m_Mobile.Deleted )
|
||||
return false;
|
||||
|
||||
if( ProcessTarget() )
|
||||
if ( ProcessTarget() )
|
||||
return true;
|
||||
else
|
||||
return base.Think();
|
||||
|
|
@ -55,7 +55,7 @@ namespace Server.Mobiles
|
|||
|
||||
public override bool DoActionWander()
|
||||
{
|
||||
if( AcquireFocusMob( m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true ) )
|
||||
if ( AcquireFocusMob( m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true ) )
|
||||
{
|
||||
m_Mobile.DebugSay( "I am going to attack {0}", m_Mobile.FocusMob.Name );
|
||||
|
||||
|
|
@ -63,7 +63,7 @@ namespace Server.Mobiles
|
|||
Action = ActionType.Combat;
|
||||
m_NextCastTime = Core.TickCount;
|
||||
}
|
||||
else if( SmartAI && m_Mobile.Mana < m_Mobile.ManaMax && !m_Mobile.Meditating )
|
||||
else if ( SmartAI && m_Mobile.Mana < m_Mobile.ManaMax && !m_Mobile.Meditating )
|
||||
{
|
||||
m_Mobile.DebugSay( "I am going to meditate" );
|
||||
|
||||
|
|
@ -77,11 +77,11 @@ namespace Server.Mobiles
|
|||
|
||||
base.DoActionWander();
|
||||
|
||||
if( Utility.RandomDouble() < 0.05 )
|
||||
if ( Utility.RandomDouble() < 0.05 )
|
||||
{
|
||||
Spell spell = CheckCastHealingSpell();
|
||||
|
||||
if( spell != null )
|
||||
if ( spell != null )
|
||||
spell.Cast();
|
||||
}
|
||||
}
|
||||
|
|
@ -92,33 +92,33 @@ namespace Server.Mobiles
|
|||
private Spell CheckCastHealingSpell()
|
||||
{
|
||||
// If I'm poisoned, always attempt to cure.
|
||||
if( m_Mobile.Poisoned )
|
||||
if ( m_Mobile.Poisoned )
|
||||
return new CureSpell( m_Mobile, null );
|
||||
|
||||
// Summoned creatures never heal themselves.
|
||||
if( m_Mobile.Summoned )
|
||||
if ( m_Mobile.Summoned )
|
||||
return null;
|
||||
|
||||
if( m_Mobile.Controlled )
|
||||
if ( m_Mobile.Controlled )
|
||||
{
|
||||
if (Core.TickCount - m_NextHealTime < 0)
|
||||
return null;
|
||||
}
|
||||
|
||||
if( !SmartAI )
|
||||
if ( !SmartAI )
|
||||
{
|
||||
if( ScaleBySkill( HealChance, SkillName.Magery ) < Utility.RandomDouble() )
|
||||
if ( ScaleBySkill( HealChance, SkillName.Magery ) < Utility.RandomDouble() )
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( Utility.Random( 0, 4 + ( m_Mobile.Hits == 0 ? m_Mobile.HitsMax : ( m_Mobile.HitsMax / m_Mobile.Hits ) ) ) < 3 )
|
||||
if ( Utility.Random( 0, 4 + ( m_Mobile.Hits == 0 ? m_Mobile.HitsMax : ( m_Mobile.HitsMax / m_Mobile.Hits ) ) ) < 3 )
|
||||
return null;
|
||||
}
|
||||
|
||||
Spell spell = null;
|
||||
|
||||
if( m_Mobile.Hits < ( m_Mobile.HitsMax - 50 ) )
|
||||
if ( m_Mobile.Hits < ( m_Mobile.HitsMax - 50 ) )
|
||||
{
|
||||
if ( UseNecromancy() )
|
||||
{
|
||||
|
|
@ -128,18 +128,18 @@ namespace Server.Mobiles
|
|||
{
|
||||
spell = new GreaterHealSpell( m_Mobile, null );
|
||||
|
||||
if( spell == null )
|
||||
if ( spell == null )
|
||||
spell = new HealSpell( m_Mobile, null );
|
||||
}
|
||||
}
|
||||
else if( m_Mobile.Hits < ( m_Mobile.HitsMax - 10 ) )
|
||||
else if ( m_Mobile.Hits < ( m_Mobile.HitsMax - 10 ) )
|
||||
{
|
||||
spell = new HealSpell( m_Mobile, null );
|
||||
}
|
||||
|
||||
double delay;
|
||||
|
||||
if( m_Mobile.Int >= 500 )
|
||||
if ( m_Mobile.Int >= 500 )
|
||||
delay = Utility.RandomMinMax( 7, 10 );
|
||||
else
|
||||
delay = Math.Sqrt( 600 - m_Mobile.Int );
|
||||
|
|
@ -151,29 +151,29 @@ namespace Server.Mobiles
|
|||
|
||||
public void RunTo( Mobile m )
|
||||
{
|
||||
if( !SmartAI )
|
||||
if ( !SmartAI )
|
||||
{
|
||||
if( !MoveTo( m, true, m_Mobile.RangeFight ) )
|
||||
if ( !MoveTo( m, true, m_Mobile.RangeFight ) )
|
||||
OnFailedMove();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if( m.Paralyzed || m.Frozen )
|
||||
if ( m.Paralyzed || m.Frozen )
|
||||
{
|
||||
if( m_Mobile.InRange( m, 1 ) )
|
||||
if ( m_Mobile.InRange( m, 1 ) )
|
||||
RunFrom( m );
|
||||
else if( !m_Mobile.InRange( m, m_Mobile.RangeFight > 2 ? m_Mobile.RangeFight : 2 ) && !MoveTo( m, true, 1 ) )
|
||||
else if ( !m_Mobile.InRange( m, m_Mobile.RangeFight > 2 ? m_Mobile.RangeFight : 2 ) && !MoveTo( m, true, 1 ) )
|
||||
OnFailedMove();
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !m_Mobile.InRange( m, m_Mobile.RangeFight ) )
|
||||
if ( !m_Mobile.InRange( m, m_Mobile.RangeFight ) )
|
||||
{
|
||||
if( !MoveTo( m, true, 1 ) )
|
||||
if ( !MoveTo( m, true, 1 ) )
|
||||
OnFailedMove();
|
||||
}
|
||||
else if( m_Mobile.InRange( m, m_Mobile.RangeFight - 1 ) )
|
||||
else if ( m_Mobile.InRange( m, m_Mobile.RangeFight - 1 ) )
|
||||
{
|
||||
RunFrom( m );
|
||||
}
|
||||
|
|
@ -187,16 +187,16 @@ namespace Server.Mobiles
|
|||
|
||||
public void OnFailedMove()
|
||||
{
|
||||
if( !m_Mobile.DisallowAllMoves && ( SmartAI ? Utility.Random( 4 ) == 0 : ScaleBySkill( TeleportChance, SkillName.Magery ) > Utility.RandomDouble() ) )
|
||||
if ( !m_Mobile.DisallowAllMoves && ( SmartAI ? Utility.Random( 4 ) == 0 : ScaleBySkill( TeleportChance, SkillName.Magery ) > Utility.RandomDouble() ) )
|
||||
{
|
||||
if( m_Mobile.Target != null )
|
||||
if ( m_Mobile.Target != null )
|
||||
m_Mobile.Target.Cancel( m_Mobile, TargetCancelType.Canceled );
|
||||
|
||||
new TeleportSpell( m_Mobile, null ).Cast();
|
||||
|
||||
m_Mobile.DebugSay( "I am stuck, I'm going to try teleporting away" );
|
||||
}
|
||||
else if( AcquireFocusMob( m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true ) )
|
||||
else if ( AcquireFocusMob( m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true ) )
|
||||
{
|
||||
m_Mobile.DebugSay( "My move is blocked, so I am going to attack {0}", m_Mobile.FocusMob.Name );
|
||||
|
||||
|
|
@ -211,12 +211,12 @@ namespace Server.Mobiles
|
|||
|
||||
public void Run( Direction d )
|
||||
{
|
||||
if( ( m_Mobile.Spell != null && m_Mobile.Spell.IsCasting ) || m_Mobile.Paralyzed || m_Mobile.Frozen || m_Mobile.DisallowAllMoves )
|
||||
if ( ( m_Mobile.Spell != null && m_Mobile.Spell.IsCasting ) || m_Mobile.Paralyzed || m_Mobile.Frozen || m_Mobile.DisallowAllMoves )
|
||||
return;
|
||||
|
||||
m_Mobile.Direction = d | Direction.Running;
|
||||
|
||||
if( !DoMove( m_Mobile.Direction, true ) )
|
||||
if ( !DoMove( m_Mobile.Direction, true ) )
|
||||
OnFailedMove();
|
||||
}
|
||||
|
||||
|
|
@ -251,9 +251,9 @@ namespace Server.Mobiles
|
|||
{
|
||||
int maxCircle = (int)( ( m_Mobile.Skills[ SkillName.Magery ].Value + 20.0 ) / ( 100.0 / 7.0 ) );
|
||||
|
||||
if( maxCircle < 1 )
|
||||
if ( maxCircle < 1 )
|
||||
maxCircle = 1;
|
||||
else if( maxCircle > 8 )
|
||||
else if ( maxCircle > 8 )
|
||||
maxCircle = 8;
|
||||
|
||||
switch( Utility.Random( maxCircle * 2 ) )
|
||||
|
|
@ -292,7 +292,7 @@ namespace Server.Mobiles
|
|||
|
||||
public virtual Spell GetRandomCurseSpellMage()
|
||||
{
|
||||
if( m_Mobile.Skills[ SkillName.Magery ].Value >= 40.0 && Utility.Random( 4 ) == 0 )
|
||||
if ( m_Mobile.Skills[ SkillName.Magery ].Value >= 40.0 && Utility.Random( 4 ) == 0 )
|
||||
return new CurseSpell( m_Mobile, null );
|
||||
|
||||
switch( Utility.Random( 3 ) )
|
||||
|
|
@ -305,7 +305,7 @@ namespace Server.Mobiles
|
|||
|
||||
public virtual Spell GetRandomManaDrainSpell()
|
||||
{
|
||||
if( m_Mobile.Skills[ SkillName.Magery ].Value >= 80.0 && Utility.RandomBool() )
|
||||
if ( m_Mobile.Skills[ SkillName.Magery ].Value >= 80.0 && Utility.RandomBool() )
|
||||
return new ManaVampireSpell( m_Mobile, null );
|
||||
|
||||
return new ManaDrainSpell( m_Mobile, null );
|
||||
|
|
@ -313,9 +313,9 @@ namespace Server.Mobiles
|
|||
|
||||
public virtual Spell DoDispel( Mobile toDispel )
|
||||
{
|
||||
if( !SmartAI )
|
||||
if ( !SmartAI )
|
||||
{
|
||||
if( ScaleBySkill( DispelChance, SkillName.Magery ) > Utility.RandomDouble() )
|
||||
if ( ScaleBySkill( DispelChance, SkillName.Magery ) > Utility.RandomDouble() )
|
||||
return new DispelSpell( m_Mobile, null );
|
||||
|
||||
return ChooseSpell( toDispel );
|
||||
|
|
@ -323,11 +323,11 @@ namespace Server.Mobiles
|
|||
|
||||
Spell spell = CheckCastHealingSpell();
|
||||
|
||||
if( spell == null )
|
||||
if ( spell == null )
|
||||
{
|
||||
if( !m_Mobile.DisallowAllMoves && Utility.Random( (int)m_Mobile.GetDistanceToSqrt( toDispel ) ) == 0 )
|
||||
if ( !m_Mobile.DisallowAllMoves && Utility.Random( (int)m_Mobile.GetDistanceToSqrt( toDispel ) ) == 0 )
|
||||
spell = new TeleportSpell( m_Mobile, null );
|
||||
else if( Utility.Random( 3 ) == 0 && !m_Mobile.InRange( toDispel, 3 ) && !toDispel.Paralyzed && !toDispel.Frozen )
|
||||
else if ( Utility.Random( 3 ) == 0 && !m_Mobile.InRange( toDispel, 3 ) && !toDispel.Paralyzed && !toDispel.Frozen )
|
||||
spell = new ParalyzeSpell( m_Mobile, null );
|
||||
else
|
||||
spell = new DispelSpell( m_Mobile, null );
|
||||
|
|
@ -340,18 +340,18 @@ namespace Server.Mobiles
|
|||
{
|
||||
Spell spell = null;
|
||||
|
||||
if( !SmartAI )
|
||||
if ( !SmartAI )
|
||||
{
|
||||
spell = CheckCastHealingSpell();
|
||||
|
||||
if( spell != null )
|
||||
if ( spell != null )
|
||||
return spell;
|
||||
|
||||
if( IsNecromancer )
|
||||
if ( IsNecromancer )
|
||||
{
|
||||
double psDamage = ( ( m_Mobile.Skills[ SkillName.SpiritSpeak ].Value - c.Skills[ SkillName.MagicResist ].Value ) / 10 ) + ( c.Player ? 18 : 30 );
|
||||
|
||||
if( psDamage > c.Hits )
|
||||
if ( psDamage > c.Hits )
|
||||
return new PainSpikeSpell( m_Mobile, null );
|
||||
}
|
||||
|
||||
|
|
@ -424,14 +424,14 @@ namespace Server.Mobiles
|
|||
|
||||
spell = CheckCastHealingSpell();
|
||||
|
||||
if( spell != null )
|
||||
if ( spell != null )
|
||||
return spell;
|
||||
|
||||
switch( Utility.Random( 3 ) )
|
||||
{
|
||||
case 0: // Poison them
|
||||
{
|
||||
if( c.Poisoned )
|
||||
if ( c.Poisoned )
|
||||
goto case 1;
|
||||
|
||||
spell = new PoisonSpell( m_Mobile, null );
|
||||
|
|
@ -445,22 +445,22 @@ namespace Server.Mobiles
|
|||
}
|
||||
default: // Set up a combo
|
||||
{
|
||||
if( m_Mobile.Mana > 15 && m_Mobile.Mana < 40 )
|
||||
if ( m_Mobile.Mana > 15 && m_Mobile.Mana < 40 )
|
||||
{
|
||||
if( c.Paralyzed && !c.Poisoned && !m_Mobile.Meditating )
|
||||
if ( c.Paralyzed && !c.Poisoned && !m_Mobile.Meditating )
|
||||
{
|
||||
m_Mobile.DebugSay( "I am going to meditate" );
|
||||
|
||||
m_Mobile.UseSkill( SkillName.Meditation );
|
||||
}
|
||||
else if( !c.Poisoned )
|
||||
else if ( !c.Poisoned )
|
||||
{
|
||||
spell = new ParalyzeSpell( m_Mobile, null );
|
||||
}
|
||||
}
|
||||
else if( m_Mobile.Mana > 60 )
|
||||
else if ( m_Mobile.Mana > 60 )
|
||||
{
|
||||
if( Utility.RandomBool() && !c.Paralyzed && !c.Frozen && !c.Poisoned )
|
||||
if ( Utility.RandomBool() && !c.Paralyzed && !c.Frozen && !c.Poisoned )
|
||||
{
|
||||
m_Combo = 0;
|
||||
spell = new ParalyzeSpell( m_Mobile, null );
|
||||
|
|
@ -485,19 +485,19 @@ namespace Server.Mobiles
|
|||
{
|
||||
Spell spell = null;
|
||||
|
||||
if( m_Combo == 0 )
|
||||
if ( m_Combo == 0 )
|
||||
{
|
||||
spell = new ExplosionSpell( m_Mobile, null );
|
||||
++m_Combo; // Move to next spell
|
||||
}
|
||||
else if( m_Combo == 1 )
|
||||
else if ( m_Combo == 1 )
|
||||
{
|
||||
spell = new WeakenSpell( m_Mobile, null );
|
||||
++m_Combo; // Move to next spell
|
||||
}
|
||||
else if( m_Combo == 2 )
|
||||
else if ( m_Combo == 2 )
|
||||
{
|
||||
if( !c.Poisoned )
|
||||
if ( !c.Poisoned )
|
||||
spell = new PoisonSpell( m_Mobile, null );
|
||||
else if ( IsNecromancer )
|
||||
spell = new StrangleSpell( m_Mobile, null );
|
||||
|
|
@ -505,13 +505,13 @@ namespace Server.Mobiles
|
|||
++m_Combo; // Move to next spell
|
||||
}
|
||||
|
||||
if( m_Combo == 3 && spell == null )
|
||||
if ( m_Combo == 3 && spell == null )
|
||||
{
|
||||
switch( Utility.Random( IsNecromancer ? 4 : 3 ) )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
if( c.Int < c.Dex )
|
||||
if ( c.Int < c.Dex )
|
||||
spell = new FeeblemindSpell( m_Mobile, null );
|
||||
else
|
||||
spell = new ClumsySpell( m_Mobile, null );
|
||||
|
|
@ -540,7 +540,7 @@ namespace Server.Mobiles
|
|||
}
|
||||
}
|
||||
}
|
||||
else if( m_Combo == 4 && spell == null )
|
||||
else if ( m_Combo == 4 && spell == null )
|
||||
{
|
||||
spell = new MindBlastSpell( m_Mobile, null );
|
||||
m_Combo = -1;
|
||||
|
|
@ -551,7 +551,7 @@ namespace Server.Mobiles
|
|||
|
||||
private TimeSpan GetDelay( Spell spell )
|
||||
{
|
||||
if( SmartAI || ( spell is DispelSpell ) )
|
||||
if ( SmartAI || ( spell is DispelSpell ) )
|
||||
{
|
||||
return TimeSpan.FromSeconds( m_Mobile.ActiveSpeed );
|
||||
}
|
||||
|
|
@ -573,12 +573,12 @@ namespace Server.Mobiles
|
|||
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 )
|
||||
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 ( AcquireFocusMob( m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true ) )
|
||||
{
|
||||
m_Mobile.DebugSay( "Something happened to my combatant, so I am going to fight {0}", m_Mobile.FocusMob.Name );
|
||||
|
||||
|
|
@ -593,11 +593,11 @@ namespace Server.Mobiles
|
|||
}
|
||||
}
|
||||
|
||||
if( !m_Mobile.InLOS( c ) )
|
||||
if ( !m_Mobile.InLOS( c ) )
|
||||
{
|
||||
m_Mobile.DebugSay( "I can't see my target" );
|
||||
|
||||
if( AcquireFocusMob( m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true ) )
|
||||
if ( AcquireFocusMob( m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true ) )
|
||||
{
|
||||
m_Mobile.DebugSay( "I will switch to {0}", m_Mobile.FocusMob.Name );
|
||||
m_Mobile.Combatant = c = m_Mobile.FocusMob;
|
||||
|
|
@ -605,26 +605,26 @@ namespace Server.Mobiles
|
|||
}
|
||||
}
|
||||
|
||||
if( !Core.AOS && SmartAI && !m_Mobile.StunReady && m_Mobile.Skills[ SkillName.Wrestling ].Value >= 80.0 && m_Mobile.Skills[ SkillName.Anatomy ].Value >= 80.0 )
|
||||
if ( !Core.AOS && SmartAI && !m_Mobile.StunReady && m_Mobile.Skills[ SkillName.Wrestling ].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 ) )
|
||||
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 ) )
|
||||
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 ) )
|
||||
else if ( !m_Mobile.InRange( c, m_Mobile.RangePerception * 3 ) )
|
||||
{
|
||||
m_Mobile.Combatant = null;
|
||||
}
|
||||
|
||||
c = m_Mobile.Combatant;
|
||||
|
||||
if( c == null )
|
||||
if ( c == null )
|
||||
{
|
||||
m_Mobile.DebugSay( "My combatant has fled, so I am on guard" );
|
||||
Action = ActionType.Guard;
|
||||
|
|
@ -633,15 +633,15 @@ namespace Server.Mobiles
|
|||
}
|
||||
}
|
||||
|
||||
if( !m_Mobile.Controlled && !m_Mobile.Summoned && m_Mobile.CanFlee )
|
||||
if ( !m_Mobile.Controlled && !m_Mobile.Summoned && m_Mobile.CanFlee )
|
||||
{
|
||||
if( m_Mobile.Hits < m_Mobile.HitsMax * 20 / 100 )
|
||||
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 )
|
||||
if ( m_Mobile.Hits < c.Hits )
|
||||
{
|
||||
// We are more hurt than them
|
||||
|
||||
|
|
@ -654,7 +654,7 @@ namespace Server.Mobiles
|
|||
flee = Utility.Random( 0, 100 ) > 10; // 10% chance to flee
|
||||
}
|
||||
|
||||
if( flee )
|
||||
if ( flee )
|
||||
{
|
||||
m_Mobile.DebugSay( "I am going to flee from {0}", c.Name );
|
||||
|
||||
|
|
@ -671,23 +671,23 @@ namespace Server.Mobiles
|
|||
Spell spell = null;
|
||||
Mobile toDispel = FindDispelTarget( true );
|
||||
|
||||
if( m_Mobile.Poisoned ) // Top cast priority is cure
|
||||
if ( m_Mobile.Poisoned ) // Top cast priority is cure
|
||||
{
|
||||
m_Mobile.DebugSay( "I am going to cure myself" );
|
||||
|
||||
spell = new CureSpell( m_Mobile, null );
|
||||
}
|
||||
else if( toDispel != null ) // Something dispellable is attacking us
|
||||
else if ( toDispel != null ) // Something dispellable is attacking us
|
||||
{
|
||||
m_Mobile.DebugSay( "I am going to dispel {0}", toDispel );
|
||||
|
||||
spell = DoDispel( toDispel );
|
||||
}
|
||||
else if( SmartAI && m_Combo != -1 ) // We are doing a spell combo
|
||||
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 have a heal spell out
|
||||
else if ( SmartAI && ( c.Spell is HealSpell || c.Spell is GreaterHealSpell ) && !c.Poisoned ) // They have a heal spell out
|
||||
{
|
||||
spell = new PoisonSpell( m_Mobile, null );
|
||||
}
|
||||
|
|
@ -699,11 +699,11 @@ namespace Server.Mobiles
|
|||
// Now we have a spell picked
|
||||
// Move first before casting
|
||||
|
||||
if( SmartAI && toDispel != null )
|
||||
if ( SmartAI && toDispel != null )
|
||||
{
|
||||
if( m_Mobile.InRange( toDispel, 10 ) )
|
||||
if ( m_Mobile.InRange( toDispel, 10 ) )
|
||||
RunFrom( toDispel );
|
||||
else if( !m_Mobile.InRange( toDispel, Core.ML ? 10 : 12 ) )
|
||||
else if ( !m_Mobile.InRange( toDispel, Core.ML ? 10 : 12 ) )
|
||||
RunTo( toDispel );
|
||||
}
|
||||
else
|
||||
|
|
@ -711,12 +711,12 @@ namespace Server.Mobiles
|
|||
RunTo( c );
|
||||
}
|
||||
|
||||
if( spell != null )
|
||||
if ( spell != null )
|
||||
spell.Cast();
|
||||
|
||||
m_NextCastTime = Core.TickCount + (int)GetDelay(spell).TotalMilliseconds;
|
||||
}
|
||||
else if( m_Mobile.Spell == null || !m_Mobile.Spell.IsCasting )
|
||||
else if ( m_Mobile.Spell == null || !m_Mobile.Spell.IsCasting )
|
||||
{
|
||||
RunTo( c );
|
||||
}
|
||||
|
|
@ -731,29 +731,29 @@ namespace Server.Mobiles
|
|||
|
||||
public override bool DoActionGuard()
|
||||
{
|
||||
if( m_LastTarget != null && m_LastTarget.Hidden )
|
||||
if ( m_LastTarget != null && m_LastTarget.Hidden )
|
||||
{
|
||||
Map map = m_Mobile.Map;
|
||||
|
||||
if( map == null || !m_Mobile.InRange( m_LastTargetLoc, Core.ML ? 10 : 12 ) )
|
||||
if ( map == null || !m_Mobile.InRange( m_LastTargetLoc, Core.ML ? 10 : 12 ) )
|
||||
{
|
||||
m_LastTarget = null;
|
||||
}
|
||||
else if( m_Mobile.Spell == null && Core.TickCount - m_NextCastTime >= 0 )
|
||||
else if ( m_Mobile.Spell == null && Core.TickCount - m_NextCastTime >= 0 )
|
||||
{
|
||||
m_Mobile.DebugSay( "I am going to reveal my last target" );
|
||||
|
||||
m_RevealTarget = new LandTarget( m_LastTargetLoc, map );
|
||||
Spell spell = new RevealSpell( m_Mobile, null );
|
||||
|
||||
if( spell.Cast() )
|
||||
if ( spell.Cast() )
|
||||
m_LastTarget = null; // only do it once
|
||||
|
||||
m_NextCastTime = Core.TickCount + (int)GetDelay(spell).TotalMilliseconds;
|
||||
}
|
||||
}
|
||||
|
||||
if( AcquireFocusMob( m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true ) )
|
||||
if ( AcquireFocusMob( m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true ) )
|
||||
{
|
||||
m_Mobile.DebugSay( "I am going to attack {0}", m_Mobile.FocusMob.Name );
|
||||
|
||||
|
|
@ -762,13 +762,13 @@ namespace Server.Mobiles
|
|||
}
|
||||
else
|
||||
{
|
||||
if( !m_Mobile.Controlled )
|
||||
if ( !m_Mobile.Controlled )
|
||||
{
|
||||
ProcessTarget();
|
||||
|
||||
Spell spell = CheckCastHealingSpell();
|
||||
|
||||
if( spell != null )
|
||||
if ( spell != null )
|
||||
spell.Cast();
|
||||
}
|
||||
|
||||
|
|
@ -782,19 +782,19 @@ namespace Server.Mobiles
|
|||
{
|
||||
Mobile c = m_Mobile.Combatant;
|
||||
|
||||
if( ( m_Mobile.Mana > 20 || m_Mobile.Mana == m_Mobile.ManaMax ) && m_Mobile.Hits > ( m_Mobile.HitsMax / 2 ) )
|
||||
if ( ( m_Mobile.Mana > 20 || m_Mobile.Mana == m_Mobile.ManaMax ) && m_Mobile.Hits > ( m_Mobile.HitsMax / 2 ) )
|
||||
{
|
||||
m_Mobile.DebugSay( "I am stronger now, my guard is up" );
|
||||
Action = ActionType.Guard;
|
||||
}
|
||||
else if( AcquireFocusMob( m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true ) )
|
||||
else if ( AcquireFocusMob( m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true ) )
|
||||
{
|
||||
m_Mobile.DebugSay( "I am scared of {0}", m_Mobile.FocusMob.Name );
|
||||
|
||||
RunFrom( m_Mobile.FocusMob );
|
||||
m_Mobile.FocusMob = null;
|
||||
|
||||
if( m_Mobile.Poisoned && Utility.Random( 0, 5 ) == 0 )
|
||||
if ( m_Mobile.Poisoned && Utility.Random( 0, 5 ) == 0 )
|
||||
new CureSpell( m_Mobile, null ).Cast();
|
||||
}
|
||||
else
|
||||
|
|
@ -810,10 +810,10 @@ namespace Server.Mobiles
|
|||
|
||||
public Mobile FindDispelTarget( bool activeOnly )
|
||||
{
|
||||
if( m_Mobile.Deleted || m_Mobile.Int < 95 || CanDispel( m_Mobile ) || m_Mobile.AutoDispel )
|
||||
if ( m_Mobile.Deleted || m_Mobile.Int < 95 || CanDispel( m_Mobile ) || m_Mobile.AutoDispel )
|
||||
return null;
|
||||
|
||||
if( activeOnly )
|
||||
if ( activeOnly )
|
||||
{
|
||||
List<AggressorInfo> aggressed = m_Mobile.Aggressed;
|
||||
List<AggressorInfo> aggressors = m_Mobile.Aggressors;
|
||||
|
|
@ -823,12 +823,12 @@ namespace Server.Mobiles
|
|||
|
||||
Mobile comb = m_Mobile.Combatant;
|
||||
|
||||
if( comb != null && !comb.Deleted && comb.Alive && !comb.IsDeadBondedPet && m_Mobile.InRange( comb, Core.ML ? 10 : 12 ) && CanDispel( comb ) )
|
||||
if ( comb != null && !comb.Deleted && comb.Alive && !comb.IsDeadBondedPet && m_Mobile.InRange( comb, Core.ML ? 10 : 12 ) && CanDispel( comb ) )
|
||||
{
|
||||
active = comb;
|
||||
activePrio = m_Mobile.GetDistanceToSqrt( comb );
|
||||
|
||||
if( activePrio <= 2 )
|
||||
if ( activePrio <= 2 )
|
||||
return active;
|
||||
}
|
||||
|
||||
|
|
@ -837,16 +837,16 @@ namespace Server.Mobiles
|
|||
AggressorInfo info = aggressed[ i ];
|
||||
Mobile m = info.Defender;
|
||||
|
||||
if( m != comb && m.Combatant == m_Mobile && m_Mobile.InRange( m, Core.ML ? 10 : 12 ) && CanDispel( m ) )
|
||||
if ( m != comb && m.Combatant == m_Mobile && m_Mobile.InRange( m, Core.ML ? 10 : 12 ) && CanDispel( m ) )
|
||||
{
|
||||
double prio = m_Mobile.GetDistanceToSqrt( m );
|
||||
|
||||
if( active == null || prio < activePrio )
|
||||
if ( active == null || prio < activePrio )
|
||||
{
|
||||
active = m;
|
||||
activePrio = prio;
|
||||
|
||||
if( activePrio <= 2 )
|
||||
if ( activePrio <= 2 )
|
||||
return active;
|
||||
}
|
||||
}
|
||||
|
|
@ -857,16 +857,16 @@ namespace Server.Mobiles
|
|||
AggressorInfo info = aggressors[ i ];
|
||||
Mobile m = info.Attacker;
|
||||
|
||||
if( m != comb && m.Combatant == m_Mobile && m_Mobile.InRange( m, Core.ML ? 10 : 12 ) && CanDispel( m ) )
|
||||
if ( m != comb && m.Combatant == m_Mobile && m_Mobile.InRange( m, Core.ML ? 10 : 12 ) && CanDispel( m ) )
|
||||
{
|
||||
double prio = m_Mobile.GetDistanceToSqrt( m );
|
||||
|
||||
if( active == null || prio < activePrio )
|
||||
if ( active == null || prio < activePrio )
|
||||
{
|
||||
active = m;
|
||||
activePrio = prio;
|
||||
|
||||
if( activePrio <= 2 )
|
||||
if ( activePrio <= 2 )
|
||||
return active;
|
||||
}
|
||||
}
|
||||
|
|
@ -878,14 +878,14 @@ namespace Server.Mobiles
|
|||
{
|
||||
Map map = m_Mobile.Map;
|
||||
|
||||
if( map != null )
|
||||
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 ) )
|
||||
if ( comb != null && !comb.Deleted && comb.Alive && !comb.IsDeadBondedPet && CanDispel( comb ) )
|
||||
{
|
||||
active = inactive = comb;
|
||||
actPrio = inactPrio = m_Mobile.GetDistanceToSqrt( comb );
|
||||
|
|
@ -893,17 +893,17 @@ namespace Server.Mobiles
|
|||
|
||||
foreach( Mobile m in m_Mobile.GetMobilesInRange( Core.ML ? 10 : 12 ) )
|
||||
{
|
||||
if( m != m_Mobile && CanDispel( m ) )
|
||||
if ( m != m_Mobile && CanDispel( m ) )
|
||||
{
|
||||
double prio = m_Mobile.GetDistanceToSqrt( m );
|
||||
|
||||
if( !activeOnly && ( inactive == null || prio < inactPrio ) )
|
||||
if ( !activeOnly && ( inactive == null || prio < inactPrio ) )
|
||||
{
|
||||
inactive = m;
|
||||
inactPrio = prio;
|
||||
}
|
||||
|
||||
if( ( m_Mobile.Combatant == m || m.Combatant == m_Mobile ) && ( active == null || prio < actPrio ) )
|
||||
if ( ( m_Mobile.Combatant == m || m.Combatant == m_Mobile ) && ( active == null || prio < actPrio ) )
|
||||
{
|
||||
active = m;
|
||||
actPrio = prio;
|
||||
|
|
@ -956,7 +956,7 @@ namespace Server.Mobiles
|
|||
{
|
||||
Target targ = m_Mobile.Target;
|
||||
|
||||
if( targ == null )
|
||||
if ( targ == null )
|
||||
return false;
|
||||
|
||||
bool isReveal = ( targ is RevealSpell.InternalTarget );
|
||||
|
|
@ -968,31 +968,31 @@ namespace Server.Mobiles
|
|||
|
||||
Mobile toTarget;
|
||||
|
||||
if( isInvisible )
|
||||
if ( isInvisible )
|
||||
{
|
||||
toTarget = m_Mobile;
|
||||
}
|
||||
else if( isDispel )
|
||||
else if ( isDispel )
|
||||
{
|
||||
toTarget = FindDispelTarget( false );
|
||||
|
||||
if( !SmartAI && toTarget != null )
|
||||
if ( !SmartAI && toTarget != null )
|
||||
RunTo( toTarget );
|
||||
else if( toTarget != null && m_Mobile.InRange( toTarget, 10 ) )
|
||||
else if ( toTarget != null && m_Mobile.InRange( toTarget, 10 ) )
|
||||
RunFrom( toTarget );
|
||||
}
|
||||
else if( SmartAI && ( isParalyze || isTeleport ) )
|
||||
else if ( SmartAI && ( isParalyze || isTeleport ) )
|
||||
{
|
||||
toTarget = FindDispelTarget( true );
|
||||
|
||||
if( toTarget == null )
|
||||
if ( toTarget == null )
|
||||
{
|
||||
toTarget = m_Mobile.Combatant;
|
||||
|
||||
if( toTarget != null )
|
||||
if ( toTarget != null )
|
||||
RunTo( toTarget );
|
||||
}
|
||||
else if( m_Mobile.InRange( toTarget, 10 ) )
|
||||
else if ( m_Mobile.InRange( toTarget, 10 ) )
|
||||
{
|
||||
RunFrom( toTarget );
|
||||
teleportAway = true;
|
||||
|
|
@ -1006,34 +1006,34 @@ namespace Server.Mobiles
|
|||
{
|
||||
toTarget = m_Mobile.Combatant;
|
||||
|
||||
if( toTarget != null )
|
||||
if ( toTarget != null )
|
||||
RunTo( toTarget );
|
||||
}
|
||||
|
||||
if( ( targ.Flags & TargetFlags.Harmful ) != 0 && toTarget != null )
|
||||
if ( ( targ.Flags & TargetFlags.Harmful ) != 0 && toTarget != null )
|
||||
{
|
||||
if( ( targ.Range == -1 || m_Mobile.InRange( toTarget, targ.Range ) ) && m_Mobile.CanSee( toTarget ) && m_Mobile.InLOS( toTarget ) )
|
||||
if ( ( targ.Range == -1 || m_Mobile.InRange( toTarget, targ.Range ) ) && m_Mobile.CanSee( toTarget ) && m_Mobile.InLOS( toTarget ) )
|
||||
{
|
||||
targ.Invoke( m_Mobile, toTarget );
|
||||
}
|
||||
else if( isDispel )
|
||||
else if ( isDispel )
|
||||
{
|
||||
targ.Cancel( m_Mobile, TargetCancelType.Canceled );
|
||||
}
|
||||
}
|
||||
else if( ( targ.Flags & TargetFlags.Beneficial ) != 0 )
|
||||
else if ( ( targ.Flags & TargetFlags.Beneficial ) != 0 )
|
||||
{
|
||||
targ.Invoke( m_Mobile, m_Mobile );
|
||||
}
|
||||
else if( isReveal && m_RevealTarget != null )
|
||||
else if ( isReveal && m_RevealTarget != null )
|
||||
{
|
||||
targ.Invoke( m_Mobile, m_RevealTarget );
|
||||
}
|
||||
else if( isTeleport && toTarget != null )
|
||||
else if ( isTeleport && toTarget != null )
|
||||
{
|
||||
Map map = m_Mobile.Map;
|
||||
|
||||
if( map == null )
|
||||
if ( map == null )
|
||||
{
|
||||
targ.Cancel( m_Mobile, TargetCancelType.Canceled );
|
||||
return true;
|
||||
|
|
@ -1041,7 +1041,7 @@ namespace Server.Mobiles
|
|||
|
||||
int px, py;
|
||||
|
||||
if( teleportAway )
|
||||
if ( teleportAway )
|
||||
{
|
||||
int rx = m_Mobile.X - toTarget.X;
|
||||
int ry = m_Mobile.Y - toTarget.Y;
|
||||
|
|
@ -1065,7 +1065,7 @@ namespace Server.Mobiles
|
|||
|
||||
LandTarget lt = new LandTarget( p, map );
|
||||
|
||||
if( ( targ.Range == -1 || m_Mobile.InRange( p, targ.Range ) ) && m_Mobile.InLOS( lt ) && map.CanSpawnMobile( px + x, py + y, lt.Z ) && !SpellHelper.CheckMulti( p, map ) )
|
||||
if ( ( targ.Range == -1 || m_Mobile.InRange( p, targ.Range ) ) && m_Mobile.InLOS( lt ) && map.CanSpawnMobile( px + x, py + y, lt.Z ) && !SpellHelper.CheckMulti( p, map ) )
|
||||
{
|
||||
targ.Invoke( m_Mobile, lt );
|
||||
return true;
|
||||
|
|
@ -1074,7 +1074,7 @@ namespace Server.Mobiles
|
|||
|
||||
int teleRange = targ.Range;
|
||||
|
||||
if( teleRange < 0 )
|
||||
if ( teleRange < 0 )
|
||||
teleRange = Core.ML ? 11 : 12;
|
||||
|
||||
for( int i = 0; i < 10; ++i )
|
||||
|
|
@ -1083,7 +1083,7 @@ namespace Server.Mobiles
|
|||
|
||||
LandTarget lt = new LandTarget( randomPoint, map );
|
||||
|
||||
if( m_Mobile.InLOS( lt ) && map.CanSpawnMobile( lt.X, lt.Y, lt.Z ) && !SpellHelper.CheckMulti( randomPoint, map ) )
|
||||
if ( m_Mobile.InLOS( lt ) && map.CanSpawnMobile( lt.X, lt.Y, lt.Z ) && !SpellHelper.CheckMulti( randomPoint, map ) )
|
||||
{
|
||||
targ.Invoke( m_Mobile, new LandTarget( randomPoint, map ) );
|
||||
return true;
|
||||
|
|
@ -1100,4 +1100,4 @@ namespace Server.Mobiles
|
|||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue