Exemplo n.º 1
0
        public static void BuildSkillUpdate(this Player p, ref UpdateClass uc)
        {
            int inc = 0;

            foreach (MirrorSkillInfo skill in p.Skills.Values)
            {
                uc.UpdateValue <uint>(PlayerFields.PLAYER_SKILL_INFO_1_1, ByteConverter.ConvertToUInt32(skill.m_skillLineID, skill.m_skillRank), inc * 3);
                uc.UpdateValue <uint>(PlayerFields.PLAYER_SKILL_INFO_1_1, ByteConverter.ConvertToUInt32(new object[] { GetMaxRank(p, skill), skill.m_skillModifier }), (inc * 3) + 1);
                uc.UpdateValue <uint>(PlayerFields.PLAYER_SKILL_INFO_1_1, ByteConverter.ConvertToUInt32(skill.m_skillStep, skill.m_padding), (inc * 3) + 2);
                inc++;
            }
        }
Exemplo n.º 2
0
 public void BuildPacket(ref UpdateClass uc)
 {
     foreach (var itm in Backpack.Items.Values)
     {
         uc.UpdateValue <ulong>(PlayerFields.PLAYER_FIELD_INV_SLOT_1, itm.Guid, (int)(itm.CurrentSlot * 2));
     }
 }
Exemplo n.º 3
0
        public static void BuildQuestUpdate(this Player p, ref UpdateClass uc)
        {
            int i = 0;

            foreach (Quest quest in p.Quests.Values)
            {
                if (quest.Status == QuestStatuses.QUEST_STATUS_COMPLETE && quest.Rewarded)
                {
                    continue;
                }

                QuestTemplate template = Database.QuestTemplates.TryGet(quest.QuestId);

                uc.UpdateValue <uint>(PlayerFields.PLAYER_QUEST_LOG_1_1, quest.QuestId, i * 6);
                uc.UpdateValue <uint>(PlayerFields.PLAYER_QUEST_LOG_1_1, 0, (i * 6) + 1);
                uc.UpdateValue <uint>(PlayerFields.PLAYER_QUEST_LOG_1_1, 0, (i * 6) + 2);
                uc.UpdateValue <uint>(PlayerFields.PLAYER_QUEST_LOG_1_1, quest.GetProgress(), (i * 6) + 3);
                uc.UpdateValue <uint>(PlayerFields.PLAYER_QUEST_LOG_1_1, 0, (i * 6) + 4); //m_questFailureTime
                uc.UpdateValue <uint>(PlayerFields.PLAYER_QUEST_LOG_1_1, 0, (i * 6) + 5); //m_qtyMonsterToKill
                i++;
            }
        }
Exemplo n.º 4
0
        public override PacketWriter BuildUpdate(UpdateTypes type = UpdateTypes.UPDATE_PARTIAL, bool self = false)
        {
            //Send update packet
            PacketWriter writer = CreateObject(false);
            UpdateClass  uc     = new UpdateClass();

            //Object Fields
            uc.UpdateValue <ulong>(ObjectFields.OBJECT_FIELD_GUID, this.Guid);
            uc.UpdateValue <uint>(ObjectFields.OBJECT_FIELD_TYPE, (uint)this.ObjectType); // UpdateType, 0x9 - (Unit + Object)
            uc.UpdateValue <uint>(ObjectFields.OBJECT_FIELD_ENTRY, this.Entry);
            uc.UpdateValue <float>(ObjectFields.OBJECT_FIELD_SCALE_X, this.Scale);

            //Unit Fields
            uc.UpdateValue <uint>(UnitFields.UNIT_CHANNEL_SPELL, this.ChannelSpell);
            uc.UpdateValue <ulong>(UnitFields.UNIT_FIELD_CHANNEL_OBJECT, this.ChannelSpell);
            uc.UpdateValue <uint>(UnitFields.UNIT_FIELD_HEALTH, this.Health.Current);
            uc.UpdateValue <uint>(UnitFields.UNIT_FIELD_MAXHEALTH, this.Health.Maximum);
            uc.UpdateValue <uint>(UnitFields.UNIT_FIELD_LEVEL, this.Template.Level.Maximum);
            uc.UpdateValue <uint>(UnitFields.UNIT_FIELD_FACTIONTEMPLATE, this.Template.FactionA);
            uc.UpdateValue <uint>(UnitFields.UNIT_FIELD_FLAGS, this.Template.UnitFlags);
            uc.UpdateValue <float>(UnitFields.UNIT_FIELD_BASEATTACKTIME, this.Template.AttackTime); //Main hand
            uc.UpdateValue <float>(UnitFields.UNIT_FIELD_BASEATTACKTIME, 0f, 1);                    //Offhand
            uc.UpdateValue <uint>(UnitFields.UNIT_FIELD_RESISTANCES, this.Template.Armor.BaseAmount);
            uc.UpdateValue <uint>(UnitFields.UNIT_FIELD_RESISTANCES, this.Template.Holy.BaseAmount, 1);
            uc.UpdateValue <uint>(UnitFields.UNIT_FIELD_RESISTANCES, this.Template.Fire.BaseAmount, 2);
            uc.UpdateValue <uint>(UnitFields.UNIT_FIELD_RESISTANCES, this.Template.Nature.BaseAmount, 3);
            uc.UpdateValue <uint>(UnitFields.UNIT_FIELD_RESISTANCES, this.Template.Frost.BaseAmount, 4);
            uc.UpdateValue <uint>(UnitFields.UNIT_FIELD_RESISTANCES, this.Template.Shadow.BaseAmount, 5);
            uc.UpdateValue <float>(UnitFields.UNIT_FIELD_BOUNDINGRADIUS, this.Template.BoundingRadius);
            uc.UpdateValue <float>(UnitFields.UNIT_FIELD_COMBATREACH, this.Template.CombatReach);
            uc.UpdateValue <uint>(UnitFields.UNIT_FIELD_DISPLAYID, this.Template.ModelID);
            uc.UpdateValue <uint>(UnitFields.UNIT_FIELD_COINAGE, this.Money);
            uc.UpdateValue <float>(UnitFields.UNIT_MOD_CAST_SPEED, 1f);
            uc.UpdateValue <uint>(UnitFields.UNIT_FIELD_DAMAGE, ByteConverter.ConvertToUInt32((ushort)this.Template.Damage.Current, (ushort)this.Template.Damage.Maximum));
            uc.UpdateValue <uint>(UnitFields.UNIT_DYNAMIC_FLAGS, this.DynamicFlags);
            uc.UpdateValue <uint>(UnitFields.UNIT_FIELD_BYTES_1, ByteConverter.ConvertToUInt32(this.StandState, this.NPCFlags, 0, 0));
            uc.BuildPacket(ref writer, true);

            writer.Compress();
            return(writer);
        }
Exemplo n.º 5
0
        public override PacketWriter BuildUpdate(UpdateTypes type = UpdateTypes.UPDATE_FULL, bool self = false)
        {
            PacketWriter packet = null;

            switch (type)
            {
            case UpdateTypes.UPDATE_FULL:
                packet = CreateObject(false);
                break;

            default:
                packet = new PacketWriter(Opcodes.SMSG_UPDATE_OBJECT);
                break;
            }

            UpdateClass uc = new UpdateClass();

            uc.UpdateValue <ulong>(ObjectFields.OBJECT_FIELD_GUID, this.Guid);
            uc.UpdateValue <uint>(ObjectFields.OBJECT_FIELD_TYPE, (uint)this.ObjectType);
            uc.UpdateValue <uint>(ObjectFields.OBJECT_FIELD_ENTRY, this.Entry);
            uc.UpdateValue <float>(ObjectFields.OBJECT_FIELD_SCALE_X, 1f);
            uc.UpdateValue <uint>(ObjectFields.OBJECT_FIELD_PADDING, 0);
            uc.UpdateValue <ulong>(ItemFields.ITEM_FIELD_OWNER, this.Owner);
            uc.UpdateValue <ulong>(ItemFields.ITEM_FIELD_CREATOR, this.Creator);
            uc.UpdateValue <ulong>(ItemFields.ITEM_FIELD_CONTAINED, this.Contained);
            uc.UpdateValue <uint>(ItemFields.ITEM_FIELD_STACK_COUNT, this.StackCount);
            uc.UpdateValue <uint>(ItemFields.ITEM_FIELD_FLAGS, this.Template.Flags);

            for (int i = 0; i < 5; i++)
            {
                uc.UpdateValue <uint>(ItemFields.ITEM_FIELD_SPELL_CHARGES, this.SpellCharges[i], i);
            }

            if (this.IsContainer) //Is a container
            {
                var c = (Container)this;
                if (c.IsBackpack) //Just incase
                {
                    return(null);
                }

                uc.UpdateValue <uint>(ContainerFields.CONTAINER_FIELD_NUM_SLOTS, c.TotalSlots);

                for (int i = 0; i < Container.MAX_BAG_SLOTS; i++)
                {
                    ulong iguid = c.Slots.ContainsKey((uint)i) ? c.Slots[(uint)i] : 0;
                    uc.UpdateValue <ulong>(ContainerFields.CONTAINER_FIELD_SLOT_1, iguid, i * 2);
                }
            }

            switch (type)
            {
            case UpdateTypes.UPDATE_PARTIAL:
                return(UpdateObject(ref uc));

            case UpdateTypes.UPDATE_FULL:
                uc.BuildPacket(ref packet, true);
                return(packet);

            default:
                return(null);
            }
        }
Exemplo n.º 6
0
        public override PacketWriter BuildUpdate(UpdateTypes type = UpdateTypes.UPDATE_PARTIAL, bool self = false)
        {
            PacketWriter packet = CreateObject(false);
            UpdateClass  uc     = new UpdateClass();

            uc.UpdateValue <ulong>(ObjectFields.OBJECT_FIELD_GUID, this.Guid);
            uc.UpdateValue <uint>(ObjectFields.OBJECT_FIELD_TYPE, (uint)this.ObjectType);
            uc.UpdateValue <uint>(ObjectFields.OBJECT_FIELD_ENTRY, this.Entry);
            uc.UpdateValue <float>(ObjectFields.OBJECT_FIELD_SCALE_X, this.Scale);
            uc.UpdateValue <uint>(ObjectFields.OBJECT_FIELD_PADDING, 0);
            uc.UpdateValue <uint>(GameObjectFields.GAMEOBJECT_DISPLAYID, Template.DisplayId);
            uc.UpdateValue <uint>(GameObjectFields.GAMEOBJECT_FLAGS, Template.Flags);
            uc.UpdateValue <uint>(GameObjectFields.GAMEOBJECT_FACTION, Template.Faction);
            uc.UpdateValue <uint>(GameObjectFields.GAMEOBJECT_STATE, (uint)State);

            for (int i = 0; i < 4; i++)
            {
                uc.UpdateValue <float>(GameObjectFields.GAMEOBJECT_ROTATION, Rotation[i], i);
            }

            uc.UpdateValue <float>(GameObjectFields.GAMEOBJECT_POS_X, this.Location.X);
            uc.UpdateValue <float>(GameObjectFields.GAMEOBJECT_POS_Y, this.Location.Y);
            uc.UpdateValue <float>(GameObjectFields.GAMEOBJECT_POS_Z, this.Location.Z);
            uc.UpdateValue <float>(GameObjectFields.GAMEOBJECT_FACING, this.Orientation);
            uc.BuildPacket(ref packet, true);
            return(packet);
        }