private void GraphicCallback(object unused) { UO.Print("Select object:"); UOObject obj = World.GetObject(UIManager.TargetObject()); if (obj.Exist) { Graphic graphic; if (obj is UOItem) { graphic = ((UOItem)obj).Graphic; } else { graphic = ((UOCharacter)obj).Model; } OnInsertText(graphic.ToString() + " "); } else { UO.PrintWarning("Invalid object selected."); } }
public static UOItem FindType(string objectName, Graphic graphic, UOColor color, Serial container) { UOItem foundItem; if (container != 0) { UOObject obj = World.GetObject(container); if (obj.Serial.IsValid) { if (obj is UOItem) { foundItem = ((UOItem)obj).AllItems.FindType(graphic, color); } else { foundItem = ((UOCharacter)obj).Layers.FindType(graphic, color); } } else { ScriptErrorException.Throw("Invalid container serial."); foundItem = new UOItem(Serial.Invalid); } } else { foundItem = World.Ground.FindType(graphic, color); } Aliases.SetObject(objectName, foundItem); return(foundItem); }
//--------------------------------------------------------------------------------------------- public static void PrintMessage(this UOObject obj, string message, UOColor color, bool supperssPrevMessages, params object[] args) { string test = message + String.Empty; bool needBranches = test.Contains("["); bool needSpaces = test.Contains("..") || test.Contains("..") || test.Contains("[ "); test = test.Replace("[", "").Replace("]", "").Replace("....", "").Replace("...", "").Replace("..", "").Trim(new char[] { ' ' }); //.ToLower(); //if (needBranches) // test = test.ToLower(); if (!String.IsNullOrEmpty(test) && needBranches) { test = "[" + (needSpaces ? " " : "") + test + (needSpaces ? " " : "") + "]"; } if (obj.Serial.IsValidCust()) { if (supperssPrevMessages) { UO.PrintObject(obj.Serial, color, "", args); //reset 1 UO.PrintObject(obj.Serial, color, "", args); //reset 2 } UO.PrintObject(obj.Serial, color, test, args); } else { UO.Print(color, test, args); } }
public static void SayToOneSteapChar(string sentence) { List <UOCharacter> vendors = World.Characters.Where(ch => ch.Distance <= 1 && ch.Serial != World.Player.Serial).OrderBy(ch => ch.GetDistance()).ToList(); UOObject vendor = null; if (vendors.Count > 0) { vendor = vendors[0]; } if (vendor == null) { World.Player.Print("[Vyber char..]"); vendor = new UOObject(UIManager.TargetObject()); } if (vendor != null && vendor.Exist) { if (String.IsNullOrEmpty(vendor.Name)) { vendor.Click(); Game.Wait(150); } UO.Say(vendor.Name + " " + sentence); } }
public SupplyCounter(UOObject container, List <UOItemTypeBase> types) { this.types = new List <UOItemTypeBase>(); if (!container.Serial.IsValid) { throw new ArgumentException("container"); } this.container = container; //this.type = type; //this.color = color; this.types.AddRange(types.ToArray()); if (container is UOItem) { collection = ((UOItem)container).AllItems; } else if (container is UOCharacter) { collection = ((UOCharacter)container).Layers; if (Track) { Notepad.WriteLine("Layers " + ((UOCharacter)container).Layers.Count()); } } else { throw new ArgumentException("Invalid container type."); } container.Changed += new ObjectChangedEventHandler(container_Changed); // Init count Recalc(); }
//--------------------------------------------------------------------------------------------- public static TargetAliasResult ParseTargets(params string[] targets) { List <string> finalTargets = new List <string>(); if (targets != null) { foreach (string target in targets) { if (!String.IsNullOrEmpty(target)) { finalTargets.AddRange(target.Split(new char[] { ',', '|', ';' }, StringSplitOptions.RemoveEmptyEntries)); } } foreach (string target in finalTargets) { TargetAliasResult serial = Targeting.ParseTarget(target); UOObject o = new UOObject(serial); if (serial.IsStatic || (serial.IsValid && o.Exist && o.Distance < 28)) { // System.Diagnostics.Debug.WriteLine("Target: " + target + " - success [" + serial + ", " + o.Distance + ", " + o.Name + "]", "Caleb"); return(serial); } //else // System.Diagnostics.Debug.WriteLine("Target: " + target + " - fail [" + serial + ", " + o.Distance + ", " + o.Name + "]", "Caleb"); } } return(Serial.Invalid); }
/// <summary> /// Initializes a new instance of the <see cref="T:SupplyCounter"/> class. /// </summary> public SupplyCounter(UOObject container, Graphic type, UOColor color) { if (!container.Serial.IsValid) { throw new ArgumentException("container"); } if (type.IsInvariant || type == 0) { throw new ArgumentOutOfRangeException("type"); } this.container = container; this.type = type; this.color = color; if (container is UOItem) { collection = ((UOItem)container).AllItems; } else if (container is UOCharacter) { collection = ((UOCharacter)container).Layers; } else { throw new ArgumentException("Invalid container type."); } container.Changed += new ObjectChangedEventHandler(container_Changed); // Init count Recalc(); }
public static void SellManual() { UOObject vendor = new UOObject(UIManager.TargetObject()); if (vendor.Exist) { UO.Say(vendor.Name + " sell "); } }
public static void Info(Serial serial) { UOObject obj = World.GetObject(serial); if (obj.Exist) { Notepad.WriteLine(obj.Description); Notepad.WriteLine(); } }
//--------------------------------------------------------------------------------------------- public static bool WaitForName(this UOObject obj) { int counter = 0; while (String.IsNullOrEmpty(obj.Name) && counter < 150) { Thread.Sleep(5); counter += 5; } return(!String.IsNullOrEmpty(obj.Name)); }
private void ColorCallback(object unused) { UO.Print("Select object:"); UOObject obj = World.GetObject(UIManager.TargetObject()); if (obj.Exist) { OnInsertText(obj.Color.ToString() + " "); } else { UO.PrintWarning("Invalid object selected."); } }
//--------------------------------------------------------------------------------------------- public static string GetUniqueKeyPostion(this UOObject obj) { if (obj is UOCharacter) { return(obj.Serial + "|" + ((UOCharacter)obj).Model + "|" + obj.Color + "|" + obj.X + "." + obj.Y); } else if (obj is UOItem) { return(obj.Serial + "|" + ((UOItem)obj).Graphic + "|" + obj.Color + "|" + obj.X + "." + obj.Y); } else { return(obj.Serial + String.Empty + "|" + obj.X + "." + obj.Y); } }
//--------------------------------------------------------------------------------------------- public static void PrintMessage(this UOObject obj, string message, UOColor color, bool supperssPrevMessages, params object[] args) { if (obj.Serial.IsValidCust()) { if (supperssPrevMessages) { UO.PrintObject(obj.Serial, color, "", args); //reset 1 UO.PrintObject(obj.Serial, color, "", args); //reset 2 } UO.PrintObject(obj.Serial, color, message, args); } else { UO.Print(color, message, args); } }
//--------------------------------------------------------------------------------------------- public static void PrintMessage(this UOObject obj, string message, MessageType type, params object[] args) { PrintMessage(obj, message, Game.GetMessageTypeColor(type), args); }
//--------------------------------------------------------------------------------------------- public static void PrintMessage(this UOObject obj, string message, MessageType type) { PrintMessage(obj, message, type, new object[0]); }
//--------------------------------------------------------------------------------------------- public static void PrintMessage(this UOObject obj, string message) { PrintMessage(obj, message, MessageType.Info); }
//--------------------------------------------------------------------------------------------- public static bool ExistCust(this UOObject obj) { return(obj.Exist && obj.Serial.IsValidCust()); }
//--------------------------------------------------------------------------------------------- public static double GetRealDistance(this UOObject obj, IUOPosition positionFrom) { return(Robot.GetRealDistance(positionFrom, obj.GetPosition())); }
//--------------------------------------------------------------------------------------------- public static void PrintMessage(this UOObject obj, string message, UOColor color, params object[] args) { PrintMessage(obj, message, color, false, args); }
//--------------------------------------------------------------------------------------------- public static void PrintMessage(this UOObject obj, string message, UOColor color) { PrintMessage(obj, message, color, false); }
//--------------------------------------------------------------------------------------------- public static IUOPosition GetPosition(this UOObject obj) { return(new UOPositionBase(obj.X, obj.Y, (ushort)obj.Z)); }
/// <summary> /// Initializes a new instance of the <see cref="T:SupplyCounter"/> class. /// </summary> public SupplyCounter(UOObject container, Graphic type, UOColor color) : this(container, new List <UOItemTypeBase>() { new UOItemTypeBase(type, color) }) { }
//--------------------------------------------------------------------------------------------- public static void PrintMessage(this UOObject obj, string message, UOColor color, bool supperssPrevMessages) { PrintMessage(obj, message, color, supperssPrevMessages, new object[0]); }
//--------------------------------------------------------------------------------------------- public static double GetRealDistance(this UOObject obj) { return(GetRealDistance(obj, World.Player)); }
//--------------------------------------------------------------------------------------------- public static double GetDistance(this UOObject obj, IUOPosition positionFrom) { return(Robot.GetRelativeVectorLength(positionFrom, obj.GetPosition())); }
//--------------------------------------------------------------------------------------------- public static double GetRealDistance(this UOObject obj, UOObject distanceFrom) { return(GetRealDistance(obj, distanceFrom.GetPosition())); }