public override void Handle(GameSession session, PacketReader packet)
    {
        byte   objectType  = packet.ReadByte(); // 0 = build, 1 = fish
        byte   unk         = packet.ReadByte();
        byte   unk2        = packet.ReadByte();
        byte   unk3        = packet.ReadByte();
        byte   unk4        = packet.ReadByte();
        byte   unk5        = packet.ReadByte();
        CoordS coord       = packet.Read <CoordS>();
        CoordS unkCoord    = packet.Read <CoordS>();
        CoordS rotation    = packet.Read <CoordS>();
        short  unk6        = packet.ReadShort();
        int    unk7        = packet.ReadInt(); // always -1 ?
        int    playerTick  = packet.ReadInt();
        int    playerTick2 = packet.ReadInt(); // packet is given twice for some reason

        if (session.Player.Guide == null)
        {
            return;
        }

        // TODO: If possible, find a way to stop having the client spam the server with this packet

        if (coord.ToFloat() == session.Player.Guide.Coord) // Possibly a temp fix to avoid spamming all players
        {
            return;
        }

        session.Player.Guide.Rotation = rotation.ToFloat();
        session.Player.Guide.Coord    = coord.ToFloat();
        session.FieldManager.BroadcastPacket(GuideObjectPacket.Sync(session.Player.Guide, unk2, unk3, unk4, unk5, unkCoord, unk6, unk7), session);
    }
Exemplo n.º 2
0
        public static Packet Send(int sourceObjectId, CoordS effectCoord, SkillCast skill)
        {
            PacketWriter         pWriter     = PacketWriter.Of(SendOp.REGION_SKILL);
            SkillCast            parentSkill = skill.ParentSkill;
            List <MagicPathMove> skillMoves  = parentSkill?.GetMagicPaths().MagicPathMoves ?? null;
            byte tileCount = (byte)(skillMoves != null ? skillMoves.Count : 1);

            pWriter.WriteEnum(RegionSkillMode.Add);
            pWriter.WriteInt(sourceObjectId);
            pWriter.WriteInt(sourceObjectId);
            pWriter.WriteInt();
            pWriter.WriteByte(tileCount);
            if (tileCount == 0)
            {
                return(pWriter);
            }

            for (int i = 0; i < tileCount; i++)
            {
                CoordF currentSkillCoord = skillMoves != null ? skillMoves[i].FireOffsetPosition : CoordF.From(0, 0, 0);
                CoordF castPosition      = Block.ClosestBlock(currentSkillCoord + effectCoord.ToFloat());

                pWriter.Write(castPosition);
            }
            pWriter.WriteInt(skill.SkillId);
            pWriter.WriteShort(skill.SkillLevel);
            pWriter.WriteLong();


            return(pWriter);
        }
        public override void Handle(GameSession session, PacketReader packet)
        {
            byte   objectType  = packet.ReadByte(); // 0 = build, 1 = fish
            byte   unk         = packet.ReadByte();
            byte   unk2        = packet.ReadByte();
            byte   unk3        = packet.ReadByte();
            byte   unk4        = packet.ReadByte();
            byte   unk5        = packet.ReadByte();
            CoordS coord       = packet.Read <CoordS>();
            CoordS unkCoord    = packet.Read <CoordS>();
            CoordS rotation    = packet.Read <CoordS>();
            short  unk6        = packet.ReadShort();
            int    unk7        = packet.ReadInt(); // always -1 ?
            int    playerTick  = packet.ReadInt();
            int    playerTick2 = packet.ReadInt(); // packet is given twice for some reason

            if (session.Player.Guide == null)
            {
                return;
            }

            session.Player.Guide.Rotation = rotation.ToFloat();
            session.Player.Guide.Coord    = coord.ToFloat();
            session.FieldManager.BroadcastPacket(GuideObjectPacket.Sync(session.Player.Guide, unk2, unk3, unk4, unk5, unkCoord, unk6, unk7), session);
        }
        public static Packet Send(int sourceObjectId, CoordS effectCoord, SkillCast skill)
        {
            PacketWriter pWriter   = PacketWriter.Of(SendOp.REGION_SKILL);
            byte         tileCount = 1; // TODO: add amount of tiles affected to SkillCast?

            pWriter.WriteEnum(RegionSkillMode.Add);
            pWriter.WriteInt(sourceObjectId);
            pWriter.WriteInt(sourceObjectId);
            pWriter.WriteInt();
            if (tileCount != 0)
            {
                pWriter.WriteByte(tileCount);
                for (int i = 0; i < tileCount; i++)
                {
                    pWriter.Write(effectCoord.ToFloat());
                }
                pWriter.WriteInt(skill.SkillId);
                pWriter.WriteShort(skill.SkillLevel);
                pWriter.WriteLong();
            }

            return(pWriter);
        }