public static int EmptyContainer(int pause, Serial source, Serial target) { pause = Math.Max(pause, 100); if (!source.IsValid) { ScriptErrorException.Throw("Source container serial is invalid."); return(-1); } if (!target.IsValid) { ScriptErrorException.Throw("Target container serial is invalid."); return(-1); } int movedCount = 0; foreach (UOItem item in World.GetItem(source).Items) { if (item.Move(0, target)) { movedCount++; } UO.Wait(pause); } return(movedCount); }
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); }
/// <summary> /// Requests status of character from server. /// </summary> /// <param name="serial">Character serial.</param> public static void RequestCharacterStatus(Serial serial) { if (!serial.IsValid) { ScriptErrorException.Throw("Character serial is invalid."); } Core.SendToServer(PacketBuilder.CharacterStatsRequest(serial, PacketBuilder.StatsRequestType.Stats)); }
public static bool MoveItem(Serial item, ushort amount, ushort x, ushort y, sbyte z) { if (!item.IsValid) { return(ScriptErrorException.Throw("Invalid item serial.")); } return(UIManager.MoveItem(item, amount, x, y, z, 0)); }
public static void Attack(Serial serial) { if (serial.IsValid) { Core.SendToServer(PacketBuilder.AttackRequest(serial), true); } else { ScriptErrorException.Throw("Invalid serial."); } }
public static void ClickObject(Serial serial) { if (serial.IsValid) { Core.SendToServer(PacketBuilder.ObjectClick(serial)); } else { ScriptErrorException.Throw("Invalid serial specified to ClickObject."); } }
public static void AddObject(string name, Serial value) { if (Helper.CheckName(ref name, false)) { Aliases.SetObject(name, value); } else { ScriptErrorException.Throw("Invalid object name."); } }
public static void Hide(Serial serial) { if (serial.IsValid) { Core.SendToClient(PacketBuilder.ObjectRemove(serial)); } else { ScriptErrorException.Throw("Invalid serial."); } }
/// <summary> /// Requests status of character from server. /// </summary> /// <param name="serial">Character serial.</param> /// <param name="timeout">Timeout period.</param> /// <returns>True when status update received; otherwise false.</returns> public static bool RequestCharacterStatus(Serial serial, int timeout) { if (!serial.IsValid) { return(ScriptErrorException.Throw("Character serial is invalid.")); } using (SpecializedObjectChangedEventWaiter ew = new SpecializedObjectChangedEventWaiter(serial, ObjectChangeType.CharUpdated)) { Core.SendToServer(PacketBuilder.CharacterStatsRequest(serial, PacketBuilder.StatsRequestType.Stats)); return(ew.Wait(timeout)); } }
public static void UseType(Graphic graphic, UOColor color) { UOItem item = World.Player.Layers.FindType(graphic, color); if (item.Serial.IsValid) { UO.UseObject(item); } else { ScriptErrorException.Throw("Type not found."); } }
public static void UseObject(Serial serial) { if (serial.IsValid) { Core.SendToServer(PacketBuilder.ObjectDoubleClick(serial)); } else { ScriptErrorException.Throw("Invalid serial specified to UseObject."); } Aliases.LastObject = serial; }
public static IRequestResult WaitTargetObject(Serial serial) { if (serial.IsValid) { RealObject obj = World.GetRealObject(serial); return(UIManager.WaitForTarget(serial, obj.X, obj.Y, obj.Z, 0)); } else { ScriptErrorException.Throw("Invalid serial specified to WaitTargetObject."); return(UIManager.FailedResult); } }
public static bool MoveItem(Serial item, ushort amount, Serial destination, ushort x, ushort y) { if (!item.IsValid) { return(ScriptErrorException.Throw("Invalid item serial.")); } if (!destination.IsValid) { return(ScriptErrorException.Throw("Destination container serial is invalid.")); } return(UIManager.MoveItem(item, amount, x, y, 0, destination)); }
public static IRequestResult WaitTargetType(Graphic graphic, UOColor color) { UOItem item = World.Player.Layers.FindType(graphic, color); if (item.Serial.IsValid) { return(WaitTargetObject(item)); } else { ScriptErrorException.Throw("Type not found."); return(UIManager.FailedResult); } }
public static void UseSkill(string skill) { skill = skill.ToLowerInvariant(); for (int i = 0; i < DataFiles.Skills.Count; i++) { if (DataFiles.Skills[i].Name.ToLowerInvariant().Contains(skill)) { UseSkill((ushort)i); return; } } ScriptErrorException.Throw("Unknown skill '{0}'", skill); }
public static bool Grab(ushort amount, Serial item, Serial recevingContainer) { if (!item.IsValid) { return(ScriptErrorException.Throw("Invalid item serial.")); } if (recevingContainer.IsValid) { return(UIManager.MoveItem(item, amount, 0xFFFF, 0xFFFF, 0, recevingContainer)); } else { return(ScriptErrorException.Throw("Invalid RecevingContainer.")); } }
public static bool BandageSelf() { UOItem bandages = World.Player.Backpack.AllItems.FindType(0x0E21); if (bandages.Exist) { UO.WaitTargetSelf(); bandages.Use(); Wait(50); return(true); } else { ScriptErrorException.Throw("No bandages found."); return(false); } }
public static void Macro(string name) { Phoenix.Macros.Macro macro; if (!RuntimeCore.Macros.TryGetValue(name, out macro)) { ScriptErrorException.Throw("Macro {0} not found.", name); return; } try { macro.Run(); } catch (Exception e) { Trace.WriteLine("Unhandled exception during macro execution. Details:\n" + e.ToString(), "Runtime"); UO.Print(Env.ErrorColor, "Macro Error: {0}", e.Message); } }
public static void Cast(string spellname, Serial target) { Byte spellNum; if (Core.SpellList.TryFind(spellname, out spellNum)) { if (target.IsValid) { WaitTargetObject(target); } Core.SendToServer(PacketBuilder.CastSpell(spellNum), true); } else { ScriptErrorException.Throw("Unknown spell '{0}'", spellname); } }
public static void AddObject(string name) { if (Helper.CheckName(ref name, false)) { UO.Print("Select {0}:", name); Serial serial = UIManager.TargetObject(); if (serial.IsValid) { Aliases.SetObject(name, serial); } else { ScriptErrorException.Throw("Invalid object serial."); } } else { ScriptErrorException.Throw("Invalid object name."); } }
public static bool EquipItem(Serial serial) { if (!serial.IsValid) { return(ScriptErrorException.Throw("Item serial is invalid.")); } byte layer = 0; try { UOItem item = World.GetItem(serial); if (item.Exist) { layer = DataFiles.Tiledata.GetArt(item.Graphic).Layer; } } catch (Exception e) { System.Diagnostics.Trace.WriteLine("Unexpected error in UO.EquipItem(). Exception:\n" + e.ToString(), "Runtime"); } return(UIManager.EquipItem(serial, World.Player.Serial, layer)); }
public static IRequestResult WaitMenu(params string[] menus) { if (menus.Length > 0) { MenuSelection[] menuList = new MenuSelection[menus.Length / 2 + menus.Length % 2]; for (int i = 0; i < menuList.Length; i++) { menuList[i].Name = menus[i * 2]; if (i * 2 + 1 < menus.Length) { menuList[i].Option = menus[i * 2 + 1]; } } return(UIManager.WaitForMenu(menuList)); } else { ScriptErrorException.Throw("Invalid number of parameters."); return(UIManager.FailedResult); } }