Ejemplo n.º 1
0
        public static void HandleLearnTalents(ref PacketReader packet, ref WorldClass session)
        {
            var pChar        = session.Character;
            var talentSpells = new List <uint>();

            BitUnpack BitUnpack = new BitUnpack(packet);

            uint talentCount = BitUnpack.GetBits <uint>(23);

            for (int i = 0; i < talentCount; i++)
            {
                var talentId = packet.Read <ushort>();

                SpecializationMgr.AddTalent(pChar, pChar.ActiveSpecGroup, talentId, true);

                talentSpells.Add(CliDB.Talent.Single(talent => talent.Id == talentId).SpellId);
            }

            HandleUpdateTalentData(ref session);

            pChar.SetUpdateField <Int32>((int)PlayerFields.SpellCritPercentage + 0, SpecializationMgr.GetUnspentTalentRowCount(pChar), 0);
            ObjectHandler.HandleUpdateObjectValues(ref session);

            foreach (var talentSpell in talentSpells)
            {
                SpellHandler.HandleLearnedSpells(ref session, new List <uint>(1)
                {
                    talentSpell
                });
            }

            Log.Message(LogType.DEBUG, "Character (Guid: {0}) learned {1} talents.", pChar.Guid, talentCount);
        }
Ejemplo n.º 2
0
        public static void HandleCliSetSpecialization(ref PacketReader packet, ref WorldClass session)
        {
            var pChar = session.Character;

            uint specGroupId = packet.Read <uint>();

            uint specId = SpecializationMgr.GetSpecIdByGroup(pChar, (byte)specGroupId);

            // check if new spec is primary or secondary
            if (pChar.SpecGroupCount == 1 && pChar.PrimarySpec == 0)
            {
                pChar.ActiveSpecGroup = 0;
                pChar.PrimarySpec     = (ushort)specId;
            }
            else
            {
                pChar.ActiveSpecGroup = 1;
                pChar.SecondarySpec   = (ushort)specId;
                pChar.SpecGroupCount  = (byte)(pChar.SpecGroupCount + 1);
            }

            SpecializationMgr.SaveSpecInfo(pChar);

            SendSpecializationSpells(ref session);

            HandleUpdateTalentData(ref session);

            pChar.SetUpdateField <Int32>((int)PlayerFields.CurrentSpecID, (int)pChar.GetActiveSpecId());
            ObjectHandler.HandleUpdateObjectValues(ref session);

            Log.Message(LogType.DEBUG, "Character (Guid: {0}) choosed spectialization {1} for spec group {2}.", pChar.Guid, pChar.GetActiveSpecId(), pChar.ActiveSpecGroup);
        }
Ejemplo n.º 3
0
        public static void HandleSendKnownSpells(ref WorldClass session)
        {
            Character pChar = session.Character;

            var specializationSpells     = SpecializationMgr.GetSpecializationSpells(pChar);
            var specializationSpellCount = ((specializationSpells != null) ? specializationSpells.Count : 0);

            var talentSpells     = SpecializationMgr.GetTalentSpells(pChar, pChar.ActiveSpecGroup);
            var talentSpellCount = ((talentSpells != null) ? talentSpells.Count : 0);

            int count = pChar.SpellList.Count + specializationSpellCount + talentSpellCount;

            PacketWriter writer  = new PacketWriter(ServerMessage.SendKnownSpells);
            BitPack      BitPack = new BitPack(writer);

            BitPack.Write(count, 22);
            BitPack.Write(1);

            BitPack.Flush();

            pChar.SpellList.ForEach(spell =>
                                    writer.WriteUInt32(spell.SpellId));

            if (specializationSpells != null)
            {
                specializationSpells.ForEach(spell => writer.WriteUInt32(spell.Spell));
            }

            if (talentSpells != null)
            {
                talentSpells.ForEach(spell => writer.WriteUInt32(spell));
            }

            session.Send(ref writer);
        }
Ejemplo n.º 4
0
        public static void SendSpecializationSpells(ref WorldClass session)
        {
            var specSpells = SpecializationMgr.GetSpecializationSpells(session.Character);
            var newSpells  = specSpells.Select(specializationSpell => specializationSpell.Spell).ToList();

            if (newSpells.Count > 0)
            {
                SpellHandler.HandleLearnedSpells(ref session, newSpells);
            }
        }
Ejemplo n.º 5
0
        public static void HandleUpdateTalentData(ref WorldClass session)
        {
            var pChar = session.Character;

            const byte glyphCount = 6;

            PacketWriter updateTalentData = new PacketWriter(ServerMessage.UpdateTalentData);
            BitPack      BitPack          = new BitPack(updateTalentData);

            updateTalentData.WriteUInt8((byte)pChar.ActiveSpecGroup);     // Active Spec (0 or 1)

            BitPack.Write(pChar.SpecGroupCount, 19);

            for (int i = 0; i < pChar.SpecGroupCount; i++)
            {
                var talents = SpecializationMgr.GetTalentsBySpecGroup(pChar, (byte)i);

                BitPack.Write(talents.Count, 23);
            }

            BitPack.Flush();

            for (int i = 0; i < pChar.SpecGroupCount; i++)
            {
                var talents = SpecializationMgr.GetTalentsBySpecGroup(pChar, (byte)i);
                var specId  = (i == 0) ? pChar.PrimarySpec : pChar.SecondarySpec;

                for (int j = 0; j < talents.Count; j++)
                {
                    updateTalentData.WriteUInt16(talents[j].Id);          // Talent Id
                }
                updateTalentData.WriteUInt32(specId);                     // Spec Id

                updateTalentData.WriteUInt8(glyphCount);                  // Glyph Count - NYI
                for (int j = 0; j < glyphCount; j++)
                {
                    updateTalentData.WriteInt16(0);                       // Glyph Id - NYI
                }
            }

            session.Send(ref updateTalentData);
        }
Ejemplo n.º 6
0
        public override void SetUpdateFields()
        {
            SetUpdateField <ulong>((int)ObjectFields.Guid, Guid);
            SetUpdateField <int>((int)ObjectFields.Type, 0x19);
            SetUpdateField <float>((int)ObjectFields.Scale, 1.0f);

            SetUpdateField <int>((int)UnitFields.Health, 123);
            SetUpdateField <int>((int)UnitFields.MaxHealth, 123);

            SetUpdateField <int>((int)UnitFields.Level, Level);
            SetUpdateField <uint>((int)UnitFields.FactionTemplate, CliDB.ChrRaces.Single(r => r.Id == Race).Faction);

            SetUpdateField <byte>((int)UnitFields.Sex, Race, 0);
            SetUpdateField <byte>((int)UnitFields.Sex, Class, 1);
            SetUpdateField <byte>((int)UnitFields.Sex, 0, 2);
            SetUpdateField <byte>((int)UnitFields.Sex, Gender, 3);

            SetUpdateField <int>((int)UnitFields.DisplayPower, 1);

            var race      = CliDB.ChrRaces.Single(r => r.Id == Race);
            var displayId = Gender == 0 ? race.MaleDisplayId : race.FemaleDisplayId;

            SetUpdateField <uint>((int)UnitFields.DisplayID, displayId);
            SetUpdateField <uint>((int)UnitFields.NativeDisplayID, displayId);

            SetUpdateField <uint>((int)UnitFields.Flags, 0x8);

            SetUpdateField <float>((int)UnitFields.BoundingRadius, 0.389F);
            SetUpdateField <float>((int)UnitFields.CombatReach, 1.5F);
            SetUpdateField <float>((int)UnitFields.ModCastingSpeed, 1);
            SetUpdateField <float>((int)UnitFields.MaxHealthModifier, 1);

            SetUpdateField <byte>((int)PlayerFields.HairColorID, Skin, 0);
            SetUpdateField <byte>((int)PlayerFields.HairColorID, Face, 1);
            SetUpdateField <byte>((int)PlayerFields.HairColorID, HairStyle, 2);
            SetUpdateField <byte>((int)PlayerFields.HairColorID, HairColor, 3);
            SetUpdateField <byte>((int)PlayerFields.RestState, FacialHair, 0);
            SetUpdateField <byte>((int)PlayerFields.RestState, 0, 1);
            SetUpdateField <byte>((int)PlayerFields.RestState, 0, 2);
            SetUpdateField <byte>((int)PlayerFields.RestState, 2, 3);
            SetUpdateField <byte>((int)PlayerFields.ArenaFaction, Gender, 0);
            SetUpdateField <byte>((int)PlayerFields.ArenaFaction, 0, 1);
            SetUpdateField <byte>((int)PlayerFields.ArenaFaction, 0, 2);
            SetUpdateField <byte>((int)PlayerFields.ArenaFaction, 0, 3);
            SetUpdateField <int>((int)PlayerFields.WatchedFactionIndex, -1);
            SetUpdateField <int>((int)PlayerFields.XP, 0);
            SetUpdateField <int>((int)PlayerFields.NextLevelXP, 400);

            SetUpdateField <int>((int)PlayerFields.CurrentSpecID, (int)GetActiveSpecId());

            SetUpdateField <int>((int)PlayerFields.CharacterPoints, SpecializationMgr.GetUnspentTalentRowCount(this));
            SetUpdateField <int>((int)PlayerFields.MaxTalentTiers, SpecializationMgr.GetMaxTalentRowCount(this));

            for (int i = 0; i < 448; i++)
            {
                if (i < Skills.Count)
                {
                    SetUpdateField <uint>((int)PlayerFields.Skill + i, Skills[i].Id);
                }
            }

            SetUpdateField <uint>((int)PlayerFields.VirtualPlayerRealm, WorldConfig.RealmId);
        }