Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="MsgCategory"></param>
        /// <param name="MsgNum"></param>
        /// <returns></returns>
        ///

        #region Add Core Timer
        public void AddCoreTimer(int strain, DateTime time, AOFunctions aof)
        {
            AOTimers newCoretimer = new AOTimers();

            newCoretimer.Function  = aof;
            newCoretimer.Timestamp = time;
            newCoretimer.Strain    = strain;
            this.CoreTimers.Add(newCoretimer);
        }
Example #2
0
        public override void CalcTrickle()
        {
            if ((this.Parent is Character) || (this.Parent is NonPlayerCharacterClass))
            {
                Character character = (Character)this.Parent;

                // calculating Nano and Heal Delta and interval
                int healinterval = 29 - Math.Min(character.Stats.Stamina.Value / 30, 27);

                character.Stats.HealInterval.StatBaseValue = (uint)healinterval; // Healinterval

                character.PurgeTimer(0);
                AOFunctions aof = new AOFunctions();
                character.AddTimer(0, DateTime.Now + TimeSpan.FromSeconds(healinterval * 1000), aof, true);

                int sitBonusInterval = 0;
                int healDelta        = character.Stats.HealDelta.Value;
                if (character.MoveMode == MoveModes.Sit)
                {
                    sitBonusInterval = 1000;
                    int healDelta2 = healDelta >> 1;
                    healDelta = healDelta + healDelta2;
                }

                character.PurgeTimer(0);
                AOTimers at = new AOTimers();
                at.Strain    = 0;
                at.Timestamp = DateTime.Now
                               + TimeSpan.FromMilliseconds(character.Stats.HealInterval.Value * 1000 - sitBonusInterval);
                at.Function.Target       = this.Parent.Id; // changed from ItemHandler.itemtarget_self;
                at.Function.TickCount    = -2;
                at.Function.TickInterval = (uint)(character.Stats.HealInterval.Value * 1000 - sitBonusInterval);
                at.Function.FunctionType = Constants.FunctiontypeHit;
                at.Function.Arguments.Values.Add(27);
                at.Function.Arguments.Values.Add(healDelta);
                at.Function.Arguments.Values.Add(healDelta);
                at.Function.Arguments.Values.Add(0);
                character.Timers.Add(at);

                if (!this.Parent.Starting)
                {
                    this.AffectStats();
                }
            }
        }
Example #3
0
        public override void CalcTrickle()
        {
            if ((this.Parent is Character) || (this.Parent is NonPlayerCharacterClass))
            {
                Character character = (Character)this.Parent;

                // calculating Nano and Heal Delta and interval
                int nanoInterval = 28
                                   -
                                   (Math.Min((int)Math.Floor(Convert.ToDouble(character.Stats.Psychic.Value) / 60), 13)
                                    * 2);
                character.Stats.NanoInterval.StatBaseValue = (uint)nanoInterval; // Healinterval

                character.PurgeTimer(1);
                AOTimers at = new AOTimers();
                at.Strain = 1;

                int nanoDelta = character.Stats.NanoDelta.Value;
                if (character.MoveMode == MoveModes.Sit)
                {
                    int nanoDelta2 = nanoDelta >> 1;
                    nanoDelta = nanoDelta + nanoDelta2;
                }

                at.Timestamp             = DateTime.Now + TimeSpan.FromSeconds(character.Stats.NanoInterval.Value);
                at.Function.Target       = this.Parent.Id; // changed from ItemHandler.itemtarget_self;
                at.Function.TickCount    = -2;
                at.Function.TickInterval = (uint)(character.Stats.NanoInterval.Value * 1000);
                at.Function.FunctionType = Constants.FunctiontypeHit;
                at.Function.Arguments.Values.Add(214);
                at.Function.Arguments.Values.Add(nanoDelta);
                at.Function.Arguments.Values.Add(nanoDelta);
                at.Function.Arguments.Values.Add(0);
                character.Timers.Add(at);

                if (!this.Parent.Starting)
                {
                    this.AffectStats();
                }
            }
        }
Example #4
0
 /// <summary>
 /// Add a new Timer
 /// </summary>
 /// <param name="strain">Strain number</param>
 /// <param name="time">Time to spark AOFunction aof</param>
 /// <param name="aof">The function the timer triggers</param>
 public void AddTimer(int strain, DateTime time, ref AOFunctions aof)
 {
     AOTimers newtimer = new AOTimers();
     newtimer.Function = aof;
     newtimer.Timestamp = time;
     newtimer.Strain = strain;
     lock (Timers)
     {
         Timers.Add(newtimer);
     }
 }
Example #5
0
        /// <summary>
        /// Read timers from database
        /// TODO: catch exceptions
        /// </summary>
        public void readTimersfromSQL()
        {
            lock (Timers)
            {
                SqlWrapper ms = new SqlWrapper();
                TimeSpan ts;
                DateTime n = DateTime.Now;
                AOTimers m_timer;
                byte[] blob = new byte[10240];
                Timers.Clear();

                ms.SqlRead("SELECT * FROM " + getSQLTablefromDynelType() + "timers WHERE ID=" + ID.ToString() + ";");
                DataTable dt = ms.ReadDT("SELECT * FROM " + getSQLTablefromDynelType() + "timers WHERE ID=" + ID.ToString() + ";");
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        ts = TimeSpan.FromSeconds((Int32)row["timespan"]);
                        m_timer = new AOTimers();
                        m_timer.Timestamp = DateTime.Now + ts;
                        m_timer.Strain = (Int32)row["strain"];
                        m_timer.Function = new AOFunctions();
                        blob = (byte[])row[3];
                        m_timer.Function.ReadFunctionfromBlob(ref blob, 0);
                    }
                }
            }
        }
Example #6
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="MsgCategory"></param>
        /// <param name="MsgNum"></param>
        /// <returns></returns>
        /// 

        #region Add Core Timer
        public void AddCoreTimer(int strain, DateTime time, AOFunctions aof)
        {
            AOTimers newCoretimer = new AOTimers();
            newCoretimer.Function = aof;
            newCoretimer.Timestamp = time;
            newCoretimer.Strain = strain;
            this.CoreTimers.Add(newCoretimer);
        }
Example #7
0
 /// <summary>
 /// Add a new Timer
 /// </summary>
 /// <param name="strain">Strain number</param>
 /// <param name="time">Time to spark AOFunction aof</param>
 /// <param name="aof">The function the timer triggers</param>
 /// <param name="dolocalstats">process local stats?</param>
 public void AddTimer(int strain, DateTime time, AOFunctions aof, bool dolocalstats)
 {
     AOTimers newtimer = new AOTimers();
     newtimer.Function = aof.ShallowCopy();
     newtimer.Function.dolocalstats = dolocalstats;
     newtimer.Timestamp = time;
     newtimer.Strain = strain;
     lock (this.timers)
     {
         this.timers.Add(newtimer);
     }
 }
Example #8
0
 /// <summary>
 /// Initialize HP and NP timers (HD/ND ticks)
 /// </summary>
 public void AddHpnpTick()
 {
     lock (this.timers)
     {
         this.stats.HealInterval.CalcTrickle();
         this.stats.NanoInterval.CalcTrickle();
         AOTimers at = new AOTimers();
         at.Strain = -1;
         at.Timestamp = DateTime.Now + TimeSpan.FromMilliseconds(100);
         at.Function.Target = this.Id;
         at.Function.TickCount = -2;
         at.Function.TickInterval = 100;
         at.Function.FunctionType = 1; // MAIN stat send timer
         this.timers.Add(at);
         /*
         PurgeTimer(0);
         PurgeTimer(1);
         AOTimers at = new AOTimers();
         at.Strain = 0;
         at.Timestamp = DateTime.Now;
         at.Function.Target = this.ID;
         at.Function.TickCount = -2;
         at.Function.TickInterval = this.Stats.HealInterval.;
         at.Function.FunctionType = ItemHandler.functiontype_modify;
         at.Function.Arguments.Add(0);
         Timers.Add(at);
         at = new AOTimers();
         at.Strain = 1;
         at.Timestamp = DateTime.Now;
         at.Function.Target = this.ID;
         at.Function.TickCount = -2;
         at.Function.TickInterval = 0;
         at.Function.FunctionType = ItemHandler.functiontype_modify;
         at.Function.Arguments.Add(0);
         Timers.Add(at);
         */
     }
 }
Example #9
0
        /// <summary>
        /// Read timers from database
        /// TODO: catch exceptions
        /// </summary>
        public void ReadTimersFromSql()
        {
            lock (this.timers)
            {
                SqlWrapper ms = new SqlWrapper();
                TimeSpan timeSpan;
                DateTime now = DateTime.Now;
                byte[] blob = new byte[10240];
                this.timers.Clear();

                ms.SqlRead(
                    "SELECT * FROM " + this.GetSqlTablefromDynelType() + "timers WHERE ID=" + this.Id.ToString() + ";");
                DataTable dt =
                    ms.ReadDatatable(
                        "SELECT * FROM " + this.GetSqlTablefromDynelType() + "timers WHERE ID=" + this.Id.ToString()
                        + ";");
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        timeSpan = TimeSpan.FromSeconds((Int32)row["timespan"]);
                        AOTimers aoTimer = new AOTimers
                            {
                                Timestamp = DateTime.Now + timeSpan,
                                Strain = (Int32)row["strain"],
                                Function = new AOFunctions()
                            };
                        MemoryStream memstream = new MemoryStream((byte[])row[3]);
                        BinaryFormatter bin = new BinaryFormatter();

                        aoTimer.Function = (AOFunctions)bin.Deserialize(memstream);
                    }
                }
            }
        }