コード例 #1
0
        public static void CreateCharacter(WvsLoginClient c, CInPacket p)
        {
            var newChar = Default();

            // create explorer:   Recv [CP_CreateNewCharacter] 16 00 06 00 70 6F 6F 70 69 65 01 00 00 00 00 00 24 4E 00 00 [4E 75 00 00] [03 00 00 00] [03 00 00 00] [86 DE 0F 00] [2F 2D 10 00] [85 5B 10 00] [8B DE 13 00] [00]
            // create resistance: Recv [CP_CreateNewCharacter] 16 00 06 00 64 6F 6F 64 6F 6F 00 00 00 00 00 00 84 4E 00 00 [30 75 00 00] [07 00 00 00] [01 00 00 00] [47 06 10 00] [00 00 00 00] [74 5D 10 00] [8C DE 13 00] [00]

            newChar.Stats.sCharacterName = p.DecodeString();

            var job = (short)p.Decode4();

            newChar.Stats.nJob = GameConstants.GetRealJobFromCreation(job);

            bool subJob = p.Decode2() > 0;                   //whether dual blade = 1 or adventurer = 0

            newChar.Stats.nSubJob = (short)(subJob ? 1 : 0); // doing it this way to reduce potential packet editing fuckery

            newChar.Stats.nFace = p.Decode4();
            var hairColor = p.Decode4();

            newChar.Stats.nHair = p.Decode4() + hairColor;
            newChar.Stats.nSkin = (byte)p.Decode4();

            var top    = p.Decode4();
            var bottom = p.Decode4();
            var shoes  = p.Decode4();
            var weapon = p.Decode4();

            newChar.Stats.nGender = p.Decode1();

            if (newChar.Stats.nSubJob == 1)
            {
                newChar.Stats.nJob = 400; // thief job
            }

            newChar.Stats.dwPosMap = GameConstants.GetStartingMap(newChar.Stats.nJob, newChar.Stats.nSubJob);

            newChar.Look.CopyStats(newChar.Stats);

            // TODO validate these against wz files
            newChar.Look.aEquip[5]  = top;
            newChar.Look.aEquip[6]  = bottom;
            newChar.Look.aEquip[7]  = shoes;
            newChar.Look.aEquip[11] = weapon;

            newChar.Insert(c.Account.ID);

            // create empty entries in mapping tables
            InitDefaultMappings(newChar.Stats.dwCharacterID);

            if (newChar.Stats.dwCharacterID < 0)
            {
                c.SendPacket(CreateCharacterPacket(false, null));
            }
            else
            {
                // add equips  // todo figure out if overalls have their own slot ID
                MasterManager.CreateNormalStatEquip(top)
                .SaveToDB(newChar.Stats.dwCharacterID, (short)(bottom > 0 ? -5 : -5));

                if (bottom > 0) // will be zero if its a champ that starts with an overall
                {
                    MasterManager.CreateNormalStatEquip(bottom)
                    .SaveToDB(newChar.Stats.dwCharacterID, -6);
                }

                MasterManager.CreateNormalStatEquip(shoes)
                .SaveToDB(newChar.Stats.dwCharacterID, -7);

                MasterManager.CreateNormalStatEquip(weapon)
                .SaveToDB(newChar.Stats.dwCharacterID, -11);

                var nWhitePot    = 2000002;
                var nManaPot     = 2000006;
                var nPotQuantity = (short)100;

                var item1 = MasterManager.CreateItem(nWhitePot) as GW_ItemSlotBundle;
                item1.nNumber = nPotQuantity;

                item1.SaveToDB(newChar.Stats.dwCharacterID, 1);

                var item2 = MasterManager.CreateItem(nManaPot) as GW_ItemSlotBundle;
                item2.nNumber = nPotQuantity;

                item2.SaveToDB(newChar.Stats.dwCharacterID, 2);

                c.SendPacket(CreateCharacterPacket(true, newChar));
            }
        }