private static void WorldItem(PacketReader p, PacketHandlerEventArgs args) { Item item = World.FindItem(p.ReadUInt32() & 0x7FFFFFFF); if (item == null || item.ItemID != 0x2006 || item.DistanceTo(World.Player) > 2 || items.Find(c => c.ItemID == item.Amount) == null) { return; } Item carver = World.FindItem(ConfigEx.GetElement <uint>(0, "BoneCarver")); carved.RemoveAll(i => !World.Items.ContainsKey(i)); if (carver != null && !carved.Contains(item.Serial)) { Targeting.CancelTarget(); Targeting.QueuedTarget = () => { Targeting.Target(item); carved.Add(item.Serial); return(true); }; WorldEx.SendToServer(new DoubleClick(carver.Serial)); } }
private static void Info(bool location, Serial serial, Point3D p, ushort gfxid) { StringBuilder str = new StringBuilder(); UOEntity entity = WorldEx.GetEntity(serial); if (entity == null) { return; } str.AppendLine("Serial: " + serial); str.AppendLine("Graphic: 0x" + gfxid.ToString("X4")); str.AppendLine("Color: 0x" + entity.Hue.ToString("X4")); str.AppendLine("Position: " + entity.Position); str.AppendLine("Distance: " + Utility.Distance(entity.Position, World.Player.Position)); str.AppendLine(); foreach (PropertyInfo property in entity.GetType().GetProperties()) { str.AppendLine(string.Format("{0}: {1}\n", property.Name, property.GetValue(entity, null))); } new MessageDialog("Info", str.ToString()) { TopMost = true }.Show(Engine.MainWindow); }
private void addTarget(bool location, Serial serial, Point3D p, ushort gfxid) { Mobile mobile = World.FindMobile(serial); if (mobile != null && !string.IsNullOrEmpty(mobile.Name)) { CorpseItem corpse = new CorpseItem(mobile.Body, mobile.Name); if (items.Find(c => c.ItemID == corpse.ItemID) == null) { items.Add(corpse); listBox.Items.Add(corpse); XElement parent = ConfigEx.GetXElement(true, "Carving"); parent.RemoveAll(); parent.SetAttributeValue("enabled", enabled); foreach (CorpseItem item in items) { parent.Add(new XElement("Corpse", new XAttribute("itemID", item.ItemID.Value.ToString("X4")), item.Name)); } } } else { WorldEx.SendMessage("Invalid target"); } }
private static void OnCommand(string[] args) { foreach (Item item in WorldEx.FindItemsG(0x2006, i => i.Amount == 0x0096 || i.Amount == 0x004D || (i.Hue == 0 && i.Amount == 0x0010))) { WorldEx.SendToClient(new RemoveObject(item)); } }
private static void OnCompressedGump(PacketReader p, PacketHandlerEventArgs e) { p.Seek(7, SeekOrigin.Begin); if (p.ReadUInt32() != 0x776CCCC1) { return; } p.Seek(19, SeekOrigin.Begin); p.Seek(p.ReadInt32(), SeekOrigin.Current); int lines = p.ReadInt32(), cLen = p.ReadInt32(), dLen = p.ReadInt32(); byte[] buffer = new byte[dLen]; ZLib.uncompress(buffer, ref dLen, p.CopyBytes(p.Position, cLen - 4), cLen - 4); 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); if (str.Trim() == "a sea horse") { WorldEx.SendMessage("Sea Horse!!! " + World.Player.Position); } pos += strLen * 2; } }
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 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 CancelArrow(PacketReader p, PacketHandlerEventArgs args) { if (p.Length == 6 && p.ReadUInt16() == 0x7 && p.ReadByte() == 1) { WorldEx.SendToClient(new QuestArrow(false, ushort.MaxValue, ushort.MaxValue)); } }
private static void OnCommand(string[] args) { bool enabled = !ConfigEx.GetElement(false, "AutoGrab"); ConfigEx.SetElement(enabled, "AutoGrab"); WorldEx.SendMessage("Autograb " + (enabled ? "enabled." : "disabled.")); OnChange(enabled); }
private static void OnCommand(string[] args) { bool enabled = !ConfigEx.GetElement(false, "BlockFriendlyFire"); ConfigEx.SetElement(enabled, "BlockFriendlyFire"); WorldEx.SendMessage("Friendly fire " + (enabled ? "blocked." : "allowed.")); OnChange(enabled); }
private static void UseKey() { lock (list) { Item item = World.Player.Backpack.FindItem(i => IsKey(i) && !IsLockpick(i) && !list.Contains(i.Serial)); if (item == null && list.Count > 0) { list.Clear(); item = World.Player.Backpack.FindItem(i => IsKey(i) && !IsLockpick(i) && !list.Contains(i.Serial)); } if (item == null) { item = World.Player.Backpack.FindItem(i => IsKey(i) && !list.Contains(i.Serial)); } if (item != null) { door = WorldEx.FindItem(i => i.IsDoor && i.DistanceTo(World.Player) <= 1); if (door != null) { timer.Start(); } else { Item item2 = WorldEx.FindItemsG(i => IsSwitch(i) && i.DistanceTo(World.Player) < 3) .OrderBy(i => Utility.DistanceSqrt(i.Position, World.Player.Position)) .FirstOrDefault(); if (item2 != null) { item = item2; } } if (!IsSwitch(item)) { list.Add(item.Serial); list.RemoveAll(i => !World.Items.ContainsKey(i)); } WorldEx.SendToServer(new DoubleClick(item.Serial)); } else { item = WorldEx.FindItemsG(i => IsSwitch(i) && i.DistanceTo(World.Player) < 3) .OrderBy(i => Utility.DistanceSqrt(i.Position, World.Player.Position)) .FirstOrDefault(); if (item != null) { WorldEx.SendToServer(new DoubleClick(item.Serial)); } else { WorldEx.SendMessage("No key found."); } } } }
public override bool PerformWait() { if (Utility.Distance(position, World.Player.Position) < 5) { return(true); } WorldEx.SendToServer(stop); return(false); }
private static void WeaponAbilities_WeaponSwitched() { WorldEx.SendToClient(new ClearAbility()); if ((int)Current > 2) { new ExtCastSpellAction((int)Current, Serial.Zero).Perform(); } Current = MoveType.None; }
private static void UseItem(ItemID itemID, ushort hue) { Item item = World.Player.Backpack.FindItem(itemID, hue); if (item != null) { WorldEx.SendToServer(new DoubleClick(item.Serial)); } }
private static void Event_PlayerMoved() { foreach (Item item in WorldEx.FindItems(i => i.ItemID == 0x2006 && i.DistanceTo(World.Player) < 3 && !list.Contains(i.Serial))) { list.Add(item.Serial); list.RemoveAll(i => !World.Items.ContainsKey(i)); WorldEx.SendToServer(new DoubleClick(item.Serial)); } }
private static void OnGet(string[] args) { bool felucca; int count; try { felucca = Convert.ToBoolean(byte.Parse(args[0])); count = byte.Parse(args[1]); } catch { return; } Serial closest = Serial.Zero; foreach (KeyValuePair <Serial, SOSInfo> sos in list) { if (sos.Value.Felucca == felucca && (!list.ContainsKey(closest) || sos.Value.Distance() < list[closest].Distance())) { closest = sos.Key; } } if (!list.ContainsKey(closest)) { return; } List <Serial> chosen = new List <Serial> { closest }; List <Serial> toAdd = GetInRange(list[closest].Location, felucca).Where(s => !chosen.Contains(s)).ToList(); while (toAdd.Count > 0) { chosen.AddRange(toAdd); toAdd.Clear(); foreach (Serial serial in chosen) { toAdd.AddRange(GetInRange(list[serial].Location, felucca).Where(s => !chosen.Contains(s) && !toAdd.Contains(s))); } } while (chosen.Count > count) { Serial farest = Serial.Zero; foreach (Serial serial in chosen) { if (!list.ContainsKey(farest) || list[closest].Distance(list[farest].Location) < list[serial].Distance(list[farest].Location)) { farest = serial; } } chosen.Remove(farest); } chosen.ForEach(s => DragDrop.Move(World.FindItem(s), Fixes.LootBag.Bag)); WorldEx.SendMessage(chosen.Count + " SOS messages found."); }
private static void OnTimer() { timer = null; if (currentSerial.IsValid && currentDmg > 0) { WorldEx.SendToClient(new Damage(currentSerial, currentDmg)); } currentSerial = currentDmg = 0; }
public override bool Perform() { if (wait.Last != 503172) { return(true); } position = World.Player.Position; WorldEx.SendToServer(forward); return(!PerformWait()); }
public override bool Perform() { Mobile closest = TargetingEx.GetClosest(3, 4); if (closest != null) { WorldEx.SendToServer(new AttackReq(closest.Serial)); } return(true); }
private static void Morph(string[] args) { ushort body; if (args.Length > 0 && ushort.TryParse(args[0], out body)) { World.Player.Body = body; WorldEx.SendToClient(new MobileUpdate(World.Player)); } }
private static void OnAttack(PacketReader p, PacketHandlerEventArgs args) { Mobile mobile = World.FindMobile(p.ReadUInt32()); if (mobile != null && (FriendsAgent.IsFriend(mobile) || mobile.Notoriety == 1 || mobile.Notoriety == 2 || mobile.Renamable)) { WorldEx.SendMessage("Attack blocked."); args.Block = true; } }
private static void OnCommand(string[] args) { try { new SpellIcon(int.Parse(args[0]) == 100 ? new Spell((char)Spell.SpellFlag.None, int.Parse(args[1]), 100, null, null) : Spell.Get(int.Parse(args[0]), int.Parse(args[1]))).ShowUnlocked(); } catch (Exception) { WorldEx.SendMessage("Invalid spell!"); } }
public override bool Perform() { Item item = World.FindItem(ConfigEx.GetElement <uint>(0, "BoneCarver")); if (item != null) { Targeting.CancelTarget(); WorldEx.SendToServer(new DoubleClick(item.Serial)); } return(true); }
private static void OnCommand() { if (responseID != 0) { ClientCommunication.SendToClient(new CloseGump(gumpID)); WorldEx.SendToServer(new GumpResponse(responseID, gumpID, 2, new int[0], new GumpTextEntry[0])); } else { WorldEx.SendMessage("You are not wielding the Spectral Scimitar!"); } }
private static void OnTarget(PacketReader p, PacketHandlerEventArgs args) { if (door != null) { WorldEx.SendToServer(new TargetResponse(new TargetInfo { Serial = door.Serial, X = door.Position.X, Y = door.Position.Y, Z = door.Position.Z, Gfx = door.ItemID })); WorldEx.SendToServer(new DoubleClick(door.Serial)); args.Block = true; } door = null; }
private static void OnCommand() { if (timer.Running) { WorldEx.SendToClient(new ToggleMove(403, false)); timer.Stop(); } else { timer.Start(); } }
private StatusBar(Serial serial) { this.serial = serial; table.Padding = new Padding(3); table.Controls.Add(barHP = new Bar(Color.Red)); if (serial == Serial.MinusOne || PacketHandlers.Party.Contains(serial)) { table.Controls.Add(barMana = new Bar(Color.Blue)); table.Controls.Add(barStamina = new Bar(Color.DarkGoldenrod)); if (PacketHandlers.Party.Contains(serial)) { barMana.Text = barStamina.Text = "-"; } } if (serial == Serial.MinusOne) { if (ConfigEx.GetAttribute(false, "ex", "Status")) { table.ColumnCount = 2; table.Controls.Add(labelFoll = new LabelEx("-", margin: 0) { ForeColor = Color.White }); table.Controls.Add(labelWeight = new LabelEx("-", margin: 0) { ForeColor = Color.White }); table.Controls.Add(labelBands = new LabelEx("-", margin: 0) { ForeColor = Color.White }); table.Controls.SetChildIndex(labelFoll, 1); table.Controls.SetChildIndex(labelWeight, 3); table.Controls.SetChildIndex(labelBands, 5); Bandages.Changed += Bandages_Changed; } ConfigEx.SetAttribute(true, "enabled", "Status"); BackColor = Color.Purple; Location = new Point(ConfigEx.GetAttribute(Location.X, "locX", "Status"), ConfigEx.GetAttribute(Location.Y, "locY", "Status")); UpdateStats(); } else { Mobile mobile = World.FindMobile(serial); if (mobile != null) { WorldEx.SendToServer(new StatusQuery(mobile)); } } Event.MobileUpdated += WorldEx_MobileUpdated; }
private static void ContainerContentUpdate(PacketReader p, PacketHandlerEventArgs args) { Serial serial = p.ReadUInt32(); p.ReadUInt16(); p.Seek(7, SeekOrigin.Current); Serial container = p.ReadUInt32(); if (container == World.Player.Backpack.Serial && serial == lastSerial && (Environment.TickCount - lastTime) < 5000) { Timer.DelayedCallback(TimeSpan.FromSeconds(0.5), () => WorldEx.SendToServer(new DoubleClick(serial))).Start(); } }
private static void Drink() { Item item = !PositionCheck.InKhaldun && !PositionCheck.InFire && !PositionCheck.InWisp ? World.Player.Backpack.FindItem(0x0F06, 0x000C) : WorldEx.FindItemG(0x37B9, 0x098F, i => i.DistanceTo(World.Player) <= GetOrbDistance() + 1) ?? WorldEx.FindItemG(0x3728, 0x0A58, i => i.DistanceTo(World.Player) <= GetOrbDistance() + 1) ?? World.Player.Backpack.FindItem((ItemID)(World.Player.Poisoned ? 0x0F07 : 0x0F0C), 0x0000); if (item != null) { WorldEx.SendToServer(new DoubleClick(item.Serial)); } }
protected override void OnTick() { if (World.Player.IsGhost || !World.Player.Visible) { WorldEx.SendToClient(new ToggleMove(403, false)); Stop(); } else if (!enabled || i++ > 5) { WorldEx.SendToServer(new CastSpellFromMacro(403)); i = 0; } }