コード例 #1
0
ファイル: ListViewPanel.cs プロジェクト: Lenothx/MySEQ
        private void mnuStickyTimer_Click(object sender, EventArgs e)
        {
            // Set or unset the sticky flag for the timer selected
            ListView.SelectedIndexCollection sel = listView.SelectedIndices;

            if (sel.Count > 0)
            {
                // We only do this for the Spawn Timer List
                if (ListType == 1)
                {
                    // This returns mobsTimer2
                    SPAWNTIMER st = eq.FindListViewTimer(listView.Items[sel[0]]);
                    if (st != null)
                    {
                        mnuStickyTimer.Checked = st.sticky;
                        st.sticky = !st.sticky;
                    }
                }
            }
        }
コード例 #2
0
ファイル: MobsTimer.cs プロジェクト: Lenothx/MySEQ
        // We're pretty positive that the mob has been processed before, here.

        // This updates KillTime and NextSpawn.

        public void Kill(SPAWNINFO mob)

        {
            try
            {
                if ((Settings.Instance.SaveSpawnLogs) || (mapName.Length > 0))
                {
                    LogSpawns(String.Format("[KILL] Loc: {0} Name: {1}", mob.SpawnLoc, mob.Name));
                }

                if (mobsTimer.ContainsKey(mob.ZoneSpawnLoc))
                {
                    SPAWNTIMER stold = (SPAWNTIMER)mobsTimer[mob.ZoneSpawnLoc];

                    string log = stold.Kill(DateTime.Now);

                    // update mobsTimer2 also with kill info
                    if (mobsTimer2.ContainsKey(stold.ZoneSpawnLoc))
                    {
                        SPAWNTIMER st2 = (SPAWNTIMER)mobsTimer2[stold.ZoneSpawnLoc];

                        st2.KillTimeDT   = stold.KillTimeDT;
                        st2.KillTimeStr  = stold.KillTimeStr;
                        st2.NextSpawnDT  = stold.NextSpawnDT;
                        st2.NextSpawnStr = stold.NextSpawnStr;
                    }

                    if (log != string.Empty && Settings.Instance.MaxLogLevel > 0)
                    {
                        SpawnTimerLog(String.Format("Updating Kill Time for Spawn: {0} Name: {1} Killed: {2}", mob.SpawnLoc, mob.Name, log));
                    }
                }
            }

            catch (Exception ex) { LogLib.WriteLine("Error updating the SPAWNTIMER for " + mob.Name + ": ", ex); }



            MustSave = true;
        }
コード例 #3
0
ファイル: SPAWNTIMER.cs プロジェクト: Lenothx/MySEQ
        // 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);
        }
コード例 #4
0
ファイル: ListViewPanel.cs プロジェクト: Lenothx/MySEQ
        private void mnuContext_Opened(object sender, EventArgs e)

        {
            mobname = "";

            ListView.SelectedIndexCollection sel = listView.SelectedIndices;
            mnuStickyTimer.Visible = ListType == 1;
            if (sel.Count > 0)
            {
                if (ListType == 0)
                {
                    mobname   = RegexHelper.FilterMobName(listView.Items[sel[0]].SubItems[18].Text);
                    mobname   = mobname.Replace("_", " ");
                    mobname   = mobname.Trim();
                    smoblevel = "";
                    smoblevel = listView.Items[sel[0]].SubItems[1].Text;
                    if (smoblevel.Length > 0)
                    {
                        bool isNum = int.TryParse(smoblevel, out var Num);

                        if (isNum)
                        {
                            moblevel = Num;
                        }
                    }
                }
                else if (ListType == 1)
                {
                    smoblevel = "";
                    smoblevel = listView.Items[sel[0]].SubItems[1].Text;
                    if (smoblevel.Length > 0)
                    {
                        bool isNum = int.TryParse(smoblevel, out var Num);

                        if (isNum)
                        {
                            moblevel = Num;
                        }
                    }
                    mobname = RegexHelper.FixMobNameMatch(listView.Items[sel[0]].SubItems[0].Text);
                    mobname = mobname.Trim();
                }
                else
                {
                    mobname = listView.Items[sel[0]].SubItems[0].Text;
                }
            }

            if ((sel.Count > 0) && (mobname.Length > 0))

            {
                mnuAddGlobalFilter.Text = "Add '" + mobname + "' &Global Alert Filter";

                mnuAddZoneFilter.Text = "'" + mobname + "'";

                toolStriConcolor.Text    = "Base Concolor on '" + mobname + "' (" + smoblevel + ")";
                mnuAddZoneFilter.Visible = true;

                menuItem3.Visible = true;

                mnuAddZoneFilter.Enabled = true;

                mnuAddGlobalFilter.Enabled = true;

                mnuAddZoneHuntFilter.Enabled = true;

                mnuAddZoneCautionFilter.Enabled = true;

                mnuAddZoneDangerFilter.Enabled = true;

                mnuAddZoneRareFilter.Enabled = true;

//                addZoneEmailAlertFilter.Enabled = ListType != 2; // Not for ground items

                mnuEditZoneFilters.Enabled = true;

                mnuEditGlobalFilters.Enabled = true;

                mnuReloadZoneFilters.Enabled = true;

                mnuSearchAllakhazam.Enabled = true;
                if (ListType == 0)
                {
                    addMapLabelToolStripMenuItem.Enabled = true;
                    f1.alertX = float.Parse(listView.Items[sel[0]].SubItems[13].Text);
                    f1.alertY = float.Parse(listView.Items[sel[0]].SubItems[14].Text);
                    f1.alertZ = float.Parse(listView.Items[sel[0]].SubItems[15].Text);
                }
                else if (ListType == 1)
                {
                    // add what is in the menu showing
                    addMapLabelToolStripMenuItem.Enabled = true;
                    f1.alertX = float.Parse(listView.Items[sel[0]].SubItems[4].Text);
                    f1.alertY = float.Parse(listView.Items[sel[0]].SubItems[5].Text);
                    f1.alertZ = float.Parse(listView.Items[sel[0]].SubItems[6].Text);
                    // search for a better name to use for this spawn point
                    SPAWNTIMER st = eq.FindListViewTimer(listView.Items[sel[0]]);
                    //SPAWNTIMER st = eq.FindTimer(1.0f, float.Parse(listView.Items[sel[0]].SubItems[4].Text), float.Parse(listView.Items[sel[0]].SubItems[5].Text));
                    if (st != null)
                    {
                        mnuStickyTimer.Checked = st.sticky;
                        foreach (string name in st.AllNames.Split(','))
                        {
                            var bname = RegexHelper.TrimName(name);
                            if (RegexHelper.RegexMatch(bname))
                            {
                                mobname = bname;
                                mnuAddZoneFilter.Text = "'" + mobname + "'";
                                f1.alertX             = st.X;
                                f1.alertY             = st.Y;
                                f1.alertZ             = st.Z;
                                break;
                            }
                        }
                    }
                }
            }
            else
            {
                // This is where we update the menu view if no selected item

                mnuAddGlobalFilter.Text = "Add '' &Global Filter";

                mnuAddZoneFilter.Text = "''";

                mnuStickyTimer.Enabled = false;

                mnuAddZoneFilter.Visible = false;

                menuItem3.Visible = false;

                mnuAddGlobalFilter.Enabled = false;

                mnuAddZoneFilter.Enabled = false;

                mnuAddZoneHuntFilter.Enabled = false;

                mnuAddZoneCautionFilter.Enabled = false;

                mnuAddZoneDangerFilter.Enabled = false;

                mnuAddZoneRareFilter.Enabled = false;

//                addZoneEmailAlertFilter.Enabled = false;

                mnuEditZoneFilters.Enabled = true;

                mnuEditGlobalFilters.Enabled = true;

                mnuReloadZoneFilters.Enabled = true;

                mnuSearchAllakhazam.Enabled = false;

                addMapLabelToolStripMenuItem.Enabled = false;
            }
        }
コード例 #5
0
ファイル: MobsTimer.cs プロジェクト: Lenothx/MySEQ
        // Add a new spawn, or do a re-spawn

        public void Spawn(SPAWNINFO si)
        {
            try

            {
                // ignore players boats boxes corpses and invis man races of level 1

                if (si.IsPlayer() || (si.Race == 141) || (si.Race == 533) || (si.Race == 376) || (si.Type == 2 || si.Type == 3))
                {
                    return;
                }



                // ignore ldon objects, mounts, pets, mercs, and familiars

                if (si.isLDONObject || si.isEventController || si.isPet || si.isMerc || si.isFamiliar || si.isMount)
                {
                    return;
                }



                // ignore any mobs where name starts with "_"

                if (si.Name.IndexOf("_") == 0)
                {
                    return;
                }



                // If made it this far, then it is a mob that can perform alerts for proximity checks.

                si.alertMob = true;



                si.SpawnLoc = String.Format("{0:f3},{1:f3}", si.Y, si.X);

                si.ZoneSpawnLoc = String.Format("{0}{1:f3},{2:f3}", mapName.ToLower(), si.Y, si.X);



                if (!mobsTimer.ContainsKey(si.ZoneSpawnLoc))

                {
                    // First spawn ever



                    SPAWNTIMER st = new SPAWNTIMER(si, DateTime.Now);

                    st.zone = mapName;

                    try

                    {
                        mobsTimer.Add(si.ZoneSpawnLoc, st);

                        if (Settings.Instance.MaxLogLevel > 0)
                        {
                            SpawnTimerLog(String.Format("Added Spawn: {0} Name: {1}", si.SpawnLoc, si.Name));
                        }
                    }

                    catch (Exception ex) { LogLib.WriteLine("Error adding new SPAWNTIMER for " + si.Name + ": ", ex); }
                }

                else

                {
                    // Process a true re-spawn

                    LogSpawns(String.Format("[SPAWN] Loc: {0} Name: {1}", si.SpawnLoc, si.Name));

                    SPAWNTIMER st = (SPAWNTIMER)mobsTimer[si.ZoneSpawnLoc];

                    SPAWNTIMER st2 = null;

                    if (mobsTimer2.ContainsKey(si.ZoneSpawnLoc))
                    {
                        st2 = (SPAWNTIMER)mobsTimer2[si.ZoneSpawnLoc];
                    }

                    int last_time = st.SpawnTimer;

                    string log = "";

                    if (st2 != null)
                    {
                        log = st2.ReSpawn(si.Name);
                        // since we updated from st2, update st values
                        st.LastSpawnName = st2.LastSpawnName;
                        st.SpawnCount    = st2.SpawnCount;
                        st.SpawnTimer    = st2.SpawnTimer;
                        st.NextSpawnDT   = st2.NextSpawnDT;
                        st.NextSpawnStr  = st2.NextSpawnStr;
                        st.SpawnTimeDT   = st2.SpawnTimeDT;
                        st.SpawnTimeStr  = st2.SpawnTimeStr;
                        st.allNames      = st2.allNames;
                        st.KillTimeDT    = st2.KillTimeDT;
                        st.KillTimeStr   = st2.KillTimeStr;
                    }
                    else
                    {
                        log = st.ReSpawn(si.Name);
                    }

                    if (Settings.Instance.MaxLogLevel > 0)
                    {
                        SpawnTimerLog(String.Format("Found Spawn: {0} Name: {1}", si.SpawnLoc, si.Name));

                        if (log != string.Empty)
                        {
                            SpawnTimerLog(log);
                        }
                    }

                    if (st.SpawnCount > 1 && st.SpawnTimer > 10)

                    {
                        // The mob was known to spawn once, and is now re-spawning for the first

                        // time... so copy it to the other hash
                        if (!mobsTimer2.ContainsKey(si.ZoneSpawnLoc))
                        {
                            mobsTimer2.Add(si.ZoneSpawnLoc, st);
                        }

                        MustSave = true;
                    }
                }
            }

            catch (Exception ex) { LogLib.WriteLine("Error creating new SPAWNTIMER for " + si.Name + ": ", ex); }
        }
コード例 #6
0
ファイル: MobsTimer.cs プロジェクト: Lenothx/MySEQ
        // 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);
        }
コード例 #7
0
ファイル: MobsTimer.cs プロジェクト: Lenothx/MySEQ
        // Loads timers from a file for the current map

        public void LoadTimers()

        {
            LogLib.WriteLine("Entering LoadTimers", LogLevel.Trace);



            if ((!Settings.Instance.saveSpawnTimers) || (mapName.Length == 0))
            {
                return;
            }

            // Dont load timers for these zones
            if (mapName == "clz" || mapName == "default" || mapName == "bazaar" || (mapName.IndexOf("guild") == 0) || mapName == "poknowledge" || mapName == "nexus")
            {
                return;
            }


            try

            {
                string timerpath = Settings.Instance.TimerDir;

                string timerfile = Path.Combine(timerpath, "spawns-" + mapName + ".txt");

                if (!Directory.Exists(timerpath))
                {
                    Directory.CreateDirectory(timerpath);
                    return;
                }

                if (!File.Exists(timerfile))

                {
                    return;
                }

                StreamReader sr;



                try

                {
                    sr = new StreamReader(File.Open(timerfile, FileMode.Open));
                }

                catch (Exception)

                {
                    return;
                }



                try

                {
                    String line;

                    int count = 0;

                    while ((line = sr.ReadLine()) != null)

                    {
                        try

                        {
                            SPAWNTIMER st = new SPAWNTIMER(line);

                            st.zone = mapName.ToLower();

                            st.ZoneSpawnLoc = st.zone + st.SpawnLoc;

                            count++;

                            if (mobsTimer.ContainsKey(st.ZoneSpawnLoc))

                            {
                                // We already know about this mob. Copy some of the information.

                                SPAWNTIMER stold = (SPAWNTIMER)mobsTimer[st.ZoneSpawnLoc];

                                // check if we add names in the merge.  If so, make sure we save.
                                int startlen = stold.allNames.Length;
                                stold.Merge(st);
                                if (stold.allNames.Length > startlen)
                                {
                                    MustSave = true;
                                }

                                if (stold.SpawnCount > 1 && stold.SpawnTimer > 10)
                                {
                                    if (!mobsTimer2.ContainsKey(stold.ZoneSpawnLoc))
                                    {
                                        mobsTimer2.Add(stold.ZoneSpawnLoc, stold);
                                    }
                                }
                            }

                            else

                            {
                                if (st.SpawnCount > 1)

                                {
                                    if (st.SpawnTimer > 10)

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

                                        if (DateTime.Now > st.KillTimeDT.Add(Diff))
                                        {
                                            st.KillTimeDT = DateTime.MinValue;
                                        }

                                        if (DateTime.Now > st.NextSpawnDT)

                                        {
                                            st.NextSpawnDT = DateTime.MinValue;

                                            st.KillTimeDT = DateTime.MinValue;

                                            st.NextSpawnStr = "";
                                        }

                                        mobsTimer2.Add(st.ZoneSpawnLoc, st);
                                    }

                                    mobsTimer.Add(st.ZoneSpawnLoc, st);
                                }
                            }
                        }

                        catch (Exception ex) { LogLib.WriteLine("Error in LoadTimers(), processing line:\r\n" + line, ex); }
                    }



                    LogLib.WriteLine("Spawns read: " + count, LogLevel.Debug);
                }

                finally

                {
                    sr.Close();
                }
            }

            catch (Exception ex) { LogLib.WriteLine("Error in LoadTimers():", ex); }



            LogLib.WriteLine("Exiting LoadTimers", LogLevel.Trace);
        }