예제 #1
0
파일: UO.World.cs 프로젝트: byterj/phoenix
        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);
        }
예제 #2
0
파일: UO.cs 프로젝트: byterj/phoenix
        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);
        }
예제 #3
0
파일: UO.World.cs 프로젝트: byterj/phoenix
        /// <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));
        }
예제 #4
0
파일: UO.World.cs 프로젝트: byterj/phoenix
        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));
        }
예제 #5
0
 public static void Attack(Serial serial)
 {
     if (serial.IsValid)
     {
         Core.SendToServer(PacketBuilder.AttackRequest(serial), true);
     }
     else
     {
         ScriptErrorException.Throw("Invalid serial.");
     }
 }
예제 #6
0
파일: UO.World.cs 프로젝트: byterj/phoenix
 public static void ClickObject(Serial serial)
 {
     if (serial.IsValid)
     {
         Core.SendToServer(PacketBuilder.ObjectClick(serial));
     }
     else
     {
         ScriptErrorException.Throw("Invalid serial specified to ClickObject.");
     }
 }
예제 #7
0
파일: UO.cs 프로젝트: byterj/phoenix
 public static void AddObject(string name, Serial value)
 {
     if (Helper.CheckName(ref name, false))
     {
         Aliases.SetObject(name, value);
     }
     else
     {
         ScriptErrorException.Throw("Invalid object name.");
     }
 }
예제 #8
0
파일: UO.cs 프로젝트: byterj/phoenix
 public static void Hide(Serial serial)
 {
     if (serial.IsValid)
     {
         Core.SendToClient(PacketBuilder.ObjectRemove(serial));
     }
     else
     {
         ScriptErrorException.Throw("Invalid serial.");
     }
 }
예제 #9
0
파일: UO.World.cs 프로젝트: byterj/phoenix
        /// <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));
            }
        }
예제 #10
0
파일: UO.World.cs 프로젝트: byterj/phoenix
        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.");
            }
        }
예제 #11
0
파일: UO.World.cs 프로젝트: byterj/phoenix
        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;
        }
예제 #12
0
 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);
     }
 }
예제 #13
0
파일: UO.World.cs 프로젝트: byterj/phoenix
        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));
        }
예제 #14
0
        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);
            }
        }
예제 #15
0
        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);
        }
예제 #16
0
파일: UO.World.cs 프로젝트: byterj/phoenix
        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."));
            }
        }
예제 #17
0
파일: UO.cs 프로젝트: byterj/phoenix
        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);
            }
        }
예제 #18
0
파일: UO.cs 프로젝트: byterj/phoenix
        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);
            }
        }
예제 #19
0
        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);
            }
        }
예제 #20
0
파일: UO.cs 프로젝트: byterj/phoenix
        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.");
            }
        }
예제 #21
0
파일: UO.World.cs 프로젝트: byterj/phoenix
        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));
        }
예제 #22
0
        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);
            }
        }