コード例 #1
0
        public void Enter(Machine machine)
        {
            machine.Utility.EquipmentSettings = machine.Utility.LoadEquipmentSettings();

            if (BuffingEquipment.Count.Equals(0) && machine.Core.CharacterFilter.Name.Equals(machine.BuffingCharacter))
            {
                foreach (Equipment item in machine.Utility.EquipmentSettings.BuffingEquipment)
                {
                    BuffingEquipment.Add(item, false);
                }
            }

            if (IdleEquipment.Count.Equals(0) && machine.Core.CharacterFilter.Name.Equals(machine.BuffingCharacter))
            {
                foreach (Equipment item in machine.Utility.EquipmentSettings.IdleEquipment)
                {
                    IdleEquipment.Add(item, true);
                }
            }

            using (WorldObjectCollection wands = machine.Core.WorldFilter.GetInventory())
            {
                wands.SetFilter(new ByObjectClassFilter(ObjectClass.WandStaffOrb));
                foreach (WorldObject wand in wands)
                {
                    machine.Core.Actions.RequestId(wand.Id);
                }
            }
        }
コード例 #2
0
ファイル: Extensions.cs プロジェクト: fartwhif/Warehouse
        public static List <Pack> GetSidePacks(this CoreManager cm)
        {
            List <WorldObject>    targetContainers = new List <WorldObject>();
            WorldObjectCollection myItems          = cm.WorldFilter.GetByOwner(cm.CharacterFilter.Id);

            foreach (WorldObject item in myItems)
            {
                if (item.ObjectClass == ObjectClass.Container)
                {
                    targetContainers.Add(item);
                }
            }
            List <Pack> sidePacks = new List <Pack>();

            foreach (WorldObject cont in targetContainers)
            {
                if (cont.Exists(LongValueKey.ItemSlots))
                {
                    sidePacks.Add(new Pack()
                    {
                        Id            = cont.Id,
                        TotalSlots    = cont.Values(LongValueKey.ItemSlots),
                        OccupiedSlots = cm.WorldFilter.GetByOwner(cont.Id).Count,
                        WorldObject   = cont
                    });
                }
            }
            return(sidePacks);
        }
コード例 #3
0
        private void CharacterFilter_LoginComplete(object sender, EventArgs e)
        {
            try
            {
                string[] keys = new string[rl.getList().Count];
                rl.getList().Keys.CopyTo(keys, 0);
                for (int i = 0; i < rl.rareCount.Count; i++)
                {
                    rl.SetValue(keys[i], 0);
                }

                //update rare list from inventory
                WorldObjectCollection woc = Core.WorldFilter.GetInventory();
                foreach (WorldObject wo in woc)
                {
                    if (rl.getList().ContainsKey(wo.Name))
                    {
                        if (wo.Values(LongValueKey.StackCount) > 0)
                        {
                            rl.rareCount[wo.Name].count += wo.Values(LongValueKey.StackCount);
                        }
                        else
                        {
                            rl.rareCount[wo.Name].count += 1;
                        }
                    }
                }

                showAllCB.Checked = false;
                updateList(false);
                loadCSV();
            }
            catch (Exception ex) { Util.LogError(ex); }
        }
コード例 #4
0
ファイル: BuyingUtils.cs プロジェクト: LucasTrask/DucasTest
        public static void AddKitsAndNotesToBuyTab()
        {
            WorldObjectCollection items = Globals.Core.WorldFilter.GetByContainer(Globals.Core.CharacterFilter.Id);
            int total = 0;
            int used  = 0;

            foreach (WorldObject item in items)
            {
                total++;
                switch (item.Name)
                {
                case "Treated Healing Kit":
                case "Trade Note (5,000)":
                case "Trade Note (10,000)":
                case "Trade Note (50,000)":
                    used++;
                    AddItemToBuyTab(item.Id);
                    break;

                case "Pack":
                case "Sack":
                    total--;
                    break;

                default:
                    break;
                }
            }
            Util.WriteToChat("Added " + used.ToString() + " items out of " + total.ToString() + ".", ChatUtil.Color.orange);
        }
コード例 #5
0
 internal int GetInventoryCount(string itemName)
 {
     using (WorldObjectCollection inventory = Machine.Core.WorldFilter.GetInventory())
     {
         inventory.SetFilter(new ByNameFilter(itemName));
         return(inventory.Quantity);
     }
 }
コード例 #6
0
 private int QuantityInInventory(string compName)
 {
     using (WorldObjectCollection inventory = Core.WorldFilter.GetInventory())
     {
         inventory.SetFilter(new ByNameFilter(compName));
         return(inventory.Quantity);
     }
 }
コード例 #7
0
ファイル: FilterCore.cs プロジェクト: patri0t86/ACManager
        /// <summary>
        /// Parses the client messages.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FilterCore_ClientDispatch(object sender, NetworkMessageEventArgs e)
        {
            if (e.Message.Type.Equals(0xF7B1))
            {
                // Materialize character (including any portal taken)
                if (e.Message.Value <int>("action").Equals(0x00A1))
                {
                    if (Machine == null)
                    {
                        Debug.Init(Path);
                        Machine = new Machine(Core, Path);
                    }

                    if (!Machine.LoggedIn)
                    {
                        CommandLineText          += Machine.Interpreter.Command;
                        Machine.AccountCharacters = AccountCharacters;
                        Machine.Core = Core;

                        // Instantiate views
                        Machine.BotManagerView = new BotManagerView(Machine);

                        Machine.CharacterEquipment.Clear();
                        Machine.FinishedInitialScan    = false;
                        Machine.Enabled                = Machine.Utility.BotSettings.BotEnabled;
                        Machine.LoggedIn               = true;
                        Core.RenderFrame              += Machine.Clock;
                        Core.WorldFilter.ChangeObject += Machine.WorldFilter_ChangeObject;

                        Debug.ToChat($"Running ACManager {Machine.Utility.Version} by Shem of Harvestgain (now Coldeve). Check out the latest on the project at https://github.com/patri0t86/ACManager.");
                        Debug.ToChat("Scanning inventory, please wait before using the Equipment manager to build suits...");

                        using (WorldObjectCollection inventory = Core.WorldFilter.GetInventory())
                        {
                            foreach (WorldObject item in inventory)
                            {
                                if (item.ObjectClass.Equals(ObjectClass.Armor) ||
                                    item.ObjectClass.Equals(ObjectClass.Jewelry) ||
                                    item.ObjectClass.Equals(ObjectClass.Clothing) ||
                                    item.ObjectClass.Equals(ObjectClass.WandStaffOrb))
                                {
                                    Machine.CharacterEquipment.Add(item);
                                    Core.Actions.RequestId(item.Id);
                                }
                            }
                        }
                    }
                }

                // Start casting
                if (Convert.ToInt32(e.Message.Value <int>("action")).Equals(0x004A))
                {
                    Machine.CastStarted = true;
                }
            }
        }
コード例 #8
0
ファイル: Casting.cs プロジェクト: patri0t86/ACManager
        public void Enter(Machine machine)
        {
            machine.Fizzled       = false;
            machine.CastCompleted = false;
            machine.CastStarted   = false;
            EnteredState          = DateTime.Now;

            if (machine.CurrentRequest.RequestType.Equals(RequestType.Buff))
            {
                if (!SentInitialInfo)
                {
                    Started         = DateTime.Now;
                    SentInitialInfo = true;
                    SpellCastCount  = 0;

                    if (machine.Inventory.LowComponents.Count > 0)
                    {
                        machine.ChatManager.Broadcast(machine.Inventory.LowCompsReport());
                    }

                    TimeSpan buffTime = TimeSpan.FromSeconds(machine.SpellsToCast.Count * 4);
                    string   message  = $"Casting {machine.SpellsToCast.Count} buffs on you. This should take about {buffTime.Minutes} minutes and {buffTime.Seconds} seconds.";

                    if (machine.CurrentRequest.RequesterGuid != 0 && !CastBanes)
                    {
                        if (ContainsBanes(machine.SpellsToCast))
                        {
                            using (WorldObjectCollection items = machine.Core.WorldFilter.GetByContainer(machine.CurrentRequest.RequesterGuid))
                            {
                                items.SetFilter(new ByObjectClassFilter(ObjectClass.Armor));
                                if (items.Count > 0)
                                {
                                    if (!items.First.Name.Contains("Covenant"))
                                    {
                                        CastBanes = true;
                                    }
                                    else
                                    {
                                        message += " You are wearing a covenant shield, so I will be skipping banes.";
                                    }
                                }
                                else
                                {
                                    message += " You are not wearing a shield, so I will be skipping banes.";
                                }
                            }
                        }
                    }
                    machine.ChatManager.SendTell(machine.CurrentRequest.RequesterName, message);
                }
            }
        }
コード例 #9
0
ファイル: NpcFinder.cs プロジェクト: LucasTrask/DucasTest
        public static WorldObject GetNpc(string name)
        {
            WorldObjectCollection nearby_npcs = Globals.Core.WorldFilter.GetByObjectClass(ObjectClass.Npc);

            foreach (WorldObject npc in nearby_npcs)
            {
                if (npc.Name.Equals(name))
                {
                    return(npc);
                }
            }
            return(null);
        }
コード例 #10
0
        private static Boolean GenerateItemLists(List <string> itemsThatCanBeTurnedIn)
        {
            WorldObjectCollection all_character_items_and_packs = Globals.Core.WorldFilter.GetByCategory(Globals.Core.CharacterFilter.Id);

            foreach (WorldObject item in all_character_items_and_packs) // cleaner looking
            {
                if (itemsThatCanBeTurnedIn.Contains(item.Name))
                {
                    turnins.Add(item.Id);
                }
            }

            return(turnins.Count > 0);
        }
コード例 #11
0
ファイル: Util.cs プロジェクト: fartwhif/Warehouse
 /// <summary>
 /// doesn't work sometimes
 /// </summary>
 /// <param name="co"></param>
 /// <returns></returns>
 private double GetMyDistanceTo(CoordsObject co)
 {
     try
     {
         WorldObjectCollection woc      = Core.WorldFilter.GetByObjectClass(ObjectClass.Player);
         CoordsObject          myCoords = woc.Current.Coordinates();
         return(myCoords.DistanceToCoords(co));
     }
     catch (Exception ex)
     {
         errorLogging.LogError(ErrorLogFile, ex);
     }
     return(-1);
 }
コード例 #12
0
ファイル: Extensions.cs プロジェクト: fartwhif/Warehouse
        public static List <WorldObject> GetAllStackableItems(this CoreManager cm)
        {
            List <WorldObject>    targetContainers = new List <WorldObject>();
            WorldObjectCollection myItems          = cm.WorldFilter.GetByOwner(cm.CharacterFilter.Id);
            List <WorldObject>    items            = new List <WorldObject>();

            foreach (WorldObject item in myItems)
            {
                if (item.ObjectClass != ObjectClass.Container && item.ObjectClass != ObjectClass.Foci && !item.IsWielded() && !item.IsEquipped() && item.StackMax().HasValue)
                {
                    items.Add(item);
                }
            }
            return(items);
        }
コード例 #13
0
 internal bool UseItem(string itemName)
 {
     using (WorldObjectCollection inventory = Machine.Core.WorldFilter.GetInventory())
     {
         inventory.SetFilter(new ByNameFilter(itemName));
         if (inventory.Quantity > 0)
         {
             Machine.Core.Actions.UseItem(inventory.First.Id, 0);
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
コード例 #14
0
        private void WorldFilter_EnterTrade(object sender, EnterTradeEventArgs e)
        {
            WorldObjectCollection players = Core.WorldFilter.GetByObjectClass(ObjectClass.Player);
            int myId = Core.CharacterFilter.Id;

            foreach (WorldObject player in players.Where(k => k.Id != myId))
            {
                if (player.Id == e.TraderId || player.Id == e.TradeeId)
                {
                    TradePartnerName = player.Name;
                    TradePartnerId   = player.Id;
                }
            }
            if (GivingItems != null)
            {
                WorldObjectCollection woc = Core.WorldFilter.GetByOwner(Core.CharacterFilter.Id);
                foreach (WorldObject wo in woc)
                {
                    if (wo.ObjectClass != ObjectClass.Container)
                    {
                        if (GivingItems.Contains(wo.Id))
                        {
                            PendingItemsToTradeAdd.Add(wo);
                        }
                    }
                }
                AddPendingItemsToTrade();
                GivingItems = null;
            }
            else
            {
                if (TradePartnerName != "")
                {
                    SayHelp(TradePartnerName, false, true);
                }
                WorldObjectCollection woc = Core.WorldFilter.GetByOwner(Core.CharacterFilter.Id);
                foreach (WorldObject wo in woc)
                {
                    if (wo.ObjectClass != ObjectClass.Container)
                    {
                        PendingItemsToTradeAdd.Add(wo);
                    }
                }
                AddPendingItemsToTrade();
            }
        }
コード例 #15
0
        static bool IsSupplyLow(string item_name, int min_count, bool onlyEquipped)
        {
            int supply = 0;
            WorldObjectCollection inventory = PluginCore.MyCore.WorldFilter.GetInventory();

            foreach (WorldObject worldObject in inventory)
            {
                if (worldObject.Name.Equals(item_name))
                {
                    if ((worldObject.Values(LongValueKey.EquippedSlots) > 0) || !onlyEquipped)
                    {
                        supply += worldObject.Values(LongValueKey.StackCount, 0);
                    }
                }
            }
            return(supply < min_count);
        }
コード例 #16
0
ファイル: Collector.cs プロジェクト: LucasTrask/DucasTest
        private static Boolean GenerateItemLists()
        {
            WorldObjectCollection all_character_items_and_packs = Globals.Core.WorldFilter.GetByCategory(Globals.Core.CharacterFilter.Id);

            foreach (WorldObject item in all_character_items_and_packs) // cleaner looking
            {                                                           // i should hard code a list of everything the Collector can accept aad compare instead of switch
                switch (item.Name)
                {
                case "Seal":
                case "Shendolain Key":
                case "Large Lugian Sinew":
                    turnins.Add(item.Id);
                    break;
                }
            }

            return(turnins.Count > 0);
        }
コード例 #17
0
        /**
         * Returns a false if no matching items found, otherwise adds item ids to respective lists
         */
        private static Boolean GenerateItemLists()
        {
            turnins.Clear();
            WorldObjectCollection all_character_items_and_packs = Globals.Core.WorldFilter.GetByCategory(Globals.Core.CharacterFilter.Id);

            foreach (WorldObject item in all_character_items_and_packs) // cleaner looking
            {
                switch (item.Name)
                {
                case "A Large Mnemosyne":
                case "An Unlocked Large Mnemosyne":
                    turnins.Add(item.Id);
                    break;
                }
            }

            return(turnins.Count > 0);
        }
コード例 #18
0
ファイル: Extensions.cs プロジェクト: fartwhif/Warehouse
        public static List <Item> GetAllMyItems(this CoreManager cm)
        {
            List <WorldObject>    targetContainers = new List <WorldObject>();
            WorldObjectCollection myItems          = cm.WorldFilter.GetByOwner(cm.CharacterFilter.Id);
            List <Item>           items            = new List <Item>();

            foreach (WorldObject item in myItems)
            {
                if (item.ObjectClass != ObjectClass.Container && item.ObjectClass != ObjectClass.Foci && !item.Attuned() && !item.IsWielded() && !item.IsEquipped())
                {
                    items.Add(new Item()
                    {
                        ItemId   = item.Id,
                        ItemName = item.RealName()
                    });
                }
            }
            return(items);
        }
コード例 #19
0
        /**
         * Takes a list of Items names, if it finds any of them, it'll build a list for each to do whatever you want to do with it.
         */
        public static MultiMap <int> FromInventory(List <String> itemTypesToLookFor)
        {
            WorldObjectCollection items = Globals.Core.WorldFilter.GetByContainer(Globals.Core.CharacterFilter.Id);

            MultiMap <int> mVD = new MultiMap <int>();

            foreach (WorldObject item in items)
            {
                if (!item.ObjectClass.ToString().Equals("Salvage"))
                {
                    //Util.WriteToChat(item.ObjectClass.ToString() + " item found. This is not salvage! ");
                }
                else
                {
                    mVD.Add(item.Type.ToString(), item.Id);
                }
            }

            return(mVD);
        }
コード例 #20
0
        private bool HaveFociOrAugmentation(int spellId)
        {
            string school = SpellSchool(spellId).Name;

            // Foci check
            using (WorldObjectCollection inventory = Core.WorldFilter.GetInventory())
            {
                inventory.SetFilter(new ByObjectClassFilter(ObjectClass.Foci));
                foreach (WorldObject foci in inventory)
                {
                    if (foci.Name.Equals("Foci of Enchantment") && school.Equals("Creature Enchantment"))
                    {
                        return(true);
                    }
                    else if (foci.Name.Equals("Foci of Artifice") && school.Equals("Item Enchantment"))
                    {
                        return(true);
                    }
                    else if (foci.Name.Equals("Foci of Verdancy") && school.Equals("Life Magic"))
                    {
                        return(true);
                    }
                }
            }

            // Infused Augmentation check
            if (school.Equals("Creature Enchantment") && Core.CharacterFilter.GetCharProperty((int)Augmentations.InfusedCreature) > 0)
            {
                return(true);
            }
            else if (school.Equals("Item Enchantment") && Core.CharacterFilter.GetCharProperty((int)Augmentations.InfusedItem) > 0)
            {
                return(true);
            }
            else if (school.Equals("Life Magic") && Core.CharacterFilter.GetCharProperty((int)Augmentations.InfusedLife) > 0)
            {
                return(true);
            }

            return(false);
        }
コード例 #21
0
ファイル: Extensions.cs プロジェクト: fartwhif/Warehouse
        public static List <Item> GetMainPackContentsForCram(this CoreManager cm)
        {
            List <WorldObject>    targetContainers = new List <WorldObject>();
            WorldObjectCollection myItems          = cm.WorldFilter.GetByContainer(cm.CharacterFilter.Id);
            List <Item>           items            = new List <Item>();

            foreach (WorldObject item in myItems)
            {
                if (item.ObjectClass != ObjectClass.Container && item.ObjectClass != ObjectClass.Foci)
                {
                    if (!item.IsEquipped() && !item.IsWielded())
                    {
                        items.Add(new Item()
                        {
                            ItemId = item.Id
                        });
                    }
                }
            }
            return(items);
        }
コード例 #22
0
        static void ApplyItemByNames(string itemA, string itemB)
        {
            int guidA = 0, guidB = 0;
            WorldObjectCollection inventory = PluginCore.MyCore.WorldFilter.GetInventory();

            foreach (WorldObject worldObject in inventory)
            {
                if (worldObject.Name.Equals(itemA))
                {
                    guidA = worldObject.Id;
                }
                if (worldObject.Name.Equals(itemB))
                {
                    guidB = worldObject.Id;
                }
                if (guidA != 0 && guidB != 0)
                {
                    break;
                }
            }
            PluginCore.MyHost.Actions.ApplyItem(guidA, guidB);
        }
コード例 #23
0
ファイル: Extensions.cs プロジェクト: fartwhif/Warehouse
        public static WorldObject GetPlayerByIdOrName(this CoreManager cm, int id, string name)
        {
            WorldObjectCollection players = cm.WorldFilter.GetByObjectClass(ObjectClass.Player);

            if (id != 0)
            {
                WorldObject plr = players.FirstOrDefault(k => k.Id == id);
                if (plr != null)
                {
                    return(plr);
                }
            }
            if (!string.IsNullOrEmpty(name))
            {
                WorldObject plr = players.FirstOrDefault(k => k.Name == name);
                if (plr != null)
                {
                    return(plr);
                }
            }
            return(null);
        }
コード例 #24
0
 internal void GetComponentLevels()
 {
     SpellComponents.Clear();
     for (int i = 0; i < Machine.Core.Filter <FileService>().ComponentTable.Length; i++)
     {
         using (WorldObjectCollection collection = Machine.Core.WorldFilter.GetInventory())
         {
             collection.SetFilter(new ByNameFilter(Machine.Core.Filter <FileService>().ComponentTable[i].Name));
             if (collection.Quantity > 0)
             {
                 if (SpellComponents.ContainsKey(Machine.Core.Filter <FileService>().ComponentTable[i].Name))
                 {
                     SpellComponents[Machine.Core.Filter <FileService>().ComponentTable[i].Name] = collection.Quantity;
                 }
                 else if (!SpellComponents.ContainsKey(Machine.Core.Filter <FileService>().ComponentTable[i].Name))
                 {
                     SpellComponents.Add(Machine.Core.Filter <FileService>().ComponentTable[i].Name, collection.Quantity);
                 }
             }
         }
     }
     CheckComponentThresholds();
 }
コード例 #25
0
        internal void UpdateInventoryFile()
        {
            // create new inventory to write to in-memory
            CharacterInventory inv = new CharacterInventory
            {
                Name = Machine.Core.CharacterFilter.Name
            };

            // go through entire components table and get quantities and add them to inventory in-memory if quantity > 0
            for (int i = 0; i < Machine.Core.Filter <FileService>().ComponentTable.Length; i++)
            {
                int quantity = GetInventoryCount(Machine.Core.Filter <FileService>().ComponentTable[i].Name);
                if (quantity > 0)
                {
                    AcmComponent component = new AcmComponent()
                    {
                        Name     = Machine.Core.Filter <FileService>().ComponentTable[i].Name,
                        Quantity = quantity
                    };
                    inv.Components.Add(component);
                }
            }

            // search for gems known in the bot settings and add them to inventory
            foreach (GemSetting gem in Machine.Utility.BotSettings.GemSettings)
            {
                using (WorldObjectCollection inventory = Machine.Core.WorldFilter.GetInventory())
                {
                    int quantity = GetInventoryCount(gem.Name);
                    if (quantity > 0)
                    {
                        Gem newGem = new Gem
                        {
                            Name     = gem.Name,
                            Quantity = quantity
                        };
                        inv.Gems.Add(newGem);
                    }
                }
            }

            // if the inventory file contains this character, update it, otherwise add it
            if (Machine.Utility.Inventory.CharacterInventories.Contains(inv))
            {
                for (int i = 0; i < Machine.Utility.Inventory.CharacterInventories.Count; i++)
                {
                    if (Machine.Utility.Inventory.CharacterInventories[i].Equals(inv))
                    {
                        Machine.Utility.Inventory.CharacterInventories[i] = inv;
                        break;
                    }
                }
            }
            else
            {
                Machine.Utility.Inventory.CharacterInventories.Add(inv);
            }

            // save inventory to file
            Machine.Utility.SaveInventory();
        }
コード例 #26
0
        private void MainLoopTimer_Tick(object sender, EventArgs e)
        {
            if (loggedIn && TimeSinceLoginStarted != null && TimeSinceLoginStarted.Elapsed.TotalSeconds > 13)
            {
                if ((TimeSinceWatchDogBark?.Elapsed.TotalSeconds ?? int.MaxValue) > 5)
                {
                    TimeSinceWatchDogBark = Stopwatch.StartNew();
                    AppMessage resp = Client.Send(AppMessage.New($"Warehouse for {Core.CharacterFilter.AccountName}", 90, true));
                    if (!WatchDogRegistered && resp != null)
                    {
                        WatchDogRegistered = true;
                        Log($"Registered with watchdog, pool occupancy: {resp.PoolSize + 1}");
                    }
                }
                if (FirstInner)
                {
                    Log($"CAUTION: Warehouse {VersionString} is running");
                    Log($"Anyone near you can take all your non-attuned items.");
                    Log($"Commands: whallowretrieve, whplayerdetectionjump, whallowjumpcmd");
                    FirstInner = false;
                }
                if (PendingRetrieveCommand != null && CharToLogin != null && Core.CharacterFilter.Id == CharToLogin.Value && PendingTradeGiveItems.Count > 0)
                {
                    TradeGiveItem(PendingRetrieveCommand.ChatterId, PendingRetrieveCommand.ChatterName, PendingTradeGiveItems.ToArray());
                    PendingTradeGiveItems.Clear();
                    PendingRetrieveCommand = null;
                    CharToLogin            = null;
                }
                else if (CharToLogin != null)
                {
                    CharToLogin = null;
                }

                if (PlayerDetectionJump)
                {
                    #region nearby player check
                    try
                    {
                        WorldObjectCollection woc = Core.WorldFilter.GetByObjectClass(ObjectClass.Player);
                        int playerCount           = woc.Quantity;
                        if (prevPlayerCount != playerCount)
                        {
                            prevPlayerCount = playerCount;
                            WantToJump      = true;
                        }
                    }
                    catch (Exception ex)
                    {
                        errorLogging.LogError(ErrorLogFile, ex);
                    }
                    #endregion
                }

                if (!ItemScanInProgress && (TimeSinceScanFinished == null || TimeSinceScanFinished.Elapsed > TimeSpan.FromMinutes(5)))
                {
                    WantToSyncItems = true;
                }

                if (!CramTimer.Enabled && !StackTimer.Enabled)
                {
                    Cram();
                }
                if (!StackTimer.Enabled)
                {
                    Stack();
                }
                if (WantToJump)
                {
                    Core.Foreground();
                    SendKey("o", true, true);
                    WantToJump = false;
                }
                SyncItems();
            }
            else if (!loggedIn)
            {
                DoLoginStuff();
                return;
            }
        }
コード例 #27
0
ファイル: ChatManager.cs プロジェクト: patri0t86/ACManager
        /// <summary>
        /// Handles all direct tells.
        /// </summary>
        /// <param name="match"></param>
        private void HandleTell(Match match)
        {
            // The actual message
            string message = match.Groups["message"].Value.ToLower();

            // The GUID of the player sending the tell
            int guid = Convert.ToInt32(match.Groups["guid"].Value);

            // The in-game character name sending the tell
            CharacterMakingRequest = match.Groups["name"].Value;

            if (!string.IsNullOrEmpty(message))
            {
                if (message.Equals("whereto") || message.Equals("where to"))
                {
                    RespondWithPortals();
                }
                else if (message.Equals("help"))
                {
                    SendTell(CharacterMakingRequest, "My list of commands are: profiles, whereto, and comps.");
                }
                else if (message.Equals("profiles"))
                {
                    RespondWithProfiles();
                }
                else if (message.Equals("cancel"))
                {
                    CancelRequest();
                }
                else if (message.Equals("comps"))
                {
                    Dictionary <string, int> components = new Dictionary <string, int>();
                    for (int i = 0; i < Machine.Core.Filter <FileService>().ComponentTable.Length; i++)
                    {
                        using (WorldObjectCollection collection = Machine.Core.WorldFilter.GetInventory())
                        {
                            collection.SetFilter(new ByNameFilter(Machine.Core.Filter <FileService>().ComponentTable[i].Name));
                            if (collection.Quantity > 0)
                            {
                                if (collection.First.Name.Contains("Scarab"))
                                {
                                    switch (collection.First.Name)
                                    {
                                    case "Lead Scarab":
                                        components.Add(collection.First.Name, collection.Quantity);
                                        break;

                                    case "Iron Scarab":
                                        components.Add(collection.First.Name, collection.Quantity);
                                        break;

                                    case "Copper Scarab":
                                        components.Add(collection.First.Name, collection.Quantity);
                                        break;

                                    case "Silver Scarab":
                                        components.Add(collection.First.Name, collection.Quantity);
                                        break;

                                    case "Gold Scarab":
                                        components.Add(collection.First.Name, collection.Quantity);
                                        break;

                                    case "Pyreal Scarab":
                                        components.Add(collection.First.Name, collection.Quantity);
                                        break;

                                    case "Platinum Scarab":
                                        components.Add(collection.First.Name, collection.Quantity);
                                        break;

                                    case "Mana Scarab":
                                        components.Add(collection.First.Name, collection.Quantity);
                                        break;
                                    }
                                }
                                else
                                {
                                    components.Add(collection.First.Name, collection.Quantity);
                                }
                            }
                        }
                    }

                    if (components.Count > 0)
                    {
                        string[] keys   = new string[components.Count];
                        int[]    values = new int[components.Count];
                        components.Keys.CopyTo(keys, 0);
                        components.Values.CopyTo(values, 0);
                        StringBuilder sb = new StringBuilder();
                        sb.Append("I currently have ");
                        for (int i = 0; i < components.Count; i++)
                        {
                            if (i.Equals(components.Count - 1) && components.Count > 1)
                            {
                                sb.Append($"and ");
                            }
                            sb.Append($"{values[i]} {keys[i]}{(values[i] > 1 ? "s" : "")}");
                            if (i < components.Count - 1)
                            {
                                sb.Append($", ");
                            }
                            if (i.Equals(components.Count - 1))
                            {
                                sb.Append(".");
                            }
                        }
                        SendTell(CharacterMakingRequest, sb.ToString());
                    }
                    else
                    {
                        SendTell(CharacterMakingRequest, "I don't have any components.");
                    }
                }
                else
                {
                    CheckCommands(guid, message, true);
                }
            }
        }
コード例 #28
0
        void Current_ChatBoxMessage(object sender, ChatTextInterceptEventArgs e)
        {
            try
            {
                if (e.Eat || string.IsNullOrEmpty(e.Text))
                {
                    return;
                }

                bool isChat = Util.IsChat(e.Text);

                if (e.Eat == false && Settings.SettingsManager.Filters.AttackEvades.Value)
                {
                    // Ruschk S****t evaded your attack.
                    if (!isChat && e.Text.Contains(" evaded your attack."))
                    {
                        e.Eat = true;
                    }
                }

                if (e.Eat == false && Settings.SettingsManager.Filters.DefenseEvades.Value)
                {
                    // You evaded Ruschk S****t!
                    if (!isChat && e.Text.StartsWith("You evaded "))
                    {
                        e.Eat = true;
                    }
                }

                if (e.Eat == false && Settings.SettingsManager.Filters.AttackResists.Value)
                {
                    // Sentient Crystal Shard resists your spell
                    // Invading Silver Scope Knight resists your spell
                    if (!isChat && e.Text.Contains(" resists your spell"))
                    {
                        e.Eat = true;
                    }
                }

                if (e.Eat == false && Settings.SettingsManager.Filters.DefenseResists.Value)
                {
                    // You resist the spell cast by Sentient Crystal Shard
                    if (!isChat && e.Text.StartsWith("You resist the spell cast by "))
                    {
                        e.Eat = true;
                    }

                    // You have no appropriate targets equipped for Ruschk Warlord's spell.
                    if (!isChat && e.Text.StartsWith("You have no appropriate target") && e.Text.Contains("spell"))
                    {
                        e.Eat = true;
                    }

                    // You are an invalid target for the spell of Ruschk Warlord.
                    if (!isChat && e.Text.StartsWith("You are an invalid target for the spell"))
                    {
                        e.Eat = true;
                    }

                    // Ruschk Warlord tried to cast a spell on you, but was too far away!
                    if (!isChat && e.Text.Contains("tried to cast a spell on you, but was too far away!"))
                    {
                        e.Eat = true;
                    }
                }

                if (e.Eat == false && Settings.SettingsManager.Filters.NPKFails.Value)
                {
                    if (!isChat && e.Text.StartsWith("You fail to affect ") && e.Text.Contains(" you are not a player killer!"))
                    {
                        e.Eat = true;
                    }

                    if (!isChat && e.Text.Contains("fails to affect you") && e.Text.Contains(" is not a player killer!"))
                    {
                        e.Eat = true;
                    }
                }

                if (e.Eat == false && Settings.SettingsManager.Filters.DirtyFighting.Value)
                {
                    // Dirty Fighting! [player] delivers a Traumatic Assault to [mob]!
                    // Dirty Fighting! [player] delivers a Bleeding Assault to [mob]!
                    // Dirty Fighting! [player] delivers a Unbalancing Assault to [mob]!
                    // Dirty Fighting! [player] delivers a Blinding Assault to [mob]!
                    if (!isChat && e.Text.StartsWith("Dirty Fighting! ") && e.Text.Contains(" delivers a "))
                    {
                        e.Eat = true;
                    }
                }

                if (e.Eat == false && Settings.SettingsManager.Filters.MonsterDeaths.Value)
                {
                    if (Trackers.Combat.Standard.CombatMessages.IsKilledByMeMessage(e.Text))
                    {
                        e.Eat = true;
                    }
                }

                if (e.Eat == false && Settings.SettingsManager.Filters.SpellCastingMine.Value)
                {
                    // You say, "Zojak
                    if (Util.IsSpellCastingMessage(e.Text, true, false))
                    {
                        e.Eat = true;
                    }
                }

                if (e.Eat == false && Settings.SettingsManager.Filters.SpellCastingOthers.Value)
                {
                    // Fat Guy In A Little Coat says, "Zojak
                    if (Util.IsSpellCastingMessage(e.Text, false))
                    {
                        e.Eat = true;
                    }
                }

                if (e.Eat == false && Settings.SettingsManager.Filters.SpellCastFizzles.Value)
                {
                    // Your spell fizzled.
                    if (!isChat && e.Text.StartsWith("Your spell fizzled."))
                    {
                        e.Eat = true;
                    }
                }

                if (e.Eat == false && Settings.SettingsManager.Filters.CompUsage.Value)
                {
                    // The spell consumed the following components:
                    if (!isChat && e.Text.StartsWith("The spell consumed the following components"))
                    {
                        e.Eat = true;
                    }
                }

                if (e.Eat == false && Settings.SettingsManager.Filters.SpellExpires.Value)
                {
                    // Don't filter rare expires
                    if (!isChat && !e.Text.Contains("Brilliance") && !e.Text.Contains("Prodigal") && !e.Text.Contains("Spectral"))
                    {
                        // The spell Defender VI on Brass Sceptre has expired.
                        // Focus Self VI has expired.
                        if (e.Text.Contains("has expired.") || e.Text.Contains("have expired."))
                        {
                            e.Eat = true;
                        }
                    }
                }


                if (e.Eat == false && Settings.SettingsManager.Filters.HealingKitSuccess.Value)
                {
                    // You heal yourself for 88 Health points. Your treated Healing Kit has 16  uses left.
                    // You expertly heal yourself for 123 Health points. Your Treated Healing Kit has 41 uses left.
                    if (!isChat && e.Text.StartsWith("You ") && e.Text.Contains(" heal yourself for "))
                    {
                        e.Eat = true;
                    }
                }

                if (e.Eat == false && Settings.SettingsManager.Filters.HealingKitFail.Value)
                {
                    // You fail to heal yourself. Your Treated Healing Kit has 18 uses left.
                    if (!isChat && e.Text.StartsWith("You fail to heal yourself. "))
                    {
                        e.Eat = true;
                    }
                }

                if (e.Eat == false && Settings.SettingsManager.Filters.Salvaging.Value)
                {
                    // You obtain 9 granite (ws 8.00) using your knowledge of Salvaging
                    if (!isChat && e.Text.StartsWith("You obtain ") && e.Text.Contains(" using your knowledge of "))
                    {
                        e.Eat = true;
                    }
                }

                if (e.Eat == false && Settings.SettingsManager.Filters.SalvagingFails.Value)
                {
                    // Salvaging Failed!
                    if (!isChat && e.Text.StartsWith("Salvaging Failed!"))
                    {
                        e.Eat = true;
                    }

                    //  The following were not suitable for salvaging: Salvaged Sunstone (79), Salvaged Sunstone (7).
                    if (!isChat && e.Text.Contains("The following were not suitable for salvaging: "))
                    {
                        e.Eat = true;
                    }
                }

                if (e.Eat == false && Settings.SettingsManager.Filters.AuraOfCraftman.Value)
                {
                    // Your Aura of the Craftman augmentation increased your skill by 5!
                    if (!isChat && e.Text.StartsWith("Your Aura of the Craftman augmentation increased your skill by 5!"))
                    {
                        e.Eat = true;
                    }
                }

                if (e.Eat == false && Settings.SettingsManager.Filters.ManaStoneUsage.Value)
                {
                    // The Mana Stone gives 6,127 points of mana to the following items:
                    if (!isChat && e.Text.StartsWith("The Mana Stone gives "))
                    {
                        e.Eat = true;
                    }
                    // You need 6,833 more mana to fully charge your items.
                    if (!isChat && e.Text.StartsWith("You need ") && e.Text.Trim().EndsWith(" more mana to fully charge your items."))
                    {
                        e.Eat = true;
                    }
                    // The Mana Stone drains 3,153 points of mana from the Fez.
                    if (!isChat && e.Text.StartsWith("The Mana Stone drains "))
                    {
                        e.Eat = true;
                    }
                    // The Fez is destroyed.
                    if (!isChat && e.Text.StartsWith("The ") && e.Text.Trim().EndsWith(" is destroyed."))
                    {
                        e.Eat = true;
                    }
                }


                if (e.Eat == false && Settings.SettingsManager.Filters.TradeBuffBotSpam.Value)
                {
                    if (Util.IsChat(e.Text, Util.ChatFlags.PlayerSaysLocal) && (e.Text.Trim().EndsWith("-t-\"") || e.Text.Trim().EndsWith("-b-\"")))
                    {
                        e.Eat = true;
                    }

                    // Trade bot emotes
                    if (!isChat && (e.Text.Trim().EndsWith("-t-") || e.Text.Trim().EndsWith("-b-")))
                    {
                        e.Eat = true;
                    }
                }

                if (e.Eat == false && Settings.SettingsManager.Filters.FailedAssess.Value)
                {
                    // Someone tried and failed to assess you!
                    if (!isChat && e.Text.Trim().EndsWith("tried and failed to assess you!"))
                    {
                        e.Eat = true;
                    }
                }


                if (e.Eat == false && Settings.SettingsManager.Filters.KillTaskComplete.Value)
                {
                    // You have killed 50 Drudge Raveners! Your task is complete!
                    if (!isChat && e.Text.StartsWith("You have killed ") && e.Text.Trim().EndsWith("Your task is complete!"))
                    {
                        e.Eat = true;
                    }
                }

                if (e.Eat == false && Settings.SettingsManager.Filters.VendorTells.Value)
                {
                    if (Util.IsChat(e.Text, Util.ChatFlags.NpcTellsYou))
                    {
                        string sourceName = Util.GetSourceOfChat(e.Text);

                        if (!string.IsNullOrEmpty(sourceName))
                        {
                            WorldObjectCollection collection = CoreManager.Current.WorldFilter.GetByName(sourceName);

                            if (collection.Count >= 1 && collection.First.ObjectClass == ObjectClass.Vendor)
                            {
                                e.Eat = true;
                            }
                        }
                    }
                }

                if (e.Eat == false && Settings.SettingsManager.Filters.MonsterTell.Value)
                {
                    if (Util.IsChat(e.Text, Util.ChatFlags.NpcTellsYou))
                    {
                        string sourceName = Util.GetSourceOfChat(e.Text);

                        if (!string.IsNullOrEmpty(sourceName))
                        {
                            WorldObjectCollection collection = CoreManager.Current.WorldFilter.GetByName(sourceName);

                            if (collection.Count >= 1 && collection.First.ObjectClass == ObjectClass.Monster)
                            {
                                e.Eat = true;
                            }
                        }
                    }
                }

                if (e.Eat == false && Settings.SettingsManager.Filters.NpcChatter.Value)
                {
                    if (Util.IsChat(e.Text, Util.ChatFlags.NpcSays))
                    {
                        string sourceName = Util.GetSourceOfChat(e.Text);

                        if (!string.IsNullOrEmpty(sourceName))
                        {
                            WorldObjectCollection collection = CoreManager.Current.WorldFilter.GetByName(sourceName);

                            if (collection.Count >= 1 && collection.First.ObjectClass == ObjectClass.Npc)
                            {
                                e.Eat = true;
                            }
                        }
                    }
                }

                if (e.Eat == false && (Settings.SettingsManager.Filters.MasterArbitratorSpam.Value || Settings.SettingsManager.Filters.AllMasterArbitratorChat.Value))
                {
                    if (isChat)
                    {
                        if (Util.GetSourceOfChat(e.Text) == "Master Arbitrator")
                        {
                            /*
                             * (We don't filter these)
                             * Master Arbitrator tells you, "If you wish to fight as a gladiator in the Arena I will require you to purchase a ticket from the Ticket Vendors over there. We do need to keep the place running don't we?"
                             * Master Arbitrator tells you, "Also, I warn you now. Prepare your fellowship ahead of time. Once you pay me you cannot change your registered group and only that group will be allowed into the Arena I assign you. After you enter the Arena you must wait one hour before recieving your reward. Our gladiators need time to rest between fights."
                             *
                             * (We don't filter these)
                             * 20:57:15 Master Arbitrator tells you, "Your fellowship's Arena battles still continue. I cannot reward anyone in your fellowship while they still have time left in the Colosseum. (4s)"
                             * 20:57:17 Master Arbitrator tells you, "Your fellowship's Arena battles still continue. I cannot reward anyone in your fellowship while they still have time left in the Colosseum. (2s)"
                             * 20:57:20 Master Arbitrator tells you, "You fought in the Colosseum's Arenas too recently. I cannot reward you for 4s."
                             *
                             * (In this set of messages, we don't filter the Well done!)
                             * 20:57:24 Master Arbitrator tells you, "Well done! I was greatly impressed with your performance in the arenas."
                             * 20:57:24 Master Arbitrator tells you, "You shall be known to all as a "Colosseum Champion"!"
                             * 20:57:24 Master Arbitrator tells you, "Take this knowledge and this Colosseum Vault Key as a reward for your accomplishments Champion."
                             * 20:57:24 Master Arbitrator tells you, "Use the the key to open the Colosseum Vault and claim some of our treasury for yourself."
                             *
                             * (In this set of messages, we don't filter the Good Luck!)
                             * 21:01:14 Your fellowship is now locked.  You may not recruit new members.  If you leave the fellowship, you have 15 minutes to be recruited back into the fellowship.
                             * 21:01:16 [Fellowship] Master Arbitrator says, "Your fellowship will be battling in Arena One."
                             * 21:01:17 [Fellowship] Master Arbitrator says, "Use one of the two portals to enter your Arena. If every member of your group is powerful enough you may skip the lower battles by using the Advanced Colosseum Arena, but any one member of your fellow may be restricted from using that portal so be careful or you may be split up."
                             * 21:01:17 [Fellowship] Master Arbitrator says, "Don't forget that you must wait one full hour after the time you enter the colosseum before I will reward you for your achievements in the Arenas."
                             * 21:01:17 [Fellowship] Master Arbitrator says, "Good Luck!"
                             */

                            if (Settings.SettingsManager.Filters.MasterArbitratorSpam.Value)
                            {
                                if (Util.IsChat(e.Text, Util.ChatFlags.NpcTellsYou))
                                {
                                    if (e.Text.Contains("\"You shall be known") || e.Text.Contains("\"Take this knowledge") || e.Text.Contains("\"Use the the key"))
                                    {
                                        e.Eat = true;
                                    }
                                }
                                else if (Util.IsChat(e.Text, Util.ChatFlags.PlayerSaysChannel))
                                {
                                    if (e.Text.Contains("\"Your fellowship") || e.Text.Contains("\"Use one of the") || e.Text.Contains("\"Don't forget"))
                                    {
                                        e.Eat = true;
                                    }
                                }
                            }

                            if (Settings.SettingsManager.Filters.AllMasterArbitratorChat.Value)
                            {
                                e.Eat = true;
                            }
                        }
                    }

                    if (Settings.SettingsManager.Filters.AllMasterArbitratorChat.Value && e.Text.StartsWith("Your fellowship is now locked.") && e.Text.Contains("you have 15 minutes to be recruited"))
                    {
                        e.Eat = true;
                    }
                }
            }
            catch (Exception ex) { Debug.LogException(ex); }
        }
コード例 #29
0
        public static ReadOnlyCollection<WorldObject> TryGetItemsForKeyword(WorldObjectCollection woCollection, string keyword, string secondOption)
        {
            var loweredKeyWord = keyword.ToLower();
            switch (loweredKeyWord)
            {
                case "keys":
                    return woCollection.GetLegendaryKeys();
                case "lvl8":
                    return woCollection.GetLevel8SpellComponents();
                case "set":
                case "sets":
                    if (string.IsNullOrEmpty(secondOption))
                    {
                        return null;
                    }

                    Sets.Armor armor;
                    if (Sets.TryParseArmorShortName(secondOption, out armor))
                    {
                        return woCollection.GetArmorSetItems(armor);
                    }

                    return null;
                case "cloak":
                case "cloaks":
                    return woCollection.GetCloaks();
                case "sigil":
                case "sigils":
                    return woCollection.GetSigils();
                case "weapon":
                case "weapons":
                    if (string.IsNullOrEmpty(secondOption))
                    {
                        return null;
                    }

                    switch (secondOption)
                    {
                        case "missile":
                            return woCollection.GetMissileWeapons();
                        case "melee":
                            return woCollection.GetMeleeWeapons();
                        case "magic":
                            return woCollection.GetMagicWeapons();
                    }

                    return null;
                case "jewelry":
                case "jew":
                    if (string.IsNullOrEmpty(secondOption))
                    {
                        return null;
                    }

                    switch (secondOption)
                    {
                        case "legendary":
                        case "leg":
                            return woCollection.GetJewelryWithLegendaryAndNoRatings();
                        case "legendary+ratings":
                        case "leg+ratings":
                        case "leg+":
                            return woCollection.GetJewelryWithLegendaryAndRatings();
                        case "ratings":
                            return woCollection.GetJewelryWithRatings();
                        case "max":
                            return woCollection.GetJewelryWithMaxRatings();
                    }

                    return null;

                default:
                    // See if it's one of the material short cut keywords
                    int possibleMaterialId;
                    if (Constants.MaterialShortCutNamesToIdTable.TryGetValue(loweredKeyWord, out possibleMaterialId))
                    {
                        return woCollection.GetFullSalvage(possibleMaterialId);
                    }

                    // It's not a known keyword
                    return null;
            }
        }
コード例 #30
0
        public void Process(Machine machine)
        {
            if (machine.Enabled)
            {
                if (machine.SpellsToCast.Count > 0 || !machine.IsBuffed)
                {
                    if (FullyEquipped)
                    {
                        if (!machine.IsBuffed && machine.Core.CharacterFilter.Name.Equals(machine.BuffingCharacter))
                        {
                            machine.NextState = SelfBuffing.GetInstance;
                        }
                        else
                        {
                            machine.NextState = Casting.GetInstance;
                        }
                    }
                    else if (BuffingEquipment.Count.Equals(0) || !machine.CurrentRequest.RequestType.Equals(RequestType.Buff))
                    {
                        using (WorldObjectCollection wands = machine.Core.WorldFilter.GetInventory())
                        {
                            wands.SetFilter(new ByObjectClassFilter(ObjectClass.WandStaffOrb));

                            if (wands.Count.Equals(0))
                            {
                                machine.ChatManager.Broadcast("Oops, my owner didn't give me a wand I can equip. I'm cancelling this request.");
                                machine.SpellsToCast.Clear();
                                machine.NextState = Idle.GetInstance;
                            }

                            foreach (WorldObject wand in wands)
                            {
                                if (wand.Values(LongValueKey.EquippedSlots) > 0)
                                {
                                    FullyEquipped = true;
                                    IdleEquipped  = true;
                                    break;
                                }
                            }

                            if (!FullyEquipped)
                            {
                                foreach (WorldObject wand in wands)
                                {
                                    if (CanWield(machine, wand) && machine.Core.Actions.BusyState.Equals(0))
                                    {
                                        machine.Core.Actions.AutoWield(wand.Id);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    else // equip the entire suit
                    {
                        foreach (KeyValuePair <Equipment, bool> item in IdleEquipment)
                        {
                            if (machine.Core.Actions.BusyState.Equals(0))
                            {
                                if (IdleEquipment[item.Key].Equals(true))
                                {
                                    if (!BuffingEquipment.ContainsKey(item.Key))
                                    {
                                        machine.Core.Actions.MoveItem(item.Key.Id, machine.Core.CharacterFilter.Id);
                                    }
                                    else
                                    {
                                        if (item.Key.ObjectClass.Equals(ObjectClass.Clothing.ToString()))
                                        {
                                            BuffingEquipment[item.Key] = true;
                                        }
                                    }
                                    IdleEquipment[item.Key] = false;
                                }
                            }
                        }

                        foreach (KeyValuePair <Equipment, bool> item in BuffingEquipment)
                        {
                            if (machine.Core.Actions.BusyState.Equals(0) && !item.Value)
                            {
                                if ((item.Key.EquipMask & (int)Ring) == (int)Ring)
                                {
                                    if (!RingEquipped)
                                    {
                                        RingEquipped = true;
                                        machine.Core.Actions.AutoWield(item.Key.Id, (int)EquipMask.RightRing, 0, 1, 1, 1);
                                    }
                                    else
                                    {
                                        machine.Core.Actions.AutoWield(item.Key.Id, (int)EquipMask.LeftRing, 0, 1, 1, 1);
                                    }
                                }
                                else if ((item.Key.EquipMask & (int)Bracelet) == (int)Bracelet)
                                {
                                    if (!BraceletEquipped)
                                    {
                                        BraceletEquipped = true;
                                        machine.Core.Actions.AutoWield(item.Key.Id, (int)EquipMask.RightBracelet, 0, 1, 1, 1);
                                    }
                                    else
                                    {
                                        machine.Core.Actions.AutoWield(item.Key.Id, (int)EquipMask.LeftBracelet, 0, 1, 1, 1);
                                    }
                                }
                                else if (item.Key.ObjectClass.Equals(ObjectClass.Clothing.ToString()))
                                {
                                    machine.Core.Actions.UseItem(item.Key.Id, 0);
                                }
                                else
                                {
                                    machine.Core.Actions.AutoWield(item.Key.Id, item.Key.EquipMask, 0, 1, 1, 1);
                                }

                                BuffingEquipment[item.Key] = true;
                            }
                        }

                        FullyEquipped = true;

                        foreach (KeyValuePair <Equipment, bool> item in BuffingEquipment)
                        {
                            if (item.Value == false)
                            {
                                FullyEquipped = false;
                                break;
                            }
                        }

                        if (FullyEquipped)
                        {
                            IdleEquipped = false;
                        }
                    }
                }
                else // done casting/buffing - remove suit
                {
                    if (FullyEquipped)
                    {
                        if (BuffingEquipment.Count > 0 && machine.CurrentRequest.RequestType.Equals(RequestType.Buff))
                        {
                            foreach (KeyValuePair <Equipment, bool> item in BuffingEquipment)
                            {
                                if (machine.Core.Actions.BusyState.Equals(0))
                                {
                                    if (BuffingEquipment[item.Key].Equals(true))
                                    {
                                        if (!IdleEquipment.ContainsKey(item.Key))
                                        {
                                            machine.Core.Actions.MoveItem(item.Key.Id, machine.Core.CharacterFilter.Id);
                                        }
                                        else
                                        {
                                            if (item.Key.ObjectClass.Equals(ObjectClass.Clothing.ToString()))
                                            {
                                                IdleEquipment[item.Key] = true;
                                            }
                                        }
                                        BuffingEquipment[item.Key] = false;
                                    }
                                }
                            }

                            FullyEquipped = false;

                            foreach (KeyValuePair <Equipment, bool> item in BuffingEquipment)
                            {
                                if (item.Value == true)
                                {
                                    FullyEquipped = true;
                                    break;
                                }
                            }
                        }
                        else // no suit equipped - remove the wand
                        {
                            using (WorldObjectCollection wands = machine.Core.WorldFilter.GetInventory())
                            {
                                wands.SetFilter(new ByObjectClassFilter(ObjectClass.WandStaffOrb));
                                foreach (WorldObject wand in wands)
                                {
                                    if (wand.Values(LongValueKey.EquippedSlots) > 0)
                                    {
                                        if (machine.Core.Actions.BusyState.Equals(0))
                                        {
                                            machine.Core.Actions.MoveItem(wand.Id, machine.Core.CharacterFilter.Id);
                                            FullyEquipped = false;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else if (!IdleEquipped) // suit is unequipped
                    {
                        if (IdleEquipment.Count.Equals(0))
                        {
                            IdleEquipped = true;
                        }
                        else
                        {
                            foreach (KeyValuePair <Equipment, bool> item in IdleEquipment)
                            {
                                if (machine.Core.Actions.BusyState.Equals(0) && !item.Value)
                                {
                                    if (item.Key.ObjectClass.Equals(ObjectClass.Clothing.ToString()))
                                    {
                                        machine.Core.Actions.UseItem(item.Key.Id, 0);
                                    }
                                    else
                                    {
                                        machine.Core.Actions.AutoWield(item.Key.Id, item.Key.EquipMask, 0, 1, 1, 1);
                                    }
                                    IdleEquipment[item.Key] = true;
                                }
                            }

                            IdleEquipped = true;

                            foreach (KeyValuePair <Equipment, bool> item in IdleEquipment)
                            {
                                if (item.Value == false)
                                {
                                    IdleEquipped = false;
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        if (machine.Core.Actions.BusyState.Equals(0))
                        {
                            machine.NextState = Idle.GetInstance;
                        }
                    }
                }
            }
            else
            {
                machine.NextState = Idle.GetInstance;
            }
        }
コード例 #31
0
        private void HandleTradeCommand(ChatMessage chatMessage)
        {
            bool   show         = false;
            bool   regex        = false;
            bool   number       = false;
            int    numberParsed = -1;
            string command      = chatMessage.ParsedCommand;

            if (chatMessage.ParsedCommand.ToLower() == "show")
            {
                command = "add";
                show    = true;
            }
            else if (command.ToLower() == "xadd")
            {
                command = "add";
                regex   = true;
            }
            if (!show)
            {
                Match match = Regex.Match(chatMessage.ParsedParameters, "^-?\\d+$", RegexOptions.IgnoreCase);
                if (match.Success)
                {
                    if (int.TryParse(chatMessage.ParsedParameters, out numberParsed))
                    {
                        number = true;
                    }
                }
            }
            switch (command.ToLower())
            {
            case "add":
                WorldObjectCollection woc = Core.WorldFilter.GetByOwner(Core.CharacterFilter.Id);
                foreach (WorldObject wo in woc)
                {
                    string itemName = wo.RealName();
                    if (show)
                    {
                        if (wo.ObjectClass != ObjectClass.Container)
                        {
                            PendingItemsToTradeAdd.Add(wo);
                        }
                    }
                    else if (number && wo.Exists(LongValueKey.Value))
                    {
                        int value = wo.Values(LongValueKey.Value);
                        if (numberParsed == value)
                        {
                            PendingItemsToTradeAdd.Add(wo);
                        }
                    }
                    else if (number && wo.Exists(LongValueKey.TotalValue))
                    {
                        int value = wo.Values(LongValueKey.TotalValue);
                        if (numberParsed == value)
                        {
                            PendingItemsToTradeAdd.Add(wo);
                        }
                    }
                    else if (regex)
                    {
                        Match match = Regex.Match(itemName, chatMessage.ParsedParameters, RegexOptions.IgnoreCase);
                        if (match.Success)
                        {
                            if (wo.ObjectClass != ObjectClass.Container)
                            {
                                PendingItemsToTradeAdd.Add(wo);
                            }
                        }
                    }
                    else if (itemName.ToLower().Contains(chatMessage.ParsedParameters.ToLower()))
                    {
                        if (wo.ObjectClass != ObjectClass.Container)
                        {
                            PendingItemsToTradeAdd.Add(wo);
                        }
                    }
                }
                if (PendingItemsToTradeAdd.Count < 1)
                {
                    SendChatCommand($"/t {chatMessage.ChatterName}, no items found");
                }
                AddPendingItemsToTrade();
                break;

            case "clear":
                PendingItemsToTradeAdd2.Clear();
                PendingItemsToTradeAdd.Clear();
                Host.Actions.TradeReset();
                break;
            }
        }