public static void Organizer(string name, object sourceContainer = null, object destinationContainer = null)
        {
            OrganizerManager manager = OrganizerManager.GetInstance();

            OrganizerEntry entry = manager.Items.FirstOrDefault(oa => oa.Name.ToLower().Equals(name.ToLower()));

            if (entry == null)
            {
                UOC.SystemMessage(string.Format(Strings.Organizer___0___not_found___, name));
                return;
            }

            if (sourceContainer != null && destinationContainer != null)
            {
                int sourceContainerSerial     = AliasCommands.ResolveSerial(sourceContainer);
                int destinatinContainerSerial = AliasCommands.ResolveSerial(destinationContainer);

                manager.Organize(entry, sourceContainerSerial, destinatinContainerSerial).Wait();
            }
            else
            {
                manager.Organize(entry).Wait();
            }
        }
Beispiel #2
0
        public static bool InFriendList(object obj)
        {
            int serial = AliasCommands.ResolveSerial(obj);

            if (serial != 0)
            {
                bool result = Options.CurrentOptions.Friends.Any(fe => fe.Serial == serial);

                if (result)
                {
                    return(true);
                }

                if (Options.CurrentOptions.IncludePartyMembersInFriends)
                {
                    result = Engine.Player?.Party?.Contains(serial) ?? false;
                }

                return(result);
            }

            UOC.SystemMessage(Strings.Invalid_or_unknown_object_id);
            return(false);
        }
Beispiel #3
0
 public static void AllyMsg(string message)
 {
     UOC.Speak(message, DEFAULT_SPEAK_HUE, JournalSpeech.Alliance);
 }
Beispiel #4
0
 public static void GuildMsg(string message)
 {
     UOC.Speak(message, DEFAULT_SPEAK_HUE, JournalSpeech.Guild);
 }
Beispiel #5
0
 public static void EmoteMsg(string message)
 {
     UOC.Speak(message, DEFAULT_SPEAK_HUE, JournalSpeech.Emote);
 }
        public static void SetAbility(string ability, string onOff = "toggle")
        {
            AbilitiesManager manager = AbilitiesManager.GetInstance();

            if (ability.ToLower().Equals("stun"))
            {
                Engine.SendPacketToServer(new StunRequest());
                return;
            }

            if (ability.ToLower().Equals("disarm"))
            {
                Engine.SendPacketToServer(new DisarmRequest());
                return;
            }

            bool primary;

            switch (ability.ToLower())
            {
            case "primary":
                primary = true;
                break;

            default:
                primary = false;
                break;
            }

            string onOffNormalized = onOff.Trim().ToLower();

            if (onOffNormalized != "toggle")
            {
                switch (onOffNormalized)
                {
                case "on":
                {
                    if (primary && manager.IsPrimaryEnabled || !primary && manager.IsSecondaryEnabled)
                    {
                        if (!MacroManager.QuietMode)
                        {
                            UOC.SystemMessage(Strings.Ability_already_set___, 0x3F);
                        }

                        return;
                    }

                    break;
                }

                case "off":
                {
                    if (primary && !manager.IsPrimaryEnabled || !primary && !manager.IsSecondaryEnabled)
                    {
                        if (!MacroManager.QuietMode)
                        {
                            UOC.SystemMessage(Strings.Ability_not_set___, 0x3F);
                        }

                        return;
                    }

                    break;
                }
                }
            }

            UOC.SystemMessage(string.Format(Strings.Setting_ability___0_____, ability), 0x3F);
            manager.SetAbility(primary ? AbilityType.Primary : AbilityType.Secondary);
        }
Beispiel #7
0
 public override void Execute()
 {
     UOC.Resync();
 }
        public bool CheckHands(int serial)
        {
            if (!Options.CurrentOptions.CheckHandsPotions)
            {
                return(false);
            }

            Item item = Engine.Items?.GetItem(serial);

            if (item == null || !_potionTypes.Contains(item.ID))
            {
                return(false);
            }

            // Explosion / Conflagaration pot doesn't need hand free
            if (item.ID == 0xf0d && item.Hue == 0 || item.ID == 0xf06 && item.Hue == 1161)
            {
                return(false);
            }

            if (_checkHandsInProgress)
            {
                UOC.SystemMessage(Strings.Arm___Disarm_already_in_progress___, (int)UOC.SystemMessageHues.Red);
                return(false);
            }

            _checkHandsInProgress = true;

            Item leftHand  = Engine.Player?.Equipment.FirstOrDefault(i => i.Layer == Layer.TwoHanded);
            Item rightHand = Engine.Player?.Equipment.FirstOrDefault(i => i.Layer == Layer.OneHanded);

            if (leftHand == null && rightHand != null)
            {
                //OSI crossbow in OneHanded layer??
                leftHand  = rightHand;
                rightHand = null;
            }

            WeaponData leftHandWD = null;

            if (leftHand != null)
            {
                leftHandWD = GetWeaponData(leftHand.ID);
            }

            if ((!(leftHandWD?.Twohanded ?? false) && leftHand?.Properties != null &&
                 !(leftHand.Properties?.Any(p => p.Cliloc == 1061171 /* Two-Handed Weapon */) ?? false) ||
                 leftHand?.Properties != null &&
                 !(leftHand.Properties?.All(p => p.Cliloc != 1072792 /* Balanced */) ?? false)) &&
                (rightHand == null || leftHand == null))
            {
                _checkHandsInProgress = false;
                return(false);
            }

            if (leftHand == null)
            {
                _checkHandsInProgress = false;
                return(false);
            }

            ActionPacketQueue.EnqueueDragDrop(leftHand.Serial, 1, Engine.Player.GetLayer(Layer.Backpack),
                                              QueuePriority.High);
            ActionPacketQueue.EnqueuePackets(
                new BasePacket[]
            {
                new UseObject(serial), new DragItem(leftHand.Serial, 1),
                new EquipRequest(leftHand.Serial, leftHand.Layer, (int)Engine.Player?.Serial)
            }, QueuePriority.High).ContinueWith(t => _checkHandsInProgress = false);

            return(true);
        }
Beispiel #9
0
        private static bool OnInfo(string[] arg)
        {
            Task.Run(async() => await UOC.InspectObjectAsync());

            return(true);
        }
Beispiel #10
0
        public static bool Cast(string name, object obj)
        {
            int serial = AliasCommands.ResolveSerial(obj);

            if (serial == 0)
            {
                UOC.SystemMessage(Strings.Invalid_or_unknown_object_id);
                return(false);
            }

            SpellData sd = _manager.GetSpellData(name) ?? _manager.GetMasteryData(name);

            if (sd == null)
            {
                UOC.SystemMessage(Strings.Unknown_spell___);
                return(false);
            }

            // Debugging only
            Stopwatch sw = new Stopwatch();

            sw.Start();
            //

            _manager.CastSpell(sd.ID);

            int  index = 0;
            bool result;

            if (Options.CurrentOptions.UseExperimentalFizzleDetection)
            {
                (index, result) = UOC.WaitForTargetOrFizzle(sd.Timeout + 1000);
            }
            else
            {
                result = TargetCommands.WaitForTarget(sd.Timeout + 500);
            }

            if (index == 0 && !result)
            {
                UOC.SystemMessage(Strings.Timeout___);
                return(false);
            }

            if (!result)
            {
                return(false);
            }

            // Debugging only
            sw.Stop();

            if (Options.CurrentOptions.Debug)
            {
                UOC.SystemMessage(
                    $"Target received in {sw.ElapsedMilliseconds}ms, Spell data timeout: {sd.Timeout}ms");
            }
            //

            TargetCommands.Target(serial);

            return(true);
        }
Beispiel #11
0
        public static void MoveType(int id, object sourceContainer, object destinationContainer, int x = -1,
                                    int y = -1, int z = 0, int hue = -1, int amount = -1)
        {
            int sourceSerial = AliasCommands.ResolveSerial(sourceContainer);

            if (sourceSerial == -1)
            {
                UOC.SystemMessage(Strings.Invalid_source_container___);
                return;
            }

            int destinationSerial;

            if (destinationContainer is int destSerial)
            {
                destinationSerial = destSerial;
            }
            else
            {
                destinationSerial = AliasCommands.ResolveSerial(destinationContainer);
            }

            Item sourceItem = Engine.Items.GetItem(sourceSerial);

            if (sourceItem == null)
            {
                UOC.SystemMessage(Strings.Cannot_find_item___);
                return;
            }

            if (sourceItem.Container == null)
            {
                UOC.SystemMessage(Strings.Invalid_container___);
                return;
            }

            Item entity = sourceItem.Container.SelectEntities(i => i.ID == id && (hue == -1 || i.Hue == hue))
                          .FirstOrDefault();

            if (entity == null)
            {
                return;
            }

            if (amount == -1)
            {
                amount = entity.Count;
            }

            if (amount > entity.Count)
            {
                amount = entity.Count;
            }

            if (destinationSerial == -1)
            {
                ActionPacketQueue.EnqueueDragDropGround(entity.Serial, amount, x, y, z);
            }
            else
            {
                ActionPacketQueue.EnqueueDragDrop(entity.Serial, amount, destinationSerial);
            }
        }
Beispiel #12
0
 public static void ChatMsg(string message)
 {
     UOC.ChatMsg(message);
 }
Beispiel #13
0
 public static void ClearAbility()
 {
     UOC.ClearWeaponAbility();
 }
 public static void ReplyGump(uint gumpId, int buttonId, int[] switches = null, Dictionary <int, string> textEntries = null)
 {
     UOC.GumpButtonClick(gumpId, buttonId, switches, textEntries);
 }
Beispiel #15
0
 public static void PartyMsg(string message)
 {
     UOC.PartyMessage(message);
 }
Beispiel #16
0
        public static void HeadMsg(string message, object obj = null, int hue = DEFAULT_SPEAK_HUE)
        {
            int serial = AliasCommands.ResolveSerial(obj);

            UOC.OverheadMessage(message, hue, serial);
        }
Beispiel #17
0
 public static void SetForceWalk(bool force)
 {
     UOC.SetForceWalk(force);
     UOC.SystemMessage(force ? Strings.Force_Walk_On : Strings.Force_Walk_Off);
 }
        public void SetAbility(AbilityType abilityType)
        {
            if (Engine.Player == null)
            {
                return;
            }

            switch (abilityType)
            {
            case AbilityType.Primary when !IsPrimaryEnabled:
                Enabled = AbilityType.Primary;
                break;

            case AbilityType.Secondary when !IsSecondaryEnabled:
                Enabled = AbilityType.Secondary;
                break;

            default:
                Enabled = AbilityType.None;
                break;
            }

            int twoHandSerial = Engine.Player.GetLayer(Layer.TwoHanded);

            Item twoHandItem = Engine.Items.GetItem(twoHandSerial);

            if (twoHandItem != null)
            {
                WeaponData wd =
                    (_weaponData ?? throw new InvalidOperationException()).FirstOrDefault(d =>
                                                                                          d.Graphic == twoHandItem.ID);

                if (wd != null)
                {
                    UOC.SetWeaponAbility(abilityType == AbilityType.Primary ? wd.Primary : wd.Secondary, abilityType);
                    ResendGump(wd.Primary, wd.Secondary, abilityType);
                    return;
                }
            }

            int oneHandSerial = Engine.Player.GetLayer(Layer.OneHanded);

            Item oneHandItem = Engine.Items.GetItem(oneHandSerial);

            if (oneHandItem != null)
            {
                WeaponData wd =
                    (_weaponData ?? throw new InvalidOperationException()).FirstOrDefault(d =>
                                                                                          d.Graphic == oneHandItem.ID);

                if (wd != null)
                {
                    UOC.SetWeaponAbility(abilityType == AbilityType.Primary ? wd.Primary : wd.Secondary, abilityType);
                    ResendGump(wd.Primary, wd.Secondary, abilityType);
                    return;
                }
            }

            // Fists etc
            ResendGump(5, 11, abilityType);
            UOC.SetWeaponAbility(abilityType == AbilityType.Primary ? 5 : 11, abilityType);
        }
Beispiel #19
0
 public static void Msg(string message, int hue = DEFAULT_SPEAK_HUE)
 {
     UOC.Speak(message, hue);
 }
 public static void ReplyGump(uint gumpId, int buttonId)
 {
     UOC.GumpButtonClick(gumpId, buttonId);
 }
Beispiel #21
0
 public static void YellMsg(string message)
 {
     UOC.Speak(message, DEFAULT_SPEAK_HUE, JournalSpeech.Yell);
 }
Beispiel #22
0
 public static void ReplyGump(uint gumpId, int buttonId, int[] switches = null)
 {
     UOC.GumpButtonClick(gumpId, buttonId, switches);
 }
Beispiel #23
0
 public static void WhisperMsg(string message)
 {
     UOC.Speak(message, DEFAULT_SPEAK_HUE, JournalSpeech.Whisper);
 }