Ejemplo n.º 1
0
        static public void F_CREATE_CHARACTER(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;
            CreateInfo Info;

            Info.slot = packet.GetUint8();
            Info.race = packet.GetUint8();
            Info.career = packet.GetUint8();
            Info.sex = packet.GetUint8();
            Info.model = packet.GetUint8();
            Info.NameSize = packet.GetUint16();
            packet.Skip(2);

            byte[] Traits = new byte[8];
            packet.Read(Traits, 0, Traits.Length);
            packet.Skip(7);

            string Name = packet.GetString(Info.NameSize);

            if (Name.Length > 2 && !CharMgr.NameIsUsed(Name))
            {
                CharacterInfo CharInfo = CharMgr.GetCharacterInfo(Info.career);
                if (CharInfo == null)
                {
                    Log.Error("ON_CREATE", "Can not find career :" + Info.career);
                }
                else
                {

                    Log.Success("OnCreate", "New Character : " + Name);

                    Character Char = new Character();
                    Char.AccountId = cclient._Account.AccountId;
                    Char.bTraits = Traits;
                    Char.Career = Info.career;
                    Char.CareerLine = CharInfo.CareerLine;
                    Char.ModelId = Info.model;
                    Char.Name = Name;
                    Char.Race = Info.race;
                    Char.Realm = CharInfo.Realm;
                    Char.RealmId = Program.Rm.RealmId;
                    Char.Sex = Info.sex;
                    Char.FirstConnect = true;

                    if (!CharMgr.CreateChar(Char))
                    {
                        Log.Error("CreateCharacter", "Hack : can not create more than 10 characters!");
                    }
                    else
                    {

                        Character_item Citm = null;
                        List < CharacterInfo_item > Items = CharMgr.GetCharacterInfoItem(Char.CareerLine);

                        foreach (CharacterInfo_item Itm in Items)
                        {
                            if (Itm == null)
                                continue;

                            Citm = new Character_item();
                            Citm.Counts = Itm.Count;
                            Citm.CharacterId = Char.CharacterId;
                            Citm.Entry = Itm.Entry;
                            Citm.ModelId = Itm.ModelId;
                            Citm.SlotId = Itm.SlotId;
                            CharMgr.CreateItem(Citm);
                        }

                        Character_value CInfo = new Character_value();
                        CInfo.CharacterId = Char.CharacterId;
                        CInfo.Level = 1;
                        CInfo.Money = 0;
                        CInfo.Online = false;
                        CInfo.RallyPoint = CharInfo.RallyPt;
                        CInfo.RegionId = CharInfo.Region;
                        CInfo.Renown = 0;
                        CInfo.RenownRank = 1;
                        CInfo.RestXp = 0;
                        CInfo.Skills = CharInfo.Skills;
                        CInfo.Speed = 100;
                        CInfo.WorldO = CharInfo.WorldO;
                        CInfo.WorldX = CharInfo.WorldX;
                        CInfo.WorldY = CharInfo.WorldY;
                        CInfo.WorldZ = CharInfo.WorldZ;
                        CInfo.Xp = 0;
                        CInfo.ZoneId = CharInfo.ZoneId;

                        CharMgr.Database.AddObject(CInfo);
                        Program.AcctMgr.UpdateRealmCharacters(Program.Rm.RealmId, (uint)CharMgr.Database.GetObjectCount<Character>(" Realm=1"), (uint)CharMgr.Database.GetObjectCount<Character>(" Realm=2"));

                        Char.Value = CInfo;

                        PacketOut Out = new PacketOut((byte)Opcodes.F_SEND_CHARACTER_RESPONSE);
                        Out.WritePascalString(cclient._Account.Username);
                        cclient.SendPacket(Out);
                    }
                }
            }
            else
            {
                PacketOut Out = new PacketOut((byte)Opcodes.F_SEND_CHARACTER_ERROR);
                Out.WritePascalString(cclient._Account.Username);
                cclient.SendPacket(Out);
            }
        }
Ejemplo n.º 2
0
        public bool Load(Character_item Item)
        {
            if (Item == null)
                return false;

            Info = WorldMgr.GetItem_Info(Item.Entry);
            if (Info == null)
            {
                Log.Error("ItemInterface", "Load : Info==null,Entry=" + Item.Entry);
                return false;
            }

            CharItem = Item;
            return true;
        }
Ejemplo n.º 3
0
        public Character_item Create(UInt32 CharacterId)
        {
            CharItem = new Character_item();
            CharItem.CharacterId = CharacterId;
            CharItem.Counts = _Count;
            CharItem.Entry = Info.Entry;
            CharItem.ModelId = _ModelId;
            CharItem.SlotId = _SlotId;
            CharMgr.CreateItem(CharItem);

            return CharItem;
        }
Ejemplo n.º 4
0
        public static void LoadItem(Character_item CharItem)
        {
            lock (_Items)
            {
                _Items[CharItem.Guid] = CharItem;

                if (!_CharItems.ContainsKey(CharItem.CharacterId))
                    _CharItems.Add(CharItem.CharacterId, new List<Character_item>() { CharItem });
                else
                    _CharItems[CharItem.CharacterId].Add(CharItem);
            }
        }
Ejemplo n.º 5
0
        public static void DeleteItem(Character_item Itm)
        {
            //Log.Info("DeleteItem", "Guid=" + Itm.Guid + ",CharId=" + Itm.CharacterId);

            lock (_Items)
            {
                if (_CharItems.ContainsKey(Itm.CharacterId))
                    _CharItems[Itm.CharacterId].Remove(Itm);

                _Items[Itm.Guid] = null;
            }

            CharMgr.Database.DeleteObject(Itm);
        }
Ejemplo n.º 6
0
        public static bool CreateItem(Character_item Item)
        {
            lock (_Items)
            {
                for (int i = 0; i < _Items.Length; ++i)
                {
                    if (_Items[i] == null)
                    {
                        Item.Guid = i;
                        LoadItem(Item);
                        Database.AddObject(Item);
                        return true;
                    }
                }
            }

            Log.Error("CreateItem", "Maximum number of items reaches !");
            return false;
        }