public override void OnFilter( PacketReader p, PacketHandlerEventArgs args ) { if ( args.Block ) return; // 0, 1, 2 Serial serial = p.ReadUInt32(); // 3, 4, 5, 6 ushort body = p.ReadUInt16(); // 7, 8 MessageType type = (MessageType)p.ReadByte(); // 9 if ( type != m_Type ) return; ushort hue = p.ReadUInt16(); // 10, 11 ushort font = p.ReadUInt16(); string name = p.ReadStringSafe( 30 ); string text = p.ReadStringSafe(); for(int i=0;i<m_Strings.Length;i++) { if ( text.IndexOf( m_Strings[i] ) != -1 ) { args.Block = true; return; } } }
private static void OnCompressedGump(PacketReader p, PacketHandlerEventArgs e) { p.MoveToData(); uint sender = p.ReadUInt32(); uint id = p.ReadUInt32(); if (id == responseID) _responseSender = sender; if (id != compressedID) return; p.Seek(19, SeekOrigin.Begin); p.Seek(p.ReadInt32(), SeekOrigin.Current); int lines = p.ReadInt32(), cLen = p.ReadInt32(), dLen = p.ReadInt32(); if (cLen < 5) return; byte[] buffer = new byte[dLen]; ZLib.uncompress(buffer, ref dLen, p.CopyBytes(p.Position, cLen - 4), cLen - 4); string afk = string.Empty; for (int i = 0, pos = 0; i < lines; i++) { int strLen = (buffer[pos++] << 8) | buffer[pos++]; string str = Encoding.BigEndianUnicode.GetString(buffer, pos, strLen * 2); int index = str.IndexOf('>'); if (index != -1 && index < str.Length - 1) afk += str[index + 1].ToString().ToUpper().Normalize(NormalizationForm.FormD)[0]; pos += strLen * 2; } afk = afk.Trim(); if (afk.Length == 5 && _responseSender != 0) { /*ClientCommunication.SendToClient(new CloseGump(responseID)); WorldEx.SendToServer(new GumpResponse(responseSender, responseID, 0x310, new int[0], new[] { new GumpTextEntry(0x310, afk) })); responseSender = 0;*/ WorldEx.OverHeadMessage(afk); } }
public override void OnFilter( PacketReader p, PacketHandlerEventArgs args ) { uint serial = p.ReadUInt32(); ushort itemID = p.ReadUInt16(); if ( (serial & 0x80000000) != 0 ) p.ReadUInt16(); // amount if ( (itemID & 0x8000) != 0 ) itemID = (ushort)((itemID&0x7FFF) + p.ReadSByte()); // itemID offset ushort x = p.ReadUInt16(); ushort y = p.ReadUInt16(); if ( (x & 0x8000) != 0 ) p.ReadByte(); // direction short z = p.ReadSByte(); if ( ( y & 0x8000 ) != 0 ) p.ReadUInt16(); // hue bool visable = true; if ( ( y & 0x4000 ) != 0 ) { int flags = p.ReadByte(); visable = ( (flags&0x80) == 0 ); } if ( IsStaffItem( itemID ) || !visable ) args.Block = true; }
public static void AsciiSpeech( Packet p, PacketHandlerEventArgs args ) { // 0, 1, 2 Serial serial = p.ReadUInt32(); // 3, 4, 5, 6 ushort body = p.ReadUInt16(); // 7, 8 MessageType type = (MessageType)p.ReadByte(); // 9 ushort hue = p.ReadUInt16(); // 10, 11 ushort font = p.ReadUInt16(); string name = p.ReadStringSafe( 30 ); string text = p.ReadStringSafe(); if ( World.Player != null && serial == Serial.Zero && body == 0 && type == MessageType.Regular && hue == 0xFFFF && font == 0xFFFF && name == "SYSTEM" ) { args.Block = true; p.Seek( 3, SeekOrigin.Begin ); p.WriteAsciiFixed( "", (int)p.Length-3 ); ClientCommunication.DoFeatures( World.Player.Features ) ; } else { HandleSpeech( p, args, serial, body, type, hue, font, "A", name, text ); if ( !serial.IsValid ) BandageTimer.OnAsciiMessage( text ); } }
private static void CombatantChange(PacketReader p, PacketHandlerEventArgs e) { Serial ser = p.ReadUInt32(); if (ser.IsMobile && ser != World.Player.Serial && ser != Serial.Zero && ser != Serial.MinusOne) { m_LastCombatant = ser; } }
private static void MobileIncoming(PacketReader p, PacketHandlerEventArgs args) { Mobile m = World.FindMobile(p.ReadUInt32()); if (m != null && m.Notoriety == (byte)m_Type && m_Type != AutoTargType.none) { Targeting.SetLastTargetTo(m); World.Player.SendMessage(MsgLevel.Force, "New target acquired."); } }
private static void Handle(Delegate del, PacketHandlerEventArgs args, params object[] parameters) { if (del != null) foreach (Delegate d in del.GetInvocationList()) { bool? result = (bool?)d.Method.Invoke(d.Target, parameters); if (result.HasValue) args.Block = result.Value; } }
private static void OnASCIIMessage(PacketReader p, PacketHandlerEventArgs args) { Serial serial = p.ReadUInt32(); ItemID graphic = p.ReadUInt16(); byte type = p.ReadByte(); ushort hue = p.ReadUInt16(); ushort font = p.ReadUInt16(); string name = p.ReadStringSafe(30); string msg = p.ReadStringSafe().Trim(); Handle(asciiMessage, args, serial, graphic, type, hue, font, string.Empty, name, msg); }
private static void OnMessageLocalizedAffix(PacketReader p, PacketHandlerEventArgs args) { Serial serial = p.ReadUInt32(); ItemID graphic = p.ReadUInt16(); byte type = p.ReadByte(); ushort hue = p.ReadUInt16(); ushort font = p.ReadUInt16(); int num = p.ReadInt32(); string name = p.ReadStringSafe(30); Handle(localizedMessage, args, serial, graphic, type, hue, font, num, name, string.Empty); }
private static void ClientDoubleClick(PacketReader p, PacketHandlerEventArgs args) { Serial serial = p.ReadUInt32(); if (items.ContainsKey(serial)) { args.Block = true; WorldEx.SendToServer(new DoubleClick(items[serial].List.Last())); } else args.Block = PacketHandler.ProcessViewers(clientDoubleClick, p); }
private static void OnCompressedGump(PacketReader p, PacketHandlerEventArgs e) { p.MoveToData(); uint sender = p.ReadUInt32(); uint id = p.ReadUInt32(); if (id == gumpID) { responseID = sender; e.Block = enabled; } }
private static void OnGumpResponse(Packet p, PacketHandlerEventArgs args) { p.ReadUInt32(); if (p.ReadUInt32() != gumpID) return; uint buttonID = p.ReadUInt32(); if ((buttonID - 2) % 6 == 0) { p.Seek(-4, SeekOrigin.Current); p.Write(buttonID + (uint)ConfigEx.GetElement(TeleportType.Default, "RuneBook")); } }
private static void OnCompressedGump(PacketReader p, PacketHandlerEventArgs e) { p.Seek(7, SeekOrigin.Begin); if (p.ReadUInt32() != 0x1105B263) return; p.Seek(19, SeekOrigin.Begin); p.Seek(p.ReadInt32() + 4, SeekOrigin.Current); int cLen = p.ReadInt32(), dLen = p.ReadInt32(); byte[] buffer = new byte[dLen]; ZLib.uncompress(buffer, ref dLen, p.CopyBytes(p.Position, cLen - 4), cLen - 4); int strLen = (buffer[0] << 8) | buffer[1]; string[] str = Encoding.BigEndianUnicode.GetString(buffer, 2, strLen * 2).Split(','); string[] lat = str[0].Split('°'); int yLat = int.Parse(lat[0]); int yMins = int.Parse(lat[1].Split('\'')[0]); bool ySouth = lat[1][lat[1].Length - 1] == 'S'; string[] lon = str[1].Split('°'); int xLong = int.Parse(lon[0]); int xMins = int.Parse(lon[1].Split('\'')[0]); bool xEast = lon[1][lon[1].Length - 1] == 'E'; const int xWidth = 5120; const int yHeight = 4096; const int xCenter = 1323; const int yCenter = 1624; double absLong = xLong + ((double)xMins / 60); double absLat = yLat + ((double)yMins / 60); if (!xEast) absLong = 360.0 - absLong; if (!ySouth) absLat = 360.0 - absLat; int x = xCenter + (int)((absLong * xWidth) / 360); int y = yCenter + (int)((absLat * yHeight) / 360); if (x < 0) x += xWidth; else if (x >= xWidth) x -= xWidth; if (y < 0) y += yHeight; else if (y >= yHeight) y -= yHeight; onGump(x, y); }
private static void OnLocalizedMessage(PacketReader p, PacketHandlerEventArgs args) { Serial serial = p.ReadUInt32(); ItemID graphic = p.ReadUInt16(); byte type = p.ReadByte(); ushort hue = p.ReadUInt16(); ushort font = p.ReadUInt16(); int num = p.ReadInt32(); string name = p.ReadStringSafe(30); string arguments = p.ReadUnicodeStringBE(((p.Length - 1) - p.Position) / 2); Handle(localizedMessage, args, serial, graphic, type, hue, font, num, name, arguments); }
private static void ContainerContentUpdate2(Packet p, PacketHandlerEventArgs args) { Serial serial = p.ReadUInt32(); Item item = World.FindItem(serial); if (item != null && item.Container == World.Player.Backpack && item.IsContainer) { if (containers.ContainsKey(serial)) containers[serial] = item; else containers.Add(serial, item); } }
public override void OnFilter( PacketReader p, PacketHandlerEventArgs args ) { if ( ClientCommunication.AllowBit( FeatureBit.LightFilter ) ) { args.Block = true; if ( World.Player != null ) { World.Player.LocalLightLevel = 0; World.Player.GlobalLightLevel = 0; } } }
public override void OnFilter( PacketReader p, PacketHandlerEventArgs args ) { p.ReadByte(); // flags ushort sound = p.ReadUInt16(); for (int i=0;i<m_Sounds.Length;i++) { if ( m_Sounds[i] == sound ) { args.Block = true; return; } } }
private static void OnHuedEffect(PacketReader p, PacketHandlerEventArgs args) { byte type = p.ReadByte(); Serial src = p.ReadUInt32(); Serial dest = p.ReadUInt32(); ItemID itemID = p.ReadUInt16(); p.Seek(10, SeekOrigin.Current); byte speed = p.ReadByte(); byte count = p.ReadByte(); p.ReadUInt32(); uint hue = p.ReadUInt32(); uint mode = p.ReadUInt32(); Handle(huedEffect, args, type, src, dest, itemID, speed, count, hue, mode); }
private static void ContainerContent(Packet p, PacketHandlerEventArgs args) { int count = p.ReadUInt16(); for (int i = 0; i < count; i++) { Item item = World.FindItem(p.ReadUInt32()); Item container = item.Container as Item; if (container != null && container.ItemID == 0x2006) foreach (LootItem loot in items) if (item.ItemID == loot.Graphic && (item.Hue == loot.Color || loot.Color == 0xFFFF)) { if (Fixes.LootBag.Bag != 0) DragDrop.Move(item, Fixes.LootBag.Bag); WorldEx.OverHeadMessage(loot.Name, container); } p.Seek(15, System.IO.SeekOrigin.Current); } }
private static void ContainerContent(Packet p, PacketHandlerEventArgs args) { List<Serial> toRemove = new List<Serial>(); for (ushort count = p.ReadUInt16(); count > 0; count--) { Item item = World.FindItem(p.ReadUInt32()); if (item != null && item.Container == World.Player.Backpack) foreach (FakeItem fake in items.Values) if (item.ItemID == fake.OrigID && item.Hue == fake.OrigHue) { if (!fake.List.Contains(item.Serial)) fake.List.Add(item.Serial); toRemove.Add(item.Serial); } p.Seek(15, SeekOrigin.Current); } if (toRemove.Count > 0) Resend(); toRemove.ForEach(s => WorldEx.SendToClient(new RemoveObject(s))); }
private static void ContainerContentUpdate1(PacketReader p, PacketHandlerEventArgs args) { Serial serial = p.ReadUInt32(); if (containers.ContainsKey(serial)) { Item item = World.FindItem(serial); if (item == null || item.Deleted || item != containers[serial]) args.Block = true; else { ushort itemID = (ushort)(p.ReadUInt16() + p.ReadSByte()); ushort amount = p.ReadUInt16(); if (amount == 0) amount = 1; Point3D position = new Point3D(p.ReadUInt16(), p.ReadUInt16(), 0); p.ReadUInt32(); ushort hue = p.ReadUInt16(); args.Block = item.ItemID == itemID && item.Amount == amount && item.Position == position && item.Hue == hue; } } }
private static void MobileMoving(PacketReader p, PacketHandlerEventArgs args) { Mobile m = World.FindMobile(p.ReadUInt32()); if (m != null && m.Notoriety == (byte)m_Type && m_Type != AutoTargType.none) { Point3D oldPos = m.Position; Point3D newPos = new Point3D(p.ReadUInt16(), p.ReadUInt16(), p.ReadSByte()); int dist = Utility.Distance(World.Player.Position, newPos); int oldDist = Utility.Distance(World.Player.Position, oldPos); int range = 15; if (Config.GetBool("RangeCheckLT")) { range = Config.GetInt("LTRange"); } if (oldDist > dist && oldDist > range && dist <= range) { Targeting.SetLastTargetTo(m); World.Player.SendMessage(MsgLevel.Force, "New target acquired."); } } }
public override void OnFilter( PacketReader p, PacketHandlerEventArgs args ) { // completely skip this filter if we've been connected for more thn 1 minute if ( ClientCommunication.ConnectionStart + TimeSpan.FromMinutes( 1.0 ) < DateTime.Now ) return; try { p.Seek( 0, System.IO.SeekOrigin.Begin ); byte packetID = p.ReadByte(); p.MoveToData(); uint ser = p.ReadUInt32(); uint tid = p.ReadUInt32(); int x = p.ReadInt32(); int y = p.ReadInt32(); string layout = null; if ( packetID == 0xDD ) { layout = p.GetCompressedReader().ReadString(); } else { ushort layoutLength = p.ReadUInt16(); layout = p.ReadString( layoutLength ); } if ( layout != null && layout.IndexOf( m_VetRewardStr ) != -1 ) args.Block = true; } catch { } }
private static void EquipRequest( PacketReader p, PacketHandlerEventArgs args ) { Serial iser = p.ReadUInt32(); // item being dropped serial Layer layer = (Layer)p.ReadByte(); Serial mser = p.ReadUInt32(); Item item = World.FindItem( iser ); if ( MacroManager.AcceptActions ) { if ( layer == Layer.Invalid || layer > Layer.LastValid ) { if ( item != null ) { layer = item.Layer; if ( layer == Layer.Invalid || layer > Layer.LastValid ) layer = (Layer)item.ItemID.ItemData.Quality; } } if ( layer > Layer.Invalid && layer <= Layer.LastUserValid ) MacroManager.Action( new DropAction( mser, Point3D.Zero, layer ) ); } if ( item == null ) return; Mobile m = World.FindMobile( mser ); if ( m == null ) return; if ( Config.GetBool( "QueueActions" ) ) args.Block = DragDropManager.Drop( item, m, layer ); }
private static void EncodedPacket( PacketReader p, PacketHandlerEventArgs args ) { /*ushort id = p.ReadUInt16(); switch ( id ) { case 1: // object property list { Serial s = p.ReadUInt32(); if ( s.IsItem ) { Item item = World.FindItem( s ); if ( item == null ) World.AddItem( item=new Item( s ) ); item.ReadPropertyList( p ); if ( item.ModifiedOPL ) { args.Block = true; ClientCommunication.SendToClient( item.ObjPropList.BuildPacket() ); } } else if ( s.IsMobile ) { Mobile m = World.FindMobile( s ); if ( m == null ) World.AddMobile( m=new Mobile( s ) ); m.ReadPropertyList( p ); if ( m.ModifiedOPL ) { args.Block = true; ClientCommunication.SendToClient( m.ObjPropList.BuildPacket() ); } } break; } }*/ }
private static void EquipmentUpdate( Packet p, PacketHandlerEventArgs args ) { Serial serial = p.ReadUInt32(); Item i = World.FindItem( serial ); bool isNew = false; if ( i == null ) { World.AddItem( i=new Item( serial ) ); isNew = true; Item.UpdateContainers(); } else { i.CancelRemove(); } if ( !DragDropManager.EndHolding( serial ) ) return; ushort iid = p.ReadUInt16(); i.ItemID = (ushort)(iid + p.ReadSByte()); // signed, itemID offset i.Layer = (Layer)p.ReadByte(); Serial ser = p.ReadUInt32();// cont must be set after hue (for counters) i.Hue = p.ReadUInt16(); i.Container = ser; int ltHue = Config.GetInt( "LTHilight" ); if ( ltHue != 0 && Targeting.IsLastTarget( i.Container as Mobile ) ) { p.Seek( -2, SeekOrigin.Current ); p.Write( (ushort)(ltHue&0x3FFF) ); } if ( i.Layer == Layer.Backpack && isNew && Config.GetBool( "AutoSearch" ) && ser == World.Player.Serial ) { m_IgnoreGumps.Add( i ); PlayerData.DoubleClick( i ); } }
private static void DisplayStringQuery( PacketReader p, PacketHandlerEventArgs args ) { // See also Packets.cs: StringQueryResponse /*if ( MacroManager.AcceptActions ) { int serial = p.ReadInt32(); byte type = p.ReadByte(); byte index = p.ReadByte(); MacroManager.Action( new WaitForTextEntryAction( serial, type, index ) ); }*/ }
private static void DropRequest( PacketReader p, PacketHandlerEventArgs args ) { Serial iser = p.ReadUInt32(); int x = p.ReadInt16(); int y = p.ReadInt16(); int z = p.ReadSByte(); if ( Engine.UsePostKRPackets ) /* grid num */p.ReadByte(); Point3D newPos = new Point3D( x, y, z ); Serial dser = p.ReadUInt32(); if ( Macros.MacroManager.AcceptActions ) MacroManager.Action( new DropAction( dser, newPos ) ); Item i = World.FindItem( iser ); if ( i == null ) return; Item dest = World.FindItem( dser ); if ( dest != null && dest.IsContainer && World.Player != null && ( dest.IsChildOf( World.Player.Backpack ) || dest.IsChildOf( World.Player.Quiver ) ) ) i.IsNew = true; if ( Config.GetBool( "QueueActions" ) ) args.Block = DragDropManager.Drop( i, dser, newPos ); }
private static void CustomHouseInfo( PacketReader p, PacketHandlerEventArgs args ) { p.ReadByte(); // compression p.ReadByte(); // Unknown Item i = World.FindItem( p.ReadUInt32() ); if ( i != null ) { i.HouseRevision = p.ReadInt32(); i.HousePacket = p.CopyBytes( 0, p.Length ); } }
private static void DeathAnimation( PacketReader p, PacketHandlerEventArgs args ) { Serial killed = p.ReadUInt32(); if ( Config.GetBool( "AutoCap" ) ) { Mobile m = World.FindMobile( killed ); if ( m != null && ( ( m.Body >= 0x0190 && m.Body <= 0x0193 ) || ( m.Body >= 0x025D && m.Body <= 0x0260 ) ) && Utility.Distance( World.Player.Position, m.Position ) <= 12 ) ScreenCapManager.DeathCapture(); } }
public static void OnSpeech(Packet pvSrc, PacketHandlerEventArgs args) { MessageType type = (MessageType)pvSrc.ReadByte(); ushort hue = pvSrc.ReadUInt16(); ushort font = pvSrc.ReadUInt16(); string lang = pvSrc.ReadString(4); string text = ""; ArrayList keys = null; long txtOffset = 0; World.Player.SpeechHue = hue; if ((type & MessageType.Encoded) != 0) { int value = pvSrc.ReadInt16(); int count = (value & 0xFFF0) >> 4; keys = new ArrayList(); keys.Add((ushort)value); for (int i = 0; i < count; ++i) { if ((i & 1) == 0) { keys.Add(pvSrc.ReadByte()); } else { keys.Add(pvSrc.ReadByte()); keys.Add(pvSrc.ReadByte()); } } txtOffset = pvSrc.Position; text = pvSrc.ReadUTF8StringSafe(); type &= ~MessageType.Encoded; } else { txtOffset = pvSrc.Position; text = pvSrc.ReadUnicodeStringSafe(); } text = text.Trim(); char commandToggle = Client.IsOSI ? '-' : '>'; if (text.Length > 0) { if (text[0] != commandToggle) { Macros.MacroManager.Action(new Macros.SpeechAction(type, hue, font, lang, keys, text)); ScriptManager.AddToScript($"msg \'{text}\'"); } else { text = text.Substring(1); string[] split = text.Split(' ', '\t'); if (m_List.ContainsKey(split[0])) { CommandCallback call = (CommandCallback)m_List[split[0]]; if (call != null) { string[] param = new String[split.Length - 1]; for (int i = 0; i < param.Length; i++) { param[i] = split[i + 1]; } call(param); args.Block = true; } } else { World.Player.SendMessage(MsgLevel.Force, "Unknown command"); } } } }
private static void TargetResponse(PacketReader p, PacketHandlerEventArgs args) { m_NoShowTarget = false; TargetInfo info = new TargetInfo { Type = p.ReadByte(), TargID = p.ReadUInt32(), Flags = p.ReadByte(), Serial = p.ReadUInt32(), X = p.ReadUInt16(), Y = p.ReadUInt16(), Z = p.ReadInt16(), Gfx = p.ReadUInt16() }; m_ClientTarget = false; if (RazorEnhanced.ScriptRecorder.OnRecord) { RazorEnhanced.ScriptRecorder.Record_Target(info); } if (info.Serial != 0 && info.Serial.IsMobile) { RazorEnhanced.Target.TargetMessage(info.Serial, false); } // check for cancel if (info.X == 0xFFFF && info.X == 0xFFFF && (info.Serial <= 0 || info.Serial >= 0x80000000)) { m_HasTarget = false; if (m_Intercept) { args.Block = true; Timer.DelayedCallbackState(TimeSpan.Zero, m_OneTimeRespCallback, info).Start(); EndIntercept(); if (m_PreviousID != 0) { m_CurrentID = m_PreviousID; m_AllowGround = m_PreviousGround; m_CurFlags = m_PrevFlags; m_PreviousID = 0; ResendTarget(); } } else if (m_FilterCancel.Contains((uint)info.TargID) || info.TargID == LocalTargID) { args.Block = true; } m_FilterCancel.Clear(); return; } ClearQueue(); if (m_Intercept) { if (info.TargID == LocalTargID) { Timer.DelayedCallbackState(TimeSpan.Zero, m_OneTimeRespCallback, info).Start(); m_HasTarget = false; args.Block = true; if (m_PreviousID != 0) { m_CurrentID = m_PreviousID; m_AllowGround = m_PreviousGround; m_CurFlags = m_PrevFlags; m_PreviousID = 0; ResendTarget(); } m_FilterCancel.Clear(); return; } else { EndIntercept(); } } m_HasTarget = false; if (CheckHealPoisonTarg(m_CurrentID, info.Serial)) { ResendTarget(); args.Block = true; } if (info.Serial != World.Player.Serial) { if (info.Serial.IsValid) { // only let lasttarget be a non-ground target m_LastTarget = info; if (info.Flags == 1) { m_LastHarmTarg = info; } else if (info.Flags == 2) { m_LastBeneTarg = info; } LastTargetChanged(); } m_LastGroundTarg = info; // ground target is the true last target } m_FilterCancel.Clear(); }
private static void NewTarget(PacketReader p, PacketHandlerEventArgs args) { bool prevAllowGround = m_AllowGround; uint prevID = m_CurrentID; byte prevFlags = m_CurFlags; bool prevClientTarget = m_ClientTarget; m_AllowGround = p.ReadBoolean(); // allow ground m_CurrentID = p.ReadUInt32(); // target uid m_CurFlags = p.ReadByte(); // flags // the rest of the packet is 0s // check for a server cancel command if (!m_AllowGround && m_CurrentID == 0 && m_CurFlags == 3) { m_HasTarget = false; m_FromGrabHotKey = false; m_ClientTarget = false; if (m_Intercept) { EndIntercept(); World.Player.SendMessage(MsgLevel.Error, LocString.OTTCancel); } return; } if (Spell.LastCastTime + TimeSpan.FromSeconds(3.0) > DateTime.UtcNow && Spell.LastCastTime + TimeSpan.FromSeconds(0.5) <= DateTime.UtcNow && m_SpellTargID == 0) { m_SpellTargID = m_CurrentID; } m_HasTarget = true; m_ClientTarget = false; if (m_QueueTarget == null && Macros.MacroManager.AcceptActions && MacroManager.Action(new WaitForTargetAction())) { args.Block = true; } else if (m_QueueTarget != null && m_QueueTarget()) { ClearQueue(); args.Block = true; } if (args.Block) { if (prevClientTarget) { m_AllowGround = prevAllowGround; m_CurrentID = prevID; m_CurFlags = prevFlags; m_ClientTarget = true; if (!m_Intercept) { CancelClientTarget(); } } } else { m_ClientTarget = true; if (m_Intercept) { if (m_OnCancel != null) { m_OnCancel(); } EndIntercept(); World.Player.SendMessage(MsgLevel.Error, LocString.OTTCancel); m_FilterCancel.Add((uint)prevID); } } }
private static void TargetResponse(PacketReader p, PacketHandlerEventArgs args) { TargetInfo info = new TargetInfo(); info.Type = p.ReadByte(); info.TargID = p.ReadUInt32(); info.Flags = p.ReadByte(); info.Serial = p.ReadUInt32(); info.X = p.ReadUInt16(); info.Y = p.ReadUInt16(); info.Z = p.ReadInt16(); info.Gfx = p.ReadUInt16(); m_ClientTarget = false; //if (Config.GetBool("ShowAttackTargetOverhead")) //{ // Mobile m = World.FindMobile(info.Serial); // if (m != null) // { // if (FriendsAgent.IsFriend(m)) // { // World.Player.OverheadMessage(63, $"Target: {m.Name}"); // } // else // { // World.Player.OverheadMessage(m.GetNotorietyColorInt(), $"Target: {m.Name}"); // } // } //} // check for cancel if (info.X == 0xFFFF && info.X == 0xFFFF && (info.Serial <= 0 || info.Serial >= 0x80000000)) { m_HasTarget = false; m_FilterCancel.Clear(); return; } ClearQueue(); m_HasTarget = false; if (info.Serial != World.Player.Serial) { if (info.Serial.IsValid) { // only let lasttarget be a non-ground target m_LastTarget = info; if (info.Flags == 1) { m_LastHarmTarg = info; } else if (info.Flags == 2) { m_LastBeneTarg = info; } LastTargetChanged(); } m_LastGroundTarg = info; // ground target is the true last target } else { } }
public static void OnSpeech( Packet pvSrc, PacketHandlerEventArgs args ) { MessageType type = (MessageType)pvSrc.ReadByte(); ushort hue = pvSrc.ReadUInt16(); ushort font = pvSrc.ReadUInt16(); string lang = pvSrc.ReadString( 4 ); string text = ""; ArrayList keys = null; long txtOffset = 0; World.Player.SpeechHue = hue; if ( (type & MessageType.Encoded) != 0 ) { int value = pvSrc.ReadInt16(); int count = (value & 0xFFF0) >> 4; keys = new ArrayList(); keys.Add( (ushort)value ); for ( int i = 0; i < count; ++i ) { if ( (i & 1) == 0 ) { keys.Add( pvSrc.ReadByte() ); } else { keys.Add( pvSrc.ReadByte() ); keys.Add( pvSrc.ReadByte() ); } } txtOffset = pvSrc.Position; text = pvSrc.ReadUTF8StringSafe(); type &= ~MessageType.Encoded; } else { txtOffset = pvSrc.Position; text = pvSrc.ReadUnicodeStringSafe(); } text = text.Trim(); if ( text.Length > 0 ) { if ( text[0] != '-' ) { if ( ClientCommunication.TranslateEnabled && text[0] != '[' && text[0] != ']' ) { StringBuilder sb = new StringBuilder( 512 ); uint outLen = 512; ClientCommunication.TranslateDo( text, sb, ref outLen ); text = sb.ToString(); pvSrc.Seek( txtOffset, System.IO.SeekOrigin.Begin ); if ( keys != null && keys.Count > 0 ) pvSrc.WriteUTF8Null( text ); else pvSrc.WriteBigUniNull( text ); pvSrc.UnderlyingStream.SetLength( pvSrc.Position ); } Macros.MacroManager.Action( new Macros.SpeechAction( type, hue, font, lang, keys, text ) ); } else { text = text.Substring( 1 ); string[] split = text.Split( ' ', '\t' ); CommandCallback call = (CommandCallback)m_List[split[0]]; if ( call != null ) { string[] param = new String[split.Length-1]; for(int i=0;i<param.Length;i++) param[i] = split[i+1]; call( param ); args.Block = true; } } } }
private static void ExtendedClientCommand( Packet p, PacketHandlerEventArgs args ) { ushort ext = p.ReadUInt16(); switch ( ext ) { case 0x10: // query object properties { break; } case 0x15: // context menu response { UOEntity ent = null; Serial ser = p.ReadUInt32(); ushort idx = p.ReadUInt16(); if ( ser.IsMobile ) ent = World.FindMobile( ser ); else if ( ser.IsItem ) ent = World.FindItem( ser ); if ( ent != null && ent.ContextMenu != null && ent.ContextMenu.ContainsKey( idx ) ) { ushort menu = (ushort)ent.ContextMenu[idx]; if ( menu != 0 && MacroManager.AcceptActions ) MacroManager.Action( new ContextMenuAction( ent, idx, menu ) ); } break; } case 0x1C:// cast spell { Serial ser = Serial.MinusOne; if ( p.ReadUInt16() == 1 ) ser = p.ReadUInt32(); ushort sid = p.ReadUInt16(); Spell s = Spell.Get( sid ); if ( s != null ) { s.OnCast( p ); args.Block = true; if ( Macros.MacroManager.AcceptActions ) MacroManager.Action( new ExtCastSpellAction( s, ser ) ); } break; } case 0x24: { // for the cheatx0r part 2... anything outside this range indicates some haxing, just hide it with 0x30s byte b = p.ReadByte(); if ( b < 0x25 || b >= 0x5E+0x25 ) { p.Seek( -1, SeekOrigin.Current ); p.Write( (byte)0x30 ); } //using ( StreamWriter w = new StreamWriter( "bf24.txt", true ) ) // w.WriteLine( "{0} : 0x{1:X2}", DateTime.Now.ToString( "HH:mm:ss.ffff" ), b ); break; } } }
internal static void OnSpeech(Packet pvSrc, PacketHandlerEventArgs args) { MessageType type = (MessageType)pvSrc.ReadByte(); ushort hue = pvSrc.ReadUInt16(); ushort font = pvSrc.ReadUInt16(); string lang = pvSrc.ReadString(4); string text = ""; List <ushort> keys = null; long txtOffset = 0; World.Player.SpeechHue = hue; if ((type & MessageType.Encoded) != 0) { int value = pvSrc.ReadInt16(); int count = (value & 0xFFF0) >> 4; keys = new List <ushort> { (ushort)value }; for (int i = 0; i < count; ++i) { if ((i & 1) == 0) { keys.Add(pvSrc.ReadByte()); } else { keys.Add(pvSrc.ReadByte()); keys.Add(pvSrc.ReadByte()); } } txtOffset = pvSrc.Position; text = pvSrc.ReadUTF8StringSafe(); type &= ~MessageType.Encoded; } else { txtOffset = pvSrc.Position; text = pvSrc.ReadUnicodeStringSafe(); } if (RazorEnhanced.ScriptRecorder.OnRecord) { RazorEnhanced.ScriptRecorder.Record_UnicodeSpeech(type, text, hue); } text = text.Trim(); if (text.Length <= 1) { return; } { if (text[0] == '-' && text[1] != '-') { text = text.Substring(1).ToLower(); string[] split = text.Split(' ', '\t'); if (m_List.ContainsKey(split[0])) { CommandCallback call = (CommandCallback)m_List[split[0]]; if (call != null) { string[] param = new String[split.Length - 1]; for (int i = 0; i < param.Length; i++) { param[i] = split[i + 1]; } call(param); args.Block = true; } } } else if (text[0] == '-' && text[1] == '-') { args.Block = true; Assistant.UOAssist.PostTextSend(text.Substring(2)); } } }
private static void ExtendedPacket( PacketReader p, PacketHandlerEventArgs args ) { ushort type = p.ReadUInt16(); switch ( type ) { case 0x04: // close gump { // int serial, int tid if ( World.Player != null ) World.Player.HasGump = false; break; } case 0x06: // party messages { OnPartyMessage( p, args ); break; } case 0x08: // map change { if ( World.Player != null ) World.Player.Map = p.ReadByte(); break; } case 0x14: // context menu { p.ReadInt16(); // 0x01 UOEntity ent = null; Serial ser = p.ReadUInt32(); if ( ser.IsMobile ) ent = World.FindMobile( ser ); else if ( ser.IsItem ) ent = World.FindItem( ser ); if ( ent != null ) { byte count = p.ReadByte(); try { ent.ContextMenu.Clear(); for(int i=0;i<count;i++) { ushort idx = p.ReadUInt16(); ushort num = p.ReadUInt16(); ushort flags = p.ReadUInt16(); ushort color = 0; if ( (flags&0x02) != 0 ) color = p.ReadUInt16(); ent.ContextMenu.Add( idx, num ); } } catch { } } break; } case 0x18: // map patches { if ( World.Player != null ) { int count = p.ReadInt32() * 2; try { World.Player.MapPatches = new int[count]; for(int i=0;i<count;i++) World.Player.MapPatches[i] = p.ReadInt32(); } catch { } } break; } case 0x19: // stat locks { if ( p.ReadByte() == 0x02 ) { Mobile m = World.FindMobile( p.ReadUInt32() ); if ( World.Player == m && m != null ) { p.ReadByte();// 0? byte locks = p.ReadByte(); World.Player.StrLock = (LockType)((locks>>4) & 3); World.Player.DexLock = (LockType)((locks>>2) & 3); World.Player.IntLock = (LockType)(locks & 3); } } break; } case 0x1D: // Custom House "General Info" { Item i = World.FindItem( p.ReadUInt32() ); if ( i != null ) i.HouseRevision = p.ReadInt32(); break; } } }
private static void TargetResponse(PacketReader p, PacketHandlerEventArgs args) { TargetInfo info = new TargetInfo { Type = p.ReadByte(), TargID = p.ReadUInt32(), Flags = p.ReadByte(), Serial = p.ReadUInt32(), X = p.ReadUInt16(), Y = p.ReadUInt16(), Z = p.ReadInt16(), Gfx = p.ReadUInt16() }; m_ClientTarget = false; OverheadTargetMessage(info); // check for cancel if (info.X == 0xFFFF && info.X == 0xFFFF && (info.Serial <= 0 || info.Serial >= 0x80000000)) { m_HasTarget = false; m_FromGrabHotKey = false; if (m_Intercept) { args.Block = true; Timer.DelayedCallbackState(TimeSpan.Zero, m_OneTimeRespCallback, info).Start(); EndIntercept(); if (m_PreviousID != 0) { m_CurrentID = m_PreviousID; m_AllowGround = m_PreviousGround; m_CurFlags = m_PrevFlags; m_PreviousID = 0; ResendTarget(); } } else if (m_FilterCancel.Contains((uint)info.TargID) || info.TargID == LocalTargID) { args.Block = true; } m_FilterCancel.Clear(); return; } ClearQueue(); if (m_Intercept) { if (info.TargID == LocalTargID) { Timer.DelayedCallbackState(TimeSpan.Zero, m_OneTimeRespCallback, info).Start(); m_HasTarget = false; m_FromGrabHotKey = false; args.Block = true; if (m_PreviousID != 0) { m_CurrentID = m_PreviousID; m_AllowGround = m_PreviousGround; m_CurFlags = m_PrevFlags; m_PreviousID = 0; ResendTarget(); } m_FilterCancel.Clear(); return; } else { EndIntercept(); } } m_HasTarget = false; if (CheckHealPoisonTarg(m_CurrentID, info.Serial)) { ResendTarget(); args.Block = true; } if (info.Serial != World.Player.Serial) { if (info.Serial.IsValid) { // only let lasttarget be a non-ground target m_LastTarget = info; if (info.Flags == 1) { m_LastHarmTarg = info; } else if (info.Flags == 2) { m_LastBeneTarg = info; } LastTargetChanged(); LastBeneficialTargetChanged(); LastHarmfulTargetChanged(); } m_LastGroundTarg = info; // ground target is the true last target if (Macros.MacroManager.AcceptActions) { MacroManager.Action(new AbsoluteTargetAction(info)); } } else { if (Macros.MacroManager.AcceptActions) { KeyData hk = HotKey.Get((int)LocString.TargetSelf); if (hk != null) { MacroManager.Action(new HotKeyAction(hk)); } else { MacroManager.Action(new AbsoluteTargetAction(info)); } } } if (World.Player.LastSpell == 52 && !GateTimer.Running) { GateTimer.Start(); } m_FilterCancel.Clear(); }
internal static void OnSpeech(Packet pvSrc, PacketHandlerEventArgs args) { MessageType type = (MessageType)pvSrc.ReadByte(); ushort hue = pvSrc.ReadUInt16(); ushort font = pvSrc.ReadUInt16(); string lang = pvSrc.ReadString(4); World.Player.SpeechHue = hue; string text; long txtOffset; if ((type & MessageType.Encoded) != 0) { int value = pvSrc.ReadInt16(); int count = (value & 0xFFF0) >> 4; List <ushort> keys = new List <ushort> { (ushort)value }; for (int i = 0; i < count; ++i) { if ((i & 1) == 0) { keys.Add(pvSrc.ReadByte()); } else { keys.Add(pvSrc.ReadByte()); keys.Add(pvSrc.ReadByte()); } } txtOffset = pvSrc.Position; text = pvSrc.ReadUTF8StringSafe(); type &= ~MessageType.Encoded; } else { txtOffset = pvSrc.Position; text = pvSrc.ReadUnicodeStringSafe(); } if (RazorEnhanced.ScriptRecorder.OnRecord) { RazorEnhanced.ScriptRecorder.Record_UnicodeSpeech(type, text, hue); } text = text.Trim(); if (text.Length <= 1) { return; } if (Client.IsOSI) { if (text[0] == '-' && text[1] != '-') { args.Block = ExecCommand(text); } else if (text[0] == '-' && text[1] == '-') { args.Block = true; Assistant.UOAssist.PostTextSend(text.Substring(2)); } } else { if (text[0] == '<') { args.Block = ExecCommand(text); } } }
public static void OnSpeech(Packet pvSrc, PacketHandlerEventArgs args) { MessageType type = (MessageType)pvSrc.ReadByte(); ushort hue = pvSrc.ReadUInt16(); ushort font = pvSrc.ReadUInt16(); string lang = pvSrc.ReadString(4); string text = ""; ArrayList keys = null; long txtOffset = 0; World.Player.SpeechHue = hue; if ((type & MessageType.Encoded) != 0) { int value = pvSrc.ReadInt16(); int count = (value & 0xFFF0) >> 4; keys = new ArrayList(); keys.Add((ushort)value); for (int i = 0; i < count; ++i) { if ((i & 1) == 0) { keys.Add(pvSrc.ReadByte()); } else { keys.Add(pvSrc.ReadByte()); keys.Add(pvSrc.ReadByte()); } } txtOffset = pvSrc.Position; text = pvSrc.ReadUTF8StringSafe(); type &= ~MessageType.Encoded; } else { txtOffset = pvSrc.Position; text = pvSrc.ReadUnicodeStringSafe(); } text = text.Trim(); if (text.Length > 0) { if (text[0] != '-') { if (ClientCommunication.TranslateEnabled && text[0] != '[' && text[0] != ']') { StringBuilder sb = new StringBuilder(512); uint outLen = 512; ClientCommunication.TranslateDo(text, sb, ref outLen); text = sb.ToString(); pvSrc.Seek(txtOffset, System.IO.SeekOrigin.Begin); if (keys != null && keys.Count > 0) { pvSrc.WriteUTF8Null(text); } else { pvSrc.WriteBigUniNull(text); } pvSrc.UnderlyingStream.SetLength(pvSrc.Position); } Macros.MacroManager.Action(new Macros.SpeechAction(type, hue, font, lang, keys, text)); } else { text = text.Substring(1); string[] split = text.Split(' ', '\t'); CommandCallback call = (CommandCallback)m_List[split[0]]; if (call != null) { string[] param = new String[split.Length - 1]; for (int i = 0; i < param.Length; i++) { param[i] = split[i + 1]; } call(param); args.Block = true; } } } }