示例#1
0
        public void loadConfig(string fname)
        {
            StreamReader readfile;
            try
            {

                readfile = new StreamReader(new FileStream(fname, FileMode.Open), Encoding.UTF8);
                if (readfile == null)
                    return;
            }
            catch
            {
                MessageBox.Show("couldn't open file {0} for reading", fname);
                return;
            }
            string line;
            int count;
            line = readfile.ReadLine();
            try
            {
                count = Convert.ToInt32(line);
            }
            catch
            {
                count = 0;
            }
            listView1.Items.Clear();
            c.fightbufflist.Clear();
            buffid = 0;
            char[] sep = new char[2];
            sep[0] = ','; sep[1] = ' ';

            for (int i = 0; i < count; i++)
            {
                try
                {
                    line = readfile.ReadLine();
                    string snames = "";
                    string[] firstsplit = line.Split(':');
                    PlayerBuffs b = new PlayerBuffs();
                    b.player = firstsplit[0];
                    b.buffid = buffid;
                    buffid++;
                    b.mre = new System.Threading.ManualResetEvent(false);
                    b.objid = 0;
                    b.bufflist = new Dictionary<uint, skill>();
                    CharInfo[] cinfos = new CharInfo[gs.allplayerinfo.Count];
                    gs.allplayerinfo.Values.CopyTo(cinfos, 0);
                    if (b.player == c.pinfo.Name || b.player == "Self" || b.player == "self")
                    {
                        //self buffs
                        b.objid = c.pinfo.ObjID;
                    }
                    else if (b.player == "")
                    {
                        b.self = true;
                    }
                    else if (b.player == gs.leader.pinfo.Name)
                    {
                        b.objid = gs.leader.pinfo.ObjID;
                    }
                    else
                    {
                        foreach (CharInfo cinfo in cinfos)
                        {
                            if (b.player == cinfo.Name)
                            {
                                b.objid = cinfo.ID;
                                break;
                            }
                        }
                    }
                    string[] secondsplit = firstsplit[1].Split(sep, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string s in secondsplit)
                    {
                        try
                        {
                            uint skillid = Convert.ToUInt32(s);
                            string skillname = gs.skills[skillid].name;
                            foreach (skill loadskill in allskills.Items)
                            {
                                if (loadskill.id == skillid)
                                {
                                    //found a match
                                    b.bufflist.Add(skillid, loadskill);
                                    if (snames == "")
                                        snames = loadskill.name;
                                    else
                                        snames = snames + ";" + loadskill.name;
                                    break;
                                }
                            }
                        }
                        catch
                        {
                        }
                    }
                    c.fightbufflist.Add(b);
                    //update view box
                    ListViewItem lvit = new ListViewItem(b.player);
                    lvit.SubItems.Add(snames);
                    lvit.SubItems.Add("--");
                    lvit.Tag = b;
                    listView1.Items.Add(lvit);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
            readfile.Close();
        }
示例#2
0
        private void doBuff(ByteBuffer useskillmsg, int skillindex, PlayerBuffs p)
        {
            if (p.objid == 0 && p.self != true)
            {
                //we haven't found the player yet
                //search in allplayerinfo
                CharInfo[] cinfos = new CharInfo[gs.allplayerinfo.Count];
                gs.allplayerinfo.Values.CopyTo(cinfos, 0);
                foreach (CharInfo cinfo in cinfos)
                {
                    if (p.player == cinfo.Name)
                    {
                        p.objid = cinfo.ID;
                    }
                }

            }

            if (p.objid != 0)
            {
                //target the guy
                //execute the list of skills on him
                ByteBuffer action = new ByteBuffer();
                action.WriteByte(0x1f);
                action.WriteUInt32(p.objid);
                action.WriteInt32(pinfo.X);
                action.WriteInt32(pinfo.Y);
                action.WriteInt32(pinfo.Z);
                action.WriteByte(0);

                NewMessage(action);
                p.lastuse = DateTime.Now;
                foreach (skill s in p.bufflist.Values)
                {
                    if (s.lastuse.AddMilliseconds(s.reuseDelay) > DateTime.Now)
                    {
                        ReSkill r = new ReSkill(s, p.objid);
                        lock (redolistlock)
                        {
                            redolist.Enqueue(r);
                        }
                        continue;
                    }
                    useskillmsg.SetIndex(skillindex);
                    useskillmsg.WriteUInt32(s.id);
                    NewMessage(useskillmsg);
                    s.mre.WaitOne(10000);
                    s.mre.Reset();
                    if (s.skillstate())
                    {
                        System.Threading.Thread.Sleep((int)s.hitTime);
                    }
                    else
                    {
                        ReSkill r = new ReSkill(s, p.objid);
                        lock (redolistlock)
                        {
                            redolist.Enqueue(r);
                        }
                    }
                    //wait for response
                    //s.lastuse = DateTime.Now;

                }

            }
            else if (p.self)
            {
                p.lastuse = DateTime.Now;
                foreach (skill s in p.bufflist.Values)
                {
                    if (s.lastuse.AddMilliseconds(s.reuseDelay) > DateTime.Now)
                    {
                        ReSkill r = new ReSkill(s, p.objid);
                        lock (redolistlock)
                        {
                            redolist.Enqueue(r);
                        }
                        continue;
                    }
                    useskillmsg.SetIndex(skillindex);
                    useskillmsg.WriteUInt32(s.id);
                    NewMessage(useskillmsg);
                    s.mre.WaitOne(10000);
                    s.mre.Reset();
                    if (s.skillstate())
                    {
                        System.Threading.Thread.Sleep((int)s.hitTime);
                    }
                    else
                    {
                        ReSkill r = new ReSkill(s, p.objid);
                        lock (redolistlock)
                        {
                            redolist.Enqueue(r);
                        }
                    }
                    //wait for response
                    //s.lastuse = DateTime.Now;

                }

            }
        }
示例#3
0
        private void button1_Click(object sender, EventArgs e)
        {
            PlayerBuffs buff = null;

            char[] sep = new char[1];
            sep[0] = ';';
            string[] names = value.Text.Split(sep);

            foreach (string name in names)
            {
                buff = new PlayerBuffs();
                buff.bufflist = new Dictionary<uint, skill>();
                buff.mre = new System.Threading.ManualResetEvent(false);
                buff.buffid = buffid;
                buffid++;
                buff.objid = 0;
                buff.player = name;
                CharInfo[] cinfos = new CharInfo[gs.allplayerinfo.Count];
                gs.allplayerinfo.Values.CopyTo(cinfos, 0);
                if (buff.player == c.pinfo.Name || buff.player == "Self" || buff.player == "self")
                {
                    //self buffs
                    buff.objid = c.pinfo.ObjID;
                }
                else if (buff.player == "")
                {
                    buff.self = true;
                }
                else if (buff.player == gs.leader.pinfo.Name)
                {
                    buff.objid = gs.leader.pinfo.ObjID;
                }
                else
                {
                    foreach (CharInfo cinfo in cinfos)
                    {
                        if (buff.player == cinfo.Name)
                        {
                            buff.objid = cinfo.ID;
                            break;
                        }
                    }
                }

                ListBox.ObjectCollection all = sklist.Items;
                string snames = "";
                foreach (object o in all)
                {
                    try
                    {
                        skill s = (skill)o;
                        buff.bufflist.Add(s.id, s);
                        if (snames == "")
                            snames = s.name;
                        else
                            snames = snames + ";" + s.name;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Exception in add {0}", ex.ToString());
                    }
                }
                c.fightbufflist.Add(buff);

                //update view box
                ListViewItem lvit = new ListViewItem(buff.player);
                lvit.SubItems.Add(snames);
                lvit.SubItems.Add("--");
                lvit.Tag = buff;
                listView1.Items.Add(lvit);
            }

            //int sindex = allskills.SelectedIndex;
            //if (sindex != -1)
            //{
            //    string skillname = allskills.Items[allskills.SelectedIndex].ToString();
            //    skill s = (skill)(allskills.Items[allskills.SelectedIndex]);
            //    buff.bufflist.Add(s.id, s);
            //    //uint skillid = ((skill)sl.Items[sl.SelectedIndex]).id;
            //    //buff.skillid.Add(skillid, skillname);

            //    try
            //    {

            //        if (buff.objid == 0)
            //        {
            //            CharInfo[] cinfos = new CharInfo[gs.allplayerinfo.Count];
            //            gs.allplayerinfo.Values.CopyTo(cinfos, 0);
            //            foreach (CharInfo cinfo in cinfos)
            //            {
            //                if (buff.player == cinfo.Name)
            //                {
            //                    buff.objid = cinfo.ID;
            //                }
            //            }

            //            c.bufflist.Add(buff);
            //        }
            //    }
            //    catch
            //    {
            //    }
            //}
        }
示例#4
0
        private void button1_Click(object sender, EventArgs e)
        {
            PlayerBuffs buff = null;

            char[] sep = new char[1];
            sep[0] = ';';
            string[] names = value.Text.Split(sep);
            uint timeBuff;
            try
            {
                timeBuff = Convert.ToUInt32(tbBuffTime.Text);
            }
            catch
            {
                timeBuff = 18;
            }

            lock (c.bufflock)
            {

                foreach (string name in names)
                {
                    buff = new PlayerBuffs();
                    buff.bufflist = new Dictionary<uint, skill>();
                    buff.mre = new System.Threading.ManualResetEvent(false);
                    buff.buffid = buffid;
                    buffid++;
                    buff.objid = 0;
                    buff.player = name;
                    buff.bufftimer = timeBuff;
                    buff.lastuse = new DateTime();
                    CharInfo[] cinfos = new CharInfo[gs.allplayerinfo.Count];
                    gs.allplayerinfo.Values.CopyTo(cinfos, 0);
                    if (buff.player == c.pinfo.Name || buff.player == "Self" || buff.player == "self")
                    {
                        //self buffs
                        buff.objid = c.pinfo.ObjID;
                    }
                    else if (buff.player == "")
                    {
                        buff.self = true;
                    }
                    else if (buff.player == gs.leader.pinfo.Name)
                    {
                        buff.objid = gs.leader.pinfo.ObjID;
                    }
                    else
                    {
                        foreach (CharInfo cinfo in cinfos)
                        {
                            if (buff.player == cinfo.Name)
                            {
                                buff.objid = cinfo.ID;
                                break;
                            }
                        }
                    }

                    ListBox.ObjectCollection all = sklist.Items;
                    string snames = "";
                    foreach (object o in all)
                    {
                        try
                        {
                            skill s = (skill)o;
                            buff.bufflist.Add(s.id, s);
                            if (snames == "")
                                snames = s.name;
                            else
                                snames = snames + ";" + s.name;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Exception in add {0}", ex.ToString());
                        }
                    }
                    c.bufflist.Add(buff);
                    //update view box
                    ListViewItem lvit = new ListViewItem(buff.player);
                    lvit.SubItems.Add(snames);
                    lvit.SubItems.Add("--");
                    lvit.Tag = buff;
                    listView1.Items.Add(lvit);
                }
            }
        }