예제 #1
0
        public void processHyperJump(ref byte[] rpcData)
        {
            double       xDest  = 0;
            double       yDest  = 0;
            double       zDest  = 0;
            PacketReader reader = new PacketReader(rpcData);

            xDest = reader.readDouble(1);
            yDest = reader.readDouble(1);
            zDest = reader.readDouble(1);

            // ToDo: figure out what this 6 bytes are could be
            // Skip 6 bytes as we currently didnt knew
            byte[] unknownJumpBytes = reader.readBytes(6);
            float  maybeMaxHeight   = reader.readFloat(1);

            reader.incrementOffsetByValue(1);
            UInt32 clientJumpIdUnknown = reader.readUInt32(1);

            // Players current X Z Y
            double x = 0;
            double y = 0;
            double z = 0;

            byte[] Ltvector3d = Store.currentClient.playerInstance.Position.getValue();
            NumericalUtils.LtVector3dToDoubles(Ltvector3d, ref x, ref y, ref z);
            int   rotation = (int)Store.currentClient.playerInstance.YawInterval.getValue()[0];
            float xPos     = (float)x;
            float yPos     = (float)y;
            float zPos     = (float)z;

            LtVector3f[] JumpMovements = Maths.ParabolicMovement(new LtVector3f(xPos, yPos, zPos),
                                                                 new LtVector3f((float)xDest, (float)yDest, (float)zDest), 50, 128);

            float  distance = Maths.getDistance(xPos, yPos, zPos, (float)xDest, (float)yDest, (float)zDest);
            UInt16 duration = (UInt16)(distance * 0.5f);

            UInt32 startTime = TimeUtils.getUnixTimeUint32();
            UInt32 endTime   = startTime + duration;

            ServerPackets packets = new ServerPackets();

            packets.sendHyperJumpID(clientJumpIdUnknown);
            Store.currentClient.playerData.isJumping = true;
            Store.currentClient.playerData.incrementJumpID();
            UInt32 maybeTimeBasedValue = 40384248;

            foreach (LtVector3f currentJumpPos in JumpMovements)
            {
                Steps.Add(new JumpStep(currentJumpPos, new LtVector3f((float)xDest, (float)yDest, (float)zDest),
                                       maybeMaxHeight, endTime, Store.currentClient.playerData.getJumpID(), maybeTimeBasedValue));
                //packets.SendHyperJumpStepUpdate(currentJumpPos, xDest, yDest, zDest, maybeMaxHeight, endTime);
                maybeTimeBasedValue = maybeTimeBasedValue + 100;
            }

            hyperjumpTimer = new Timer(ProcessJumpStep, this, 0, 0);

            //packets.SendHyperJumpUpdate(xPos,yPos,zPos,(float)xDest,(float)yDest,(float)zDest,startTime,endTime);
        }
예제 #2
0
        public void processHyperJumpCancel(ref byte[] rpcData)
        {
            double       xDest  = 0;
            double       yDest  = 0;
            double       zDest  = 0;
            PacketReader reader = new PacketReader(rpcData);

            xDest = reader.readDouble(1);
            yDest = reader.readDouble(1);
            zDest = reader.readDouble(1);

            // ToDo: figure out what this 6 bytes are could be
            // Skip 6 bytes as we currently didnt knew
            reader.incrementOffsetByValue(6);
            UInt32 maybeMaxHeight = reader.readUInt32(1);

            reader.setOffsetOverrideValue(rpcData.Length - 4);
            UInt32 clientJumpIdUnknown = reader.readUInt32(1);

            // Players current X Z Y
            double x = 0; double y = 0; double z = 0;

            byte[] Ltvector3d = Store.currentClient.playerInstance.Position.getValue();
            NumericalUtils.LtVector3dToDoubles(Ltvector3d, ref x, ref y, ref z);
            int   rotation = (int)Store.currentClient.playerInstance.YawInterval.getValue()[0];
            float xPos     = (float)x;
            float yPos     = (float)y;
            float zPos     = (float)z;

            float  distance = Maths.getDistance(xPos, yPos, zPos, (float)xDest, (float)yDest, (float)zDest);
            UInt16 duration = (UInt16)(distance * 0.5);

            UInt32 startTime = TimeUtils.getUnixTimeUint32();
            UInt32 endTime   = startTime + duration;

            ServerPackets packets = new ServerPackets();

            packets.sendHyperJumpID(clientJumpIdUnknown);
            packets.SendHyperJumpUpdate(xPos, yPos, zPos, (float)xDest, (float)yDest, (float)zDest, startTime, endTime);
        }