public void processAbility(ref byte[] packet) { byte[] ability = { packet[0], packet[1] }; byte[] targetView = { packet[2], packet[3] }; UInt16 AbilityID = NumericalUtils.ByteArrayToUint16(ability, 1); UInt16 viewId = 0; currentTargetViewId = NumericalUtils.ByteArrayToUint16(targetView, 1); // load the ability name from a list to see if we match the right ability DataLoader AbilityLoader = DataLoader.getInstance(); this.currentAbility = AbilityLoader.getAbilityByID(AbilityID); // lets create a message for the client - we will later execute the right AbilityScript for it ServerPackets pak = new ServerPackets(); pak.sendSystemChatMessage(Store.currentClient, "Ability ID is " + AbilityID.ToString() + " and the name is " + currentAbility.getAbilityName() + " and Target ViewId Is " + currentTargetViewId, "BROADCAST"); // ToDo: do something with the entity (or queue a fx hit animation or something lol) this.processAbilityScript(this.currentAbility); }
public void processVendorOpen(ref byte[] objectID) { // ToDo: Dynamic Shop Vendors PacketContent pak = new PacketContent(); Vendor vendor = DataLoader.getInstance().getVendorByGoIDandMetrId(NumericalUtils.ByteArrayToUint32(objectID, 1), 1); if (vendor != null) { // ToDo: send the Packet (and give it the items ?) ServerPackets serverPacket = new ServerPackets(); serverPacket.sendVendorWindow(Store.currentClient, vendor); } //pak.addHexBytes("810D7CADD943000000A07EB1D1400000008000BEA940000000E0E74CA7402000140000140080002000800018008000040080002C008000F4118000540680004C088000BC06800000068000AC058000700D8000740D8000900D8000940D8000980D80009C0D8000240080003C0080001C0080"); //Store.currentClient.messageQueue.addRpcMessage(pak.returnFinalPacket()); }
public void sendEmotePerform(WorldClient client, UInt32 emoteID) { 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; /* * byte sampleEmoteMsg[] = * { * 0x03, 0x02, 0x00, 0x01, 0x28, 0xAA, 0x40, 0x00, 0x25, 0x01, 0x00, 0x00, 0x10, 0xBB, 0xBB, 0xBB, * 0xBB, 0xCC, 0xCC, 0xCC, 0xCC, 0xDD, 0xDD, 0xDD, 0xDD, 0x2A, 0x9F, 0x1E, 0x20, 0x00, 0x00, * };*/ // Example REsponse for /rolldice 02 03 02 00 01 28 01 40 00 25 <ID> 00 00 10 cd a7 65 c7 00 00 be 42 33 ff 72 46 b9 51 32 22 00 00 // Example REsponse for /rolldice 02 03 02 00 01 28 01 40 00 25 5c 00 00 10 cd a7 65 c7 00 00 be 42 33 ff 72 46 b9 51 32 22 00 00 // Example Response for ClapEmote: 02 03 02 00 01 28 06 40 00 25 04 00 00 10 34 49 84 c7 00 00 be 42 27 a4 7f 46 b3 a6 5e 18 00 00 // Python Example self.emotePacket="\x02\x03\x02\x00\x01\x28<emoteNum>\x40\x00\x25<emoteID>\x00\x00\x10<coordX><coordY><coordZ>\x2a\x9f\x1e\x20\x00\x00" // 02 03 02 00 01 28 01 40 00 25 01 00 00 ea 33 47 00 00 be 42 80 55 bd c7 b9 51 32 22 00 00 // ToDo: parse list and get the f*****g id from uint DataLoader objectLoader = DataLoader.getInstance(); byte emoteByte = new byte(); emoteByte = objectLoader.findEmoteByLongId(emoteID); if (emoteByte > 0) { byte[] emotePak = { 0x01, 0x28, 0x01, 0x40, 0x00, 0x25, emoteByte, 0x00, 0x00, 0x10 }; PacketContent pak = new PacketContent(); pak.addUint16(2, 1); pak.addByteArray(emotePak); pak.addFloatLtVector3f(xPos, yPos, zPos); pak.addHexBytes("b9513222"); // We dont know what they are - maybe rotation ? pak.addByte(0x00); //pak.addByteArray(client.playerInstance.Position.getValue()); client.messageQueue.addObjectMessage(pak.returnFinalPacket(), false); client.FlushQueue(); } }
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 processUnmountItem(ref byte[] rpcData) { byte sourceSlot = rpcData[0]; byte destSlot = rpcData[1]; UInt32 clothingItemId = Store.dbManager.WorldDbHandler.GetItemGOIDAtInventorySlot(rpcData[0]); DataLoader dataLoader = DataLoader.getInstance(); ClothingItem item = dataLoader.getItemValues(clothingItemId); // Update Appeareance as we know which appeareance to update (as we unmount item it should be ok to set zeros for the values) string partModel = null; string partColor = null; switch (item.getClothesType()) { case "1950892361": case "FEMALE HAT": case "MALE HAT": partModel = "hat"; break; case "2001027401": case "FEMALE GLASSES": case "MALE GLASSES": partModel = "glasses"; partColor = "glassescolor"; break; case "1750286665": // New Way but lets stay old values there case "FEMALE SHIRT": case "MALE SHIRT": partModel = "shirt"; partColor = "shirtcolor"; break; case "1816609097": case "FEMALE GLOVES": case "MALE GLOVES": partModel = "gloves"; break; case "2001682761": case "FEMALE COAT": case "MALE COAT": partModel = "coat"; partColor = "coatcolor"; break; case "1397768521": case "MALE PANTS": case "FEMALE PANTS": partModel = "pants"; partColor = "pantscolor"; break; case "1733050697": case "FEMALE LEGGINGS": partModel = "leggins"; break; case "2001092937": case "FEMALE SHOES": case "MALE SHOES": partModel = "shoes"; partColor = "shoecolor"; break; } if (partModel != null) { Store.dbManager.WorldDbHandler.updateRsiPartValue(partModel, 0); } if (partColor != null && item.getColorId() > 0) { Store.dbManager.WorldDbHandler.updateRsiPartValue(partColor, 0); } // Move slot UInt16 newSlotId = Store.dbManager.WorldDbHandler.getFirstNewSlot(); Store.dbManager.WorldDbHandler.updateInventorySlot(sourceSlot, newSlotId); // Send move packet ServerPackets pak = new ServerPackets(); pak.sendInventoryItemMove(sourceSlot, newSlotId, Store.currentClient); Store.dbManager.WorldDbHandler.setRsiValues(); int[] current = Store.currentClient.playerData.getRsiValues(); Store.currentClient.playerData.setRsiValues(current); byte[] rsiData = PacketsUtils.getRSIBytes(current); pak.sendAppeareanceUpdate(Store.currentClient, rsiData); }
public void processMountItem(ref byte[] rpcData) { byte sourceSlot = rpcData[0]; byte destSlot = rpcData[1]; UInt32 clothingItemId = Store.dbManager.WorldDbHandler.GetItemGOIDAtInventorySlot(rpcData[0]); DataLoader dataLoader = DataLoader.getInstance(); ClothingItem item = dataLoader.getItemValues(clothingItemId); string partModel = null; string partColor = null; UInt16 toRealSlotId = 0; switch (item.getClothesType()) { case "1950892361": case "FEMALE HAT": case "MALE HAT": toRealSlotId = 0x61; partModel = "hat"; break; case "2001027401": case "FEMALE GLASSES": case "MALE GLASSES": toRealSlotId = 0x62; partModel = "glasses"; partColor = "glassescolor"; break; case "1750286665": // New Way but lets stay old values there case "FEMALE SHIRT": case "MALE SHIRT": toRealSlotId = 0x63; partModel = "shirt"; partColor = "shirtcolor"; break; case "1816609097": case "FEMALE GLOVES": case "MALE GLOVES": toRealSlotId = 0x64; partModel = "gloves"; break; case "2001682761": case "FEMALE COAT": case "MALE COAT": toRealSlotId = 0x65; partModel = "coat"; partColor = "coatcolor"; break; case "1397768521": case "MALE PANTS": case "FEMALE PANTS": toRealSlotId = 0x66; partModel = "pants"; partColor = "pantscolor"; break; case "1733050697": case "FEMALE LEGGINGS": toRealSlotId = 0x67; partModel = "leggins"; break; case "2001092937": case "FEMALE SHOES": case "MALE SHOES": toRealSlotId = 0x68; partModel = "shoes"; partColor = "shoecolor"; break; } if (partModel != null) { Store.dbManager.WorldDbHandler.updateRsiPartValue(partModel, item.getModelId()); } if (partColor != null) { Store.dbManager.WorldDbHandler.updateRsiPartValue(partColor, item.getColorId()); } Store.dbManager.WorldDbHandler.setRsiValues(); int[] current = Store.currentClient.playerData.getRsiValues(); Store.currentClient.playerData.setRsiValues(current); byte[] rsiData = PacketsUtils.getRSIBytes(current); // Move the wear item from the wearing slot to the next new slot (but maybe doesnt work if inventory is full) ServerPackets pak = new ServerPackets(); if (Store.dbManager.WorldDbHandler.isSlotinUseByItem(toRealSlotId)) { UInt16 newSlotId = Store.dbManager.WorldDbHandler.getFirstNewSlot(); Store.dbManager.WorldDbHandler.updateInventorySlot(toRealSlotId, newSlotId); pak.sendInventoryItemMove(toRealSlotId, newSlotId, Store.currentClient); } pak.sendAppeareanceUpdate(Store.currentClient, rsiData); Store.dbManager.WorldDbHandler.updateInventorySlot(sourceSlot, toRealSlotId); pak.sendInventoryItemMove(sourceSlot, toRealSlotId, Store.currentClient); }
public static void Main(string[] args) { var customCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone(); customCulture.NumberFormat.NumberDecimalSeparator = "."; System.Threading.Thread.CurrentThread.CurrentCulture = customCulture; HealthCheck hc = new HealthCheck(); if (hc.doTests()) { Output.WriteLine("\nHealth checks OK. Proceeding.\n"); // Create Store.auth = new AuthSocket(); Store.margin = new MarginSocket(); Store.world = new WorldSocket(); Store.worldThreads = new WorldThreads(); Store.config = new ServerConfig("Config.xml"); Store.config.LoadDbParams(); Store.config.LoadServerParams(); Store.worldConfig = new WorldConfig("WorldConfig.xml"); /* Load Game Data */ DataLoader.getInstance(); /* Initialize DB Stuff */ Store.dbManager = new databases.DatabaseManager(); if (Store.config.dbParams.DbType == "mysql") { Store.dbManager.AuthDbHandler = new databases.MyAuthDBAccess(); Store.dbManager.MarginDbHandler = new databases.MyMarginDBAccess(); Store.dbManager.WorldDbHandler = new databases.MyWorldDbAccess(); } /* Initialize the MPM object */ Store.dbManager.WorldDbHandler.ResetOnlineStatus(); Store.Mpm = new MultiProtocolManager(); /* Initialize the scripting server */ Store.rpcScriptManager = new ScriptManager(); var scrLoader = new ScriptLoader(); scrLoader.LoadScripts(); //<<-- This does /* External console */ if (Store.config.serverParams.AdminConsoleEnabled) { ConsoleSocket adminConsole = new ConsoleSocket(); adminConsole.startServer(); } // Now everything should be loaded - START THE ENGINES!!! Store.auth.startServer(); Store.margin.startServer(); Store.world.startServer(); // Check if execution keeps going after starting Output.WriteLine("Im'running :D"); // Capture Ctrl C key to clean and then end the program Console.CancelKeyPress += delegate { Output.WriteLine("Closing Auth server and threads"); Store.auth.stopServer(); Output.WriteLine("Closing Margin server and threads"); Store.margin.stopServer(); Output.WriteLine("Closing World server and threads"); Store.world.stopServer(); Output.WriteLine("Server exited"); }; } else { Output.WriteLine("\nHealth checks not passed. Aborting launch."); Output.WriteLine("Please check the errors above or press Enter to close the window."); Console.ReadLine(); } }
private void createCharacterRSI(byte[] packet, NetworkStream client) { // Instance the Data Loader DataLoader ItemLoader = DataLoader.getInstance(); isNewCreatedChar = true; string debugHexPacket = StringUtils.bytesToString_NS(packet); // lets read the values // the IDs for the Appeareance is always uint16 goID byte[] bodyTypeIDByte = new byte[4]; byte[] professionByte = new byte[4]; byte[] facialdetailBytes = new byte[4]; byte[] facialdetailColorBytes = new byte[4]; byte[] hairBytes = new byte[4]; byte[] hairColorBytes = new byte[4]; byte[] skintoneBytes = new byte[4]; byte[] tatooBytes = new byte[4]; byte[] headIDBytes = new byte[4]; // Clothing byte[] shirtIDBytes = new byte[4]; byte[] pantsIDBytes = new byte[4]; byte[] outerwearIDBytes = new byte[4]; byte[] hatIDBytes = new byte[4]; byte[] eyewearIDBytes = new byte[4]; byte[] footwearIDBytes = new byte[4]; byte[] glovesIDBytes = new byte[4]; //byte[] legginsIDBytes = new byte[4]; // RSI ArrayUtils.copy(packet, 3, skintoneBytes, 0, 2); // Done! ArrayUtils.copy(packet, 7, bodyTypeIDByte, 0, 2); // Done! ArrayUtils.copy(packet, 15, hairBytes, 0, 2); // Done! ArrayUtils.copy(packet, 19, hairColorBytes, 0, 2); // Done! ArrayUtils.copy(packet, 23, tatooBytes, 0, 2); // Done! ArrayUtils.copy(packet, 27, headIDBytes, 0, 2); ArrayUtils.copy(packet, 31, facialdetailBytes, 0, 2); ArrayUtils.copy(packet, 35, facialdetailColorBytes, 0, 2); ArrayUtils.copy(packet, 67, professionByte, 0, 2); UInt16 body = 0; UInt16 gender = 0; UInt32 bodyTypeId = NumericalUtils.ByteArrayToUint32(bodyTypeIDByte, 1); UInt16 hairId = NumericalUtils.ByteArrayToUint16(hairBytes, 1); UInt16 haircolor = NumericalUtils.ByteArrayToUint16(hairColorBytes, 1); UInt16 tattoo = NumericalUtils.ByteArrayToUint16(tatooBytes, 1); UInt16 facialDetailColor = NumericalUtils.ByteArrayToUint16(facialdetailColorBytes, 1); UInt16 skintone = NumericalUtils.ByteArrayToUint16(skintoneBytes, 1); UInt16 headID = NumericalUtils.ByteArrayToUint16(headIDBytes, 1); // Get Values by "NewRSI" IDs NewRSIItem hairItem = ItemLoader.getNewRSIItemByTypeAndID("HAIR", hairId); NewRSIItem bodyItem = ItemLoader.getNewRSIItemByTypeAndID("BODY", (ushort)bodyTypeId); NewRSIItem headItem = ItemLoader.getNewRSIItemByTypeAndID("HEAD", headID); Store.dbManager.MarginDbHandler.updateRSIValue("body", bodyItem.internalId.ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("sex", bodyItem.gender.ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("face", headItem.internalId.ToString(), newCharID); // ToDo: Store.dbManager.MarginDbHandler.updateRSIValue("hair", hairItem.internalId.ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("haircolor", haircolor.ToString(), newCharID); // ToDo: check if it is correct Store.dbManager.MarginDbHandler.updateRSIValue("tattoo", tattoo.ToString(), newCharID); // ToDo: Store.dbManager.MarginDbHandler.updateRSIValue("facialdetailcolor", facialDetailColor.ToString(), newCharID); // ToDo: Store.dbManager.MarginDbHandler.updateRSIValue("skintone", skintone.ToString(), newCharID); // Clothing Items // ToDo: GLOVES ARE MISSING! ArrayUtils.copy(packet, 43, shirtIDBytes, 0, 2); ArrayUtils.copy(packet, 47, glovesIDBytes, 0, 2); ArrayUtils.copy(packet, 55, pantsIDBytes, 0, 2); ArrayUtils.copy(packet, 51, outerwearIDBytes, 0, 2); ArrayUtils.copy(packet, 34, hatIDBytes, 0, 2); ArrayUtils.copy(packet, 39, eyewearIDBytes, 0, 2); ArrayUtils.copy(packet, 63, footwearIDBytes, 0, 2); ClothingItem shirt = ItemLoader.getItemValues(NumericalUtils.ByteArrayToUint16(shirtIDBytes, 1)); ClothingItem pants = ItemLoader.getItemValues(NumericalUtils.ByteArrayToUint16(pantsIDBytes, 1)); ClothingItem outerwear = ItemLoader.getItemValues(NumericalUtils.ByteArrayToUint16(outerwearIDBytes, 1)); ClothingItem hat = ItemLoader.getItemValues(NumericalUtils.ByteArrayToUint16(hatIDBytes, 1)); ClothingItem eyewear = ItemLoader.getItemValues(NumericalUtils.ByteArrayToUint16(eyewearIDBytes, 1)); ClothingItem footwear = ItemLoader.getItemValues(NumericalUtils.ByteArrayToUint16(footwearIDBytes, 1)); ClothingItem gloves = ItemLoader.getItemValues(NumericalUtils.ByteArrayToUint16(glovesIDBytes, 1)); Store.dbManager.MarginDbHandler.updateRSIValue("hat", hat.getModelId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("shirt", shirt.getModelId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("shirtcolor", shirt.getModelId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("coat", outerwear.getModelId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("coatcolor", outerwear.getModelId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("pants", pants.getModelId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("pantscolor", pants.getModelId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("shoes", pants.getModelId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("shoecolor", pants.getModelId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("glasses", pants.getModelId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("glassescolor", pants.getModelId().ToString(), newCharID); // ToDO: Figre out the ITem Slots for "currentlyWearing" Items and add the ITems correctly to the Inventory // FirstName UInt16 currentOffset = 79; byte[] firstNameLenBytes = new byte[2]; ArrayUtils.copy(packet, currentOffset, firstNameLenBytes, 0, 2); UInt16 firstNameLen = NumericalUtils.ByteArrayToUint16(firstNameLenBytes, 1); currentOffset += 2; byte[] firstNameBytes = new byte[NumericalUtils.ByteArrayToUint16(firstNameLenBytes, 1) - 1]; ArrayUtils.copy(packet, currentOffset, firstNameBytes, 0, firstNameLen - 1); string firstNameString = StringUtils.charBytesToString(firstNameBytes); currentOffset += firstNameLen; // LastName byte[] lastNameLenBytes = new byte[2]; ArrayUtils.copy(packet, currentOffset, lastNameLenBytes, 0, 2); UInt16 lastNameLen = NumericalUtils.ByteArrayToUint16(lastNameLenBytes, 1); currentOffset += 2; byte[] lastNameBytes = new byte[NumericalUtils.ByteArrayToUint16(lastNameLenBytes, 1) - 1]; ArrayUtils.copy(packet, currentOffset, lastNameBytes, 0, lastNameLen - 1); string lastNameString = StringUtils.charBytesToString(lastNameBytes); currentOffset += lastNameLen; // Description byte[] descriptionLenBytes = new byte[2]; ArrayUtils.copy(packet, currentOffset, descriptionLenBytes, 0, 2); UInt16 descriptionLen = NumericalUtils.ByteArrayToUint16(descriptionLenBytes, 1); currentOffset += 2; byte[] descriptionBytes = new byte[NumericalUtils.ByteArrayToUint16(descriptionLenBytes, 1) - 1]; ArrayUtils.copy(packet, currentOffset, descriptionBytes, 0, descriptionLen - 1); string descriptionString = StringUtils.charBytesToString(descriptionBytes); currentOffset += lastNameLen; // Update Characters values Store.dbManager.MarginDbHandler.updateCharacter(firstNameString, lastNameString, descriptionString, newCharID); // Add the Basic Abilitys... Store.dbManager.MarginDbHandler.addAbility(-2147481600, 0, newCharID, 1, 1); Store.dbManager.MarginDbHandler.addAbility(-2147367936, 1, newCharID, 1, 1); Store.dbManager.MarginDbHandler.addAbility(-2147294208, 2, newCharID, 0, 1); Store.dbManager.MarginDbHandler.addAbility(-2147281920, 3, newCharID, 0, 0); Store.dbManager.MarginDbHandler.addAbility(-2147280896, 4, newCharID, 0, 0); Store.dbManager.MarginDbHandler.addAbility(-2147437568, 5, newCharID, 1, 1); Store.dbManager.MarginDbHandler.addAbility(-2147425280, 6, newCharID, 0, 0); Store.dbManager.MarginDbHandler.addAbility(-2147404800, 7, newCharID, 0, 0); Store.dbManager.MarginDbHandler.addAbility(-2147445760, 8, newCharID, 0, 0); Store.dbManager.MarginDbHandler.addAbility(-2146493440, 9, newCharID, 0, 0); Store.dbManager.MarginDbHandler.addAbility(-2146453504, 10, newCharID, 1, 0); // we have all created - lets load the charData loadCharacter(packet, client, this.newCharID); }
private void createCharacterRSI(byte[] packet, NetworkStream client) { // Instance the Data Loader DataLoader itemLoader = DataLoader.getInstance(); isNewCreatedChar = true; string debugHexPacket = StringUtils.bytesToString_NS(packet); // ToDo: Replace all with Packet Reader Instance PacketReader reader = new PacketReader(packet); reader.incrementOffsetByValue(3); UInt16 body = 0; UInt16 gender = 0; UInt16 skintone = reader.readUInt16(1); reader.setOffsetOverrideValue(7); UInt16 bodyTypeId = reader.readUInt16(1); reader.setOffsetOverrideValue(15); UInt16 hairId = reader.readUInt16(1); reader.setOffsetOverrideValue(19); UInt16 haircolor = reader.readUInt16(1); reader.setOffsetOverrideValue(23); UInt16 tattoo = reader.readUInt16(1); reader.setOffsetOverrideValue(27); UInt16 headId = reader.readUInt16(1); reader.setOffsetOverrideValue(31); UInt16 facialDetail = reader.readUInt16(1); reader.setOffsetOverrideValue(35); // ToDo: it has a bug - figure out correct position UInt16 facialDetailColor = reader.readUInt16(1); // ToDo: Remove this when facialDetailColor is parsed properly facialDetailColor = 0; reader.setOffsetOverrideValue(67); UInt16 profession = reader.readUInt16(1); // lets read the values // the IDs for the Appeareance is always uint16 goID // Extra Hint: there are no leggins in Char Creation Process reader.setOffsetOverrideValue(35); UInt16 hatId = reader.readUInt16(1); reader.setOffsetOverrideValue(39); UInt16 eyewearId = reader.readUInt16(1); reader.setOffsetOverrideValue(43); UInt16 shirtId = reader.readUInt16(1); reader.setOffsetOverrideValue(47); UInt16 glovesId = reader.readUInt16(1); reader.setOffsetOverrideValue(51); UInt16 outerwearId = reader.readUInt16(1); reader.setOffsetOverrideValue(55); UInt16 pantsId = reader.readUInt16(1); reader.setOffsetOverrideValue(63); UInt16 footwearId = reader.readUInt16(1); // Get Values by "NewRSI" IDs NewRSIItem hairItem = itemLoader.getNewRSIItemByTypeAndID("HAIR", hairId); NewRSIItem bodyItem = itemLoader.getNewRSIItemByTypeAndID("BODY", (ushort)bodyTypeId); NewRSIItem headItem = itemLoader.getNewRSIItemByTypeAndID("HEAD", headId); Store.dbManager.MarginDbHandler.updateRSIValue("body", bodyItem.internalId.ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("sex", bodyItem.gender.ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("face", headItem.internalId.ToString(), newCharID); // ToDo: Store.dbManager.MarginDbHandler.updateRSIValue("hair", hairItem.internalId.ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("haircolor", haircolor.ToString(), newCharID); // ToDo: check if it is correct Store.dbManager.MarginDbHandler.updateRSIValue("tattoo", tattoo.ToString(), newCharID); // ToDo: Store.dbManager.MarginDbHandler.updateRSIValue("facialdetail", facialDetail.ToString(), newCharID); // ToDo: Store.dbManager.MarginDbHandler.updateRSIValue("facialdetailcolor", facialDetailColor.ToString(), newCharID); // ToDo: Store.dbManager.MarginDbHandler.updateRSIValue("skintone", skintone.ToString(), newCharID); // Clothing Items ClothingItem shirt = itemLoader.getItemValues(shirtId); ClothingItem pants = itemLoader.getItemValues(pantsId); ClothingItem outerwear = itemLoader.getItemValues(outerwearId); ClothingItem hat = itemLoader.getItemValues(hatId); ClothingItem eyewear = itemLoader.getItemValues(eyewearId); ClothingItem footwear = itemLoader.getItemValues(footwearId); ClothingItem gloves = itemLoader.getItemValues(glovesId); Store.dbManager.MarginDbHandler.updateRSIValue("hat", hat.getModelId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("shirt", shirt.getModelId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("shirtcolor", shirt.getColorId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("coat", outerwear.getModelId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("coatcolor", outerwear.getColorId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("pants", pants.getModelId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("pantscolor", pants.getColorId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("shoes", footwear.getModelId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("shoecolor", footwear.getColorId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("glasses", eyewear.getModelId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("glassescolor", eyewear.getColorId().ToString(), newCharID); Store.dbManager.MarginDbHandler.updateRSIValue("gloves", gloves.getModelId().ToString(), newCharID); Store.dbManager.MarginDbHandler.AddItemToSlot(hatId, 0x61, newCharID); Store.dbManager.MarginDbHandler.AddItemToSlot(eyewearId, 0x62, newCharID); Store.dbManager.MarginDbHandler.AddItemToSlot(shirtId, 0x63, newCharID); Store.dbManager.MarginDbHandler.AddItemToSlot(glovesId, 0x64, newCharID); Store.dbManager.MarginDbHandler.AddItemToSlot(outerwearId, 0x65, newCharID); Store.dbManager.MarginDbHandler.AddItemToSlot(pantsId, 0x66, newCharID); Store.dbManager.MarginDbHandler.AddItemToSlot(footwearId, 0x68, newCharID); // FirstName UInt16 currentOffset = 79; byte[] firstNameLenBytes = new byte[2]; ArrayUtils.copy(packet, currentOffset, firstNameLenBytes, 0, 2); UInt16 firstNameLen = NumericalUtils.ByteArrayToUint16(firstNameLenBytes, 1); currentOffset += 2; byte[] firstNameBytes = new byte[NumericalUtils.ByteArrayToUint16(firstNameLenBytes, 1) - 1]; ArrayUtils.copy(packet, currentOffset, firstNameBytes, 0, firstNameLen - 1); string firstNameString = StringUtils.charBytesToString(firstNameBytes); currentOffset += firstNameLen; // LastName byte[] lastNameLenBytes = new byte[2]; ArrayUtils.copy(packet, currentOffset, lastNameLenBytes, 0, 2); UInt16 lastNameLen = NumericalUtils.ByteArrayToUint16(lastNameLenBytes, 1); currentOffset += 2; byte[] lastNameBytes = new byte[NumericalUtils.ByteArrayToUint16(lastNameLenBytes, 1) - 1]; ArrayUtils.copy(packet, currentOffset, lastNameBytes, 0, lastNameLen - 1); string lastNameString = StringUtils.charBytesToString(lastNameBytes); currentOffset += lastNameLen; // Description byte[] descriptionLenBytes = new byte[2]; ArrayUtils.copy(packet, currentOffset, descriptionLenBytes, 0, 2); UInt16 descriptionLen = NumericalUtils.ByteArrayToUint16(descriptionLenBytes, 1); currentOffset += 2; byte[] descriptionBytes = new byte[NumericalUtils.ByteArrayToUint16(descriptionLenBytes, 1) - 1]; ArrayUtils.copy(packet, currentOffset, descriptionBytes, 0, descriptionLen - 1); string descriptionString = StringUtils.charBytesToString(descriptionBytes); currentOffset += lastNameLen; // Update Characters values Store.dbManager.MarginDbHandler.updateCharacter(firstNameString, lastNameString, descriptionString, newCharID); // Add the Basic Abilitys... addStartAbilitys(newCharID); // we have all created - lets load the charData loadCharacter(packet, client, this.newCharID); }