コード例 #1
0
        static public uint GetCharID(string str)
        {
            str = str.ToUpperInvariant();

            //is self?
            if (System.String.Equals(str, Globals.gamedata.my_char.Name.ToUpperInvariant()))
            {
                return(Globals.gamedata.my_char.ID);
            }

            //is it a party member?
            Globals.PartyLock.EnterReadLock();
            try
            {
                PartyMember pmem = Util.GetCharParty(str);

                if (pmem != null)
                {
                    return(pmem.ID);
                }
            }
            finally
            {
                Globals.PartyLock.ExitReadLock();
            }

            //is in the list of chars?
            Globals.PlayerLock.EnterReadLock();
            try
            {
                CharInfo player = Util.GetChar(str);

                if (player != null)
                {
                    return(player.ID);
                }
            }
            finally
            {
                Globals.PlayerLock.ExitReadLock();
            }

            return(0);
        }
コード例 #2
0
        static public string GetCharName(uint id)
        {
            //is self?
            if (id == Globals.gamedata.my_char.ID)
            {
                return(Globals.gamedata.my_char.Name);
            }

            //is it a party member?
            Globals.PartyLock.EnterReadLock();
            try
            {
                PartyMember pmem = Util.GetCharParty(id);

                if (pmem != null)
                {
                    return(pmem.Name);
                }
            }
            finally
            {
                Globals.PartyLock.ExitReadLock();
            }

            //is in the list of chars?
            Globals.PlayerLock.EnterReadLock();
            try
            {
                CharInfo player = Util.GetChar(id);

                if (player != null)
                {
                    return(player.Name);
                }
            }
            finally
            {
                Globals.PlayerLock.ExitReadLock();
            }

            return("-nobody-");
        }
コード例 #3
0
        static public void GetCharLoc(uint id, ref int x, ref int y, ref int z)
        {
            //this is for getting the location of a player, self or otherwise, for the purpose of buffing
            //dont give 2 shits about buffing mobs/items

            //is self?
            if (Globals.gamedata.my_char.ID == id)
            {
                x = Util.Float_Int32(Globals.gamedata.my_char.X);
                y = Util.Float_Int32(Globals.gamedata.my_char.Y);
                z = Util.Float_Int32(Globals.gamedata.my_char.Z);
                return;
            }

            //is my pet?
            if (Globals.gamedata.my_pet.ID == id)
            {
                x = Util.Float_Int32(Globals.gamedata.my_pet.X);
                y = Util.Float_Int32(Globals.gamedata.my_pet.Y);
                z = Util.Float_Int32(Globals.gamedata.my_pet.Z);
                return;
            }
            if (Globals.gamedata.my_pet1.ID == id)
            {
                x = Util.Float_Int32(Globals.gamedata.my_pet1.X);
                y = Util.Float_Int32(Globals.gamedata.my_pet1.Y);
                z = Util.Float_Int32(Globals.gamedata.my_pet1.Z);
                return;
            }
            if (Globals.gamedata.my_pet2.ID == id)
            {
                x = Util.Float_Int32(Globals.gamedata.my_pet2.X);
                y = Util.Float_Int32(Globals.gamedata.my_pet2.Y);
                z = Util.Float_Int32(Globals.gamedata.my_pet2.Z);
                return;
            }
            if (Globals.gamedata.my_pet3.ID == id)
            {
                x = Util.Float_Int32(Globals.gamedata.my_pet3.X);
                y = Util.Float_Int32(Globals.gamedata.my_pet3.Y);
                z = Util.Float_Int32(Globals.gamedata.my_pet3.Z);
                return;
            }

            //is in the list of chars?
            Globals.PlayerLock.EnterReadLock();
            try
            {
                CharInfo player = Util.GetChar(id);

                if (player != null)
                {
                    x = Util.Float_Int32(player.X);
                    y = Util.Float_Int32(player.Y);
                    z = Util.Float_Int32(player.Z);
                    return;
                }
            }
            finally
            {
                Globals.PlayerLock.ExitReadLock();
            }

            //is it a party member?
            Globals.PartyLock.EnterReadLock();
            try
            {
                PartyMember pmem = Util.GetCharParty(id);

                if (pmem != null)
                {
                    x = pmem.X;
                    y = pmem.Y;
                    z = pmem.Z;
                    return;
                }
            }
            finally
            {
                Globals.PartyLock.ExitReadLock();
            }
        }
コード例 #4
0
        static public void GetLoc(uint id, ref int x, ref int y, ref int z)
        {
            //is self?
            if (Globals.gamedata.my_char.ID == id)
            {
                x = Util.Float_Int32(Globals.gamedata.my_char.X);
                y = Util.Float_Int32(Globals.gamedata.my_char.Y);
                z = Util.Float_Int32(Globals.gamedata.my_char.Z);
                return;
            }

            //is my pet?
            if (Globals.gamedata.my_pet.ID == id)
            {
                x = Util.Float_Int32(Globals.gamedata.my_pet.X);
                y = Util.Float_Int32(Globals.gamedata.my_pet.Y);
                z = Util.Float_Int32(Globals.gamedata.my_pet.Z);
                return;
            }
            if (Globals.gamedata.my_pet1.ID == id)
            {
                x = Util.Float_Int32(Globals.gamedata.my_pet1.X);
                y = Util.Float_Int32(Globals.gamedata.my_pet1.Y);
                z = Util.Float_Int32(Globals.gamedata.my_pet1.Z);
                return;
            }
            if (Globals.gamedata.my_pet2.ID == id)
            {
                x = Util.Float_Int32(Globals.gamedata.my_pet2.X);
                y = Util.Float_Int32(Globals.gamedata.my_pet2.Y);
                z = Util.Float_Int32(Globals.gamedata.my_pet2.Z);
                return;
            }
            if (Globals.gamedata.my_pet3.ID == id)
            {
                x = Util.Float_Int32(Globals.gamedata.my_pet3.X);
                y = Util.Float_Int32(Globals.gamedata.my_pet3.Y);
                z = Util.Float_Int32(Globals.gamedata.my_pet3.Z);
                return;
            }

            //is in the list of chars?
            Globals.PlayerLock.EnterReadLock();
            try
            {
                CharInfo player = Util.GetChar(id);

                if (player != null)
                {
                    x = Util.Float_Int32(player.X);
                    y = Util.Float_Int32(player.Y);
                    z = Util.Float_Int32(player.Z);
                    return;
                }
            }
            finally
            {
                Globals.PlayerLock.ExitReadLock();
            }

            //is it a party member?
            Globals.PartyLock.EnterReadLock();
            try
            {
                PartyMember pmem = Util.GetCharParty(id);

                if (pmem != null)
                {
                    x = pmem.X;
                    y = pmem.Y;
                    z = pmem.Z;
                    return;
                }
            }
            finally
            {
                Globals.PartyLock.ExitReadLock();
            }

            Globals.NPCLock.EnterReadLock();
            try
            {
                NPCInfo npc = Util.GetNPC(id);

                if (npc != null)
                {
                    x = Util.Float_Int32(npc.X);
                    y = Util.Float_Int32(npc.Y);
                    z = Util.Float_Int32(npc.Z);
                    return;
                }
            }
            finally
            {
                Globals.NPCLock.ExitReadLock();
            }
        }
コード例 #5
0
ファイル: ClientPackets.cs プロジェクト: stephenZh/l2net
        public static void Add_PartyBuff(uint object_id, uint skill_id, int skill_duration, PartyMember ph)
        {
            // XXX: Not Thread Safe by itself
            try
            {
                if (Globals.gamedata.PartyMembers.ContainsKey(object_id))
                {
                    try
                    {
                        CharBuff cb = new CharBuff();
                        cb.ID = skill_id;
                        cb.SkillLevel = 1; // partyspelld doesnt give level, so set to 1 so we can lookup the name if needed
                        /*if (skill_duration == -1)
                        {
                            // slothmo: this is a delete for a buff we don't have...
                            // d00d: actually -1 == toggle buff, fix later
                        }
                        else
                        {*/
                            cb.ExpiresTime = System.DateTime.Now.AddSeconds(skill_duration).Ticks;
                            cb.EFFECT_TIME = skill_duration;
                            //v392B11: This hopefully fixes F4 packeterror
                            if (ph.my_buffs.ContainsKey(cb.ID))
                            {
                                ph.my_buffs[cb.ID] = cb;
                            }
                            else
                            {
                                ph.my_buffs.Add(cb.ID, cb);
                            }
                        //}
                    }
                    finally
                    {

                    }
                }
            }
            finally
            {
            }
        }
コード例 #6
0
ファイル: ClientPackets.cs プロジェクト: stephenZh/l2net
        public static void Load_PartyInfo(ByteBuffer buff)
        {
            Globals.gamedata.PartyLeader = buff.ReadUInt32();
            Globals.gamedata.PartyLoot = buff.ReadUInt32();
            uint cnt = buff.ReadUInt32();

            Globals.PartyLock.EnterWriteLock();
            try
            {
                Globals.gamedata.PartyMembers.Clear();
                Globals.gamedata.PartyCount = cnt;

                for (uint i = 0; i < cnt; i++)
                {
                    PartyMember pmem = new PartyMember();
                    pmem.Load(buff);

                    if (Globals.gamedata.PartyMembers.ContainsKey(pmem.ID))
                    {
                        Globals.gamedata.PartyMembers[pmem.ID] = pmem;
                    }
                    else
                    {
                        Globals.gamedata.PartyMembers.Add(pmem.ID, pmem);
                    }
                }
            }
            finally
            {
                Globals.PartyLock.ExitWriteLock();
            }

            if (Globals.gamedata.CurrentScriptState == ScriptState.Running)
            {
                ScriptEvent sc_ev = new ScriptEvent();
                sc_ev.Type = EventType.JoinParty;
                ScriptEngine.SendToEventQueue(sc_ev);
            }
        }
コード例 #7
0
ファイル: ClientPackets.cs プロジェクト: stephenZh/l2net
        public static void Add_PartyInfo(ByteBuffer buff)
        {
            buff.ReadUInt32();
            buff.ReadUInt32();

            PartyMember pmem = new PartyMember();
            pmem.Load(buff);

            Globals.PartyLock.EnterWriteLock();
            try
            {
                if (Globals.gamedata.PartyMembers.ContainsKey(pmem.ID))
                {
                    Globals.gamedata.PartyMembers[pmem.ID] = pmem;
                }
                else
                {
                    Globals.gamedata.PartyMembers.Add(pmem.ID, pmem);
                    Globals.gamedata.PartyCount++;
                }
            }
            finally
            {
                Globals.PartyLock.ExitWriteLock();
            }
        }