private static bool OnLocalizedMessageAffix(ref byte[] packet, ref int length) { PacketReader reader = new PacketReader(packet, length, false); int serial = reader.ReadInt32(); int graphic = reader.ReadInt16(); JournalSpeech messageType = (JournalSpeech)reader.ReadByte(); int hue = reader.ReadInt16(); int font = reader.ReadInt16(); int cliloc = reader.ReadInt32(); MessageAffixType affixType = (MessageAffixType)reader.ReadByte(); string name = reader.ReadString(30); string affix = reader.ReadString(); string[] arguments = reader.ReadUnicodeString() .Split(new[] { '\t' }, StringSplitOptions.RemoveEmptyEntries); JournalEntry journalEntry = new JournalEntry { Serial = serial, ID = graphic, SpeechType = messageType, SpeechHue = hue, SpeechFont = font, Cliloc = cliloc, Name = name, Arguments = arguments }; string text = Cliloc.GetLocalString(journalEntry.Cliloc, journalEntry.Arguments); if (affixType.HasFlag(MessageAffixType.Prepend)) { journalEntry.Text = $"{affix}{text}"; } else if (affixType.HasFlag(MessageAffixType.Append)) { journalEntry.Text = $"{text}{affix}"; } bool block = RepeatedMessagesFilter.CheckMessage(journalEntry); if (block && RepeatedMessagesFilter.FilterOptions.SendToJournal) { IncomingPacketHandlers.AddToJournal(journalEntry); } return(block || ClilocFilter.CheckMessageAffix(journalEntry, affixType, affix)); }
public UnicodeText(int serial, int graphic, JournalSpeech speechType, int hue, int font, string lang, string name, string text) { byte[] textBytes = Encoding.BigEndianUnicode.GetBytes(text); int len = 48 + textBytes.Length; _writer = new PacketWriter(len); _writer.Write((byte)0xAE); _writer.Write((short)len); _writer.Write(serial); _writer.Write((ushort)graphic); _writer.Write((byte)speechType); _writer.Write((short)hue); _writer.Write((short)font); _writer.WriteAsciiFixed(lang, 4); _writer.WriteAsciiFixed(name, 30); _writer.Write(textBytes, 0, textBytes.Length); }
private static void OnLocalizedTextAffix(PacketReader reader) { int serial = reader.ReadInt32(); int graphic = reader.ReadInt16(); JournalSpeech messageType = (JournalSpeech)reader.ReadByte(); int hue = reader.ReadInt16(); int font = reader.ReadInt16(); int cliloc = reader.ReadInt32(); MessageAffixType affixType = (MessageAffixType)reader.ReadByte(); string name = reader.ReadString(30); string affix = reader.ReadString(); string[] arguments = reader.ReadUnicodeString() .Split(new[] { '\t' }, StringSplitOptions.RemoveEmptyEntries); JournalEntry journalEntry = new JournalEntry { Serial = serial, ID = graphic, SpeechType = messageType, SpeechHue = hue, SpeechFont = font, Cliloc = cliloc, Name = name, Arguments = arguments }; string text = Cliloc.GetLocalString(journalEntry.Cliloc, journalEntry.Arguments); if (affixType.HasFlag(MessageAffixType.Prepend)) { journalEntry.Text = $"{affix}{text}"; } else if (affixType.HasFlag(MessageAffixType.Append)) { journalEntry.Text = $"{text}{affix}"; } Engine.Journal.Write(journalEntry); JournalEntryAddedEvent?.Invoke(journalEntry); }
public static void Speak(string text, int hue = 34, JournalSpeech speechType = JournalSpeech.Say) { int[] keywords = new int[0]; if (speechType == JournalSpeech.Say) { keywords = Speech.GetKeywords(text.ToLower()); } PacketWriter writer = new PacketWriter(); writer.Write((byte)0xAD); writer.Write((short)0); // len; writer.Write(keywords.Length > 0 ? (byte)0xC0 : (byte)speechType); writer.Write((short)hue); writer.Write((short)0x3); writer.WriteAsciiFixed(Strings.UO_LOCALE, 4); if (keywords.Length > 0) { byte[] bytes = GetKeywordBytes(keywords); writer.Write(bytes, 0, bytes.Length); writer.WriteAsciiNull(text); } else { writer.WriteBigUniNull(text); } byte[] packet = writer.ToArray(); packet[1] = (byte)(packet.Length << 8); packet[2] = (byte)packet.Length; Engine.SendPacketToServer(packet, packet.Length); }