public static SubPacket BuildPacket(uint sourcePlayerActorId, uint targetEventActorId, string conditionName, List <LuaParam> luaParams) { byte[] data = new byte[PACKET_SIZE - 0x20]; using (MemoryStream mem = new MemoryStream(data)) { using (BinaryWriter binWriter = new BinaryWriter(mem)) { binWriter.Write((UInt32)sourcePlayerActorId); binWriter.Write((UInt32)targetEventActorId); int test = 0x75dc1705; //This will crash if set to 0 on pushCommand but not for mining which has to be 0???? binWriter.Write((UInt32)test); binWriter.Write((UInt32)0x30400000); binWriter.Write(Encoding.ASCII.GetBytes(conditionName), 0, Encoding.ASCII.GetByteCount(conditionName) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(conditionName)); binWriter.Seek(0x30, SeekOrigin.Begin); LuaUtils.WriteLuaParams(binWriter, luaParams); } } return(new SubPacket(OPCODE, sourcePlayerActorId, data)); }
public static SubPacket BuildPacket(uint sourceActorId, List <LuaParam> luaParams) { byte[] data = new byte[PACKET_SIZE - 0x20]; using (MemoryStream mem = new MemoryStream(data)) { using (BinaryWriter binWriter = new BinaryWriter(mem)) { LuaUtils.WriteLuaParams(binWriter, luaParams); } } return(new SubPacket(OPCODE, sourceActorId, data)); }
public static SubPacket BuildPacket(uint sourceActorId, uint actorId, uint textOwnerActorId, ushort textId, byte log, List <LuaParam> lParams) { int lParamsSize = findSizeOfParams(lParams); byte[] data; ushort opcode; if (lParamsSize <= 0x8) { data = new byte[SIZE_GAMEMESSAGE_WITH_ACTOR2 - 0x20]; opcode = OPCODE_GAMEMESSAGE_WITH_ACTOR2; } else if (lParamsSize <= 0x10) { data = new byte[SIZE_GAMEMESSAGE_WITH_ACTOR3 - 0x20]; opcode = OPCODE_GAMEMESSAGE_WITH_ACTOR3; } else if (lParamsSize <= 0x20) { data = new byte[SIZE_GAMEMESSAGE_WITH_ACTOR4 - 0x20]; opcode = OPCODE_GAMEMESSAGE_WITH_ACTOR4; } else { data = new byte[SIZE_GAMEMESSAGE_WITH_ACTOR5 - 0x20]; opcode = OPCODE_GAMEMESSAGE_WITH_ACTOR5; } using (MemoryStream mem = new MemoryStream(data)) { using (BinaryWriter binWriter = new BinaryWriter(mem)) { binWriter.Write((UInt32)actorId); binWriter.Write((UInt32)textOwnerActorId); binWriter.Write((UInt16)textId); binWriter.Write((UInt16)log); LuaUtils.WriteLuaParams(binWriter, lParams); if (lParamsSize <= 0x14 - 12) { binWriter.Seek(0x14, SeekOrigin.Begin); binWriter.Write((UInt32)8); } } } return(new SubPacket(opcode, sourceActorId, data)); }
public static SubPacket BuildPacket(uint sourceActorId, uint textOwnerActorId, ushort textId, string sender, byte log, List <LuaParam> lParams) { int lParamsSize = findSizeOfParams(lParams); byte[] data; ushort opcode; if (lParamsSize <= 0x8) { data = new byte[SIZE_GAMEMESSAGE_WITH_CUSTOM_SENDER2 - 0x20]; opcode = OPCODE_GAMEMESSAGE_WITH_CUSTOM_SENDER2; } else if (lParamsSize <= 0x10) { data = new byte[SIZE_GAMEMESSAGE_WITH_CUSTOM_SENDER3 - 0x20]; opcode = OPCODE_GAMEMESSAGE_WITH_CUSTOM_SENDER3; } else if (lParamsSize <= 0x20) { data = new byte[SIZE_GAMEMESSAGE_WITH_CUSTOM_SENDER4 - 0x20]; opcode = OPCODE_GAMEMESSAGE_WITH_CUSTOM_SENDER4; } else { data = new byte[SIZE_GAMEMESSAGE_WITH_CUSTOM_SENDER5 - 0x20]; opcode = OPCODE_GAMEMESSAGE_WITH_CUSTOM_SENDER5; } using (MemoryStream mem = new MemoryStream(data)) { using (BinaryWriter binWriter = new BinaryWriter(mem)) { binWriter.Write((UInt32)textOwnerActorId); binWriter.Write((UInt16)textId); binWriter.Write((UInt16)log); binWriter.Write(Encoding.ASCII.GetBytes(sender), 0, Encoding.ASCII.GetByteCount(sender) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(sender)); LuaUtils.WriteLuaParams(binWriter, lParams); if (lParamsSize <= 0x14 - 12) { binWriter.Seek(0x30, SeekOrigin.Begin); binWriter.Write((UInt32)8); } } } return(new SubPacket(opcode, sourceActorId, data)); }
public static SubPacket BuildPacket(uint sourceActorId, string objectName, string className, List <LuaParam> initParams) { byte[] data = new byte[PACKET_SIZE - 0x20]; using (MemoryStream mem = new MemoryStream(data)) { using (BinaryWriter binWriter = new BinaryWriter(mem)) { int value1 = 0x00; //Instance ID? int value2 = 0x3040; binWriter.Write((Int16)value1); binWriter.Write((Int16)value2); binWriter.Write(Encoding.ASCII.GetBytes(objectName), 0, Encoding.ASCII.GetByteCount(objectName) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(objectName)); binWriter.BaseStream.Seek(0x24, SeekOrigin.Begin); binWriter.Write(Encoding.ASCII.GetBytes(className), 0, Encoding.ASCII.GetByteCount(className) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(className)); binWriter.BaseStream.Seek(0x44, SeekOrigin.Begin); LuaUtils.WriteLuaParams(binWriter, initParams); } } return(new SubPacket(OPCODE, sourceActorId, data)); }
public static SubPacket BuildPacket(uint sourcePlayerActorId, uint eventOwnerActorID, string eventStarter, string callFunction, List <LuaParam> luaParams) { byte[] data = new byte[PACKET_SIZE - 0x20]; int maxBodySize = data.Length - 0x80; using (MemoryStream mem = new MemoryStream(data)) { using (BinaryWriter binWriter = new BinaryWriter(mem)) { binWriter.Write((UInt32)sourcePlayerActorId); binWriter.Write((UInt32)eventOwnerActorID); binWriter.Write((Byte)5); binWriter.Write(Encoding.ASCII.GetBytes(eventStarter), 0, Encoding.ASCII.GetByteCount(eventStarter) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(eventStarter)); binWriter.Seek(0x29, SeekOrigin.Begin); binWriter.Write(Encoding.ASCII.GetBytes(callFunction), 0, Encoding.ASCII.GetByteCount(callFunction) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(callFunction)); binWriter.Seek(0x49, SeekOrigin.Begin); LuaUtils.WriteLuaParams(binWriter, luaParams); } } return(new SubPacket(OPCODE, sourcePlayerActorId, data)); }