Exemplo n.º 1
0
        // When will the mob spawn next? Returns 0 if not available.

        // TODO: optimize this, as it is called much more often than the mob is being updated

        public int SecondsUntilSpawn(DateTime now)

        {
            int checkTimer = 0;



            if (NextSpawnDT != DateTime.MinValue)

            {
                TimeSpan Diff = NextSpawnDT.Subtract(now);

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

                if (checkTimer <= 0)

                {
                    checkTimer = 0;
                }
            }



            return(checkTimer);
        }
Exemplo n.º 2
0
        public string Kill(DateTime dt)

        {
            KillTimeDT = dt;

            KillTimeStr = dt.ToLongTimeString() + " " + dt.ToShortDateString();

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

            NextSpawnDT = KillTimeDT.Add(Diff);

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

            listNeedsUpdate = true;

            return(KillTimeStr);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        public string GetDescription()

        {
            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 moved to new, common method, as equal for all paths.
                StringBuilder spawnTimer = StBuilder();

                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);

                return(spawnTimer.ToString());
            }
            else if (SpawnTimer > 0)

            {
                StringBuilder spawnTimer = StBuilder();

                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);

                return(spawnTimer.ToString());
            }
            else
            {
                StringBuilder spawnTimer = StBuilder();

                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);

                return(spawnTimer.ToString());
            }
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
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);
        }