public void sendElevatorPanel(WorldClient client, StaticWorldObject objectValues) { PacketContent pak = new PacketContent(); pak.addUint16((UInt16)RPCResponseHeaders.SERVER_ELEVATOR_PANEL, 0); pak.addUint16(objectValues.sectorID, 1); pak.addHexBytes("2200"); client.messageQueue.addRpcMessage(pak.returnFinalPacket()); }
public StaticWorldObject getObjectValues(UInt32 objectId) { Output.WriteLine("REQUEST OBJECT WITH ID :" + StringUtils.bytesToString_NS(NumericalUtils.uint32ToByteArray(objectId, 0))); StaticWorldObject worldObject = null; worldObject = WorldObjectsDB.Find(delegate(StaticWorldObject temp) { return(temp.mxoId == objectId); }); if (worldObject == null) { worldObject = new StaticWorldObject(); } return(worldObject); }
public void AddWorldObjectToWorldServer(StaticWorldObject worldObject) { UInt16 typeId = NumericalUtils.ByteArrayToUint16(worldObject.type, 1); switch (typeId) { case 6568: Subway subway = new Subway(worldObject); Subways.Add(subway); WorldSocket.subways.Add(subway); WorldSocket.gameServerEntities.Add(subway); subway.StartCountdown(); break; } }
public void loadWorldObjectsDb(string path) { Output.Write("Loading Static Objects from " + path + " - please wait..."); ArrayList staticWorldObjects = loadCSV(path, ','); StaticWorldObject worldObject = null; int linecount = 1; foreach (string[] data in staticWorldObjects) { if (linecount > 1) { //Output.WriteLine("Show Colums for Line : " + linecount.ToString() + " GOID: " + data[1].ToString() + " Name " + data[0].ToString()); worldObject = new StaticWorldObject(); worldObject.metrId = Convert.ToUInt16(data[0]); worldObject.sectorID = Convert.ToUInt16(data[1]); worldObject.mxoId = NumericalUtils.ByteArrayToUint32(StringUtils.hexStringToBytes(data[2]), 1); worldObject.staticId = NumericalUtils.ByteArrayToUint32(StringUtils.hexStringToBytes(data[3]), 1); worldObject.type = StringUtils.hexStringToBytes(data[4].Substring(0, 4)); worldObject.exterior = Convert.ToBoolean(data[5]); worldObject.pos_x = double.Parse(data[6], CultureInfo.InvariantCulture); worldObject.pos_y = double.Parse(data[7], CultureInfo.InvariantCulture); worldObject.pos_z = double.Parse(data[8], CultureInfo.InvariantCulture); worldObject.rot = double.Parse(data[9], CultureInfo.InvariantCulture); worldObject.quat = data[10]; if (data[3] == "01003039") { Output.writeToLogForConsole("[DEMO DOOR] 01003039, X: " + worldObject.pos_x + ", Y: " + worldObject.pos_y + ", Z: " + worldObject.pos_z + ", ROT: " + worldObject.rot + ", TypeId: " + StringUtils.bytesToString_NS(worldObject.type)); } WorldObjectsDB.Add(worldObject); worldObject = null; } linecount++; } }
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; } }
public void processObjectStatic(ref byte[] packet) { byte[] objectID = new byte[4]; byte[] sectorID = new byte[2]; ArrayUtils.copyTo(packet, 0, objectID, 0, 4); ArrayUtils.copyTo(objectID, 2, sectorID, 0, 2); UInt32 numericObjectId = NumericalUtils.ByteArrayToUint32(objectID, 1); // Ok sector Bytes are something like 30 39 (reversed but the result must be 39 03) UInt16 numericSectorId = NumericalUtils.ByteArrayToUint16(sectorID, 1); // strip out object id string id = StringUtils.bytesToString_NS(objectID); // get the type byte[] objectType = new byte[1]; ArrayUtils.copy(packet, 4, objectType, 0, 1); int objectTypeID = packet[4]; DataLoader objectLoader = DataLoader.getInstance(); StaticWorldObject objectValues = objectLoader.getObjectValues(NumericalUtils.ByteArrayToUint32(objectID, 1)); // create a new System message but fill it in the switch block ServerPackets pak = new ServerPackets(); switch (objectTypeID) { // Case 03 is not only a staticWorldObject ... case (int)objectTypesStatic.DOOR: Output.writeToLogForConsole("[OI HELPER] INTERACT WITH DOOR | Object ID :" + id + " Sector ID : " + numericSectorId); // just a test if (objectValues != null && objectValues.type != null) { GameObjectItem item = objectLoader.getGameObjectItemById(NumericalUtils.ByteArrayToUint16(objectValues.type, 1)); //Store.currentClient.messageQueue.addRpcMessage(PacketsUtils.createSystemMessage("[OI HELPER] Door StrType: !" + item.getName() + " with Type ID " + StringUtils.bytesToString_NS(objectValues.type), Store.currentClient)); this.processObjectInteraction(objectValues, item); } break; case (int)objectTypesStatic.HARDLINE_SYNC: pak.sendSystemChatMessage(Store.currentClient, "Hardline Interaction(not done yet)!", "MODAL"); break; case (int)objectTypesStatic.HARDLINE_UPLOAD: Output.writeToLogForConsole("[OBJECT HELPER] Upload Hardline will be used for combat tests"); Store.currentClient.playerData.lastClickedObjectId = numericObjectId; new TestUnitHandler().processTestCombat(ref packet); break; case (int)objectTypesStatic.HARDLINE_LAEXIT: // Exit LA pak.sendSystemChatMessage(Store.currentClient, "Exit to LA Dialog should popup", "MODAL"); new TeleportHandler().processHardlineExitRequest(); break; case (int)objectTypesStatic.HUMAN_NPC: pak.sendSystemChatMessage(Store.currentClient, "Open Vendor Dialog for Object ID" + StringUtils.bytesToString_NS(objectID), "MODAL"); this.processVendorOpen(ref objectID); break; case (int)objectTypesStatic.COLLECTOR: pak.sendSystemChatMessage(Store.currentClient, "Collector Interaction (not done yet)!", "MODAL"); break; case (int)objectTypesStatic.ENVIROMENT: GameObjectItem enviromentItem = objectLoader.getGameObjectItemById(NumericalUtils.ByteArrayToUint16(objectValues.type, 1)); UInt16 enviromentTypeID = NumericalUtils.ByteArrayToUint16(objectValues.type, 1); switch (enviromentTypeID) { case 6952: // ToDo: implement Elevator Panel pak.sendElevatorPanel(Store.currentClient, objectValues); break; default: pak.sendSystemChatMessage(Store.currentClient, "Enviroment Type ID " + objectValues.type + " name " + enviromentItem.getName(), "MODAL"); break; } pak.sendSystemChatMessage(Store.currentClient, "Enviroment Type ID " + objectValues.type + " name " + enviromentItem.getName(), "MODAL"); break; default: pak.sendSystemChatMessage(Store.currentClient, "[OI HELPER] Unknown Object Type : " + objectTypeID.ToString() + "| Object ID :" + id, "MODAL"); break; } }
public void processOpenDoor(StaticWorldObject door) { UInt16 typeId = NumericalUtils.ByteArrayToUint16(door.type, 1); byte[] masterViewId = { 0x01, 0x00 }; byte[] seperator = { 0xcd, 0xab }; Store.currentClient.playerData.newViewIdCounter++; // It is just for a test Later we will change this to have a List with Views and Object IDs byte[] disarmDifficultyMaybe = { 0x03, 0x84 }; byte[] endViewID = { 0x00, 0x00 }; byte[] spawnCounter = NumericalUtils.uint16ToByteArrayShort(Store.currentClient.playerData.assignSpawnIdCounter()); Output.WriteLine("[DOOR]POS X : " + door.pos_x.ToString() + " POS Y: " + door.pos_y.ToString() + " POS Z: " + door.pos_z.ToString() + ", TypeId: " + StringUtils.bytesToString_NS(door.type)); switch (typeId) { case 417: case 419: // ToDo: Packet Format for Elevator // 02 03 01 00 // 08 // a3 01 // 6b 01 f0 3d be // cd ab 03 88 00 00 00 00 ff ff 7f 3f 00 00 00 00 f3 04 35 33 // 22 00 00 00 00 40 f4 fb 40 00 00 00 00 00 90 75 40 00 00 00 00 00 40 af 40 ff ff ff ff 19 00 00 // 11 00 01 00 04 61 97 e1 47 f0 bf 2d 44 de 30 35 45 00 00 PacketContent content = new PacketContent(); content.addByteArray(masterViewId); content.addByte(0x08); content.addByteArray(door.type); content.addByteArray(NumericalUtils.uint32ToByteArray(door.mxoId, 1)); content.addByteArray(spawnCounter); // Spawn Object Counter content.addByteArray(seperator); content.addByte(0x03); // Number of Attributes to parse (3) content.addByte(0x88); // GROUP 1 - more groups ON, Attribute 4 (305,Orientation,LTQuaternion,16) SET (10001000) content.addByteArray(StringUtils.hexStringToBytes(door.quat)); // ToDo: replace it later with the real LTQuaternion content.addByte(0x22); // GROUP 2 - more groups OFF, Attribute 2,6 SET (00100010) content.addDoubleLtVector3d(door.pos_x, door.pos_y, door.pos_z); content.addByteArray(new byte[] { 0xff, 0xff, 0xff, 0xff }); content.addByteArray(NumericalUtils.uint16ToByteArray(Store.currentClient.playerData.newViewIdCounter, 1)); content.addByteArray(endViewID); content.addByte(0x00); Store.currentClient.messageQueue.addObjectMessage(content.returnFinalPacket(), false); break; case 2506: // ToDo: Packet Format for Elevator break; default: PacketContent contentDefault = new PacketContent(); contentDefault.addByteArray(masterViewId); contentDefault.addByte(0x08); contentDefault.addByteArray(door.type); contentDefault.addByteArray(NumericalUtils.uint32ToByteArray(door.mxoId, 1)); contentDefault.addByteArray(spawnCounter); // Spawn Object Counter contentDefault.addByteArray(seperator); contentDefault.addByteArray(disarmDifficultyMaybe); contentDefault.addByte(0x00); // isZionAligned? contentDefault.addByteArray(StringUtils.hexStringToBytes("0000000000803F000000000000000041")); // ToDo: replace it later with the real values from the object contentDefault.addDoubleLtVector3d(door.pos_x, door.pos_y, door.pos_z); contentDefault.addByteArray(StringUtils.hexStringToBytes("34080000")); contentDefault.addByteArray(NumericalUtils.uint16ToByteArray(Store.currentClient.playerData.newViewIdCounter, 1)); contentDefault.addByteArray(endViewID); contentDefault.addByte(0x00); Store.currentClient.messageQueue.addObjectMessage(contentDefault.returnFinalPacket(), false); break; } }