Exemple #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);
                }
            }
        }
Exemple #2
0
 internal int GetInventoryCount(string itemName)
 {
     using (WorldObjectCollection inventory = Machine.Core.WorldFilter.GetInventory())
     {
         inventory.SetFilter(new ByNameFilter(itemName));
         return(inventory.Quantity);
     }
 }
 private int QuantityInInventory(string compName)
 {
     using (WorldObjectCollection inventory = Core.WorldFilter.GetInventory())
     {
         inventory.SetFilter(new ByNameFilter(compName));
         return(inventory.Quantity);
     }
 }
Exemple #4
0
        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);
                }
            }
        }
Exemple #5
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);
         }
     }
 }
        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);
        }
Exemple #7
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();
 }
Exemple #8
0
        /// <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);
                }
            }
        }
Exemple #9
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;
            }
        }