public static hexStringToBytes ( string hexString ) : byte[] | ||
hexString | string | |
return | byte[] |
public void sendMarketPlaceList(WorldClient client) { // ToDo: make it dynamic with database later (but the "handler" should give the items as arguments for this method // List Marketplace Items byte[] headerSeperator = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; // Should foreach this later on "Real Server" DynamicArray listItems = new DynamicArray(); listItems.append(StringUtils.hexStringToBytes("8703000000000034bdcf1200401f00000310db6a4a")); // Foot Wear listItems.append(0x00); // Seperate each item listItems.append(StringUtils.hexStringToBytes("2e00000003a04a000bd012000000FFFF01aedc6a4a")); // Google listItems.append(0x00); // Seperate each item listItems.append(StringUtils.hexStringToBytes("721a000003a04a000bd012000000FFFF01aedc6a4a")); // Item Data listItems.append(0x00); // Seperate each item listItems.append(StringUtils.hexStringToBytes("2e00000003a04a000bd01200000000FF01aedc6a4a")); // Item Data listItems.append(0x00); // Seperate each item // get data size byte[] itemSize = NumericalUtils.uint16ToByteArray((UInt16)listItems.getBytes().Length, 1); PacketContent pak = new PacketContent(); pak.addUint16((UInt16)RPCResponseHeaders.SERVER_LOAD_MARKERPLACE, 0); pak.addUintShort(9); // list offset pak.addByteArray(headerSeperator); pak.addUint16((UInt16)listItems.getBytes().Length, 1); pak.addByteArray(listItems.getBytes()); client.messageQueue.addRpcMessage(pak.returnFinalPacket()); }
public static byte[] createTeleportPacket(int x, int y, int z) { // Adjust coords between human view and mxo format x = x * 100; y = y * 100; z = z * 100; // End adjust byte[] xHex = NumericalUtils.floatToByteArray(x + 0.0f, 1); byte[] yHex = NumericalUtils.floatToByteArray(y + 0.0f, 1); byte[] zHex = NumericalUtils.floatToByteArray(z + 0.0f, 1); byte[] header = StringUtils.hexStringToBytes("0200011c11f7025c00030000"); byte[] tail = StringUtils.hexStringToBytes("0000"); DynamicArray din = new DynamicArray(); din.append(header); din.append(xHex); din.append(yHex); din.append(zHex); din.append(tail); return(din.getBytes()); }
public void testHyperJumpPaket() { // TEST PAK // FULL PAK : 829AF325490302000308F3FA8446BB2E0D463E2251C633F98328FF016401000000000000000000000008416E646572736F6E0654686F6D6173FF0480731AE98280600400028E000000010000000000008F010002002A0302FF280A3200F0204604008E168428000000605085D64000000000007EA3400000008025DAC9C000FF0000000000F7000000EB0000000000280AFF00315E00000000000000000000000000000000FF000000000000000000000000803F110000004BB10000710200003F0000000122000000000000000500010004F3FA8446BB2E0D463E2251C60000 byte[] hyperJumpTestPak = StringUtils.hexStringToBytes("02000308F3FA8446BB2E0D463E2251C633F98328FF016401000000000000000000000008416E646572736F6E0654686F6D6173FF0480731AE98280600400028E000000010000000000008F010002002A0302FF280A3200F0204604008E168428000000605085D64000000000007EA3400000008025DAC9C000FF0000000000F7000000EB0000000000280AFF00315E00000000000000000000000000000000FF000000000000000000000000803F110000004BB10000710200003F0000000122000000000000000500010004F3FA8446BB2E0D463E2251C60000"); Store.currentClient.messageQueue.addObjectMessage(hyperJumpTestPak, true); }
private void sendMarginData(string data, NetworkStream client) { byte[] response = StringUtils.hexStringToBytes(data); byte[] encryptedResponse = marginEncr.encrypt(response); sendTCPVariableLenPacket(encryptedResponse, client); System.Threading.Thread.Sleep(50); }
public void testCloseCombat(ref byte[] packet) { byte[] targetViewWithSpawnId = new byte[4]; ArrayUtils.copy(packet, 0, targetViewWithSpawnId, 0, 4); string hexString = StringUtils.bytesToString_NS(targetViewWithSpawnId); string hexStringPak = StringUtils.bytesToString_NS(packet); Store.currentClient.messageQueue.addObjectMessage(StringUtils.hexStringToBytes("020003010C00808400808080800100001000"), false); // Make me combat mode "on" // The 55 View Packet PacketContent ilCombatHandler = new PacketContent(); ilCombatHandler.addHexBytes("01000C370036CDAB0205"); ilCombatHandler.addByteArray(Store.currentClient.playerInstance.Position.getValue()); ilCombatHandler.addHexBytes("cdec4023"); // Time starts i think ilCombatHandler.addHexBytes("fd0000"); // view ID fd00 Store.currentClient.messageQueue.addObjectMessage(ilCombatHandler.returnFinalPacket(), false); Store.currentClient.flushQueue(); // The other 03 Packet for combat PacketContent unknownCreatePak = new PacketContent(); unknownCreatePak.addByteArray(StringUtils.hexStringToBytes("010002A700")); unknownCreatePak.addByteArray(StringUtils.hexStringToBytes("FD00")); // ViewID from Combat Object unknownCreatePak.addByteArray(StringUtils.hexStringToBytes("01")); unknownCreatePak.addByteArray(Store.currentClient.playerInstance.Position.getValue()); unknownCreatePak.addByteArray(StringUtils.hexStringToBytes("0100000003000000")); unknownCreatePak.addByteArray(targetViewWithSpawnId); unknownCreatePak.addUint16(2, 1); unknownCreatePak.addUint16(Store.currentClient.playerData.selfSpawnIdCounter, 1); unknownCreatePak.addByteArray(StringUtils.hexStringToBytes("01010207030000200BF5C2000020C19420B9C300000000000020C100000000070001001201000007037608E00603145200008B0B0024145200008B0B0024882300008B0B00240000000000000000000000000000000064000000640000000010001010000000020000001000000002000000000000000000000000")); Store.currentClient.messageQueue.addObjectMessage(unknownCreatePak.returnFinalPacket(), false); Store.currentClient.flushQueue(); }
public void processUpdateExp() { Random rand = new Random(); UInt32 expval = (UInt32)rand.Next(1000, 200000); ArrayList content = new ArrayList(); // ToDo : Save new EXP Value in the Database and update mpm exp // ToDo2 : Check if exp events are running to multiple the EXP // The Animation DynamicArray expanim = new DynamicArray(); expanim.append(0x80); expanim.append(0xe6); expanim.append(NumericalUtils.uint32ToByteArray(expval, 1)); expanim.append(0x01); // Gain Type expanim.append(StringUtils.hexStringToBytes("000000")); Store.currentClient.messageQueue.addRpcMessage(expanim.getBytes()); // The BAR DynamicArray expbar = new DynamicArray(); expbar.append(0x80); expbar.append(0xe5); expbar.append(NumericalUtils.uint32ToByteArray(expval, 1)); expbar.append(0x01); // Gain Type expbar.append(StringUtils.hexStringToBytes("000000")); Store.currentClient.messageQueue.addRpcMessage(expbar.getBytes()); }
private byte[] loadBackgroundInfo(int charID) { Hashtable charInfo = Store.dbManager.MarginDbHandler.getCharInfo(charID); // in margin packet firstname,lastname are everytime 32 bytes and background 1024 - so we must pad it string firstname = (string)charInfo["firstname"].ToString().PadRight(32, '\x00'); string lastname = (string)charInfo["lastname"].ToString().PadRight(32, '\x00'); string background = (string)charInfo["background"].ToString().PadRight(1024, '\x00'); string district = (string)charInfo["district"]; /* * string repMero = StringUtils.bytesToString_NS(NumericalUtils.uint16ToByteArray((UInt16)charInfo["repMero"], 1)); * string repMachine = StringUtils.bytesToString_NS(NumericalUtils.uint16ToByteArray((UInt16)charInfo["repMachine"], 1)); * string repNiobe = StringUtils.bytesToString_NS(NumericalUtils.uint16ToByteArray((UInt16)charInfo["repNiobe"], 1)); * string repGM = StringUtils.bytesToString_NS(NumericalUtils.uint16ToByteArray((UInt16)charInfo["repGM"], 1)); * string repZion = StringUtils.bytesToString_NS(NumericalUtils.uint16ToByteArray((UInt16)charInfo["repZion"], 1)); */ // Set the default value string worldFlag = "00"; // 01 = onWorld , 00 = LA . In World you have to take care to not spawn the Character in LA State if (district != "la") { worldFlag = "01"; } byte[] firstNameBytes = StringUtils.stringToBytes(firstname); byte[] lastNameBytes = StringUtils.stringToBytes(lastname); byte[] backgroundBytes = StringUtils.stringToBytes(background); string firstPart; if (isNewCreatedChar == false) { firstPart = "01000000640000007B0000006500000000000000000000006C000000000000002B010000"; } else { firstPart = ""; } string exp = "E7CBC012"; string cash = "FCBE4BEE"; string timestamp = "875D714A"; string repBytes = "ecfa" + "ecfb" + "ecfc" + "ecfd" + "ecfe" + "ecff"; // string repBytes = repMero + repMachine + repNiobe + repGM + repZion; string lastPart = exp + cash + "0105000000" + timestamp + repBytes + "000003" + worldFlag + "0301310000b402320000b403380000b403510000000400520000000b00540000000100"; string fullPacket = firstPart + StringUtils.bytesToString_NS(firstNameBytes) + StringUtils.bytesToString_NS(lastNameBytes) + StringUtils.bytesToString_NS(backgroundBytes) + lastPart; if (isNewCreatedChar == true) { Output.WriteLine("Load Background Reply for Created Char:\n" + fullPacket); } byte[] dataPak = StringUtils.hexStringToBytes(fullPacket); return(dataPak); }
public void processTestCombat(ref byte[] packet) { // Description: // 0xbc Header should set a bonus new AnimationHelper().processPlayFX((UInt32)FXList.FX_CHARACTER_STUN_CAST); byte[] tactic = StringUtils.hexStringToBytes("81682D001D00030000007200000050004D0000000000003DB9000000000E00416674657257686F72754E656F000A00436F72727570746564001680BC1100D9030077030000890300000000010000A040"); Store.currentClient.messageQueue.addRpcMessage(tactic); }
public void processMarketTest(ref byte[] packet) { byte[] marketCat = new byte[4]; ArrayUtils.copy(packet, 0, marketCat, 0, 4); Console.WriteLine("Open Market Place for Category : " + StringUtils.charBytesToString(marketCat)); byte[] response = { 0x0b, 0x81, 0x25, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; byte[] notEmptyResponse = StringUtils.hexStringToBytes("812a090000000000001800f09a00000000040086d1120080841e00a086010030086e4a"); // Should be the viewData when the marketplace get opened Store.currentClient.messageQueue.addRpcMessage(notEmptyResponse); }
private byte[] loadBackgroundInfo(int charID) { MarginCharacter marginCharacter = Store.dbManager.MarginDbHandler.getCharInfo(charID); PacketContent pak = new PacketContent(); if (!isNewCreatedChar) { pak.addByteArray(StringUtils.hexStringToBytes("01000000640000007B0000006500000000000000000000006C000000000000002B010000")); } pak.addStringWithFixedSized(marginCharacter.firstname, 32); pak.addStringWithFixedSized(marginCharacter.lastname, 32); pak.addStringWithFixedSized(marginCharacter.background, 1024); // ToDo: Analyse it and (Rep zion => 82, Rep Machine 2, RepMero 81 //pak.addHexBytes("000000000000000000178604E40008AF2F0175020000A39F714A81FF81FF81FF670067006700000003000301310000B402320000B403380000B4044E0000000200510000001600520000001900540000001300"); pak.addUint32(marginCharacter.exp, 1); pak.addUint32(marginCharacter.cash, 1); pak.addUintShort(0x01); // Flag - always 1 pak.addUint32(200, 1); // CQ Points pak.addByteArray(TimeUtils.getCurrentTime()); //pak.addByteArray(StringUtils.hexStringToBytes("875D714A")); // Last Changed Timestamp - current its static - needs to be dynamic // Rputation Bytes (int16[7]) pak.addInt16(-116, 1); pak.addInt16(-117, 1); pak.addInt16(-20, 1); pak.addInt16(-59, 1); pak.addInt16(-58, 1); pak.addInt16(-57, 1); pak.addInt16(2, 1); pak.addByte(0x03); // 01 = onWorld , 00 = LA . In World you have to take care to not spawn the Character in LA State if (marginCharacter.districtId != 0) { pak.addByte(0x01); } else { pak.addByte(0x00); } pak.addHexBytes("0301310000b402320000b403380000b403510000000400520000000b00540000000100"); // The Last Part #if DEBUG if (isNewCreatedChar == true) { Output.WriteLine("Load Background Reply for Created Char:\n" + pak.returnFinalPacket()); } #endif return(pak.returnFinalPacket()); }
private void loadNPCSignPosts(string path) { ArrayList csvData = loadCSV(path, ';'); int linecount = 1; foreach (string[] data in csvData) { if (linecount > 0) { NPC_Singpost singpost = new NPC_Singpost(); singpost.mxoStaticId = UInt32.Parse(data[0]); singpost.districtId = ushort.Parse(data[1]); singpost.xPos = float.Parse(data[3]); singpost.yPos = float.Parse(data[4]); singpost.zPos = float.Parse(data[5]); singpost.SingpostNameString = data[6]; singpost.AnimationID0 = StringUtils.hexStringToBytes(data[7]); singpost.SingpostReqReputation = ushort.Parse(data[8]); singpost.DescriptionRez_ID = StringUtils.hexStringToBytes(data[9]); if (data.ElementAtOrDefault(10) != null) { singpost.wQuad = float.Parse(data[10]); } if (data.ElementAtOrDefault(11) != null) { if (data[11].Length > 0) { singpost.xQuad = float.Parse(data[11]); } } if (data.ElementAtOrDefault(12) != null) { if (data[12].Length > 0) { singpost.yQuad = float.Parse(data[12]); } } if (data.ElementAtOrDefault(13) != null) { if (data[13].Length > 0) { singpost.zQuad = float.Parse(data[13]); } } Signposts.Add(singpost); } linecount++; } }
public static byte[] createVendorPacket(int id, WorldClient client) { //ToDo: Near check as it should contain the size if i am right ArrayList content = new ArrayList(); content.Add(StringUtils.hexStringToBytes("4a810d7cadd94300000000a0b7f6c000000000003c9440000000000051c8c020000a0000140080002000800018008000040080002c008000f41180009806800090078000c4068000640680")); byte[] packet = createRpcPacket(content, false, client); return(packet); }
// ToDo: Move it to player Packets and make a ?moa command for it public void processChangeMoaRSI(byte[] rsi) { DynamicArray din = new DynamicArray(); din.append(0x03); din.append(0x02); din.append(0x00); din.append(StringUtils.hexStringToBytes("028100808080b052c7de12ab04")); din.append(rsi); din.append(0x41); din.append(0x00); }
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); }
public void processObjectDynamic(ref byte[] packet) { PacketReader reader = new PacketReader(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]; // create a new System message but fill it in the switch block ServerPackets pak = new ServerPackets(); #if DEBUG pak.sendSystemChatMessage(Store.currentClient, "Object Type ID IS " + objectTypeID.ToString() + " Dynamic Object RPC : " + StringUtils.bytesToString_NS(packet), "BROADCAST"); #endif switch (objectTypeID) { case (int)objectTypesDynamic.LOOT: UInt32[] theTestArrayLoots = new UInt32[2]; theTestArrayLoots[0] = NumericalUtils.ByteArrayToUint32(StringUtils.hexStringToBytes("8e220000"), 1); pak.SendLootWindow(5000, Store.currentClient, theTestArrayLoots); break; default: pak.sendSystemChatMessage(Store.currentClient, "[OI HELPER] Unknown Object Type : " + objectTypeID.ToString() + "| Object ID :" + id, "MODAL"); break; } }
public void sendPlayerAttributes(WorldClient client) { // ToDo: Load dynamic if we know what to load //client.messageQueue.addRpcMessage(StringUtils.hexStringToBytes("80bc15002f0000f70300000802000000000000000000")); //client.messageQueue.addRpcMessage(StringUtils.hexStringToBytes("80bc15002f0000f70300000802000000000000000000")); //client.messageQueue.addRpcMessage(StringUtils.hexStringToBytes("80bc1500300000f70300000702ecffffff0000000000")); //client.messageQueue.addRpcMessage(StringUtils.hexStringToBytes("80bc1500310000f70300005004000000000000000000")); //client.messageQueue.addRpcMessage(StringUtils.hexStringToBytes("80bc1500320000f7030000f403000000000000000000")); //client.messageQueue.addRpcMessage(StringUtils.hexStringToBytes("80bc1500330000f70300005104f6ffffff0000000000")); //client.messageQueue.addRpcMessage(StringUtils.hexStringToBytes("80bc56002a0000b3a900000904090000000100000000")); //client.messageQueue.addRpcMessage(StringUtils.hexStringToBytes("80b23a0400000802")); //client.messageQueue.addRpcMessage(StringUtils.hexStringToBytes("80b2110011000802")); //client.messageQueue.addRpcMessage(StringUtils.hexStringToBytes("81A500000700052300687474703A2F2F6D786F656D752E696E666F2F666F72756D2F696E6465782E70687000")); // Has forum url - but is not flash traffic - or ? client.messageQueue.addRpcMessage(StringUtils.hexStringToBytes("80bc55005100000b0000003702330000000000000000")); // this adds super jump points dude //client.messageQueue.addRpcMessage(StringUtils.hexStringToBytes("2E070000000000000000002400000000000000000000000000000000000000000000000011005768617427732075702062726F736B6900")); createFlashTraffic(client, "http://mxo.hardlinedreams.com"); }
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 sendSystemChatMessage(WorldClient client, string message, string type) { byte typeByte; switch (type) { case "SYSTEM": typeByte = 0x07; break; case "MODAL": typeByte = 0x17; break; case "FRAMEMODAL": typeByte = 0xd7; break; case "BROADCAST": typeByte = 0xc7; break; default: typeByte = 0x07; break; } UInt16 messageSize = (UInt16)(message.Length + 1); byte[] hexContents = StringUtils.hexStringToBytes("00000000000000000024000000000000000000000000000000000000000000000000"); PacketContent pak = new PacketContent(); pak.addByte((byte)RPCResponseHeaders.SERVER_CHAT_MESSAGE_RESPONSE); pak.addByte(typeByte); pak.addByteArray(hexContents); pak.addSizedTerminatedString(message); client.messageQueue.addRpcMessage(pak.returnFinalPacket()); client.FlushQueue(); }
public static byte[] createSystemMessage(string message, WorldClient client) { byte[] messageBytes = StringUtils.stringToBytes(message + "\x00"); DynamicArray din = new DynamicArray(); UInt16 messageSize = (UInt16)(message.Length + 1); byte[] messageSizeHex = NumericalUtils.uint16ToByteArray(messageSize, 1); byte[] hexContents = StringUtils.hexStringToBytes("0700000000000000000024000000000000000000000000000000000000000000000000"); din.append((byte)RPCResponseHeaders.SERVER_CHAT_MESSAGE_RESPONSE); din.append(hexContents); din.append(messageSizeHex); din.append(messageBytes); return(din.getBytes()); }
public void processPlayerSetup() { // REFACTOR: Move to PlayerHandler and PlayerPackets (and location header to Server Packets) ServerPackets packets = new ServerPackets(); //packets.sendWorldCMD(Store.currentClient, Store.currentClient.playerData.getDistrictId(), "bluesky2"); // Test our skies //packets.sendWorldCMD(Store.currentClient, Store.currentClient.playerData.getDistrictId(),"Massive"); packets.sendWorldCMD(Store.currentClient, Store.currentClient.playerData.getDistrictId(), "Massive,WinterSky3"); //packets.sendWorldCMD(Store.currentClient, Store.currentClient.playerData.getDistrictId(), "bluesky2"); packets.sendEXPCurrent(Store.currentClient, (UInt32)Store.currentClient.playerData.getExperience()); packets.sendInfoCurrent(Store.currentClient, (UInt32)Store.currentClient.playerData.getInfo()); /* * long exp = Store.currentClient.playerData.getExperience(); * long cash = Store.currentClient.playerData.getInfo(); * string expStr = "80e1" + StringUtils.bytesToString_NS(NumericalUtils.uint32ToByteArray((UInt32)exp, 1)) + "00000000"; * string cashStr = "80df" + StringUtils.bytesToString_NS(NumericalUtils.uint32ToByteArray((UInt32)cash, 1)) + "00000000"; */ // There are for testing - need to change this later to load from ClientObject / DB UInt16 focus = 24; UInt16 belief = 25; UInt16 vitality = 26; UInt16 perception = 27; UInt16 reason = 28; packets.sendAttribute(Store.currentClient, focus, 0x4e); packets.sendAttribute(Store.currentClient, perception, 0x4f); packets.sendAttribute(Store.currentClient, reason, 0x51); packets.sendAttribute(Store.currentClient, belief, 0x52); packets.sendAttribute(Store.currentClient, vitality, 0x54); /* * string focusRPC = "80ad4e" + StringUtils.bytesToString_NS(NumericalUtils.uint16ToByteArray(focus, 0)) + "000802"; * string beliefRPC = "80ad52" + StringUtils.bytesToString_NS(NumericalUtils.uint16ToByteArray(belief, 0)) + "000802"; * string vitalityRPC = "80ad54" + StringUtils.bytesToString_NS(NumericalUtils.uint16ToByteArray(vitality, 0)) + "000802"; * string perceptionRPC = "80ad4f" + StringUtils.bytesToString_NS(NumericalUtils.uint16ToByteArray(perception, 0)) + "000802"; * string reasonRPC = "80ad51" + StringUtils.bytesToString_NS(NumericalUtils.uint16ToByteArray(reason, 0)) + "000802"; * * * Store.currentClient.messageQueue.addRpcMessage(StringUtils.hexStringToBytes(focusRPC)); // Focus * Store.currentClient.messageQueue.addRpcMessage(StringUtils.hexStringToBytes(beliefRPC)); // Belief * Store.currentClient.messageQueue.addRpcMessage(StringUtils.hexStringToBytes(vitalityRPC)); // Vitality * Store.currentClient.messageQueue.addRpcMessage(StringUtils.hexStringToBytes(perceptionRPC)); // Perception * Store.currentClient.messageQueue.addRpcMessage(StringUtils.hexStringToBytes(reasonRPC)); // Reason */ //Store.currentClient.messageQueue.addRpcMessage(StringUtils.hexStringToBytes("808615A0070000000000000000000000000000000000000000210000000000230000000000")); // Disable later /* * 8167170020001C2200C60111000000000000002900000807006D786F656D750007006D786F656D750002000200000000000000 * Store.currentClient.messageQueue.addRpcMessage(StringUtils.hexStringToBytes("80b2110011000802")); // What is this ? Check it later * * Store.currentClient.messageQueue.addRpcMessage(StringUtils.hexStringToBytes("80bc4503110000020000001100110000000000000000")); * Store.currentClient.messageQueue.addRpcMessage(StringUtils.hexStringToBytes("80bc450002000002000000cc00040000000000000000")); * Store.currentClient.messageQueue.addRpcMessage(StringUtils.hexStringToBytes("80bc45000300000b0000003702330000000000000000")); * Store.currentClient.messageQueue.addRpcMessage(StringUtils.hexStringToBytes("80bc45000400002d0000002304030000000000000000")); * Store.currentClient.messageQueue.addRpcMessage(StringUtils.hexStringToBytes("80bc45000500002d0000002004030000000000000000")); * Store.currentClient.messageQueue.addRpcMessage(StringUtils.hexStringToBytes("80bc45000600002d0000001904010000000000000000")); * Store.currentClient.messageQueue.addRpcMessage(StringUtils.hexStringToBytes("80bc45000700002d0000004204010000000000000000")); * Store.currentClient.messageQueue.addRpcMessage(StringUtils.hexStringToBytes("80bc4500080000340000008302440000000000000000")); * Store.currentClient.messageQueue.addRpcMessage(StringUtils.hexStringToBytes("80bc45000900004c0000001504040000000000000000")); * Store.currentClient.messageQueue.addRpcMessage(StringUtils.hexStringToBytes("80bc45000a00004c0000000604040000000000000000")); * Store.currentClient.messageQueue.addRpcMessage(StringUtils.hexStringToBytes("80bc45000b00004c0000001904020000000000000000")); * Store.currentClient.messageQueue.addRpcMessage(StringUtils.hexStringToBytes("80bc45000c0000530000001504010000000000000000")); * Store.currentClient.messageQueue.addRpcMessage(StringUtils.hexStringToBytes("80bc45000d0000530000001904010000000000000000")); * Store.currentClient.messageQueue.addRpcMessage(StringUtils.hexStringToBytes("80b23a0400000802")); * Store.currentClient.messageQueue.addRpcMessage(StringUtils.hexStringToBytes("80bc45033a0400530000003a04000000000000000000")); * Store.currentClient.messageQueue.addRpcMessage(StringUtils.hexStringToBytes("80bc45000e0000530000000604010000000000000000")); * Store.currentClient.messageQueue.addRpcMessage(StringUtils.hexStringToBytes("80bc45000f00005f0000007c04050000000000000000")); * Store.currentClient.messageQueue.addRpcMessage(StringUtils.hexStringToBytes("80bc45001000005f0000000704050000000000000000")); * Store.currentClient.messageQueue.addRpcMessage(StringUtils.hexStringToBytes("80bc4500110000620000000604010000000000000000")); * Store.currentClient.messageQueue.addRpcMessage(StringUtils.hexStringToBytes("80b2350400000802")); */ // Test icon + bonus EDIT DOESNT WORK IN THIS STATE Store.currentClient.messageQueue.addRpcMessage(StringUtils.hexStringToBytes("80bc1500450000f70300000702ecffffff0000000000")); }
public void parseCommand(string data) { Output.WriteLine("[Chat Command helper] Chat command is: '" + data + "'"); string[] commands = data.Split(' '); string command = commands[0].ToLower(); try{ if (command.Equals("?fix") && commands.Length > 1) { int maxRPC = int.Parse(commands[1]); for (int i = 0; i < maxRPC; i++) { Store.currentClient.playerData.setRPCCounter((UInt16)i); Store.currentClient.messageQueue.addRpcMessage(PacketsUtils.createSystemMessage("Trying to fix! " + i, Store.currentClient)); } } if (command.Equals("?teleport") && commands.Length == 4) { // parse the coord parameters parameters as int Store.currentClient.messageQueue.addObjectMessage(new PlayerHelper().teleport(int.Parse(commands[1]), int.Parse(commands[2]), int.Parse(commands[3])), false); Store.currentClient.messageQueue.addRpcMessage(PacketsUtils.createSystemMessage("Teleported!", Store.currentClient)); } if (command.Equals("?rsi") && commands.Length == 3) { //parse the rsi part and value Store.currentClient.messageQueue.addObjectMessage(new PlayerHelper().changeRsi(commands[1], int.Parse(commands[2])), false); Store.currentClient.messageQueue.addRpcMessage(PacketsUtils.createSystemMessage("Rsi changed!", Store.currentClient)); } if (command.StartsWith("?message")) { Output.WriteLine("[COMMAND HELPER]MESSAGE RECEIVED"); byte[] theMessage = PacketsUtils.createSystemMessageWithoutRPC(commands[1]); Store.world.sendRPCToAllPlayers(theMessage); } if (command.Equals("?playanim")) { string animId = commands[1]; if (animId.Length == 4) { ServerPackets pak = new ServerPackets(); pak.sendPlayerAnimation(Store.currentClient, animId); } } if (command.StartsWith("?playfx")) { string fxHEDID = commands[1]; DynamicArray din = new DynamicArray(); byte[] animationId = StringUtils.hexStringToBytes(fxHEDID); byte[] viewID = { 0x02, 0x00 }; Random rand = new Random(); ushort updateViewCounter = (ushort)rand.Next(3, 200); byte[] updateCount = NumericalUtils.uint16ToByteArrayShort(updateViewCounter); Output.WriteLine("Check if its really one byte or two : " + StringUtils.bytesToString(updateCount)); din.append(viewID); din.append(0x02); din.append(0x80); din.append(0x80); din.append(0x80); din.append(0x90); din.append(0xed); din.append(0x00); din.append(0x30); din.append(animationId); din.append(updateCount); Store.currentClient.messageQueue.addObjectMessage(din.getBytes(), false); } if (command.Contains("?send")) { // Sends a packet from a file string filename = "packet.txt"; TextReader tr = new StreamReader(filename); string hexContent = tr.ReadToEnd(); hexContent = hexContent.Replace(" ", string.Empty); hexContent = hexContent.Replace(" ", Environment.NewLine); tr.Close(); if (hexContent.Length > 0) { Store.currentClient.messageQueue.addObjectMessage(StringUtils.hexStringToBytes(hexContent), false); Output.writeToLogForConsole("[SENDPACK FROM FILE] Content : " + hexContent); } } if (command.Contains("?combat")) { byte[] dummypak = new byte[4]; TestUnitHandler test = new TestUnitHandler(); test.testCloseCombat(ref dummypak); } if (command.Contains("?mob")) { UInt32[] rsiIDs = new UInt32[10]; rsiIDs[0] = 0xB7010058; rsiIDs[1] = 0x89090058; rsiIDs[2] = 0xB5010058; rsiIDs[3] = 0x3A030008; rsiIDs[4] = 0x32030008; rsiIDs[5] = 0xD0010058; rsiIDs[6] = 0xD4010058; rsiIDs[7] = 0xB8040004; // Smith rsiIDs[8] = 0x92010058; // Seraph rsiIDs[9] = 0x56050004; Random rand = new Random(); int index = rand.Next(0, 9); 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); byte[] xPos = NumericalUtils.floatToByteArray((float)x, 1); byte[] yPos = NumericalUtils.floatToByteArray((float)y, 1); byte[] zPos = NumericalUtils.floatToByteArray((float)z, 1); UInt64 currentEntityId = WorldSocket.entityIdCounter; WorldSocket.entityIdCounter++; uint rotation = 0; npc theMob = new npc(); theMob.setEntityId(currentEntityId); theMob.setDistrict(Convert.ToUInt16(data[0].ToString())); theMob.setDistrictName(Store.currentClient.playerData.getDistrict()); theMob.setName("HD Protector"); theMob.setLevel(255); theMob.setHealthM(UInt16.Parse(data[4].ToString())); theMob.setHealthC(UInt16.Parse(data[5].ToString())); theMob.setMobId((ushort)rsiIDs[index]); theMob.setRsiHex(StringUtils.bytesToString_NS(NumericalUtils.uint32ToByteArray(rsiIDs[index], 1))); theMob.setXPos(x); theMob.setYPos(y); theMob.setZPos(z); theMob.xBase = x; theMob.yBase = y; theMob.zBase = z; theMob.setRotation(rotation); theMob.setIsDead(false); theMob.setIsLootable(false); WorldSocket.npcs.Add(theMob); // we use this for a test to see if we can spawn mobs and how we can handle them // We refactor this } if (command.Contains("?sendrpc")) { // sends a RPC Packet from a File string filename = "rpcpacket.txt"; TextReader tr = new StreamReader(filename); string hexContent = tr.ReadToEnd(); hexContent = hexContent.Replace(" ", string.Empty); hexContent = hexContent.Replace(" ", Environment.NewLine); Output.Write("SEND RPC COMMAND : CONTENT : " + hexContent); tr.Close(); if (hexContent.Length > 0) { Store.currentClient.messageQueue.addRpcMessage(StringUtils.hexStringToBytes(hexContent)); Output.writeToLogForConsole("[SENDRPC FROM FILE] Content : " + hexContent); } } if (command.Contains("?checkrpc")) { DynamicArray din = new DynamicArray(); din.append(StringUtils.hexStringToBytes("2E1000FF7D020024000000310000000000000000000000000000000000000000000000000B0053796E61707A65373737001D004F6E2079656168204920646F2072656D656D62657220796F75203A2900")); Store.currentClient.messageQueue.addRpcMessage(din.getBytes()); } if (command.Contains("?testrpc")) { UInt16 maxRPC = 33279; // Just to reference if (Store.currentClient.playerData.currentTestRPC <= maxRPC) { // Only if it is below we send it - we test with a 5 size packet DynamicArray din = new DynamicArray(); if (Store.currentClient.playerData.currentTestRPC < 127) { din.append(NumericalUtils.uint16ToByteArrayShort(Store.currentClient.playerData.currentTestRPC)); } else { din.append(NumericalUtils.uint16ToByteArray(Store.currentClient.playerData.currentTestRPC, 0)); } din.append(0x00); din.append(0x00); din.append(0x00); Store.currentClient.messageQueue.addRpcMessage(din.getBytes()); ServerPackets pak = new ServerPackets(); pak.sendSystemChatMessage(Store.currentClient, "Test RPC Header : " + Store.currentClient.playerData.currentTestRPC.ToString(), "MODAL"); Store.currentClient.playerData.currentTestRPC++; } } if (command.Equals("?save")) { new PlayerHelper().savePlayerInfo(Store.currentClient); ServerPackets pak = new ServerPackets(); pak.sendSaveCharDataMessage(Store.currentClient, StringUtils.charBytesToString_NZ(Store.currentClient.playerInstance.CharacterName.getValue())); } } catch (Exception e) { Store.currentClient.messageQueue.addRpcMessage(PacketsUtils.createSystemMessage("Error parsing command!", Store.currentClient)); Output.WriteLine("[CHAT COMMAND PARSER] Error parsing request: " + data); Output.WriteLine("[CHAT COMMAND PARSER] DEBUG: " + e.Message + "\n" + e.StackTrace); } }
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; } }
private void sendMarginCharData(byte[] data, byte opcode, NetworkStream client) { // This Method will be used to send the real Data to the client // Format for general LoadCharacterReply Responses: // 10 00 00 00 <- everytime the same // 00 f9 76 04 <- uint32 Char ID // 00 00 00 09 <- uint32 number of Character Replys (just raise one up) // 00 05 <- viewData opcode (what data is inside) uint16 // 10 00 <- if it has Data it is 10 00 if not is just 00 00 (and no Data can follow up and packet ends here) // e1 00 <- short / uint16 data size // DATA byte[] header = { 0x10, 0x00, 0x00, 0x00 }; // Raise one up loadCharCounter++; // Add the counter byte[] counterByte = new byte[4]; counterByte = NumericalUtils.uint32ToByteArray(loadCharCounter, 1); // get the datasize for the packet byte[] dataSize = NumericalUtils.uint16ToByteArray((UInt16)data.Length, 1); // charId byte[] charID = NumericalUtils.uint32ToByteArray(this.newCharID, 0); // viewData code byte[] responseCode = { 0x00, opcode }; string pakData = StringUtils.bytesToString_NS(header) + StringUtils.bytesToString_NS(charID) + StringUtils.bytesToString_NS(counterByte) + StringUtils.bytesToString_NS(responseCode); string hasData; // this needs improvement... if (data.Length == 0 && opcode == 0x01) { hasData = "0000"; } else { hasData = "1000" + StringUtils.bytesToString_NS(dataSize) + StringUtils.bytesToString_NS(data); } pakData += hasData; PacketContent pak = new PacketContent(); // Dump the Packet Data to see whats in //Console.WriteLine("Response Load Pak : " + pakData); // Do the viewData byte[] response = StringUtils.hexStringToBytes(pakData); Output.WritePacketLog(StringUtils.bytesToString(response), "MARGINSERVER", "0", "0", "0"); Output.WriteDebugLog("[MARGIN SERVER RESPONSE] for OPCODE " + opcode + " : " + StringUtils.bytesToString(response)); byte[] encryptedResponse = marginEncr.encrypt(response); sendTCPVariableLenPacket(encryptedResponse, client); System.Threading.Thread.Sleep(50); }
public void processChangeTactic(ref byte[] packet) { byte[] tactic = StringUtils.hexStringToBytes("80bc15008a0000f90300000802ecffffff0100000000"); Store.currentClient.messageQueue.addRpcMessage(tactic); }
private void loadCharacter(byte[] packet, NetworkStream client, UInt32 theCharId) { byte[] charIDB = new byte[4]; if (theCharId == 0) { ArrayUtils.copy(packet, 3, charIDB, 0, 4); //Offset for charID is 3 in request uint charId = (uint)NumericalUtils.ByteArrayToUint32(charIDB, 1); // Remove current instances for this character if (Store.margin.isAnotherClientActive(charId) == true) { CharacterAlreadyInUseReply(client); return; } this.newCharID = charId; } charIDB = NumericalUtils.uint32ToByteArray(this.newCharID, 1); //New harcoded sessionID is: ac 53 02 00 //Old is: 28 A9 02 00 string [] marginValues = new string[0x0e]; marginValues[8] = "000b10001e000700000001000800000000000a00000003000d00000000001c0000000100"; marginValues[0xc] = "000e10000000"; marginValues[0xd] = "010f10000000"; // Some Items string itemData = "0170A7000000000010" + "020B8F00000000001803B80200000000001804EE9900000000000005F399000000000000065F0900000000100007C80900000000000008D59D000000000C0009EA040000000000480AD61E0000000000380BF21800000000001C0C66900000000000140DB30400000000001C0E04A80000000018000F3743000000000028108D2200000000002411441A00000000004415808C00000000004462EB0300000000001C63CC5A00000000004464ECB2000000000048651CB3000000000038663E9500000000006868EA0400000000001C"; byte[] inventory = StringUtils.hexStringToBytes(itemData); // Loaded Abilities string loadedAbs = "000032080080070000E400800B0000E002800C00006403800E0000340180110032B400801600322C0080290032D404802B0000DC04802F00322800803000323000803E0001E404804200322005805D0000E800805E0032D000805F00327C01806B00008801806F00001C0580990001280580A40000A40080A60000AC0080AC0000EC0080B00000000180B10000040180B80032240180BB0032300180BC00004C0180C50000A00080D80001EC0480DD00012C0580EA0001E80480F400013005800D01013405801D0101680780200132740580280100E004802C01013805803601018C05803801017805803A01325C0780490100840180520100D8088056010124"; byte[] loadAbilitys = StringUtils.hexStringToBytes(loadedAbs); // Known Abilities string abilityData = "0000320800800100014800800200017C0080030000080280040000140380050001300480060001B40080070000E4008008000018038009000F9400800A0000E002800B0000E002800C00006403800D00009000800E00003401800F00018C00801000006C0080110032B40080120000E402801300001003801400016400801500322004801600322C0080170001AC09801800012C008019000F9400801A0032C401801B00010800801C00018400801D0000F803801E001A3802801F00010400802000006C0280210001240580220032B40980230032640680240001680080250087DF11842600000400802700001C0080280032540480290032D404802A003210"; byte[] knownAbilitiys = StringUtils.hexStringToBytes(abilityData); // Known Hardlines string hardlineData = "0207000000021f000000022300000002240000000225000000022600000002270000000229000000022b000000022f00000002300000000231000000023200000002340000000235000000023600000002370000000238000000023b000000023f000000024000000002410000000243000000024500000002480000000249000000024a000000024b000000024d000000024e000000024f000000025000000002510000000252000000025400000002550000000256000000025700000002580000000259000000025a000000025b000000025c000000025d000000025e000000025f000000026000000002610000000262000000026300000002640000000265000000026600000002670000000269000000026a000000026b000000026c000000026d000000026e000000026f000000027000000002710000000130000000013100000001370000000141000000014500000001480000000149000000014a000000014b000000014c000000014e000000014f0000000150000000015100000001520000000163000000016400000001650000000166000000016700000001680000000169000000016a000000016b000000016d000000016f00000001700000000171000000017200000001730000000174000000017700000001780000000179000000017a000000017b000000017c000000017d000000017e000000017f000000018000000001810000000182000000018300000001840000000185000000018600000001870000000188000000018a000000018b000000018c000000018d000000018e000000019000000001910000000192000000019300000001940000000195000000019600000001970000000198000000019900000003020000000303000000030400000003050000000306000000030700000003080000000309000000030a000000030b000000030c000000030d000000030e000000030f000000031000000003110000000312000000031300000003140000000315000000031600000003170000000318000000"; //string hardlineData = Store.dbManager.MarginDbHandler.loadAllHardlines(); byte[] knownHardlines = StringUtils.hexStringToBytes(hardlineData); // Contacts string missionContacts = "0700000001000800000000000a00000003000d00000000001c0000000100"; byte[] knownContacts = StringUtils.hexStringToBytes(missionContacts); byte[] codeArchiveTest = StringUtils.hexStringToBytes("04000000A7010000AC010000CC010000D1010000D60100001302000019020000650200006602000068020000B4020000B5020000B6020000BB020000BC020000C2020000C4020000D5020000D6020000DE020000E2020000E3020000E6020000E7020000E90200003F03000086030000A0030000AA030000E3030000FC030000FE030000030400000604000008040000090400000A040000270400004C0400004E040000BB040000C2040000CE040000EB040000EC040000EE040000F5040000F6040000F7040000F9040000540900005F09000082090000BE090000BF090000C1090000C4090000C7090000C8090000C9090000040A0000080A0000B0120000"); byte[] empty = new byte[0]; // New Margin Method to send Data // Pre-Load Abilities so that we just need to filter the result later loadAbilities((int)this.newCharID); sendMarginCharData(empty, 0x01, client); sendMarginCharData(loadBackgroundInfo((int)this.newCharID), 0x02, client); sendMarginCharData(empty, 0x03, client); // BuddyList (but old one) sendMarginCharData(empty, 0x04, client); // Unknown - no one has data there so ignore it //sendMarginCharData(loadInventory((int)this.newCharID), 0x05, client); // Inventory sendMarginCharData(StringUtils.hexStringToBytes(itemData), 0x05, client); // Inventory CR1 sendMarginCharData(loadEquippedAbilities(), 0x06, client); // Loaded Abilitys //sendMarginCharData(empty, 0x06, client); // Loaded Abilitys CR1 sendMarginCharData(loadKnownAbilities(), 0x07, client); // Known Abilities sendMarginCharData(knownHardlines, 0x08, client); // Hardlines sendMarginCharData(empty, 0x09, client); // Access Nodes? //sendMarginCharData(codeArchiveTest, 0x0a, client); // Code Storage sendMarginCharData(empty, 0x0a, client); // Code Storage CR1 sendMarginCharData(knownContacts, 0x0b, client); // Contacts sendMarginCharData(empty, 0x0e, client); // ModT (has a seperate format) sendMarginData("1000000000" + StringUtils.bytesToString_NS(charIDB) + "10270d010f10000000", client); /* This is the server MOTD announcement (its disabled now) */ /*DynamicArray announcement = new DynamicArray(); * byte[] header = {0x10,0x00,0x00,0x00,0x00,0xac,0x53,0x02,0x00,0x10,0x27,0x0E,0x01,0x0D,0x10,0x00}; * TimeUtils tim = new TimeUtils(); * byte[] currentTime = tim.getUnixTime(); * //Load motd from file * XmlParser xmlP = new XmlParser(); * string[] data=xmlP.loadDBParams("Config.xml"); * string motd=data[5]; * * if (!motd.Equals("")){ // if MOTD not empty * byte[] text = StringUtils.stringToBytes(motd); * byte[] size = NumericalUtils.uint16ToByteArray((UInt16)(currentTime.Length+text.Length),1); * * announcement.append(header); * announcement.append(size); * announcement.append(currentTime); * announcement.append(text); * * byte[] encryptedResponse14 = marginEncr.encrypt(announcement.getBytes()); * sendTCPVariableLenPacket(encryptedResponse14, client); * }*/ /* End of the MOTD */ //Output.WriteLine("[MARGIN] UserID "+this.userID+" waiting for session reply from world"); //waitForWorldReply(); //TODO: enabling this outputted the "no usage" bug //Output.WriteLine("[MARGIN] World Session Reply OK for UserID "+this.userID); //System.Threading.Thread.Sleep(1000); //EstablishUDPSessionReply(packet, client); }
public void loadAbilityDB(string path) { Output.Write("Loading Abilities.."); // load the CSV into an ArrayList collection ArrayList abilityDB = loadCSV(path, ';'); int linecount = 1; // Create a new List foreach (string[] data in abilityDB) { AbilityItem ability = new AbilityItem(); // we want to skip the first line as it should have the Names if (linecount > 1) { ability.setAbilityID(Convert.ToUInt16(data[0])); ability.setGOID(Convert.ToInt32(data[1])); ability.setAbilityName(data[2]); if (data[3].Length > 0) { ability.setIsCastable(bool.Parse(data[3])); } if (data.Length >= 5) { if (data[4].Length > 0) { ability.setCastingTime(float.Parse(data[4], CultureInfo.InvariantCulture)); } } if (data.Length >= 6) { if (data[5].Length > 2) { ability.setCastAnimStart(StringUtils.hexStringToBytes(data[5])); } } if (data.Length >= 7) { if (data[6].Length > 2) { ability.setCastAnimMid(StringUtils.hexStringToBytes((data[6]))); } } if (data.Length >= 8) { if (data[7].Length > 2) { ability.setCastAnimEnd(StringUtils.hexStringToBytes(data[7])); } } if (data.Length >= 9) { if (data[8].Length > 0) { ability.setActivationFX(UInt32.Parse(data[8])); } } if (data.Length >= 10) { if (data[9].Length > 0) { ability.setValueFrom(Int16.Parse(data[9])); } } if (data.Length >= 11) { if (data[10].Length > 0) { ability.setValueTo(UInt16.Parse(data[10])); } } if (data.Length >= 12) { if (data[11].Length > 0) { ability.setIsBuff(bool.Parse(data[11])); } } if (data.Length >= 13) { if (data[12].Length > 0) { CultureInfo ci = (CultureInfo)CultureInfo.CurrentCulture.Clone(); ci.NumberFormat.CurrencyDecimalSeparator = "."; ability.setBuffTime(float.Parse(data[12], NumberStyles.Any, ci)); } } if (data.Length >= 14) { if (data[13].Length > 0) { ability.setAbilityExecutionFX(UInt32.Parse(data[13])); } } AbilityDB.Add(ability); } 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 static byte[] createMessage(string message, string type, WorldClient client) { byte typeByte; switch (type) { case "TEAM": typeByte = 0x05; break; case "CREW": typeByte = 0x02; break; case "FACTION": typeByte = 0x03; break; case "SYSTEM": typeByte = 0x07; break; case "MODAL": typeByte = 0x17; break; case "FRAMEMODAL": typeByte = 0xd7; break; case "BROADCAST": typeByte = 0xc7; break; case "AREA": typeByte = 0x10; break; default: typeByte = 0x07; break; } byte[] messageBytes = StringUtils.stringToBytes(message + "\x00"); DynamicArray din = new DynamicArray(); UInt16 messageSize = (UInt16)(message.Length + 1); byte[] messageSizeHex = NumericalUtils.uint16ToByteArray(messageSize, 1); byte[] hexContents = StringUtils.hexStringToBytes("00000000000000000024000000000000000000000000000000000000000000000000"); din.append((byte)RPCResponseHeaders.SERVER_CHAT_MESSAGE_RESPONSE); // Response header din.append(typeByte); din.append(hexContents); din.append(messageSizeHex); din.append(messageBytes); return(din.getBytes()); }
public void addHexBytes(String hexbytes) { packet.append(StringUtils.hexStringToBytes(hexbytes)); }
public void LoadMissions() { string[] xmlMissionFiles = Directory.GetFiles(@".\data\missions", "*.xml"); foreach (string file in xmlMissionFiles) { XmlDocument missionDocument = new XmlDocument(); missionDocument.Load(file); XmlNode missionNode = missionDocument.SelectSingleNode("mission"); if (missionNode != null && missionNode.HasChildNodes) { Mission theMission = new Mission(); theMission.title = missionNode.Attributes["title"].InnerText; theMission.description = missionNode.Attributes["description"].InnerText; theMission.exp = int.Parse(missionNode.Attributes["exp"].InnerText); theMission.info = int.Parse(missionNode.Attributes["info"].InnerText); theMission.repZion = int.Parse(missionNode.Attributes["repZion"].InnerText); theMission.repMachine = int.Parse(missionNode.Attributes["repMachine"].InnerText); theMission.repMero = int.Parse(missionNode.Attributes["repMero"].InnerText); foreach (XmlNode childNode in missionNode.ChildNodes) { if (childNode.Name.Equals("phase")) { MissionPhase phase = new MissionPhase(); foreach (XmlNode phaseItem in childNode.ChildNodes) { switch (phaseItem.Name) { case "dialog": MissionDialog dialog = new MissionDialog(); dialog.text = phaseItem.Attributes["text"].InnerText; dialog.type = phaseItem.Attributes["type"].InnerText; var innerText = phaseItem.Attributes["trigger"].InnerText; dialog.trigger = (MissionDialog.DIALOG_TRIGGER)Enum.Parse(typeof(MissionDialog.DIALOG_TRIGGER), innerText, true); phase.dialogs.Add(dialog); break; case "objective": MissionObjective objective = new MissionObjective(); objective.description = phaseItem.Attributes["description"].InnerText; objective.command = phaseItem.Attributes["command"].InnerText; if (phaseItem.Attributes["item"] != null) { objective.itemId = StringUtils.hexStringToBytes(phaseItem.Attributes["item"].InnerText); } objective.dialog = phaseItem.Attributes["dialog"].InnerText; phase.missionObjectives.Add(objective); break; case "npc": Mob theMob = new Mob(); theMob.setName(phaseItem.Attributes["handle"].InnerText); theMob.setLevel(ushort.Parse(phaseItem.Attributes["level"].InnerText)); theMob.setHealthM(UInt16.Parse(phaseItem.Attributes["maxHP"].InnerText)); theMob.setRsiHex(phaseItem.Attributes["rsi"].InnerText); theMob.setXPos(float.Parse(phaseItem.Attributes["x"].InnerText)); theMob.setYPos(float.Parse(phaseItem.Attributes["y"].InnerText)); theMob.setZPos(float.Parse(phaseItem.Attributes["z"].InnerText)); phase.npcs.Add(theMob); break; case "gameobject": // ToDo: this is a little bit tricky break; } } theMission.phases.Add(phase); } } missions.Add(theMission); } } }