Ejemplo 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);
        }
Ejemplo n.º 2
0
        public static byte[] EncodeWaypoints(INavigationGrid navGrid, List <Vector2> waypoints)
        {
            var numCoords = waypoints.Count * 2;

            var maskBytes    = new byte[(numCoords - 3) / 8 + 1];
            var tempStream   = new MemoryStream();
            var resultStream = new MemoryStream();
            var tempBuffer   = new BinaryWriter(tempStream);
            var resultBuffer = new BinaryWriter(resultStream);

            var lastCoord  = new Vector2();
            var coordinate = 0;

            foreach (var waypoint in waypoints)
            {
                var curVector = new Vector2((waypoint.X - navGrid.MiddleOfMap.X) / 2, (waypoint.Y - navGrid.MiddleOfMap.Y) / 2);
                if (coordinate == 0)
                {
                    tempBuffer.Write((short)curVector.X);
                    tempBuffer.Write((short)curVector.Y);
                }
                else
                {
                    var relative   = new Vector2(curVector.X - lastCoord.X, curVector.Y - lastCoord.Y);
                    var isAbsolute = IsAbsolute(relative);

                    if (isAbsolute.Item1)
                    {
                        tempBuffer.Write((short)curVector.X);
                    }
                    else
                    {
                        tempBuffer.Write((byte)relative.X);
                    }

                    if (isAbsolute.Item2)
                    {
                        tempBuffer.Write((short)curVector.Y);
                    }
                    else
                    {
                        tempBuffer.Write((byte)relative.Y);
                    }

                    SetBitmaskValue(ref maskBytes, coordinate - 2, !isAbsolute.Item1);
                    SetBitmaskValue(ref maskBytes, coordinate - 1, !isAbsolute.Item2);
                }
                lastCoord   = curVector;
                coordinate += 2;
            }

            if (numCoords > 2)
            {
                resultBuffer.Write(maskBytes);
            }

            resultBuffer.Write(tempStream.ToArray());

            return(resultStream.ToArray());
        }
Ejemplo n.º 3
0
 public CastSpellResponse(INavigationGrid navGrid, ISpell s, float x, float y, float xDragEnd, float yDragEnd, uint futureProjNetId, uint spellNetId)
     : base(PacketCmd.PKT_S2C_CAST_SPELL_ANS, s.Owner.NetId)
 {
     Write(Environment.TickCount); // syncID
     Write((byte)0);               // Unk
     Write((short)0x66);           // Buffer size from here
     Write((int)s.GetId());        // Spell hash, for example hash("EzrealMysticShot")
     Write((uint)spellNetId);      // Spell net ID
     Write((byte)(s.Level - 1));
     Write(1.0f);                  // attackSpeedMod
     WriteNetId(s.Owner);
     WriteNetId(s.Owner);
     Write((int)s.Owner.GetObjHash());
     Write((uint)futureProjNetId); // The projectile ID that will be spawned
     Write((float)x);
     Write((float)navGrid.GetHeightAtLocation(x, y));
     Write((float)y);
     Write((float)xDragEnd);
     Write((float)navGrid.GetHeightAtLocation(xDragEnd, yDragEnd));
     Write((float)yDragEnd);
     Write((byte)0);                                              // numTargets (if >0, what follows is a list of {uint32 targetNetId, uint8 hitResult})
     Write((float)s.SpellData.GetCastTime());                     // designerCastTime
     Write(0.0f);                                                 // extraTimeForCast
     Write((float)s.SpellData.GetCastTime() /*+ s.ChannelTime*/); // designerTotalTime
     Write((float)s.GetCooldown());
     Write(0.0f);                                                 // startCastTime
     Write((byte)0);                                              // flags (isAutoAttack, secondAttack, forceCastingOrChannelling, mShouldOverrideCastPosition)
     Write((byte)s.Slot);
     Write((float)s.SpellData.ManaCost[s.Level]);
     Write((float)s.Owner.X);
     Write((float)s.Owner.GetZ());
     Write((float)s.Owner.Y);
     Write((long)1); // Unk
 }
Ejemplo n.º 4
0
 public CastSpellResponse(INavigationGrid navGrid, ISpell s, Vector2 start, Vector2 end, uint futureProjNetId, uint spellNetId)
 {
     NavGrid         = navGrid;
     Spell           = s;
     Start           = start;
     End             = end;
     FutureProjNetId = futureProjNetId;
     SpellNetId      = spellNetId;
 }
Ejemplo n.º 5
0
        public SpawnCampMonster(INavigationGrid navGrid, IMonster m)
            : base(PacketCmd.PKT_S2C_OBJECT_SPAWN, m.NetId)
        {
            Write((byte)0x79);
            Write((byte)0x01);
            Write((byte)0x77);
            Write((byte)0x01);

            Write((byte)0x63); // 0x63 (99) for jungle monster, 3 for minion
            WriteNetId(m);
            WriteNetId(m);
            Write((byte)0x40);
            Write(m.X);                                                 //x
            Write(m.GetZ());                                            //z
            Write(m.Y);                                                 //y
            Write(m.X);                                                 //x
            Write(m.GetZ());                                            //z
            Write(m.Y);                                                 //y
            Write(m.Facing.X);                                          //facing x
            Write(navGrid.GetHeightAtLocation(m.Facing.X, m.Facing.Y)); //facing z
            Write(m.Facing.Y);                                          //facing y

            WriteConstLengthString(m.Name, 64);

            WriteConstLengthString(m.Model, 64);

            WriteConstLengthString(m.Name, 64);

            WriteConstLengthString(m.SpawnAnimation, 64);

            Write((int)m.Team);          // Probably a short
            Fill(0, 12);                 // Unk
            Write((int)m.CampId);        // Camp id. Camp needs to exist
            Write(0);                    // Unk
            Write((int)m.CampUnk);
            Write(1);                    // Unk
            Write(m.SpawnAnimationTime); // After this many seconds, the camp icon appears in the minimap
            Write(1191.533936f);         // Unk
            Write(1);                    // Unk
            Fill(0, 40);                 // Unk
            Write(1.0f);                 // Unk
            Fill(0, 13);                 // Unk
            Write((byte)3);              //type 3=champ/jungle; 2=minion
            Write((byte)0xF1);           //<-|
            Write((byte)0xFB);           //  |-> Unk
            Write((byte)0x27);           //  |
            Write((byte)0x00);           //<-|
            Write(m.X);                  //x
            Write(m.Y);                  //y
            Write(-0.8589599f);          // rotation1 from -1 to 1
            Write(0.5120428f);           // rotation2 from -1 to 1
        }
Ejemplo n.º 6
0
        public INavigationGrid GetNavigationGrid(int mapId)
        {
            foreach (var dataPackage in _loadedPackages)
            {
                INavigationGrid toReturnNavgrid = dataPackage.GetNavigationGrid(mapId);

                if (toReturnNavgrid != null)
                {
                    return(toReturnNavgrid);
                }
            }

            throw new ContentNotFoundException($"No NavGrid for map with id {mapId} found in packages, skipping map load...");
        }
Ejemplo n.º 7
0
        public MovementResponse(INavigationGrid navGrid, List <IGameObject> actors)
            : base(PacketCmd.PKT_S2C_MOVE_ANS)
        {
            Write(Environment.TickCount); // syncID
            Write((short)actors.Count);

            foreach (var actor in actors)
            {
                var waypoints = actor.Waypoints;
                var numCoords = waypoints.Count * 2;
                Write((byte)numCoords);
                WriteNetId(actor);
                Write(Movement.EncodeWaypoints(navGrid, waypoints));
            }
        }
Ejemplo n.º 8
0
        public SpawnMonster(INavigationGrid navGrid, IMonster m)
            : base(PacketCmd.PKT_S2C_OBJECT_SPAWN)
        {
            WriteNetId(m);
            Write((short)345);
            Write((short)343);

            Write((byte)0x63); // 0x63 (99) for jungle monster, 3 for minion
            WriteNetId(m);
            WriteNetId(m);
            Write((byte)0x40);
            Write(m.X);                                                 //x
            Write(m.GetZ());                                            //z
            Write(m.Y);                                                 //y
            Write(m.X);                                                 //x
            Write(m.GetZ());                                            //z
            Write(m.Y);                                                 //y
            Write(m.Facing.X);                                          //facing x
            Write(navGrid.GetHeightAtLocation(m.Facing.X, m.Facing.Y)); //facing z
            Write(m.Facing.Y);                                          //facing y

            WriteConstLengthString(m.Name, 64);

            WriteConstLengthString(m.Model, 64);

            WriteConstLengthString(m.Name, 64);

            Fill(0, 64);        // empty

            Write((int)m.Team); // Probably a short
            Fill(0, 12);
            Write(1);           //campId 1
            Write(100);
            Write(74);
            Write((long)1);
            Write(115.0066f);
            Write((byte)0);

            Fill(0, 11);
            Write(1.0f);        // Unk
            Fill(0, 13);
            Write((byte)3);     //type 3=champ/jungle; 2=minion
            Write(13337);
            Write(m.X);         //x
            Write(m.Y);         //y
            Write(-0.8589599f); // rotation1 from -1 to 1
            Write(0.5120428f);  //rotation2 from -1 to 1
        }
Ejemplo n.º 9
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));
            }
        }
Ejemplo n.º 10
0
        public Dash(INavigationGrid navGrid,
                    IAttackableUnit u,
                    ITarget t,
                    float dashSpeed,
                    bool keepFacingLastDirection,
                    float leapHeight = 0.0f,
                    float followTargetMaxDistance = 0.0f,
                    float backDistance            = 0.0f,
                    float travelTime = 0.0f
                    ) : base(PacketCmd.PKT_S2C_DASH)
        {
            Write(Environment.TickCount); // syncID
            Write((short)1);              // Number of dashes
            Write((byte)4);               // Waypoints size * 2
            WriteNetId(u);
            Write(dashSpeed);
            Write(leapHeight);
            Write(u.X);
            Write(u.Y);
            Write((byte)(keepFacingLastDirection ? 0x01 : 0x00));
            if (t.IsSimpleTarget)
            {
                Write((uint)0);
            }
            else
            {
                WriteNetId(t as IGameObject);
            }

            Write(followTargetMaxDistance);
            Write(backDistance);
            Write(travelTime);

            var waypoints = new List <Vector2>
            {
                new Vector2(u.X, u.Y),
                new Vector2(t.X, t.Y)
            };

            Write(Movement.EncodeWaypoints(navGrid, waypoints));
        }
Ejemplo n.º 11
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));
            }
        }
Ejemplo n.º 12
0
 public MovementResponse(INavigationGrid navGrid, IGameObject obj)
     : this(navGrid, new List <IGameObject> {
     obj
 })
 {
 }
Ejemplo n.º 13
0
 public static short TargetYToNormalFormat(INavigationGrid navGrid, float value)
 {
     return(FormatCoordinate(value, navGrid.MiddleOfMap.Y));
 }
Ejemplo n.º 14
0
 public static Vector2 TranslateToCenteredCoordinates(Vector2 vector, INavigationGrid grid)
 {
     // For unk reason coordinates are translated to 0,0 as a map center, so we gotta get back the original
     // mapSize contains the real center point coordinates, meaning width/2, height/2
     return(new Vector2((vector.X - grid.MiddleOfMap.X) / 2, (vector.Y - grid.MiddleOfMap.Y) / 2));
 }
Ejemplo n.º 15
0
 public static List <CompressedWaypoint> Vector2ToWaypoint(List <Vector2> wp, INavigationGrid grid)
 {
     return(wp.ConvertAll(v => Vector2ToWaypoint(TranslateToCenteredCoordinates(v, grid))));
 }