Beispiel #1
0
        public static void F_INIT_PLAYER(BaseClient client, PacketIn packet)
        {
            GameClient cclient = (GameClient)client;

            Player Plr = cclient.Plr;

            if (Plr == null)
            {
                return;
            }

            // clear all lockouts if they are expired
            InstanceService.ClearLockouts(Plr);

            if (!Plr.IsInWorld()) // If the player is not on a map, then we add it to the map
            {
                ushort zoneId   = Plr.Info.Value.ZoneId;
                ushort regionId = (ushort)Plr.Info.Value.RegionId;

                Zone_Info info = ZoneService.GetZone_Info(zoneId);
                if (info?.Type == 0)
                {
                    RegionMgr region = WorldMgr.GetRegion(regionId, true);
                    if (region.AddObject(Plr, zoneId, true))
                    {
                        return;
                    }
                }
                else if (info?.Type == 4 || info?.Type == 5 || info?.Type == 6)  // login into a instance results in teleport outside
                {
                    if (InstanceService._InstanceInfo.TryGetValue(zoneId, out Instance_Info II))
                    {
                        Zone_jump ExitJump = null;
                        if (Plr.Realm == Realms.REALMS_REALM_ORDER)
                        {
                            ExitJump = ZoneService.GetZoneJump(II.OrderExitZoneJumpID);
                        }
                        else if (Plr.Realm == Realms.REALMS_REALM_DESTRUCTION)
                        {
                            ExitJump = ZoneService.GetZoneJump(II.DestrExitZoneJumpID);
                        }

                        if (ExitJump == null)
                        {
                            Log.Error("Exit Jump in Instance", " " + zoneId + " missing!");
                        }
                        else
                        {
                            Plr.Teleport(ExitJump.ZoneID, ExitJump.WorldX, ExitJump.WorldY, ExitJump.WorldZ, ExitJump.WorldO);
                        }
                    }
                    return;
                }

                // Warp a player to their bind point if they attempt to load into a scenario map.
                RallyPoint rallyPoint = RallyPointService.GetRallyPoint(Plr.Info.Value.RallyPoint);

                if (rallyPoint != null)
                {
                    Plr.Teleport(rallyPoint.ZoneID, rallyPoint.WorldX, rallyPoint.WorldY, rallyPoint.WorldZ, rallyPoint.WorldO);
                }
                else
                {
                    CharacterInfo cInfo = CharMgr.GetCharacterInfo(Plr.Info.Career);
                    Plr.Teleport(cInfo.ZoneId, (uint)cInfo.WorldX, (uint)cInfo.WorldY, (ushort)cInfo.WorldZ,
                                 (ushort)cInfo.WorldO);
                }
            }
            else
            {
                Plr.Loaded = false;
                Plr.StartInit();
            }
        }
Beispiel #2
0
        public static void F_CREATE_CHARACTER(BaseClient client, PacketIn packet)
        {
            GameClient cclient = (GameClient)client;
            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);

            ushort duplicate = 0;

            for (int i = 0; i < name.Length; i++)
            {
                if (i != 0)
                {
                    if (name[i] == name[i - 1])
                    {
                        duplicate++;
                    }
                    else
                    {
                        duplicate = 0;
                    }

                    if (duplicate > 3)
                    {
                        break;
                    }
                }
            }

            if (name.Length > 2 && !CharMgr.NameIsUsed(name) && CharMgr.AllowName(name) && !CharMgr.NameIsDeleted(name) && duplicate < 3)
            {
                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
                    {
                        AccountId    = cclient._Account.AccountId,
                        bTraits      = traits,
                        Career       = Info.career,
                        CareerLine   = CharInfo.CareerLine,
                        ModelId      = Info.model,
                        Name         = name,
                        Race         = Info.race,
                        Realm        = CharInfo.Realm,
                        RealmId      = Program.Rm.RealmId,
                        Sex          = Info.sex,
                        FirstConnect = true
                    };

                    if (!CharMgr.CreateChar(Char))
                    {
                        Log.Error("CreateCharacter", "Hack : can not create more than 10 characters!");
                    }
                    else
                    {
                        List <CharacterInfo_item> Items = CharMgr.GetCharacterInfoItem(Char.CareerLine);

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

                            CharacterItem Citm = new CharacterItem
                            {
                                Counts       = Itm.Count,
                                CharacterId  = Char.CharacterId,
                                Entry        = Itm.Entry,
                                ModelId      = Itm.ModelId,
                                SlotId       = Itm.SlotId,
                                PrimaryDye   = 0,
                                SecondaryDye = 0
                            };
                            CharMgr.CreateItem(Citm);
                        }

                        Character_value CInfo = new Character_value
                        {
                            CharacterId = Char.CharacterId,
                            Level       = 1,
                            Money       = 2000,
                            Online      = false,
                            RallyPoint  = CharInfo.RallyPt,
                            RegionId    = CharInfo.Region,
                            Renown      = 0,
                            RenownRank  = 1,
                            RestXp      = 0,
                            Skills      = CharInfo.Skills,
                            Speed       = 100,
                            PlayedTime  = 0,
                            WorldO      = CharInfo.WorldO,
                            WorldX      = CharInfo.WorldX,
                            WorldY      = CharInfo.WorldY,
                            WorldZ      = CharInfo.WorldZ,
                            Xp          = 0,
                            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"));

                        CharacterClientData clientData = new CharacterClientData {
                            CharacterId = Char.CharacterId
                        };
                        CharMgr.Database.AddObject(clientData);

                        Char.Value      = CInfo;
                        Char.ClientData = clientData;

                        PacketOut Out = new PacketOut((byte)Opcodes.F_SEND_CHARACTER_RESPONSE, 32);
                        Out.WritePascalString(cclient._Account.Username);
                        cclient.SendPacket(Out);
                    }
                }
            }
            else
            {
                PacketOut Out = new PacketOut((byte)Opcodes.F_SEND_CHARACTER_ERROR, 64);
                Out.FillString(cclient._Account.Username, 24);
                Out.WriteStringBytes("You have entered a duplicate or invalid name. Please enter a new name.");
                cclient.SendPacket(Out);
            }
        }