BaseCreature/AI Core.TickCount

This commit is contained in:
Mark Sturgill 2013-10-06 18:57:37 -07:00
parent be920e0c31
commit b3535985d7
3 changed files with 34 additions and 32 deletions

View file

@ -45,7 +45,7 @@ namespace Server.Mobiles
{
public Timer m_Timer;
protected ActionType m_Action;
private DateTime m_NextStopGuard;
private int m_NextStopGuard;
public BaseCreature m_Mobile;
@ -830,7 +830,7 @@ namespace Server.Mobiles
m_Mobile.FocusMob = null;
m_Mobile.Combatant = null;
m_Mobile.CurrentSpeed = m_Mobile.ActiveSpeed;
m_NextStopGuard = DateTime.UtcNow + TimeSpan.FromSeconds(10);
m_NextStopGuard = Core.TickCount + (int)TimeSpan.FromSeconds(10).TotalMilliseconds;
m_Mobile.CurrentSpeed = m_Mobile.ActiveSpeed;
break;
@ -928,7 +928,7 @@ namespace Server.Mobiles
{
m_Mobile.DebugSay("Praise the shepherd!");
}
else if (DateTime.UtcNow < m_NextStopGuard)
else if (Core.TickCount - m_NextStopGuard < 0)
{
m_Mobile.DebugSay("I am on guard");
//m_Mobile.Turn( Utility.Random(0, 2) - 1 );
@ -2718,7 +2718,7 @@ namespace Server.Mobiles
m_Timer.Start();
}
private DateTime m_NextDetectHidden;
private int m_NextDetectHidden;
public virtual bool CanDetectHidden { get { return m_Mobile.Skills[SkillName.DetectHidden].Value > 0; } }
@ -2734,7 +2734,7 @@ namespace Server.Mobiles
{
m_Owner = owner;
m_Owner.m_NextDetectHidden = DateTime.UtcNow;
m_Owner.m_NextDetectHidden = Core.TickCount;
Priority = TimerPriority.FiftyMS;
}
@ -2802,7 +2802,7 @@ namespace Server.Mobiles
}
}
if (m_Owner.CanDetectHidden && DateTime.UtcNow > m_Owner.m_NextDetectHidden)
if (m_Owner.CanDetectHidden && Core.TickCount - m_Owner.m_NextDetectHidden >= 0)
{
m_Owner.DetectHidden();
@ -2815,7 +2815,7 @@ namespace Server.Mobiles
int min = delay * (9 / 10); // 13s at 1000 int, 33s at 400 int, 54s at <250 int
int max = delay * (10 / 9); // 16s at 1000 int, 41s at 400 int, 66s at <250 int
m_Owner.m_NextDetectHidden = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(min, max));
m_Owner.m_NextDetectHidden = Core.TickCount + (int)TimeSpan.FromSeconds(Utility.RandomMinMax(min, max)).TotalMilliseconds;
}
}
}

View file

@ -15,8 +15,8 @@ namespace Server.Mobiles
{
public class MageAI : BaseAI
{
private DateTime m_NextCastTime;
private DateTime m_NextHealTime;
private int m_NextCastTime;
private int m_NextHealTime;
public MageAI( BaseCreature m )
: base( m )
@ -61,7 +61,7 @@ namespace Server.Mobiles
m_Mobile.Combatant = m_Mobile.FocusMob;
Action = ActionType.Combat;
m_NextCastTime = DateTime.UtcNow;
m_NextCastTime = Core.TickCount;
}
else if( SmartAI && m_Mobile.Mana < m_Mobile.ManaMax && !m_Mobile.Meditating )
{
@ -101,7 +101,7 @@ namespace Server.Mobiles
if( m_Mobile.Controlled )
{
if( DateTime.UtcNow < m_NextHealTime )
if (Core.TickCount - m_NextHealTime < 0)
return null;
}
@ -144,7 +144,7 @@ namespace Server.Mobiles
else
delay = Math.Sqrt( 600 - m_Mobile.Int );
m_NextHealTime = DateTime.UtcNow + TimeSpan.FromSeconds( delay );
m_NextHealTime = Core.TickCount + (int)TimeSpan.FromSeconds(delay).TotalMilliseconds;
return spell;
}
@ -664,7 +664,7 @@ namespace Server.Mobiles
}
}
if( m_Mobile.Spell == null && DateTime.UtcNow > m_NextCastTime && m_Mobile.InRange( c, Core.ML ? 10 : 12 ) )
if (m_Mobile.Spell == null && Core.TickCount - m_NextCastTime >= 0 && m_Mobile.InRange(c, Core.ML ? 10 : 12))
{
// We are ready to cast a spell
@ -714,7 +714,7 @@ namespace Server.Mobiles
if( spell != null )
spell.Cast();
m_NextCastTime = DateTime.UtcNow + GetDelay( spell );
m_NextCastTime = Core.TickCount + (int)GetDelay(spell).TotalMilliseconds;
}
else if( m_Mobile.Spell == null || !m_Mobile.Spell.IsCasting )
{
@ -739,7 +739,7 @@ namespace Server.Mobiles
{
m_LastTarget = null;
}
else if( m_Mobile.Spell == null && DateTime.UtcNow > m_NextCastTime )
else if( m_Mobile.Spell == null && Core.TickCount - m_NextCastTime >= 0 )
{
m_Mobile.DebugSay( "I am going to reveal my last target" );
@ -749,7 +749,7 @@ namespace Server.Mobiles
if( spell.Cast() )
m_LastTarget = null; // only do it once
m_NextCastTime = DateTime.UtcNow + GetDelay( spell );
m_NextCastTime = Core.TickCount + (int)GetDelay(spell).TotalMilliseconds;
}
}