Esempio n. 1
0
        // A true re-spawn has been detected

        public string ReSpawn(string name)

        {
            string log = "";

            try

            {
                SpawnCount++;

                // if it looks like a named, leave last spawn name alone
                if (LastSpawnName.Length > 0)
                {
                    // See if mob name starts with capital letter or #
                    if (!RegexHelper.RegexMatch(LastSpawnName))
                    {
                        LastSpawnName = name;
                    }
                }
                else
                {
                    LastSpawnName = name;
                }
                NextSpawnStr = "";

                NextSpawnDT = DateTime.MinValue;

                SpawnTimeDT = DateTime.Now;

                SpawnTimeStr = SpawnTimeDT.ToLongTimeString() + " " + SpawnTimeDT.ToShortDateString();

                // put name at beginning of list of AllNames

                var newnames  = RegexHelper.TrimName(name);
                var namecount = 1;
                foreach (var tname in AllNames.Split(','))
                {
                    var bname = RegexHelper.TrimName(tname);
                    if (newnames.IndexOf(bname) < 0 && namecount < 12)
                    {
                        newnames += ", " + bname;
                        namecount++;
                    }
                }

                AllNames = newnames;

                if (KillTimeDT != DateTime.MinValue)

                {
                    // This mob has been killed already - now we can calculate

                    // the respawn time

                    int last_Timer = SpawnTimer;

                    TimeSpan Diff = SpawnTimeDT.Subtract(KillTimeDT);

                    SpawnTimer = (Diff.Hours * 3600) + (Diff.Minutes * 60) + Diff.Seconds;

                    if (Settings.Instance.MaxLogLevel > 0)
                    {
                        string spawnTimer = $"{Diff.Hours:00}:{Diff.Minutes:00}:{Diff.Seconds:00}";

                        log = $"Setting Timer for Spawn: {SpawnLoc} Name: {name} Count: {SpawnCount} Last Kill Time: {KillTimeStr} Current Spawn Time: {SpawnTimeStr} Timer: {spawnTimer} = {SpawnTimer} secs Old: {last_Timer} secs";
                    }

                    // ... and forget about the kill

                    KillTimeDT = DateTime.MinValue;

                    KillTimeStr = "";
                }
            }
            catch (Exception ex) { LogLib.WriteLine("Error updating Timer SPAWNTIMER for " + name + ": ", ex); }

            listNeedsUpdate = true;

            return(log);
        }
Esempio n. 2
0
        // A true re-spawn has been detected

        public string ReSpawn(string name)

        {
            string log = "";

            try

            {
                this.SpawnCount++;

                // if it looks like a named, leave last spawn name alone
                if (this.LastSpawnName.Length > 0)
                {
                    // See if mob name starts with capital letter or #
                    if (!Regex.IsMatch(this.LastSpawnName, "^[A-Z#]"))
                    {
                        this.LastSpawnName = name;
                    }
                }
                else
                {
                    this.LastSpawnName = name;
                }
                this.NextSpawnStr = "";

                this.NextSpawnDT = DateTime.MinValue;

                this.SpawnTimeDT = DateTime.Now;

                this.SpawnTimeStr = SpawnTimeDT.ToLongTimeString() + " " + SpawnTimeDT.ToShortDateString();



                // put name at beginning of list of AllNames



                string namet = Regex.Replace(name.Replace("_", " "), "[0-9]", "");

                string newnames = namet;

                int namecount = 1;

                string[] names = AllNames.Split(',');

                foreach (string tname in names)

                {
                    string bname = Regex.Replace(tname.Replace("_", " "), "[0-9]", "").Trim();

                    if (newnames.IndexOf(bname) < 0)

                    {
                        if (namecount < 12)

                        {
                            newnames += ", " + bname;

                            namecount++;
                        }
                    }
                }

                AllNames = newnames;



                if (this.KillTimeDT != DateTime.MinValue)

                {
                    // This mob has been killed already - now we can calculate

                    // the respawn time


                    int last_Timer = this.SpawnTimer;

                    TimeSpan Diff = this.SpawnTimeDT.Subtract(this.KillTimeDT);

                    this.SpawnTimer = (Diff.Hours * 3600) + (Diff.Minutes * 60) + Diff.Seconds;

                    if (Settings.Instance.MaxLogLevel > 0)
                    {
                        string spawnTimer = String.Format("{0}:{1}:{2}", Diff.Hours.ToString("00"), Diff.Minutes.ToString("00"), Diff.Seconds.ToString("00"));

                        log = String.Format("Setting Timer for Spawn: {0} Name: {1} Count: {2} Last Kill Time: {3} Current Spawn Time: {4} Timer: {5} = {6} secs Old: {7} secs",

                                            SpawnLoc, name, this.SpawnCount, this.KillTimeStr, this.SpawnTimeStr, spawnTimer, this.SpawnTimer, last_Timer);
                    }

                    // ... and forget about the kill



                    this.KillTimeDT = DateTime.MinValue;

                    this.KillTimeStr = "";
                }
            }

            catch (Exception ex) { LogLib.WriteLine("Error updating Timer SPAWNTIMER for " + name + ": ", ex); }



            listNeedsUpdate = true;



            return(log);
        }