Beispiel #1
0
 public static void InvokeCreateCharRequest(CreateCharRequestEventArgs e)
 {
     if (CreateCharRequest != null)
     {
         CreateCharRequest(e);
     }
 }
Beispiel #2
0
 public void InvokeCreateCharRequest( CreateCharRequestEventArgs e )
 {
     if ( CreateCharRequest != null )
         CreateCharRequest( e );
 }
Beispiel #3
0
 private static CityInfo GetStartLocation( CreateCharRequestEventArgs args, bool isYoung )
 {
     if ( args.State.Version == null || args.State.Version < ClientVersion.Client70130 )
     {
         if ( args.Mobile.Race == Race.Gargoyle )
             return new CityInfo( "Royal City", "Royal City", 738, 3486, -19, Map.TerMur, 1150169 );
         else
             return new CityInfo( "New Haven", "New Haven Bank", 3503, 2574, 14, Map.Trammel, 1150168 );
     }
     else
     {
         return args.City;
     }
 }
Beispiel #4
0
        private static void EventSink_CreateCharRequest( CreateCharRequestEventArgs args )
        {
            string name = args.Name.Trim();

            if ( !VerifyName( name ) )
            {
                Console.WriteLine( "Login: {0}: Character creation failed, invalid name '{1}'", args.State, args.Name );

                args.State.BlockAllPackets = false;
                args.State.Send( new PopupMessage( PMMessage.InvalidName ) );
                return;
            }

            if ( !VerifyProfession( args.Profession ) )
                args.Profession = 0;

            Mobile newChar = CreateMobile( args.Account as Account );

            if ( newChar == null )
            {
                Console.WriteLine( "Login: {0}: Character creation failed, account full", args.State );
                return;
            }

            args.Mobile = newChar;
            m_Mobile = newChar;

            newChar.IsPlayer = true;
            newChar.AccessLevel = ( (Account) args.Account ).AccessLevel;
            newChar.Female = args.Female;
            newChar.Race = args.Race;
            newChar.Hue = newChar.Race.ClipSkinHue( args.Hue & 0x3FFF ) | 0x8000;
            newChar.Hunger = 20;

            bool young = false;

            if ( newChar is PlayerMobile )
            {
                PlayerMobile pm = (PlayerMobile) newChar;

                pm.Profession = args.Profession;

                if ( pm.AccessLevel == AccessLevel.Player && ( (Account) pm.Account ).Young && ( pm.Profession != 0 ) && !( pm.Profession == 6 || pm.Profession == 7 ) )
                    young = pm.Young = true;

                if ( pm.Race == Race.Gargoyle )
                    pm.LoyaltyInfo.SetValue( Engines.Loyalty.LoyaltyGroup.GargoyleQueen, 2000 );
            }

            newChar.Name = name;

            AddBackpack( newChar );

            SetStats( newChar, args.Str, args.Dex, args.Int );
            SetSkills( newChar, args.Skills, args.Profession );

            Race race = newChar.Race;

            if ( race.ValidateHair( newChar, args.HairID ) )
            {
                newChar.HairItemID = args.HairID;
                newChar.HairHue = race.ClipHairHue( args.HairHue & 0x3FFF );
            }

            if ( race.ValidateFacialHair( newChar, args.BeardID ) )
            {
                newChar.FacialHairItemID = args.BeardID;
                newChar.FacialHairHue = race.ClipHairHue( args.BeardHue & 0x3FFF );
            }

            if ( args.Profession <= 3 )
            {
                AddShirt( newChar, args.ShirtHue );
                AddPants( newChar, args.PantsHue );
                AddShoes( newChar );
            }

            var acct = args.Account as Account;

            if ( acct.GetTag( "GivenStarterKit" ) == null && newChar.Backpack != null )
            {
                var token = new StarterKitToken();
                token.Owner = newChar;
                newChar.Backpack.DropItem( token );

                acct.SetTag( "GivenStarterKit", "true" );
            }

            CityInfo city = GetStartLocation( args, young );

            newChar.MoveToWorld( city.Location, city.Map );

            Console.WriteLine( "Login: {0}: New character being created (account={1})", args.State, ( (Account) args.Account ).Username );
            Console.WriteLine( " - Character: {0} (serial={1})", newChar.Name, newChar.Serial );
            Console.WriteLine( " - Started: {0} {1} in {2}", city.City, city.Location, city.Map.ToString() );
        }
Beispiel #5
0
        public void CreateCharacterNew( GameClient state, PacketReader pvSrc )
        {
            /*int unk1 = */
            pvSrc.ReadInt32();
            /*int unk2 = */
            pvSrc.ReadInt32();
            /*int unk3 = */
            pvSrc.ReadByte();
            string name = pvSrc.ReadString( 30 );

            pvSrc.Seek( 2, SeekOrigin.Current );
            int flags = pvSrc.ReadInt32();
            pvSrc.Seek( 8, SeekOrigin.Current );
            int prof = pvSrc.ReadByte();
            pvSrc.Seek( 15, SeekOrigin.Current );

            int genderRace = pvSrc.ReadByte();

            int str = pvSrc.ReadByte();
            int dex = pvSrc.ReadByte();
            int intl = pvSrc.ReadByte();
            int is1 = pvSrc.ReadByte();
            int vs1 = pvSrc.ReadByte();
            int is2 = pvSrc.ReadByte();
            int vs2 = pvSrc.ReadByte();
            int is3 = pvSrc.ReadByte();
            int vs3 = pvSrc.ReadByte();
            int is4 = pvSrc.ReadByte();
            int vs4 = pvSrc.ReadByte();
            int hue = pvSrc.ReadUInt16();
            int hairVal = pvSrc.ReadInt16();
            int hairHue = pvSrc.ReadInt16();
            int hairValf = pvSrc.ReadInt16();
            int hairHuef = pvSrc.ReadInt16();
            pvSrc.ReadByte();
            int cityIndex = pvSrc.ReadByte();
            /*int charSlot = */
            pvSrc.ReadInt32();
            uint clientIP = pvSrc.ReadUInt32();
            int shirtHue = pvSrc.ReadInt16();
            int pantsHue = pvSrc.ReadInt16();

            /*
            0x00, 0x01
            0x02, 0x03 -> Human Male, Human Female
            0x04, 0x05 -> Elf Male, Elf Female
            0x05, 0x06 -> Gargoyle Male, Gargoyle Female
            */

            bool female = ( ( genderRace % 2 ) != 0 );

            Race race = null;

            byte raceId = (byte) ( genderRace < 4 ? 0 : ( ( genderRace / 2 ) - 1 ) );
            race = Race.Races[raceId];

            if ( race == null )
                race = Race.DefaultRace;

            clientIP = (uint) IPAddress.NetworkToHostOrder( (int) clientIP );

            state.ClientAddress = new IPAddress( (long) clientIP );

            CityInfo[] info = state.CityInfo;
            IAccount a = state.Account;

            if ( Utility.IsUsingMulticlient( state, Environment.Config.Login.MaxLoginsPerPC ) )
            {
                Console.WriteLine( "Login: {0}: Multiclient detected, disconnecting...", state );
                state.Send( new PopupMessage( PMMessage.LoginSyncError ) );
                state.Dispose();
                return;
            }

            if ( info == null || a == null || cityIndex < 0 || cityIndex >= info.Length )
            {
                state.Dispose();
            }
            else
            {
                // Check if anyone is using this account
                for ( int i = 0; i < a.Length; ++i )
                {
                    Mobile check = a[i];

                    if ( check != null && check.Map != Map.Internal )
                    {
                        Console.WriteLine( "Login: {0}: Account in use", state );
                        state.Send( new PopupMessage( PMMessage.CharInWorld ) );
                        return;
                    }
                }

                state.Flags = flags;

                CreateCharRequestEventArgs args = new CreateCharRequestEventArgs(
                    state, a,
                    name, female, hue,
                    str, dex, intl,
                    info[cityIndex],
                    new SkillNameValue[4]
                    {
                        new SkillNameValue( (SkillName)is1, vs1 ),
                        new SkillNameValue( (SkillName)is2, vs2 ),
                        new SkillNameValue( (SkillName)is3, vs3 ),
                        new SkillNameValue( (SkillName)is4, vs4 ),
                    },
                    shirtHue, pantsHue,
                    hairVal, hairHue,
                    hairValf, hairHuef,
                    prof,
                    race
                    );

                state.BlockAllPackets = true;

                try
                {
                    EventSink.Instance.InvokeCreateCharRequest( args );
                }
                catch ( Exception ex )
                {
                    Logger.Error( "Exception disarmed in CreateCharRequest {0}: {1}", name, ex );
                }

                Mobile m = args.Mobile;

                if ( m != null )
                {
                    state.Mobile = m;
                    m.Client = state;

                    state.BlockAllPackets = false;

                    try
                    {
                        EventSink.Instance.InvokeCharacterCreated( new CharacterCreatedEventArgs( m ) );
                    }
                    catch ( Exception ex )
                    {
                        Logger.Error( "Exception disarmed in CharacterCreated {0}: {1}", m, ex );
                    }

                    DoLogin( state, m );
                }
                else
                {
                    state.BlockAllPackets = false;
                    state.Dispose();
                }
            }
        }
Beispiel #6
0
        public void CreateCharacterEnhanced( GameClient state, PacketReader pvSrc )
        {
            pvSrc.ReadInt32(); // 0xEDEDEDED

            /*int charSlot = */
            pvSrc.ReadInt32();

            string name = pvSrc.ReadString( 30 );

            pvSrc.Seek( 30, SeekOrigin.Current );

            int prof = pvSrc.ReadByte();
            int cityIndex = pvSrc.ReadByte();
            int genderId = pvSrc.ReadByte();
            int raceId = pvSrc.ReadByte();

            int str = pvSrc.ReadByte();
            int dex = pvSrc.ReadByte();
            int intl = pvSrc.ReadByte();

            int hue = pvSrc.ReadUInt16();

            pvSrc.Seek( 8, SeekOrigin.Current );

            int is1 = pvSrc.ReadByte();
            int vs1 = pvSrc.ReadByte();
            int is2 = pvSrc.ReadByte();
            int vs2 = pvSrc.ReadByte();
            int is3 = pvSrc.ReadByte();
            int vs3 = pvSrc.ReadByte();
            int is4 = pvSrc.ReadByte();
            int vs4 = pvSrc.ReadByte();

            pvSrc.Seek( 25, SeekOrigin.Current );

            pvSrc.ReadByte(); // 0x0B
            int hairHue = pvSrc.ReadInt16();
            int hairVal = pvSrc.ReadInt16();

            pvSrc.ReadByte(); // 0x0C
            int pantsHue = pvSrc.ReadInt16();
            /*int pantsVal = */
            pvSrc.ReadInt16();

            pvSrc.ReadByte(); // 0x0D
            int shirtHue = pvSrc.ReadInt16();
            /*int shirtVal = */
            pvSrc.ReadInt16();

            pvSrc.ReadByte(); // 0x0F
            /*int faceHue = */
            pvSrc.ReadInt16();
            /*int faceVal = */
            pvSrc.ReadInt16();

            pvSrc.ReadByte(); // 0x10
            int hairValf = pvSrc.ReadInt16();
            int hairHuef = pvSrc.ReadInt16();

            // male=0, female=1
            bool female = ( genderId == 1 );

            // human=0, elf=1, gargoyle=2
            raceId = raceId - 1; // convert to zero-based
            if ( raceId < 0 )
                raceId = 0;
            if ( raceId >= Race.Races.Length )
                raceId = Race.Races.Length;

            Race race = Race.Races[raceId];
            if ( race == null )
                race = Race.DefaultRace;

            CityInfo[] info = state.CityInfo;
            IAccount a = state.Account;

            if ( info == null || a == null || cityIndex < 0 || cityIndex >= info.Length )
            {
                state.Dispose();
            }
            else
            {
                // Check if anyone is using this account
                for ( int i = 0; i < a.Length; ++i )
                {
                    Mobile check = a[i];

                    if ( check != null && check.Map != Map.Internal )
                    {
                        Console.WriteLine( "Login: {0}: Account in use", state );
                        state.Send( new PopupMessage( PMMessage.CharInWorld ) );
                        return;
                    }
                }

                CreateCharRequestEventArgs args = new CreateCharRequestEventArgs(
                    state, a,
                    name, female, hue,
                    str, dex, intl,
                    info[cityIndex],
                    new SkillNameValue[4]
                    {
                        new SkillNameValue( (SkillName)is1, vs1 ),
                        new SkillNameValue( (SkillName)is2, vs2 ),
                        new SkillNameValue( (SkillName)is3, vs3 ),
                        new SkillNameValue( (SkillName)is4, vs4 ),
                    },
                    shirtHue, pantsHue,
                    hairVal, hairHue,
                    hairValf, hairHuef,
                    prof,
                    race
                    );

                state.BlockAllPackets = true;

                try
                {
                    EventSink.Instance.InvokeCreateCharRequest( args );
                }
                catch ( Exception ex )
                {
                    Logger.Error( "Exception disarmed in CreateCharRequest {0}: {1}", name, ex );
                }

                Mobile m = args.Mobile;

                if ( m != null )
                {
                    state.Mobile = m;
                    m.Client = state;

                    state.BlockAllPackets = false;

                    try
                    {
                        EventSink.Instance.InvokeCharacterCreated( new CharacterCreatedEventArgs( m ) );
                    }
                    catch ( Exception ex )
                    {
                        Logger.Error( "Exception disarmed in CharacterCreated {0}: {1}", m, ex );
                    }

                    DoLogin( state, m );
                }
                else
                {
                    state.BlockAllPackets = false;
                    state.Dispose();
                }
            }
        }