doublesToLtVector3d() 공개 정적인 메소드

public static doublesToLtVector3d ( double x, double y, double z ) : byte[]
x double
y double
z double
리턴 byte[]
예제 #1
0
파일: Mob.cs 프로젝트: vitalyo7/mxo-hd
        public Object599 getCreationData()
        {
            var themob = new Object599();

            themob.DisableAllAttributes();

            themob.CharacterName.enable();
            themob.Health.enable();
            themob.MaxHealth.enable();
            themob.Level.enable();
            themob.NPCRank.enable();
            themob.RSIDescription.enable();
            themob.MoreInfoID.enable();
            themob.StopFollowActiveTracker.enable();
            themob.ScriptCounter.enable();
            themob.Description.enable();
            themob.CombatantMode.enable();
            themob.Position.enable();
            themob.YawInterval.enable();
            themob.IsDead.enable();
            themob.IsEnemy.enable();
            themob.IsFriendly.enable();
            themob.StealthAwareness.enable();
            themob.TitleAbility.enable();
            themob.ConditionStateFlags.enable();
            themob.CurrentState.enable();

            themob.CharacterName.setValue(getName());
            themob.Health.setValue(getHealthC());
            themob.MaxHealth.setValue(getHealthM());
            themob.Level.setValue(getLevel());
            themob.NPCRank.setValue(1);
            themob.RSIDescription.setValue(StringUtils.hexStringToBytes(getRsiHex()));
            themob.MoreInfoID.setValue(StringUtils.hexStringToBytes(getRsiHex())); // ToDo: Make dynamic
            themob.StopFollowActiveTracker.setValue(0x01);
            themob.ScriptCounter.setValue(1);
            themob.Description.setValue(StringUtils.hexStringToBytes(getRsiHex())); // ToDo: Make dynamic
            themob.CombatantMode.setValue(0x22);
            themob.Position.setValue(NumericalUtils.doublesToLtVector3d(getXPos(), getYPos(), getZPos()));
            themob.YawInterval.setValue((byte)getRotation());
            themob.IsDead.setValue(false);
            themob.IsEnemy.setValue(true);
            themob.IsFriendly.setValue(false);
            themob.StealthAwareness.setValue(0x11);
            byte[] titleAbility = { 0x00, 0x10, 0x00, 0x00 };
            themob.TitleAbility.setValue(titleAbility);
            themob.ConditionStateFlags.setValue(StringUtils.hexStringToBytes("00001000"));
            themob.CurrentState.setValue(StringUtils.hexStringToBytes("06080000"));

            return(themob);
        }
예제 #2
0
        public int parseAttributes(ref byte[] buffer, int _offset)
        {
            int  offset = _offset;
            byte flag   = 0x00;

            flag = BufferHandler.readByte(ref buffer, ref offset);

            byte[] stateData = new byte[buffer.Length - offset + 2];
            ArrayUtils.copy(buffer, offset - 2, stateData, 0, buffer.Length - offset + 2);
            //Flag Bits{0,0,0,0,Vector3f Position Update,  Yaw Update,Animation Update, AttributesPacked Update?}


            switch (flag)
            {
            case 0x02:
                Action.setValue(BufferHandler.readBytes(ref buffer, ref offset, Action.getSize()));
                break;


            case 0x04:
                YawInterval.setValue(BufferHandler.readBytes(ref buffer, ref offset, YawInterval.getSize()));
                break;


            case 0x08:
                double x = (double)NumericalUtils.byteArrayToFloat(BufferHandler.readBytes(ref buffer, ref offset, 4), 1);
                double y = (double)NumericalUtils.byteArrayToFloat(BufferHandler.readBytes(ref buffer, ref offset, 4), 1);
                double z = (double)NumericalUtils.byteArrayToFloat(BufferHandler.readBytes(ref buffer, ref offset, 4), 1);
                Position.setValue(NumericalUtils.doublesToLtVector3d(x, y, z));
                break;

            case 0x0e:
                // UInt16 unknown + LtVector3f
                UInt16 unknown = NumericalUtils.ByteArrayToUint16(BufferHandler.readBytes(ref buffer, ref offset, 2), 1);
                float  xPos    = NumericalUtils.byteArrayToFloat(BufferHandler.readBytes(ref buffer, ref offset, 4), 1);
                float  yPos    = NumericalUtils.byteArrayToFloat(BufferHandler.readBytes(ref buffer, ref offset, 4), 1);
                float  zPos    = NumericalUtils.byteArrayToFloat(BufferHandler.readBytes(ref buffer, ref offset, 4), 1);
                Position.setValue(NumericalUtils.doublesToLtVector3d((double)xPos, (double)yPos, (double)zPos));
                break;
            }

            // TODO: update player attribute packets someday (announce it to my spawners)
            Store.world.sendViewPacketToAllPlayers(stateData, Store.currentClient.playerData.getCharID(), NumericalUtils.ByteArrayToUint16(Store.currentClient.playerInstance.GetGoid(), 1), Store.currentClient.playerData.getEntityId());
            return(offset);
        }
예제 #3
0
        public void processObjectInteraction(StaticWorldObject staticWorldObject, GameObjectItem item)
        {
            WorldSocket.gameServerEntities.Add(staticWorldObject);
            UInt16 typeId = NumericalUtils.ByteArrayToUint16(staticWorldObject.type, 1);

            Store.currentClient.playerData.newViewIdCounter++; // It is just for a test Later we will change this to have a List with Views and Object IDs

            NumericalUtils.uint16ToByteArrayShort(Store.currentClient.playerData.assignSpawnIdCounter());
            ServerPackets packets = new ServerPackets();

            packets.sendSystemChatMessage(Store.currentClient, "Door ID " + staticWorldObject.mxoId + " Type ID " + typeId.ToString() + " POS X:" + staticWorldObject.pos_x.ToString() + " Y:" + staticWorldObject.pos_y.ToString() + " Z:" + staticWorldObject.pos_z.ToString() + typeId, "BROADCAST");


            switch (typeId)
            {
            case 343:
            case 346:
            case 359:
            case 365:
            case 414:
            case 415:
            case 416:
            case 576:
            case 6958:
            case 6965:
            case 6963:
            case 6964:
            case 6972:
                // ObjectAttribute364
                ObjectAttributes364 door364 = new ObjectAttributes364("DOOR364", typeId, staticWorldObject.mxoId);
                door364.DisableAllAttributes();
                door364.Orientation.enable();
                door364.Position.enable();
                door364.CurrentState.enable();
                // Set Values
                door364.Position.setValue(NumericalUtils.doublesToLtVector3d(staticWorldObject.pos_x, staticWorldObject.pos_y, staticWorldObject.pos_z));
                door364.CurrentState.setValue(StringUtils.hexStringToBytes("34080000"));
                door364.Orientation.setValue(StringUtils.hexStringToBytes(staticWorldObject.quat));
                //door364.Orientation.setValue(StringUtils.hexStringToBytes("000000000000803F0000000000000000")); // ToDo: Replace it with staticWorldObject.quat when it is okay

                // ToDo: We make a little Entity "Hack" so that we have a unique id : metrid + fullmxostatic_id is entity
                String entityMxOHackString = "" + staticWorldObject.metrId + "" + staticWorldObject.mxoId;
                UInt64 entityId            = UInt64.Parse(entityMxOHackString);

                packets.sendSpawnStaticObject(Store.currentClient, door364, entityId);

                break;

            case 6601:
            case 6994:
            case 341:
            case 417:
            case 419:

                ObjectAttributes363 door363 = new ObjectAttributes363("DOOR363", typeId, staticWorldObject.mxoId);
                door363.DisableAllAttributes();
                door363.Orientation.enable();
                door363.Position.enable();
                door363.CurrentState.enable();
                // Set Values
                door363.Position.setValue(NumericalUtils.doublesToLtVector3d(staticWorldObject.pos_x, staticWorldObject.pos_y, staticWorldObject.pos_z));
                door363.Orientation.setValue(StringUtils.hexStringToBytes(staticWorldObject.quat));
                //door363.Orientation.setValue(StringUtils.hexStringToBytes("000000000000803F0000000000000000")); // ToDo: Replace it with staticWorldObject.quat when it is okay
                door363.CurrentState.setValue(StringUtils.hexStringToBytes("34080000"));

                // ToDo: We make a little Entity "Hack" so that we have a unique id : metrid + fullmxostatic_id is entity
                String entity363MxOHackString = "" + staticWorldObject.metrId + "" + staticWorldObject.mxoId;
                UInt64 entity363Id            = UInt64.Parse(entity363MxOHackString);

                packets.sendSpawnStaticObject(Store.currentClient, door363, entity363Id);
                break;

            case 592:
                new TeleportHandler().processHardlineExitRequest();
                break;

            default:
                new ServerPackets().sendSystemChatMessage(Store.currentClient, "Unknown Object Interaction with Object Type " + staticWorldObject.type + " and Name " + item.getName(), "MODAL");
                break;
            }
        }
예제 #4
0
 public void addDoubleLtVector3d(double x, double y, double z)
 {
     packet.append(NumericalUtils.doublesToLtVector3d(x, y, z));
 }
예제 #5
0
        public int parseAttributes(ref byte[] buffer, int _offset)
        {
            _offset++;
            byte flag = 0x00;

            flag = BufferHandler.readByte(ref buffer, ref _offset);

            byte[] stateData = new byte[buffer.Length - _offset + 2];
            ArrayUtils.copy(buffer, _offset - 2, stateData, 0, buffer.Length - _offset + 2);
            //Flag Bits{0,0,0,0,Vector3f Position Update,  Yaw Update,Animation Update, AttributesPacked Update?}

            double x = 0;
            double y = 0;
            double z = 0;

            switch (flag)
            {
            case 0x02:
                Action.setValue(BufferHandler.readBytes(ref buffer, ref _offset, Action.getSize()));
                break;


            case 0x04:
                YawInterval.setValue(BufferHandler.readBytes(ref buffer, ref _offset, YawInterval.getSize()));
                break;


            case 0x08:
                x = (double)NumericalUtils.byteArrayToFloat(BufferHandler.readBytes(ref buffer, ref _offset, 4), 1);
                y = (double)NumericalUtils.byteArrayToFloat(BufferHandler.readBytes(ref buffer, ref _offset, 4), 1);
                z = (double)NumericalUtils.byteArrayToFloat(BufferHandler.readBytes(ref buffer, ref _offset, 4), 1);
                Position.setValue(NumericalUtils.doublesToLtVector3d(x, y, z));
                break;

            case 0x0a:
                YawInterval.setValue(BufferHandler.readByte(ref buffer, ref _offset));
                x = (double)NumericalUtils.byteArrayToFloat(BufferHandler.readBytes(ref buffer, ref _offset, 4), 1);
                y = (double)NumericalUtils.byteArrayToFloat(BufferHandler.readBytes(ref buffer, ref _offset, 4), 1);
                z = (double)NumericalUtils.byteArrayToFloat(BufferHandler.readBytes(ref buffer, ref _offset, 4), 1);
                Position.setValue(NumericalUtils.doublesToLtVector3d(x, y, z));
                break;

            case 0x0e:
                // UInt16 unknown + LtVector3f
                UInt16 unknown = NumericalUtils.ByteArrayToUint16(BufferHandler.readBytes(ref buffer, ref _offset, 2), 1);
                x = NumericalUtils.byteArrayToFloat(BufferHandler.readBytes(ref buffer, ref _offset, 4), 1);
                y = NumericalUtils.byteArrayToFloat(BufferHandler.readBytes(ref buffer, ref _offset, 4), 1);
                z = NumericalUtils.byteArrayToFloat(BufferHandler.readBytes(ref buffer, ref _offset, 4), 1);
                Position.setValue(NumericalUtils.doublesToLtVector3d(x, y, z));
                break;

            default:
                // ToDo: we need a proper way to proove if there is a 00 00 04 somewhere (and if set the offset to it)

                // If this doesnt match we need to write this somewhere...
                string message = "RPCMAIN : Unknown Client 03 Request Packet \r\n" +
                                 "Flag: " + flag + "\r\n " +
                                 "Content: \n" +
                                 StringUtils.bytesToString(stateData) + "\r\n";
                Output.WriteClientViewRequestLog(message);

                // ...and we dont want to crash so we just say "offset is full packet"
                _offset = buffer.Length - 1;
                break;
            }

            // TODO: update player attribute packets someday (announce it to my spawners)
            Store.world.sendViewPacketToAllPlayers(stateData, Store.currentClient.playerData.getCharID(), NumericalUtils.ByteArrayToUint16(Store.currentClient.playerInstance.GetGoid(), 1), Store.currentClient.playerData.getEntityId());
            return(_offset);
        }