static public WoWPoint GetLocationFromDB(MoveToType type, uint entry)
        {
            NpcResult npcResults = null;

            switch (type)
            {
            case MoveToType.NearestRepair:
                npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId,
                                                      ObjectManager.Me.Location, UnitNPCFlags.Repair);
                break;

            case MoveToType.NearestVendor:
                npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId,
                                                      ObjectManager.Me.Location, UnitNPCFlags.Vendor);
                break;

            case MoveToType.NpcByID:
                npcResults = NpcQueries.GetNpcById(entry);
                break;
            }
            if (npcResults != null)
            {
                return(npcResults.Location);
            }
            else
            {
                return(WoWPoint.Zero);
            }
        }
Exemplo n.º 2
0
        public static WoWPoint GetLocationFromDB(MoveToType type, uint entry)
        {
            NpcResult npcResults = null;

            switch (type)
            {
            case MoveToType.NearestAH:
                npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId,
                                                      ObjectManager.Me.Location, UnitNPCFlags.Auctioneer);
                break;

            case MoveToType.NearestBanker:
                npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId,
                                                      ObjectManager.Me.Location, UnitNPCFlags.Banker);
                break;

            case MoveToType.NearestFlight:
                npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId,
                                                      ObjectManager.Me.Location, UnitNPCFlags.Flightmaster);
                break;

            case MoveToType.NearestGB:
                npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId,
                                                      ObjectManager.Me.Location, UnitNPCFlags.GuildBanker);
                break;

            case MoveToType.NearestReagentVendor:
                npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId,
                                                      ObjectManager.Me.Location, UnitNPCFlags.ReagentVendor);
                break;

            case MoveToType.NearestRepair:
                npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId,
                                                      ObjectManager.Me.Location, UnitNPCFlags.Repair);
                break;

            case MoveToType.NearestVendor:
                npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId,
                                                      ObjectManager.Me.Location, UnitNPCFlags.Vendor);
                break;

            case MoveToType.NpcByID:
                npcResults = NpcQueries.GetNpcById(entry);
                break;
            }
            if (npcResults != null)
            {
                return(npcResults.Location);
            }
            return(WoWPoint.Zero);
        }
Exemplo n.º 3
0
        public TalkToAndListenToStory(Dictionary <string, string> args)
            : base(args)
        {
            try
            {
                int[] tmpMobIds;

                LogMessage("warning", "*****\n"
                           + "* THIS BEHAVIOR IS DEPRECATED, and may be retired in a near, future release.\n"
                           + "*\n"
                           + "* TalkToAndListenToStory adds _no_ _additonal_ _value_ over the InteractWith behavior (with the \"GossipOption\" attribute).\n"
                           + "* Please update the profile to use InteractWith in preference to the TalkToAndListenToStory behavior.\n"
                           + "*****");


                // QuestRequirement* attributes are explained here...
                //    http://www.thebuddyforum.com/mediawiki/index.php?title=Honorbuddy_Programming_Cookbook:_QuestId_for_Custom_Behaviors
                // ...and also used for IsDone processing.
                tmpMobIds = GetAttributeAsArray <int>("MobIds", true, ConstrainAs.MobId, new[] { "NpcIds" }, null);
                QuestId   = GetAttributeAsNullable <int>("QuestId", true, ConstrainAs.QuestId(this), null) ?? 0;
                QuestRequirementComplete = GetAttributeAsNullable <QuestCompleteRequirement>("QuestCompleteRequirement", false, null, null) ?? QuestCompleteRequirement.NotComplete;
                QuestRequirementInLog    = GetAttributeAsNullable <QuestInLogRequirement>("QuestInLogRequirement", false, null, null) ?? QuestInLogRequirement.InLog;


                foreach (int mobId in tmpMobIds)
                {
                    _npcResults.Enqueue(NpcQueries.GetNpcById((uint)mobId));
                }
            }

            catch (Exception except)
            {
                // Maintenance problems occur for a number of reasons.  The primary two are...
                // * Changes were made to the behavior, and boundary conditions weren't properly tested.
                // * The Honorbuddy core was changed, and the behavior wasn't adjusted for the new changes.
                // In any case, we pinpoint the source of the problem area here, and hopefully it
                // can be quickly resolved.
                LogMessage("error", "BEHAVIOR MAINTENANCE PROBLEM: " + except.Message
                           + "\nFROM HERE:\n"
                           + except.StackTrace + "\n");
                IsAttributeProblem = true;
            }
        }
Exemplo n.º 4
0
        public override void Pulse()
        {
            if (!_pulseTimer.IsFinished)
            {
                return;
            }

            _pulseTimer.Reset();

            if (LogoutAtCap && WoWCurrency.GetCurrencyByType(WoWCurrencyType.HonorPoints).Amount > 3750 && WoWCurrency.GetCurrencyByType(WoWCurrencyType.JusticePoints).Amount > 3750)
            {
                Slog("HonorPoints and Justice Points are Capped! Logging out!");
                InactivityDetector.ForceLogout(true);
            }
            // We should avoid overriding any poi set by the core
            if (BotPoi.Current.Type != PoiType.None)
            {
                return;
            }

            // There are no vendors in battlegrounds or dungeons !
            if (Styx.Logic.Battlegrounds.IsInsideBattleground || Me.IsInInstance)
            {
                return;
            }

            // First item in the list. We should check item by item so we don't end up buying the last item in the list with lower cost.
            var firstItem = BuyItemList.FirstOrDefault();

            // BuyItemList looks to be empty. Wait for user to populate the list
            if (firstItem == null)
            {
                return;
            }

            // Should check if we have enough currency.
            var currencyType = Enum.Parse(typeof(WoWCurrencyType), firstItem.ItemCostType);

            // Something went wrong with parsing. We should avoid buying that item.
            if (!(currencyType is WoWCurrencyType))
            {
                Slog("Couldn't parse item's cost type ({0}). Please consult to the plugin writer", firstItem.ItemCostType);
                BuyItemList.Remove(firstItem);

                return;
            }

            // Actually checking if we have enough of that currency now.
            var currency   = WoWCurrency.GetCurrencyByType((WoWCurrencyType)currencyType);
            var currencyJp = WoWCurrency.GetCurrencyByType(WoWCurrencyType.JusticePoints);
            var currencyHp = WoWCurrency.GetCurrencyByType(WoWCurrencyType.HonorPoints);

            if (currency == null)
            {
                return;
            }

            if (currency.Amount < firstItem.ItemCost)
            {
                // Don't ever buy justice points to buy honor points and vice versa. Otherwise we will enter in an endless loop which will drop
                // the total of our points.
                if (firstItem.ItemId != 392 && firstItem.ItemId != 395 && BuyOppositePointToBuildUp)
                {
                    if (currency.CurrencyType == WoWCurrencyType.JusticePoints && currencyHp.Amount >= 375)
                    {
                        // We set this to true here. So we don't end up spending all our honor points if the Only remove hp/jp points when capped is true
                        _forceAddedPoints = true;
                        if (Me.IsAlliance)
                        {
                            var buyJusticePoint = new BuyItemInfo
                            {
                                ItemCost       = 375,
                                ItemName       = "Justice Points",
                                ItemSupplierId = 52029,
                                ItemId         = 395,
                                ItemCostType   = WoWCurrencyType.HonorPoints.ToString()
                            };
                            Slog(
                                "Adding Justice Point to the Buy List so we can build up Justice Points to buy {0}.", firstItem.ItemName);
                            BuyItemList.Insert(0, buyJusticePoint);
                        }
                        if (Me.IsHorde)
                        {
                            var buyJusticePoint = new BuyItemInfo
                            {
                                ItemCost       = 375,
                                ItemName       = "Justice Points",
                                ItemSupplierId = 52033,
                                ItemId         = 395,
                                ItemCostType   = WoWCurrencyType.HonorPoints.ToString()
                            };
                            Slog(
                                "Adding Justice Point to the Buy List so we can build up Justice Points to buy {0}.", firstItem.ItemName);
                            BuyItemList.Insert(0, buyJusticePoint);
                        }
                    }
                    if (currency.CurrencyType == WoWCurrencyType.HonorPoints && currencyJp.Amount >= 375)
                    {
                        // We set this to true here. So we don't end up spending all our justice points if the Only remove hp/jp points when capped is true
                        _forceAddedPoints = true;
                        if (Me.IsAlliance)
                        {
                            var buyHonorPoint = new BuyItemInfo
                            {
                                ItemCost       = 375,
                                ItemName       = "Honor Points",
                                ItemSupplierId = 52028,
                                ItemId         = 392,
                                ItemCostType   = WoWCurrencyType.JusticePoints.ToString()
                            };
                            Slog("Adding HonorPoint to the Buy List so we can build up HonorPoints to buy {0}.", firstItem.ItemName);
                            BuyItemList.Insert(0, buyHonorPoint);
                        }
                        if (Me.IsHorde)
                        {
                            var buyHonorPoint = new BuyItemInfo
                            {
                                ItemCost       = 375,
                                ItemName       = "Honor Points",
                                ItemSupplierId = 52034,
                                ItemId         = 392,
                                ItemCostType   = WoWCurrencyType.JusticePoints.ToString()
                            };
                            Slog("Adding HonorPoint to the Buy List so we can build up HonorPoints to buy {0}.", firstItem.ItemName);
                            BuyItemList.Insert(0, buyHonorPoint);
                        }
                    }
                }
                return;
            }


            // We need to find the vendor
            var vendorAsUnit =
                ObjectManager.GetObjectsOfType <WoWUnit>(false, false).FirstOrDefault(
                    u => u.Entry == firstItem.ItemSupplierId);
            Vendor vendor;

            // Vendor is not around. This won't work
            if (vendorAsUnit == null)
            {
                // Check the database for the vendor as a second hope
                NpcResult npc = NpcQueries.GetNpcById(firstItem.ItemSupplierId);
                if (npc != null)
                {
                    vendor = new Vendor(npc.Entry, npc.Name, Vendor.VendorType.Unknown, npc.Location);
                }
                else
                {
                    Slog("Please move your toon close to the vendor. Otherwise HonorCap won't be able to buy items.");
                    return;
                }
            }
            else
            {
                vendor = new Vendor(vendorAsUnit, Vendor.VendorType.Unknown);
            }

            // Setting ItemToBuy here so VendorBehavior knows which item we want.
            ItemToBuy = firstItem;

            //We need to make sure vender is usable, so removing blacklist.
            if (Blacklist.Contains(vendorAsUnit))
            {
                Slog("For whatever reason vender is blacklisted, Clearing Blacklist.");
                Blacklist.Flush();
            }

            // Finally setting the poi
            BotPoi.Current = new BotPoi(vendor, PoiType.Buy);
        }