public override void UpdateTitleBar() { if (!ClientRunning) { return; } if (World.Player != null && Config.GetBool("TitleBarDisplay")) { ResetTitleBarBuilder(); TitleBarBuilder.Replace(@"{char}", World.Player.Name); TitleBarBuilder.Replace(@"{crimtime}", World.Player.CriminalTime != 0 ? $"{World.Player.CriminalTime}" : "-"); TitleBarBuilder.Replace(@"{hp}", $"{World.Player.Hits}"); TitleBarBuilder.Replace(@"{mana}", $"{World.Player.Mana}"); TitleBarBuilder.Replace(@"{stam}", $"{World.Player.Stam}"); TitleBarBuilder.Replace(@"{weight}", World.Player.Weight.ToString()); TitleBarBuilder.Replace(@"{bandage}", BandageTimer.Running ? $"{BandageTimer.Count}" : "-"); TitleBarBuilder.Replace(@"{statbar}", string.Empty); TitleBarBuilder.Replace(@"{mediumstatbar}", string.Empty); TitleBarBuilder.Replace(@"{largestatbar}", string.Empty); foreach (Counter c in Counter.List) { if (c.Enabled) { TitleBarBuilder.Replace($"{{{c.Format}}}", c.GetTitlebarString(false, false)); } } base.UpdateTitleBar(); } else { SetTitleStr(string.Empty); } }
public static void OnLocalizedMessage(int num) { if (Running) { if (num == 500955 || (num >= 500962 && num <= 500969) || (num >= 503252 && num <= 503261) || num == 1010058 || num == 1010648 || num == 1010650 || num == 1060088 || num == 1060167) { Stop(); if (Config.GetBool("ShowBandageTimer") && Config.GetBool("ShowBandageEnd")) { ShowBandagingStatusMessage(Config.GetString("BandageEndMessage")); } return; } // Check if they are re-healing before the timer ends if (num == 500956) { Start(); if (Config.GetBool("ShowBandageTimer") && Config.GetBool("ShowBandageStart")) { ShowBandagingStatusMessage(Config.GetString("BandageStartMessage")); } } } else { // Start timer as soon as there is the "You begin applying the bandages." message if (num == 500956) { Start(); if (Config.GetBool("ShowBandageTimer") && Config.GetBool("ShowBandageStart")) { ShowBandagingStatusMessage(Config.GetString("BandageStartMessage")); } } } }
public void AutoStackResource() { if (!IsResource || !Config.GetBool("AutoStack") || m_AutoStackCache.Contains(Serial)) { return; } foreach (Item check in World.Items.Values) { if (check.Container == null && check.ItemID == ItemID && check.Hue == Hue && Utility.InRange(World.Player.Position, check.Position, 2)) { DragDropManager.DragDrop(this, check); m_AutoStackCache.Add(Serial); return; } } DragDropManager.DragDrop(this, World.Player.Position); m_AutoStackCache.Add(Serial); }
internal void OverheadMessageFrom(int hue, string from, string text, bool ascii) { if (Config.GetBool("FilterOverheadMessages")) { if (!MessageQueue.Enqueue(this, hue, "O", text)) { return; } } if (ascii) { Client.Instance.SendToClient(new AsciiMessage(Serial, m_Body, MessageType.Regular, hue, 3, from, text)); } else { Client.Instance.SendToClient(new UnicodeMessage(Serial, m_Body, MessageType.Regular, hue, 3, Language.CliLocName, from, text)); } }
internal void SendMessage(MsgLevel lvl, string text) { if (lvl >= (MsgLevel)Config.GetInt("MessageLevel") && text.Length > 0) { int hue; switch (lvl) { case MsgLevel.Error: case MsgLevel.Warning: hue = Config.GetInt("WarningColor"); break; case MsgLevel.Friend: hue = Config.GetInt("FriendOverheadFormatHue"); break; default: hue = Config.GetInt("SysColor"); break; } PacketHandlers.SysMessages.Add(text); if (PacketHandlers.SysMessages.Count >= 25) { PacketHandlers.SysMessages.RemoveRange(0, 10); } if (Config.GetBool("FilterRazorMessages")) { if (!MessageQueue.Enqueue(0xFFFFFFFF, null, 0, MessageType.Regular, (ushort)hue, 3, Language.CliLocName, "System", text)) { return; } } Client.Instance.SendToClient(new UnicodeMessage(0xFFFFFFFF, -1, MessageType.Regular, hue, 3, Language.CliLocName, "System", text)); } }
public static void UpdateFlip() { bool h = Config.GetBool("FlipVidH"), v = Config.GetBool("FlipVidV"); if (!h && !v) { m_Flip = RotateFlipType.RotateNoneFlipNone; } else if (h && !v) { m_Flip = RotateFlipType.RotateNoneFlipX; } else if (!h && v) { m_Flip = RotateFlipType.RotateNoneFlipY; } else //if ( h && v ) { m_Flip = RotateFlipType.RotateNoneFlipXY; } }
public static void LastTarget(bool forceQ) { //if ( Macros.MacroManager.AcceptActions ) // MacroManager.Action( new LastTargetAction() ); if (m_HasTarget) { if (!DoLastTarget()) { ResendTarget(); } } else if (forceQ || Config.GetBool("QueueTargets")) { if (!forceQ) { World.Player.OverheadMessage(LocString.QueuedLT); } m_QueueTarget = LastTargetAction; } }
public static void CheckLastTargetRange(Mobile m) { if (World.Player == null) { return; } if (m_HasTarget && m != null && m_LastTarget != null && m.Serial == m_LastTarget.Serial && m_QueueTarget == LastTargetAction) { if (Config.GetBool("RangeCheckLT") && ClientCommunication.AllowBit(FeatureBit.RangeCheckLT)) { if (Utility.InRange(World.Player.Position, m.Position, Config.GetInt("LTRange"))) { if (m_QueueTarget()) { ClearQueue(); } } } } }
public static void CheckTextFlags(Mobile m) { if (Config.GetBool("SmartLastTarget") && ClientCommunication.AllowBit(FeatureBit.SmartLT)) { bool harm = m_LastHarmTarg != null && m_LastHarmTarg.Serial == m.Serial; bool bene = m_LastBeneTarg != null && m_LastBeneTarg.Serial == m.Serial; if (harm) { m.OverheadMessage(0x90, String.Format("[{0}]", Language.GetString(LocString.HarmfulTarget))); } if (bene) { m.OverheadMessage(0x3F, String.Format("[{0}]", Language.GetString(LocString.BeneficialTarget))); } } if (m_LastTarget != null && m_LastTarget.Serial == m.Serial) { m.OverheadMessage(0x3B2, String.Format("[{0}]", Language.GetString(LocString.LastTarget))); } }
private void AutoOpenDoors(bool onDirChange) { if (!Visible && !Config.GetBool("AutoOpenDoorWhenHidden")) { return; } if (Body != 0x03DB && !IsGhost && ((int)(Direction & Direction.Mask)) % 2 == 0 && Config.GetBool("AutoOpenDoors") && Client.Instance.AllowBit(FeatureBit.AutoOpenDoors)) { int x = Position.X, y = Position.Y, z = Position.Z; /* Check if one more tile in the direction we just moved is a door */ Utility.Offset(Direction, ref x, ref y); if (World.Items.Values.Any(s => s.IsDoor && s.Position.X == x && s.Position.Y == y && s.Position.Z - 15 <= z && s.Position.Z + 15 >= z)) { if (Client.IsOSI) { Client.Instance.SendToServer(new OpenDoorMacro()); } else { // ClassicUO requires a slight pause before attempting to // open a door after a direction change if (onDirChange) { _doorTimer.Start(); } else { Client.Instance.SendToServer(new OpenDoorMacro()); } } } } }
private void AutoOpenDoors() { if (Body != 0x03DB && !IsGhost && ((int)(Direction & Direction.Mask)) % 2 == 0 && Config.GetBool("AutoOpenDoors")) { int x = Position.X, y = Position.Y, z = Position.Z; /* Check if one more tile in the direction we just moved is a door */ Utility.Offset(Direction, ref x, ref y); foreach (Item i in World.Items.Values) { if (i.IsDoor && i.Position.X == x && i.Position.Y == y && i.Position.Z - 15 <= z && i.Position.Z + 15 >= z) { ClientCommunication.SendToServer(new OpenDoorMacro()); break; } } } }
public static bool IsLastTarget(Mobile m) { if (m != null) { if (Config.GetBool("SmartLastTarget")) { if (m_LastHarmTarg != null && m_LastHarmTarg.Serial == m.Serial) { return(true); } } else { if (m_LastTarget != null && m_LastTarget.Serial == m.Serial) { return(true); } } } return(false); }
private static bool CheckHealPoisonTarg(uint targID, Serial ser) { if (World.Player == null) { return(false); } if (targID == m_SpellTargID && ser.IsMobile && (World.Player.LastSpell == Spell.ToID(1, 4) || World.Player.LastSpell == Spell.ToID(4, 5)) && Config.GetBool("BlockHealPoison") && Client.Instance.AllowBit(FeatureBit.BlockHealPoisoned)) { Mobile m = World.FindMobile(ser); if (m != null && m.Poisoned) { World.Player.SendMessage(MsgLevel.Warning, LocString.HealPoisonBlocked); return(true); } } return(false); }
public static bool IsLastTarget(Mobile m) { if (m != null) { if (Config.GetBool("SmartLastTarget") && Client.Instance.AllowBit(FeatureBit.SmartLT)) { if (m_LastHarmTarg != null && m_LastHarmTarg.Serial == m.Serial) { return(true); } } else { if (m_LastTarget != null && m_LastTarget.Serial == m.Serial) { return(true); } } } return(false); }
public static void TargetSelf(bool forceQ) { if (World.Player == null) { return; } //if ( Macros.MacroManager.AcceptActions ) // MacroManager.Action( new TargetSelfAction() ); if (m_HasTarget) { if (!DoTargetSelf()) { ResendTarget(); } } else if (forceQ || Config.GetBool("QueueTargets")) { m_QueueTarget = TargetSelfAction; } }
protected override void OnTick() { Client.Instance.RequestTitlebarUpdate(); if (!Config.GetBool("BuffDebuffEveryXSeconds") || !Config.GetBool("ShowBuffDebuffOverhead")) { return; } foreach (BuffsDebuffs buffsDebuff in World.Player.BuffsDebuffs) { TimeSpan diff = DateTime.UtcNow - buffsDebuff.Timestamp; int timeLeft = buffsDebuff.Duration - (int)diff.TotalSeconds; if (!IsFiltered(buffsDebuff.ClilocMessage1) && timeLeft % Config.GetInt("BuffDebuffSeconds") == 0) { World.Player.OverheadMessage(Config.GetInt("BuffHue"), Config.GetString("BuffDebuffFormat").Replace("{action}", string.Empty) .Replace("{name}", buffsDebuff.ClilocMessage1) .Replace("{duration}", timeLeft.ToString())); } } }
public string GetTitlebarString(bool dispImg, bool dispColor) { StringBuilder sb = new StringBuilder(); if (dispImg) { sb.AppendFormat("~I{0:X4}", m_ItemID); if (m_Hue > 0 && m_Hue < 0xFFFF) { sb.Append(m_Hue.ToString("X4")); } else { sb.Append('~'); } sb.Append(": "); } if (!dispColor) { sb.Append(m_Count.ToString()); } else if (m_Flag && Config.GetBool("HighlightReagents")) { sb.AppendFormat("~^C00000{0}~#~", m_Count); } else if (m_Count == 0 || m_Count < Config.GetInt("CounterWarnAmount")) { sb.AppendFormat("~#FF0000{0}~#~", m_Count); } else { sb.Append(m_Count.ToString()); } return(sb.ToString()); }
public static void FullRecount() { Reset(); if (World.Player != null) { SupressWarnings = true; if (World.Player.Backpack != null) { while (World.Player.Backpack.Contains.Count > 0) { ((Item)World.Player.Backpack.Contains[0]).Remove(); } PacketHandlers.IgnoreGumps.Add(World.Player.Backpack); PlayerData.DoubleClick(World.Player.Backpack); } if (World.Player.Quiver != null) { while (World.Player.Quiver.Contains.Count > 0) { ((Item)World.Player.Quiver.Contains[0]).Remove(); } PacketHandlers.IgnoreGumps.Add(World.Player.Quiver); PlayerData.DoubleClick(World.Player.Quiver); } if (!Config.GetBool("AutoSearch")) { World.Player.SendMessage(MsgLevel.Info, LocString.NoAutoCount); } SupressWarnings = false; } }
public int GetHue(int def) { if (Config.GetBool("ForceSpellHue")) { switch (Flag) { case SpellFlag.Beneficial: return(Config.GetInt("BeneficialSpellHue")); case SpellFlag.Harmful: return(Config.GetInt("HarmfulSpellHue")); case SpellFlag.Neutral: return(Config.GetInt("NeutralSpellHue")); default: return(def); } } else { return(def); } }
public override void OnMapChange(byte old, byte cur) { List <Mobile> list = new List <Mobile>(World.Mobiles.Values); for (int i = 0; i < list.Count; i++) { Mobile m = list[i]; if (m != this && m.Map != cur) { m.Remove(); } } list = null; World.Items.Clear(); Counter.Reset(); for (int i = 0; i < Contains.Count; i++) { Item item = (Item)Contains[i]; World.AddItem(item); item.Contains.Clear(); } if (Config.GetBool("AutoSearch") && Backpack != null) { PlayerData.DoubleClick(Backpack); } UOAssist.PostMapChange(cur); if (Engine.MainWindow != null && Engine.MainWindow.MapWindow != null) { Engine.MainWindow.SafeAction(s => s.MapWindow.PlayerMoved()); } }
public static void ShowAttackOverhead(Serial serial) { if (!Config.GetBool("ShowAttackTargetOverhead")) { return; } if (Config.GetBool("ShowAttackTargetNewOnly") && serial == _lastOverheadMessageAttack) { return; } Mobile m = World.FindMobile(serial); if (m == null) { return; } World.Player.OverheadMessage(FriendsManager.IsFriend(m.Serial) ? 63 : m.GetNotorietyColorInt(), $"Attack: {m.Name}"); _lastOverheadMessageAttack = serial; }
public override bool InstallHooks(IntPtr mainWindow) { InitError error; int flags = 0; if (m_Ready) { return(false); // double init } if (Config.GetBool("Negotiate")) { flags |= 0x04; } if (ClientEncrypted) { flags |= 0x08; } if (ServerEncrypted) { flags |= 0x10; } WaitForWindow(ClientProc.Id); error = (InitError)InstallLibrary(mainWindow, ClientProc.Id, flags); if (error != InitError.SUCCESS) { FatalInit(error); return(false); } // When InstallLibrary finishes, we get a UONETEVENT saying it's ready. return(true); }
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 bool UpdateContainer() { if (!(m_Parent is Serial) || Deleted) { return(true); } object o = null; Serial contSer = (Serial)m_Parent; if (contSer.IsItem) { o = World.FindItem(contSer); } else if (contSer.IsMobile) { o = World.FindMobile(contSer); } if (o == null) { return(false); } m_Parent = o; if (m_Parent is Item) { ((Item)m_Parent).AddItem(this); } else if (m_Parent is Mobile) { ((Mobile)m_Parent).AddItem(this); } if (World.Player != null && (IsChildOf(World.Player.Backpack) || IsChildOf(World.Player.Quiver))) { bool exempt = SearchExemptionAgent.IsExempt(this); if (!exempt) { Counter.Count(this); } if (m_IsNew) { if (m_AutoStack) { AutoStackResource(); } if (IsContainer && !exempt && (!IsPouch || !Config.GetBool("NoSearchPouches")) && Config.GetBool("AutoSearch")) { PacketHandlers.IgnoreGumps.Add(this); PlayerData.DoubleClick(this); for (int c = 0; c < Contains.Count; c++) { Item icheck = (Item)Contains[c]; if (icheck.IsContainer && !SearchExemptionAgent.IsExempt(icheck) && (!icheck.IsPouch || !Config.GetBool("NoSearchPouches"))) { PacketHandlers.IgnoreGumps.Add(icheck); PlayerData.DoubleClick(icheck); } } } } } m_AutoStack = m_IsNew = false; return(true); }
//private DateTime m_LastActivate; public override bool OnMessage(MainForm razor, uint wParam, int lParam) { bool retVal = true; switch ((UONetMessage)(wParam & 0xFFFF)) { case UONetMessage.Ready: //Patch status if (lParam == (int)InitError.NO_MEMCOPY) { if (MessageBox.Show(Engine.ActiveWindow, Language.GetString(LocString.NoMemCpy), "No Client MemCopy", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { m_Ready = false; ClientProc = null; Engine.MainWindow.CanClose = true; Engine.MainWindow.Close(); break; } } byte *baseAddr = (byte *)GetSharedAddress().ToPointer(); m_InRecv = (Buffer *)baseAddr; m_OutRecv = (Buffer *)(baseAddr + sizeof(Buffer)); m_InSend = (Buffer *)(baseAddr + sizeof(Buffer) * 2); m_OutSend = (Buffer *)(baseAddr + sizeof(Buffer) * 3); m_TitleStr = (byte *)(baseAddr + sizeof(Buffer) * 4); SetServer(m_ServerIP, m_ServerPort); CommMutex = new Mutex(); #pragma warning disable 618 CommMutex.Handle = GetCommMutex(); #pragma warning restore 618 try { string path = Ultima.Files.GetFilePath("art.mul"); if (path != null && path != string.Empty) { SetDataPath(Path.GetDirectoryName(path)); } else { SetDataPath(Path.GetDirectoryName(Ultima.Files.Directory)); } } catch { SetDataPath(""); } if (Config.GetBool("OldStatBar")) { RequestStatbarPatch(true); } m_Ready = true; Engine.MainWindow.MainForm_EndLoad(); break; case UONetMessage.NotReady: m_Ready = false; FatalInit((InitError)lParam); ClientProc = null; Engine.MainWindow.CanClose = true; Engine.MainWindow.Close(); break; // Network events case UONetMessage.Recv: OnRecv(); break; case UONetMessage.Send: OnSend(); break; case UONetMessage.Connect: m_ConnStart = DateTime.UtcNow; try { m_LastConnection = new IPAddress((uint)lParam); } catch { } break; case UONetMessage.Disconnect: OnLogout(false); break; case UONetMessage.Close: OnLogout(true); ClientProc = null; Engine.MainWindow.CanClose = true; Engine.MainWindow.Close(); break; // Hot Keys case UONetMessage.Mouse: HotKey.OnMouse((ushort)(lParam & 0xFFFF), (short)(lParam >> 16)); break; case UONetMessage.KeyDown: retVal = HotKey.OnKeyDown(lParam, ModKeys.None); break; // Activation Tracking case UONetMessage.Activate: /*if ( Config.GetBool( "AlwaysOnTop" ) ) * { * if ( (lParam&0x0000FFFF) == 0 && (lParam&0xFFFF0000) != 0 && razor.WindowState != FormWindowState.Minimized && razor.Visible ) * {// if uo is deactivating and minimized and we are not minimized * if ( !razor.ShowInTaskbar && razor.Visible ) * razor.Hide(); * razor.WindowState = FormWindowState.Minimized; * m_LastActivate = DateTime.UtcNow; * } * else if ( (lParam&0x0000FFFF) != 0 && (lParam&0xFFFF0000) != 0 && razor.WindowState != FormWindowState.Normal ) * { // is UO is activating and minimized and we are minimized * if ( m_LastActivate+TimeSpan.FromSeconds( 0.2 ) < DateTime.UtcNow ) * { * if ( !razor.ShowInTaskbar && !razor.Visible ) * razor.Show(); * razor.WindowState = FormWindowState.Normal; * //SetForegroundWindow( FindUOWindow() ); * } * m_LastActivate = DateTime.UtcNow; * } * }*/ break; case UONetMessage.Focus: if (Config.GetBool("AlwaysOnTop")) { if (lParam != 0 && !razor.TopMost) { razor.TopMost = true; Platform.SetForegroundWindow(FindUOWindow()); } else if (lParam == 0 && razor.TopMost) { razor.TopMost = false; razor.SendToBack(); } } // always use smartness for the map window if (razor.MapWindow != null && razor.MapWindow.Visible) { if (lParam != 0 && !razor.MapWindow.TopMost) { razor.MapWindow.TopMost = true; Platform.SetForegroundWindow(FindUOWindow()); } else if (lParam == 0 && razor.MapWindow.TopMost) { razor.MapWindow.TopMost = false; razor.MapWindow.SendToBack(); } } break; case UONetMessage.DLL_Error: { string error = "Unknown"; switch ((UONetMessage)lParam) { case UONetMessage.StatBar: error = "Unable to patch status bar."; break; } MessageBox.Show(Engine.ActiveWindow, "An Error has occured : \n" + error, "Error Reported", MessageBoxButtons.OK, MessageBoxIcon.Warning); break; } case UONetMessage.OnTick: // Game engine tick Timer.Slice(); break; // Unknown default: MessageBox.Show(Engine.ActiveWindow, "Unknown message from uo client\n" + ((int)wParam).ToString(), "Error?"); break; } return(retVal); }
public override void UpdateTitleBar() { if (!ClientRunning) { return; } if (World.Player != null && Config.GetBool("TitleBarDisplay")) { ResetTitleBarBuilder(); TitleBarBuilder.Replace(@"{char}", Config.GetBool("ShowNotoHue") ? $"~#{World.Player.GetNotorietyColor() & 0x00FFFFFF:X6}{World.Player.Name}~#~" : World.Player.Name); TitleBarBuilder.Replace(@"{crimtime}", World.Player.CriminalTime != 0 ? $"~^C0C0C0{World.Player.CriminalTime}~#~" : "-"); TitleBarBuilder.Replace(@"{hp}", World.Player.Poisoned ? $"~#FF8000{World.Player.Hits}~#~" : EncodeColorStat(World.Player.Hits, World.Player.HitsMax)); TitleBarBuilder.Replace(@"{mana}", EncodeColorStat(World.Player.Mana, World.Player.ManaMax)); TitleBarBuilder.Replace(@"{stam}", EncodeColorStat(World.Player.Stam, World.Player.StamMax)); TitleBarBuilder.Replace(@"{weight}", World.Player.Weight >= World.Player.MaxWeight ? $"~#FF0000{World.Player.Weight}~#~" : World.Player.Weight.ToString()); TitleBarBuilder.Replace(@"{bandage}", BandageTimer.Running ? $"~#FF8000{BandageTimer.Count}~#~" : "-"); string statStr = String.Format("{0}{1:X2}{2:X2}{3:X2}", (int)(World.Player.GetStatusCode()), (int)(World.Player.HitsMax == 0 ? 0 : (double)World.Player.Hits / World.Player.HitsMax * 99), (int)(World.Player.ManaMax == 0 ? 0 : (double)World.Player.Mana / World.Player.ManaMax * 99), (int)(World.Player.StamMax == 0 ? 0 : (double)World.Player.Stam / World.Player.StamMax * 99)); TitleBarBuilder.Replace(@"{statbar}", $"~SR{statStr}"); TitleBarBuilder.Replace(@"{mediumstatbar}", $"~SL{statStr}"); TitleBarBuilder.Replace(@"{largestatbar}", $"~SX{statStr}"); bool dispImg = Config.GetBool("TitlebarImages"); for (int i = 0; i < Counter.List.Count; i++) { Counter c = Counter.List[i]; if (c.Enabled) { TitleBarBuilder.Replace($"{{{c.Format}}}", c.GetTitlebarString(dispImg && c.DisplayImage, true)); } } base.UpdateTitleBar(); } else { SetTitleStr(string.Empty); } }
public void Dress() { if (World.Player == null) { return; } int skipped = 0, gone = 0, done = 0; List <Item> list = new List <Item>(); bool remConflicts = Config.GetBool("UndressConflicts"); if (World.Player.Backpack == null) { World.Player.SendMessage(LocString.NoBackpack); return; } if (Macros.MacroManager.AcceptActions) { Macros.MacroManager.Action(new Macros.DressAction(Name)); } for (int i = 0; i < Items.Count; i++) { Item item; if (Items[i] is Serial) { item = World.FindItem((Serial)Items[i]); if (item == null) { gone++; } else { list.Add(item); } } else if (Items[i] is ItemID) { ItemID id = (ItemID)Items[i]; // search to make sure they are not already wearing this... item = World.Player.FindItemByID(id); if (item != null) { skipped++; } else { item = World.Player.Backpack.FindItemByID(id); if (item == null) { gone++; } else { list.Add(item); } } } } foreach (Item item in list) { if (item.Container == World.Player) { skipped++; } else if (item.IsChildOf(World.Player.Backpack) || item.RootContainer == null) { Layer layer = GetLayerFor(item); if (layer == Layer.Invalid || layer > Layer.LastUserValid) { continue; } if (remConflicts) { Item conflict = World.Player.GetItemOnLayer(layer); if (conflict != null) { DragDropManager.DragDrop(conflict, FindUndressBag(conflict)); } // try to also undress conflicting hand(s) if (layer == Layer.RightHand) { conflict = World.Player.GetItemOnLayer(Layer.LeftHand); } else if (layer == Layer.LeftHand) { conflict = World.Player.GetItemOnLayer(Layer.RightHand); } else { conflict = null; } if (conflict != null && (conflict.IsTwoHanded || item.IsTwoHanded)) { DragDropManager.DragDrop(conflict, FindUndressBag(conflict)); } } DragDropManager.DragDrop(item, World.Player, layer); done++; } } if (done > 0) { World.Player.SendMessage(LocString.DressQueued, done); } if (skipped > 0) { World.Player.SendMessage(LocString.AlreadyDressed, skipped); } if (gone > 0) { World.Player.SendMessage(LocString.ItemsNotFound, gone); } }
protected override void OnTick() { ArrayList requeue = null; m_LastTick = DateTime.UtcNow; if (m_Queue != null && m_Queue.Count > 0) { this.Interval = TimeSpan.FromMilliseconds(Config.GetBool("ObjectDelayEnabled") ? Config.GetInt("ObjectDelay") : 0); //this.Interval = TimeSpan.FromMilliseconds( Config.GetInt( "ObjectDelay" ) ); while (m_Queue.Count > 0) { Serial s = (Serial)m_Queue.Peek(); if (s == Serial.Zero) // dragdrop action { DragDropManager.ProcStatus status = DragDropManager.ProcessNext(m_Queue.Count - 1); if (status != DragDropManager.ProcStatus.KeepWaiting) { m_Queue.Dequeue(); // if not waiting then dequeue it if (status == DragDropManager.ProcStatus.ReQueue) { m_Queue.Enqueue(s); } } if (status == DragDropManager.ProcStatus.KeepWaiting || status == DragDropManager.ProcStatus.Success) { break; // don't process more if we're waiting or we just processed something } } else { m_Queue.Dequeue(); Client.Instance.SendToServer(new DoubleClick(s)); break; } } if (requeue != null) { for (int i = 0; i < requeue.Count; i++) { m_Queue.Enqueue(requeue[i]); } } } else { Stop(); if (m_Total > 1 && World.Player != null) { World.Player.SendMessage(LocString.QueueFinished, m_Total, ((DateTime.UtcNow - m_StartTime) - this.Interval).TotalSeconds); } m_Last = Serial.Zero; m_Total = 0; } }
public void MoveReq(Direction dir, byte seq) { m_OutstandingMoves++; FastWalkKey++; MoveEntry e = new MoveEntry(); m_MoveInfo[seq] = e; e.IsStep = (dir & Direction.Mask) == (Direction & Direction.Mask); e.Dir = dir; ProcessMove(dir); // shouldnt this be in MoveAck?!? e.Position = Position; if (Body != 0x03DB && !IsGhost && ((int)(e.Dir & Direction.Mask)) % 2 == 0 && Config.GetBool("AutoOpenDoors") && ClientCommunication.AllowBit(FeatureBit.AutoOpenDoors)) { int x = Position.X, y = Position.Y, z = Position.Z; foreach (Item i in World.Items.Values) { if (i.Position.X == x && i.Position.Y == y && i.IsDoor && i.Position.Z - 15 <= z && i.Position.Z + 15 >= z && (m_LastDoor != i.Serial || m_LastDoorTime + TimeSpan.FromSeconds(1) < DateTime.UtcNow)) { m_LastDoor = i.Serial; m_LastDoorTime = DateTime.UtcNow; m_OpenDoorReq.Start(); break; } } } /*if ( m_OutstandingMoves < 5 && !Macros.WalkAction.IsMacroWalk( seq ) && Config.GetBool( "SmoothWalk" ) ) * { * e.FilterAck = true; * ClientCommunication.SendToClient( new MoveAcknowledge( seq, Notoriety ) ); * } * else * { * e.FilterAck = false; * }*/ e.FilterAck = false; m_WalkSeq = (byte)(seq >= 255 ? 1 : seq + 1); }
public static bool DoubleClick(object clicked, bool silent) { Serial s; if (clicked is Mobile) { s = ((Mobile)clicked).Serial.Value; } else if (clicked is Item) { s = ((Item)clicked).Serial.Value; } else if (clicked is Serial) { s = ((Serial)clicked).Value; } else { s = Serial.Zero; } if (s != Serial.Zero) { Item free = null, pack = World.Player.Backpack; if (s.IsItem && pack != null && Config.GetBool("PotionEquip") && Client.Instance.AllowBit(FeatureBit.AutoPotionEquip)) { Item i = World.FindItem(s); if (i != null && i.IsPotion && i.ItemID != 3853) // dont unequip for exploison potions { // dont worry about uneqipping RuneBooks or SpellBooks Item left = World.Player.GetItemOnLayer(Layer.LeftHand); Item right = World.Player.GetItemOnLayer(Layer.RightHand); if (left != null && (right != null || left.IsTwoHanded)) { free = left; } else if (right != null && right.IsTwoHanded) { free = right; } if (free != null) { if (DragDropManager.HasDragFor(free.Serial)) { free = null; } else { DragDropManager.DragDrop(free, pack); } } } } ActionQueue.DoubleClick(silent, s); if (free != null) { DragDropManager.DragDrop(free, World.Player, free.Layer, true); } if (s.IsItem) { World.Player.m_LastObj = s; } } return(false); }