Esempio n. 1
0
        public BeginAutoAttack(INavigationGrid navGrid, IAttackableUnit attacker, IAttackableUnit attacked, uint futureProjNetId, bool isCritical)
            : base(PacketCmd.PKT_S2C_BEGIN_AUTO_ATTACK, attacker.NetId)
        {
            WriteNetId(attacked);
            Write((byte)0x80);            // extraTime
            Write((uint)futureProjNetId); // Basic attack projectile ID, to be spawned later
            if (isCritical)
            {
                Write((byte)0x49); // attackSlot
            }
            else
            {
                Write((byte)0x40); // attackSlot
            }

            Write((byte)0x80); // not sure what this is, but it should be correct (or maybe attacked x z y?) - 4.18
            Write((byte)0x01);
            Write(MovementVector.TargetXToNormalFormat(navGrid, attacked.X));
            Write((byte)0x80);
            Write((byte)0x01);
            Write(MovementVector.TargetYToNormalFormat(navGrid, attacked.Y));
            Write((byte)0xCC);
            Write((byte)0x35);
            Write((byte)0xC4);
            Write((byte)0xD1);
            Write((float)attacker.X);
            Write((float)attacker.Y);
        }
        public override void Serialize(LittleEndianWriter writer)
        {
            writer.WriteUInt(targetNetId);
            writer.WriteByte((byte)extraTime);       // extraTime
            writer.WriteUInt(futureProjectileNetId); // Basic attack projectile ID, to be spawned later

            writer.WriteByte((byte)slot);            // attackSlot

            writer.WriteByte((byte)0x80);            // not sure what this is, but it should be correct (or maybe attacked x z y?) - 4.18
            writer.WriteByte((byte)0x01);

            writer.WriteShort((short)MovementVector.TargetXToNormalFormat(targetPosition.X, middleOfMap));
            writer.WriteByte((byte)0x80);
            writer.WriteByte((byte)0x01);
            writer.WriteShort((short)MovementVector.TargetYToNormalFormat(targetPosition.Y, middleOfMap));

            //    writer.WriteFloat(targetPosition.X);
            //    writer.WriteFloat(targetPosition.Y);



            writer.WriteByte((byte)0xCC);
            writer.WriteByte((byte)0x35);
            writer.WriteByte((byte)0xC4);
            writer.WriteByte((byte)0xD1);
            writer.WriteFloat(sourcePosition.X);
            writer.WriteFloat(sourcePosition.Y);
        }
Esempio n. 3
0
 public BeginAutoAttack(AttackableUnit attacker, AttackableUnit attacked, uint futureProjNetId, bool isCritical)
     : base(PacketCmd.PKT_S2C_BeginAutoAttack, attacker.NetId)
 {
     buffer.Write(attacked.NetId);
     buffer.Write((byte)0x80);      // extraTime
     buffer.Write(futureProjNetId); // Basic attack projectile ID, to be spawned later
     if (isCritical)
     {
         buffer.Write((byte)0x49); // attackSlot
     }
     else
     {
         buffer.Write((byte)0x40); // attackSlot
     }
     buffer.Write((byte)0x80);     // not sure what this is, but it should be correct (or maybe attacked x z y?) - 4.18
     buffer.Write((byte)0x01);
     buffer.Write(MovementVector.TargetXToNormalFormat(attacked.X));
     buffer.Write((byte)0x80);
     buffer.Write((byte)0x01);
     buffer.Write(MovementVector.TargetYToNormalFormat(attacked.Y));
     buffer.Write((byte)0xCC);
     buffer.Write((byte)0x35);
     buffer.Write((byte)0xC4);
     buffer.Write((byte)0xD1);
     buffer.Write(attacker.X);
     buffer.Write(attacker.Y);
 }
Esempio n. 4
0
        public EnterVisionAgain(INavigationGrid navGrid, IChampion c)
            : base(PacketCmd.PKT_S2C_OBJECT_SPAWN, c.NetId)
        {
            Write((short)0); // extraInfo
            Write((byte)0);  //c.getInventory().getItems().size(); // itemCount?
            //buffer.Write((short)7; // unknown

            /*
             * for (int i = 0; i < c.getInventory().getItems().size(); i++) {
             * ItemInstance* item = c.getInventory().getItems()[i];
             *
             * if (item != 0 && item.getTemplate() != 0) {
             *    buffer.Write((short)item.getStacks();
             *    buffer.Write((short)0; // unk
             *    buffer.Write((int)item.getTemplate().getId();
             *    buffer.Write((short)item.getSlot();
             * }
             * else {
             *    buffer.fill(0, 7);
             * }
             * }
             */

            Fill(0, 10);
            Write(1.0f);
            Fill(0, 13);

            Write((byte)2);               // Type of data: Waypoints=2
            Write(Environment.TickCount); // unk

            var waypoints = c.Waypoints;

            Write((byte)((waypoints.Count - c.CurWaypoint + 1) * 2)); // coordCount
            WriteNetId(c);
            Write((byte)0);                                           // movement mask; 1=KeepMoving?
            Write(MovementVector.TargetXToNormalFormat(navGrid, c.X));
            Write(MovementVector.TargetYToNormalFormat(navGrid, c.Y));
            for (var i = c.CurWaypoint; i < waypoints.Count; ++i)
            {
                Write(MovementVector.TargetXToNormalFormat(navGrid, waypoints[i].X));
                Write(MovementVector.TargetXToNormalFormat(navGrid, waypoints[i].Y));
            }
        }
Esempio n. 5
0
        public EnterVisionAgain(Champion c) : base(PacketCmd.PKT_S2C_ObjectSpawn, c.NetId)
        {
            buffer.Write((short)0); // extraInfo
            buffer.Write((byte)0);  //c.getInventory().getItems().size(); // itemCount?
            //buffer.Write((short)7; // unknown

            /*
             * for (int i = 0; i < c.getInventory().getItems().size(); i++) {
             * ItemInstance* item = c.getInventory().getItems()[i];
             *
             * if (item != 0 && item.getTemplate() != 0) {
             *    buffer.Write((short)item.getStacks();
             *    buffer.Write((short)0; // unk
             *    buffer.Write((int)item.getTemplate().getId();
             *    buffer.Write((short)item.getSlot();
             * }
             * else {
             *    buffer.fill(0, 7);
             * }
             * }
             */

            buffer.fill(0, 10);
            buffer.Write((float)1.0f);
            buffer.fill(0, 13);

            buffer.Write((byte)2);                    // Type of data: Waypoints=2
            buffer.Write((int)Environment.TickCount); // unk

            List <Vector2> waypoints = c.Waypoints;

            buffer.Write((byte)((waypoints.Count - c.CurWaypoint + 1) * 2)); // coordCount
            buffer.Write(c.NetId);
            buffer.Write((byte)0);                                           // movement mask; 1=KeepMoving?
            buffer.Write(MovementVector.TargetXToNormalFormat(c.X));
            buffer.Write(MovementVector.TargetYToNormalFormat(c.Y));
            for (int i = c.CurWaypoint; i < waypoints.Count; ++i)
            {
                buffer.Write(MovementVector.TargetXToNormalFormat(waypoints[i].X));
                buffer.Write(MovementVector.TargetXToNormalFormat(waypoints[i].Y));
            }
        }
Esempio n. 6
0
        /// <summary> TODO: Probably not the best place to have this, but still better than packet notifier </summary>
        public void TeleportTo(float x, float y)
        {
            if (!_game.Map.NavGrid.IsWalkable(x, y))
            {
                var walkableSpot = _game.Map.NavGrid.GetClosestTerrainExit(new Vector2(x, y));
                SetPosition(walkableSpot);

                x = MovementVector.TargetXToNormalFormat(_game.Map.NavGrid, walkableSpot.X);
                y = MovementVector.TargetYToNormalFormat(_game.Map.NavGrid, walkableSpot.Y);
            }
            else
            {
                SetPosition(x, y);

                x = MovementVector.TargetXToNormalFormat(_game.Map.NavGrid, x);
                y = MovementVector.TargetYToNormalFormat(_game.Map.NavGrid, y);
            }

            _game.PacketNotifier.NotifyTeleport(this, x, y);
        }
Esempio n. 7
0
        public EnterVisionAgain(INavigationGrid navGrid, IMinion m)
            : base(PacketCmd.PKT_S2C_OBJECT_SPAWN, m.NetId)
        {
            Fill(0, 13);
            Write(1.0f);
            Fill(0, 13);
            Write((byte)0x02);
            Write(Environment.TickCount); // unk

            var waypoints = m.Waypoints;

            Write((byte)((waypoints.Count - m.CurWaypoint + 1) * 2)); // coordCount
            WriteNetId(m);
            // TODO: Check if Movement.EncodeWaypoints is what we need to use here
            Write((byte)0); // movement mask
            Write(MovementVector.TargetXToNormalFormat(navGrid, m.X));
            Write(MovementVector.TargetYToNormalFormat(navGrid, m.Y));
            for (var i = m.CurWaypoint; i < waypoints.Count; i++)
            {
                Write(MovementVector.TargetXToNormalFormat(navGrid, waypoints[i].X));
                Write(MovementVector.TargetXToNormalFormat(navGrid, waypoints[i].Y));
            }
        }
Esempio n. 8
0
        public EnterVisionAgain(Minion m)
            : base(PacketCmd.PKT_S2C_ObjectSpawn, m.NetId)
        {
            buffer.fill(0, 13);
            buffer.Write(1.0f);
            buffer.fill(0, 13);
            buffer.Write((byte)0x02);
            buffer.Write((int)Environment.TickCount); // unk

            var waypoints = m.Waypoints;

            buffer.Write((byte)((waypoints.Count - m.CurWaypoint + 1) * 2)); // coordCount
            buffer.Write((int)m.NetId);
            // TODO: Check if Movement.EncodeWaypoints is what we need to use here
            buffer.Write((byte)0); // movement mask
            buffer.Write((short)MovementVector.TargetXToNormalFormat(m.X));
            buffer.Write((short)MovementVector.TargetYToNormalFormat(m.Y));
            for (int i = m.CurWaypoint; i < waypoints.Count; i++)
            {
                buffer.Write(MovementVector.TargetXToNormalFormat((float)waypoints[i].X));
                buffer.Write(MovementVector.TargetXToNormalFormat((float)waypoints[i].Y));
            }
        }
Esempio n. 9
0
        public void NotifyTeleport(Unit u, float _x, float _y)
        {
            // Can't teleport to this point of the map
            if (!_game.Map.IsWalkable(_x, _y))
            {
                _x = MovementVector.TargetXToNormalFormat(u.X);
                _y = MovementVector.TargetYToNormalFormat(u.Y);
            }
            else
            {
                u.setPosition(_x, _y);

                //TeleportRequest first(u.NetId, u.teleportToX, u.teleportToY, true);
                //sendPacket(currentPeer, first, Channel.CHL_S2C);

                _x = MovementVector.TargetXToNormalFormat(_x);
                _y = MovementVector.TargetYToNormalFormat(_y);
            }

            var second = new TeleportRequest(u.NetId, _x, _y, false);

            _game.PacketHandlerManager.broadcastPacketVision(u, second, Channel.CHL_S2C);
        }
Esempio n. 10
0
        public MinionSpawn(INavGrid navGrid, IMinion m)
            : base(PacketCmd.PKT_S2C_OBJECT_SPAWN, m.NetId)
        {
            Write((uint)0x00150017); // unk
            Write((byte)0x03);       // SpawnType - 3 = minion
            WriteNetId(m);
            WriteNetId(m);
            Write((uint)m.SpawnPosition);
            Write((byte)0xFF); // unk
            Write((byte)1);    // wave number ?

            Write((byte)m.MinionSpawnType);

            if (m.MinionSpawnType == MinionSpawnType.MINION_TYPE_MELEE)
            {
                Write((byte)0); // unk
            }
            else
            {
                Write((byte)1); // unk
            }

            Write((byte)0); // unk

            if (m.MinionSpawnType == MinionSpawnType.MINION_TYPE_CASTER)
            {
                Write(0x00010007); // unk
            }
            else if (m.MinionSpawnType == MinionSpawnType.MINION_TYPE_MELEE)
            {
                Write(0x0001000A); // unk
            }
            else if (m.MinionSpawnType == MinionSpawnType.MINION_TYPE_CANNON)
            {
                Write(0x0001000D);
            }
            else
            {
                Write(0x00010007);        // unk
            }
            Write(0x00000000);            // unk
            Write(0x00000000);            // unk
            Write((short)0x0000);         // unk
            Write(1.0f);                  // unk
            Write(0x00000000);            // unk
            Write(0x00000000);            // unk
            Write(0x00000000);            // unk
            Write((short)0x0200);         // unk
            Write(Environment.TickCount); // unk

            var waypoints = m.Waypoints;

            Write((byte)((waypoints.Count - m.CurWaypoint + 1) * 2)); // coordCount
            WriteNetId(m);
            Write((byte)0);                                           // movement mask
            Write(MovementVector.TargetXToNormalFormat(navGrid, m.X));
            Write(MovementVector.TargetYToNormalFormat(navGrid, m.Y));
            for (var i = m.CurWaypoint; i < waypoints.Count; ++i)
            {
                Write(MovementVector.TargetXToNormalFormat(navGrid, waypoints[i].X));
                Write(MovementVector.TargetXToNormalFormat(navGrid, waypoints[i].Y));
            }
        }
Esempio n. 11
0
        public MinionSpawn(Minion m)
            : base(PacketCmd.PKT_S2C_ObjectSpawn, m.NetId)
        {
            buffer.Write((uint)0x00150017); // unk
            buffer.Write((byte)0x03);       // SpawnType - 3 = minion
            buffer.Write((uint)m.NetId);
            buffer.Write((uint)m.NetId);
            buffer.Write((uint)m.SpawnPosition);
            buffer.Write((byte)0xFF); // unk
            buffer.Write((byte)1);    // wave number ?

            buffer.Write((byte)m.getType());

            if (m.getType() == MinionSpawnType.MINION_TYPE_MELEE)
            {
                buffer.Write((byte)0); // unk
            }
            else
            {
                buffer.Write((byte)1); // unk
            }

            buffer.Write((byte)0); // unk

            if (m.getType() == MinionSpawnType.MINION_TYPE_CASTER)
            {
                buffer.Write((int)0x00010007); // unk
            }
            else if (m.getType() == MinionSpawnType.MINION_TYPE_MELEE)
            {
                buffer.Write((int)0x0001000A); // unk
            }
            else if (m.getType() == MinionSpawnType.MINION_TYPE_CANNON)
            {
                buffer.Write((int)0x0001000D);
            }
            else
            {
                buffer.Write((int)0x00010007);        // unk
            }
            buffer.Write((int)0x00000000);            // unk
            buffer.Write((int)0x00000000);            // unk
            buffer.Write((short)0x0000);              // unk
            buffer.Write((float)1.0f);                // unk
            buffer.Write((int)0x00000000);            // unk
            buffer.Write((int)0x00000000);            // unk
            buffer.Write((int)0x00000000);            // unk
            buffer.Write((short)0x0200);              // unk
            buffer.Write((int)Environment.TickCount); // unk

            List <Vector2> waypoints = m.Waypoints;

            buffer.Write((byte)((waypoints.Count - m.CurWaypoint + 1) * 2)); // coordCount
            buffer.Write((int)m.NetId);
            buffer.Write((byte)0);                                           // movement mask
            buffer.Write((short)MovementVector.TargetXToNormalFormat(m.X));
            buffer.Write((short)MovementVector.TargetYToNormalFormat(m.Y));
            for (int i = m.CurWaypoint; i < waypoints.Count; ++i)
            {
                buffer.Write((short)MovementVector.TargetXToNormalFormat(waypoints[i].X));
                buffer.Write((short)MovementVector.TargetXToNormalFormat(waypoints[i].Y));
            }
        }