コード例 #1
0
ファイル: Character.cs プロジェクト: rocverde/AIO-Sandbox
        public IPacketWriter BuildForceSpeed(float modifier, bool swim = false)
        {
            var          opcode = swim ? global::Opcodes.SMSG_FORCE_SWIM_SPEED_CHANGE : global::Opcodes.SMSG_FORCE_SPEED_CHANGE;
            PacketWriter writer = new PacketWriter(Sandbox.Instance.Opcodes[opcode], opcode.ToString());

            writer.WriteUInt64(this.Guid);
            return(this.BuildForceSpeed(writer, modifier));
        }
コード例 #2
0
        public override IPacketWriter BuildForceSpeed(float modifier, SpeedType type = SpeedType.Run)
        {
            var          opcode = type == SpeedType.Swim ? global::Opcodes.SMSG_FORCE_SWIM_SPEED_CHANGE : global::Opcodes.SMSG_FORCE_SPEED_CHANGE;
            PacketWriter writer = new PacketWriter(Sandbox.Instance.Opcodes[opcode], opcode.ToString());

            writer.WriteUInt64(Guid);
            return(this.BuildForceSpeed(writer, modifier));
        }
コード例 #3
0
ファイル: Character.cs プロジェクト: rocverde/AIO-Sandbox
        public void Teleport(float x, float y, float z, float o, uint map, ref IWorldManager manager)
        {
            IsTeleporting = true;

            if (Location.Map == map)
            {
                PacketWriter movementStatus = new PacketWriter(Sandbox.Instance.Opcodes[global::Opcodes.MSG_MOVE_TELEPORT_ACK], "MSG_MOVE_TELEPORT_ACK");
                movementStatus.WriteUInt64(this.Guid);
                movementStatus.WriteUInt64(0); //Flags
                movementStatus.WriteFloat(x);
                movementStatus.WriteFloat(y);
                movementStatus.WriteFloat(z);
                movementStatus.WriteFloat(o);
                movementStatus.WriteFloat(0);
                manager.Send(movementStatus);
            }
            else
            {
                //Loading screen
                PacketWriter transferPending = new PacketWriter(Sandbox.Instance.Opcodes[global::Opcodes.SMSG_TRANSFER_PENDING], "SMSG_TRANSFER_PENDING");
                transferPending.WriteUInt32(map);
                manager.Send(transferPending);

                //New world transfer
                PacketWriter newWorld = new PacketWriter(Sandbox.Instance.Opcodes[global::Opcodes.SMSG_NEW_WORLD], "SMSG_NEW_WORLD");
                newWorld.WriteUInt32(map);
                newWorld.WriteFloat(x);
                newWorld.WriteFloat(y);
                newWorld.WriteFloat(z);
                newWorld.WriteFloat(o);
                manager.Send(newWorld);
            }

            System.Threading.Thread.Sleep(150); //Pause to factor unsent packets

            Location = new Location(x, y, z, o, map);
            manager.Send(BuildUpdate());

            IsTeleporting = false;
        }
コード例 #4
0
ファイル: Character.cs プロジェクト: rocverde/AIO-Sandbox
        public IPacketWriter BuildUpdate()
        {
            byte maskSize = ((int)Fields.MAX + 31) / 32;
            SortedDictionary <int, byte[]> fieldData = new SortedDictionary <int, byte[]>();

            byte[] maskArray = new byte[maskSize * 4];

            Action <Fields, object> SetField = (place, value) => this.SetField((int)place, value, ref fieldData, ref maskArray);

            PacketWriter writer = new PacketWriter(Sandbox.Instance.Opcodes[global::Opcodes.SMSG_UPDATE_OBJECT], "SMSG_UPDATE_OBJECT");

            writer.WriteUInt32(1);         //Number of transactions
            writer.WriteUInt8(0);
            writer.WriteUInt8(2);          //UpdateType
            writer.WriteUInt64(this.Guid);
            writer.WriteUInt8(4);          //ObjectType, 4 = Player

            writer.WriteUInt32(0);         //MovementFlagMask
            writer.WriteUInt32((uint)Environment.TickCount);
            writer.WriteFloat(Location.X); //x
            writer.WriteFloat(Location.Y); //y
            writer.WriteFloat(Location.Z); //z
            writer.WriteFloat(Location.O); //w (o)
            writer.WriteFloat(0);
            writer.WriteFloat(2.5f);       //WalkSpeed
            writer.WriteFloat(7.0f);       //RunSpeed
            writer.WriteFloat(2.5f);       //Backwards WalkSpeed
            writer.WriteFloat(4.7222f);    //SwimSpeed
            writer.WriteFloat(4.7222f);    //Backwards SwimSpeed
            writer.WriteFloat(3.14f);      //TurnSpeed

            writer.WriteUInt32(1);         //Flags, 1 - Player
            writer.WriteUInt32(1);         //AttackCycle
            writer.WriteUInt32(0);         //TimerId
            writer.WriteUInt64(0);         //VictimGuid

            SetField(Fields.OBJECT_FIELD_GUID, this.Guid);
            SetField(Fields.OBJECT_FIELD_TYPE, (uint)0x19);
            SetField(Fields.OBJECT_FIELD_ENTRY, 0);
            SetField(Fields.OBJECT_FIELD_SCALE_X, this.Scale);
            SetField(Fields.OBJECT_FIELD_PADDING, 0);
            SetField(Fields.UNIT_FIELD_TARGET, (ulong)0);
            SetField(Fields.UNIT_FIELD_HEALTH, this.Health);
            SetField(Fields.UNIT_FIELD_POWER2, 0);
            SetField(Fields.UNIT_FIELD_MAXHEALTH, this.Health);
            SetField(Fields.UNIT_FIELD_MAXPOWER2, this.Rage);
            SetField(Fields.UNIT_FIELD_LEVEL, this.Level);
            SetField(Fields.UNIT_FIELD_BYTES_0, BitConverter.ToUInt32(new byte[] { this.Race, this.Class, this.Gender, this.PowerType }, 0));
            SetField(Fields.UNIT_FIELD_STAT0, this.Strength);
            SetField(Fields.UNIT_FIELD_STAT1, this.Agility);
            SetField(Fields.UNIT_FIELD_STAT2, this.Stamina);
            SetField(Fields.UNIT_FIELD_STAT3, this.Intellect);
            SetField(Fields.UNIT_FIELD_STAT4, this.Spirit);
            SetField(Fields.UNIT_FIELD_FLAGS, 0);
            SetField(Fields.UNIT_FIELD_BASE_MANA, this.Mana);
            SetField(Fields.UNIT_FIELD_DISPLAYID, DisplayId);
            SetField(Fields.UNIT_FIELD_MOUNTDISPLAYID, MountDisplayId);
            SetField(Fields.UNIT_FIELD_BYTES_1, BitConverter.ToUInt32(new byte[] { (byte)StandState, 0, 0, 0 }, 0));
            SetField(Fields.PLAYER_SELECTION, (ulong)0);
            SetField(Fields.PLAYER_BYTES, BitConverter.ToUInt32(new byte[] { Skin, Face, HairStyle, HairColor }, 0));
            SetField(Fields.PLAYER_BYTES_2, BitConverter.ToUInt32(new byte[] { 0, FacialHair, 0, RestedState }, 0));
            SetField(Fields.PLAYER_BYTES_3, (uint)this.Gender);
            SetField(Fields.PLAYER_XP, 47);
            SetField(Fields.PLAYER_NEXT_LEVEL_XP, 200);

            SetField(Fields.UNIT_FIELD_ATTACKPOWER, 1);
            SetField(Fields.UNIT_FIELD_ATTACK_POWER_MODS, 0);
            SetField(Fields.UNIT_FIELD_RANGEDATTACKPOWER, 1);
            SetField(Fields.UNIT_FIELD_RANGED_ATTACK_POWER_MODS, 0);

            for (int i = 0; i < 32; i++)
            {
                SetField(Fields.PLAYER_EXPLORED_ZONES_1 + i, 0xFFFFFFFF);
            }

            //FillInPartialObjectData
            writer.WriteUInt8(maskSize); //UpdateMaskBlocks
            writer.WriteBytes(maskArray);
            foreach (var kvp in fieldData)
            {
                writer.WriteBytes(kvp.Value); //Data
            }
            return(writer);
        }
コード例 #5
0
        public override IPacketWriter BuildUpdate()
        {
            MaskSize = ((int)Fields.MAX + 31) / 32;
            FieldData.Clear();
            MaskArray = new byte[MaskSize * 4];

            PacketWriter writer = new PacketWriter(Sandbox.Instance.Opcodes[global::Opcodes.SMSG_UPDATE_OBJECT], "SMSG_UPDATE_OBJECT");

            writer.WriteUInt32(1);         // Number of transactions
            writer.WriteUInt8(0);
            writer.WriteUInt8(2);          // UpdateType
            writer.WriteUInt64(Guid);
            writer.WriteUInt8(4);          // ObjectType, 4 = Player

            writer.WriteUInt32(0);         // MovementFlagMask
            writer.WriteUInt32((uint)Environment.TickCount);
            writer.WriteFloat(Location.X); // x
            writer.WriteFloat(Location.Y); // y
            writer.WriteFloat(Location.Z); // z
            writer.WriteFloat(Location.O); // w (o)
            writer.WriteFloat(0);
            writer.WriteFloat(2.5f);       // WalkSpeed
            writer.WriteFloat(7.0f);       // RunSpeed
            writer.WriteFloat(2.5f);       // Backwards WalkSpeed
            writer.WriteFloat(4.7222f);    // SwimSpeed
            writer.WriteFloat(4.7222f);    // Backwards SwimSpeed
            writer.WriteFloat(3.14f);      // TurnSpeed

            writer.WriteUInt32(1);         // Flags, 1 - Player
            writer.WriteUInt32(1);         // AttackCycle
            writer.WriteUInt32(0);         // TimerId
            writer.WriteUInt64(0);         // VictimGuid

            SetField(Fields.OBJECT_FIELD_GUID, Guid);
            SetField(Fields.OBJECT_FIELD_TYPE, (uint)0x19);
            SetField(Fields.OBJECT_FIELD_ENTRY, 0);
            SetField(Fields.OBJECT_FIELD_SCALE_X, Scale);
            SetField(Fields.OBJECT_FIELD_PADDING, 0);
            SetField(Fields.UNIT_FIELD_TARGET, (ulong)0);
            SetField(Fields.UNIT_FIELD_HEALTH, Health);
            SetField(Fields.UNIT_FIELD_POWER2, 0);
            SetField(Fields.UNIT_FIELD_MAXHEALTH, Health);
            SetField(Fields.UNIT_FIELD_MAXPOWER2, Rage);
            SetField(Fields.UNIT_FIELD_LEVEL, Level);
            SetField(Fields.UNIT_FIELD_BYTES_0, ToUInt32(Race, Class, Gender, PowerType));
            SetField(Fields.UNIT_FIELD_STAT0, Strength);
            SetField(Fields.UNIT_FIELD_STAT1, Agility);
            SetField(Fields.UNIT_FIELD_STAT2, Stamina);
            SetField(Fields.UNIT_FIELD_STAT3, Intellect);
            SetField(Fields.UNIT_FIELD_STAT4, Spirit);
            SetField(Fields.UNIT_FIELD_FLAGS, 0);
            SetField(Fields.UNIT_FIELD_BASE_MANA, Mana);
            SetField(Fields.UNIT_FIELD_DISPLAYID, DisplayId);
            SetField(Fields.UNIT_FIELD_MOUNTDISPLAYID, MountDisplayId);
            SetField(Fields.UNIT_FIELD_BYTES_1, ToUInt32((byte)StandState));
            SetField(Fields.PLAYER_SELECTION, (ulong)0);
            SetField(Fields.PLAYER_BYTES, ToUInt32(Skin, Face, HairStyle, HairColor));
            SetField(Fields.PLAYER_BYTES_2, ToUInt32(b2: FacialHair, b4: RestedState));
            SetField(Fields.PLAYER_BYTES_3, ToUInt32(Gender));
            SetField(Fields.PLAYER_XP, 47);
            SetField(Fields.PLAYER_NEXT_LEVEL_XP, 200);

            SetField(Fields.UNIT_FIELD_ATTACKPOWER, 1);
            SetField(Fields.UNIT_FIELD_ATTACK_POWER_MODS, 0);
            SetField(Fields.UNIT_FIELD_RANGEDATTACKPOWER, 1);
            SetField(Fields.UNIT_FIELD_RANGED_ATTACK_POWER_MODS, 0);

            for (int i = 0; i < 32; i++)
            {
                SetField(Fields.PLAYER_EXPLORED_ZONES_1 + i, 0xFFFFFFFF);
            }

            // FillInPartialObjectData
            writer.WriteUInt8(MaskSize); // UpdateMaskBlocks
            writer.Write(MaskArray);
            foreach (var kvp in FieldData)
            {
                writer.Write(kvp.Value); // Data
            }
            return(writer);
        }