예제 #1
0
        private void launchBuff(skill s, uint objectid, int shift)
        {
            if (s.lastuse.AddMilliseconds(s.reuseDelay) > DateTime.Now)
            {
                ReSkill r = new ReSkill(s, objectid);
                lock (redolistlock)
                {
                    redolist.Enqueue(r);
                }

                return;
            }
            s.setstate(false);
            s.mre.Reset();
            useSkill(s.id, objectid, shift);
            s.mre.WaitOne(2000);
            s.mre.Reset();
            if (s.skillstate())
            {
                //wait for response
                s.lastuse = DateTime.Now;
                System.Threading.Thread.Sleep((int)s.hitTime);
            }
            else
            {
                //System.Console.WriteLine("skill failed");
                ReSkill r = new ReSkill(s, objectid);
                lock (redolistlock)
                {
                    redolist.Enqueue(r);
                }
            }
        }
예제 #2
0
        public void dancefunction()
        {
            danceq = new Queue();
            dancemre = new ManualResetEvent(false);
            evtSkill s;

            while (true)
            {
                dancemre.WaitOne();

                if (gs.buffs == false)
                {
                    lock (dancelock)
                    {
                        danceq.Clear();

                    }
                }

                while (danceq.Count > 0)
                {
                    startdance = true;
                    lock (dancelock)
                    {
                        if (danceq.Count == 0)
                            continue;

                        s = (evtSkill)danceq.Dequeue();
                    }
                    //System.Console.WriteLine("launching skill {0} - event {1}", s.act.name, s.evt.name);
                    s.succeed = false;

                    launchMagic(s.act, 0, 0);
                    //bool ret = s.mre.WaitOne(3000);
                    //s.mre.Reset();
                    if (s.succeed || s.act.skillstate())
                    {

                        ////skill succeeded
                        //probably do nothing?
                        //Console.WriteLine("skill {0} succeeded", s.act.name);
                        s.act.setstate(false);

                    }
                    else
                    {
                        //skill failed .. requeue
                        //                        Console.WriteLine("skill {0} failed", s.act.name);
                        lock (dancelock)
                        {
                            ReSkill r = new ReSkill(s.act, 0);
                            redolist.Enqueue(r);
                        }
                    }
                }
                startdance = false;
                dancemre.Reset();
            }
        }
예제 #3
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;

                }

            }
        }