Ejemplo n.º 1
0
        public Spawntimer(string str)
        {
            var parts = str.Split(';');

            SpawnLoc = parts[0];

            SpawnCount = int.Parse(parts[1]);

            SpawnTimer = int.Parse(parts[2]);

            SpawnTimeStr = parts[3];

            SpawnTimeDT = GetDateTime(SpawnTimeStr);

            KillTimeStr = parts[4];

            KillTimeDT = GetDateTime(KillTimeStr);

            NextSpawnStr = parts[5];

            NextSpawnDT = GetDateTime(NextSpawnStr);

            LastSpawnName = parts[6];

            AllNames = parts[7];

            // split up the All Names, and parse out spawn numbers in parenthesis
            _ = AllNames.Split(',').GetUpperBound(0);

            X = float.Parse(parts[8]);

            Y = float.Parse(parts[9]);

            Z = float.Parse(parts[10]);
        }
Ejemplo n.º 2
0
        public SPAWNTIMER(string str)

        {
            string[] parts = str.Split(';');

            SpawnLoc = parts[0];

            SpawnCount = int.Parse(parts[1]);

            SpawnTimer = int.Parse(parts[2]);

            SpawnTimeStr = parts[3];

            if (SpawnTimeStr.Length > 0)
            {
                SpawnTimeDT = Convert.ToDateTime(SpawnTimeStr);
            }

            KillTimeStr = parts[4];

            if (KillTimeStr.Length > 0)
            {
                KillTimeDT = Convert.ToDateTime(KillTimeStr);
            }

            NextSpawnStr = parts[5];

            if (NextSpawnStr.Length > 0)
            {
                NextSpawnDT = Convert.ToDateTime(NextSpawnStr);
            }

            LastSpawnName = parts[6];

            AllNames = parts[7];

            // split up the All Names, and parse out spawn numbers in parenthesis
            string[] subparts = AllNames.Split(',');

            int jj = subparts.GetUpperBound(0);

            X = float.Parse(parts[8]);

            Y = float.Parse(parts[9]);

            Z = float.Parse(parts[10]);
        }
Ejemplo n.º 3
0
        private StringBuilder StBuilder()
        {
            StringBuilder spawnTimer = new StringBuilder();

            spawnTimer.AppendFormat("Spawn Name: {0}\n", LastSpawnName);

            string names_to_add = "Names encountered: ";

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

            int namecount = 0;

            NameCount(spawnTimer, ref names_to_add, names, ref namecount);

            if (names_to_add.Length > 0)
            {
                spawnTimer.Append(names_to_add);
            }

            return(spawnTimer);
        }
Ejemplo n.º 4
0
        // st has been loaded from a file, and is the same spawn as "this" one.

        // Glean all useful information.

        public void Merge(SPAWNTIMER st)

        {
            LogLib.WriteLine("Merging spawn timers:", LogLevel.Debug);

            LogLib.WriteLine($"  Old: {GetAsString()}", LogLevel.Debug);

            LogLib.WriteLine($"  Other: {st.GetAsString()}", LogLevel.Debug);

            SpawnCount = st.SpawnCount; // usually makes it > 1

            SpawnTimer = st.SpawnTimer; // woot!

            //this.SpawnTimer =   // NOT!

            if (KillTimeDT == DateTime.MinValue) // woot!

            {
                KillTimeStr = st.KillTimeStr;

                TimeSpan Diff = new TimeSpan(0, 0, 0, Convert.ToInt32(SpawnTimer));

                NextSpawnDT = KillTimeDT.Add(Diff);

                NextSpawnStr = NextSpawnDT.ToLongTimeString() + " " + NextSpawnDT.ToShortDateString();
            }
            else
            {
                // Enable the timer to start on first kill

                if (st.SpawnTimer > 10)

                {
                    TimeSpan Diff = new TimeSpan(0, 0, 0, Convert.ToInt32(SpawnTimer));

                    if (DateTime.Now.Subtract(Diff) < st.SpawnTimeDT)

                    {
                        SpawnTimeDT = st.SpawnTimeDT;

                        SpawnTimeStr = st.SpawnTimeStr;
                    }

                    if (DateTime.Now.Subtract(Diff) > st.KillTimeDT)

                    {
                        KillTimeDT = DateTime.MinValue;
                    }
                    else
                    {
                        KillTimeDT = st.KillTimeDT;

                        KillTimeStr = st.KillTimeStr;
                    }

                    if (DateTime.Now > st.NextSpawnDT)

                    {
                        NextSpawnDT = DateTime.MinValue;

                        NextSpawnStr = "";
                    }
                    else
                    {
                        NextSpawnDT = st.NextSpawnDT;

                        NextSpawnStr = st.NextSpawnStr;

                        KillTimeDT = st.KillTimeDT.Subtract(Diff);
                    }
                }
            }

            int namecount = 1;

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

            // update last spawn name to be what looks like named mobs
            foreach (var tname in AllNames.Split(','))
            {
                var mname = RegexHelper.TrimName(tname);
                if (RegexHelper.RegexMatch(mname))
                {
                    LastSpawnName = mname;
                    break;
                }
            }

            listNeedsUpdate = true;
            LogLib.WriteLine($"  New: {GetAsString()}", LogLevel.Debug);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
        public String GetDescription()

        {
            String descr = null;



            int countTime = 0;

            string countTimer = "";

            if (NextSpawnDT != DateTime.MinValue)
            {
                TimeSpan Diff = NextSpawnDT.Subtract(DateTime.Now);

                countTimer = Diff.Hours.ToString("00") + ":" + Diff.Minutes.ToString("00") + ":" + Diff.Seconds.ToString("00");

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



            if (countTime > 0)

            {
                StringBuilder spawnTimer = new StringBuilder();

                spawnTimer.AppendFormat("Spawn Name: {0}\n", LastSpawnName);

                string   names_to_add = "Names encountered: ";
                string[] names        = AllNames.Split(',');

                int namecount = 0;

                foreach (string name in names)
                {
                    string namet = Regex.Replace(name.Replace("_", " "), "[0-9]", "").Trim();

                    if (namecount == 0)
                    {
                        names_to_add += namet;
                    }
                    else
                    {
                        if ((namet.Length + names_to_add.Length + 2) < 45)
                        {
                            names_to_add += ", ";
                            names_to_add += namet;
                        }
                        else
                        {
                            spawnTimer.Append(names_to_add);
                            spawnTimer.Append("\n");
                            names_to_add = namet;
                        }
                    }

                    namecount++;
                }
                if (names_to_add.Length > 0)
                {
                    spawnTimer.Append(names_to_add);
                }

                spawnTimer.Append("\n");

                spawnTimer.AppendFormat("Last Spawned At: {0}\n", SpawnTimeStr);

                spawnTimer.AppendFormat("Last Killed At: {0}\n", KillTimeStr);

                spawnTimer.AppendFormat("Next Spawn At: {0}\n", NextSpawnStr);

                spawnTimer.AppendFormat("Spawn Timer: {0} secs\n", SpawnTimer);

                spawnTimer.AppendFormat("Spawning In: {0}\n", countTimer);

                spawnTimer.AppendFormat("Spawn Count: {0}\n", SpawnCount);

                spawnTimer.AppendFormat("Y: {0:f3}  X: {1:f3}  Z: {2:f3}", Y, X, Z);

                descr = spawnTimer.ToString();
            }

            else if (SpawnTimer > 0)

            {
                StringBuilder spawnTimer = new StringBuilder();

                spawnTimer.AppendFormat("Spawn Name: {0}\n", LastSpawnName);

                string   names_to_add = "Names encountered: ";
                string[] names        = AllNames.Split(',');

                int namecount = 0;

                foreach (string name in names)
                {
                    string namet = Regex.Replace(name.Replace("_", " "), "[0-9]", "").Trim();

                    if (namecount == 0)
                    {
                        names_to_add += namet;
                    }
                    else
                    {
                        if ((namet.Length + names_to_add.Length + 2) < 45)
                        {
                            names_to_add += ", ";
                            names_to_add += namet;
                        }
                        else
                        {
                            spawnTimer.Append(names_to_add);
                            spawnTimer.Append("\n");

                            names_to_add = namet;
                        }
                    }

                    namecount++;
                }
                if (names_to_add.Length > 0)
                {
                    spawnTimer.Append(names_to_add);
                }

                spawnTimer.Append("\n");

                spawnTimer.AppendFormat("Last Spawned At: {0}\n", SpawnTimeStr);

                spawnTimer.AppendFormat("Last Killed At: {0}\n", KillTimeStr);

                spawnTimer.AppendFormat("Next Spawn At: {0}\n", "");

                spawnTimer.AppendFormat("Spawn Timer: {0} secs\n", SpawnTimer);

                spawnTimer.AppendFormat("Spawning In: {0}\n", "");

                spawnTimer.AppendFormat("Spawn Count: {0}\n", SpawnCount);

                spawnTimer.AppendFormat("Y: {0:f3}  X: {1:f3}  Z: {2:f3}", Y, X, Z);

                descr = spawnTimer.ToString();
            }

            else

            {
                StringBuilder spawnTimer = new StringBuilder();

                spawnTimer.AppendFormat("Spawn Name: {0}\n", LastSpawnName);

                string   names_to_add = "Names encountered: ";
                string[] names        = AllNames.Split(',');

                int namecount = 0;

                foreach (string name in names)
                {
                    string namet = Regex.Replace(name.Replace("_", " "), "[0-9]", "").Trim();

                    if (namecount == 0)
                    {
                        names_to_add += namet;
                    }
                    else
                    {
                        if ((namet.Length + names_to_add.Length + 2) < 45)
                        {
                            names_to_add += ", ";
                            names_to_add += namet;
                        }
                        else
                        {
                            spawnTimer.Append(names_to_add);
                            spawnTimer.Append("\n");

                            names_to_add = namet;
                        }
                    }

                    namecount++;
                }
                if (names_to_add.Length > 0)
                {
                    spawnTimer.Append(names_to_add);
                }

                spawnTimer.Append("\n");

                spawnTimer.AppendFormat("Last Spawned At: {0}\n", SpawnTimeStr);

                spawnTimer.AppendFormat("Last Killed At: {0}\n", KillTimeStr);

                spawnTimer.AppendFormat("Next Spawn At: {0}\n", "");

                spawnTimer.AppendFormat("Spawn Timer: {0} secs\n", "0");

                spawnTimer.AppendFormat("Spawning In: {0}\n", "");

                spawnTimer.AppendFormat("Spawn Count: {0}\n", SpawnCount);

                spawnTimer.AppendFormat("Y: {0:f3}  X: {1:f3}  Z: {2:f3}", Y, X, Z);

                descr = spawnTimer.ToString();
            }

            return(descr);
        }
Ejemplo n.º 8
0
        // st has been loaded from a file, and is the same spawn as "this" one.

        // Glean all useful information.

        public void Merge(SPAWNTIMER st)

        {
            LogLib.WriteLine("Merging spawn timers:", LogLevel.Debug);



            LogLib.WriteLine("  Old: " + GetAsString(), LogLevel.Debug);

            LogLib.WriteLine("  Other: " + st.GetAsString(), LogLevel.Debug);



            this.SpawnCount = st.SpawnCount; // usually makes it > 1

            this.SpawnTimer = st.SpawnTimer; // woot!

            //this.SpawnTimer =   // NOT!

            if (this.KillTimeDT == DateTime.MinValue) // woot!

            {
                this.KillTimeStr = st.KillTimeStr;



                TimeSpan Diff = new TimeSpan(0, 0, 0, Convert.ToInt32(SpawnTimer));

                NextSpawnDT = KillTimeDT.Add(Diff);

                NextSpawnStr = NextSpawnDT.ToLongTimeString() + " " + NextSpawnDT.ToShortDateString();
            }

            else

            {
                // Enable the timer to start on first kill

                if (st.SpawnTimer > 10)

                {
                    //TimeSpan Diff = new TimeSpan(0, 0, 0, Convert.ToInt32(SpawnTimer));

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

                    TimeSpan Diff = new TimeSpan(0, 0, 0, Convert.ToInt32(SpawnTimer));

                    if (DateTime.Now.Subtract(Diff) < st.SpawnTimeDT)

                    {
                        this.SpawnTimeDT = st.SpawnTimeDT;

                        this.SpawnTimeStr = st.SpawnTimeStr;
                    }



                    if (DateTime.Now.Subtract(Diff) > st.KillTimeDT)

                    {
                        this.KillTimeDT = DateTime.MinValue;
                    }

                    else

                    {
                        this.KillTimeDT = st.KillTimeDT;

                        this.KillTimeStr = st.KillTimeStr;
                    }

                    //this.KillTimeStr = "";

                    if (DateTime.Now > st.NextSpawnDT)

                    {
                        this.NextSpawnDT = DateTime.MinValue;

                        this.NextSpawnStr = "";
                    }

                    else

                    {
                        this.NextSpawnDT = st.NextSpawnDT;

                        this.NextSpawnStr = st.NextSpawnStr;

                        this.KillTimeDT = st.KillTimeDT.Subtract(Diff);
                    }
                }
            }

            int namecount = 1;

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

            foreach (string name in names)

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

                if (AllNames.IndexOf(bname) < 0)

                {
                    if (namecount < 11)

                    {
                        AllNames += ", " + bname;

                        namecount++;
                    }
                }
            }

            // update last spawn name to be what looks like named mobs
            string[] bnames = AllNames.Split(',');
            foreach (string tname in bnames)
            {
                string mname = Regex.Replace(tname.Replace("_", " "), "[0-9]", "").Trim();
                if (Regex.IsMatch(mname, "^[A-Z#]"))
                {
                    this.LastSpawnName = mname;
                    break;
                }
            }

            listNeedsUpdate = true;



            LogLib.WriteLine("  New: " + GetAsString(), LogLevel.Debug);
        }