/// <summary> /// Check if localPlayer has a way to disenchant an item /// </summary> /// <param name="me"></param> /// <param name="item"></param> /// <returns></returns> public static bool CanDisenchant(this LocalPlayer me, WoWItem item) { try { if (me != null && item != null) { // Check if not possible right now if (!SpellManager.HasSpell(13262) || StyxWoW.Me.IsDead || StyxWoW.Me.IsActuallyInCombat) { return false; } // Check if the item is in ignored list if (ButlerCoroutines.AtomsLibrary.Garrison.DisenchantItems.IgnoredItem.Contains(item.Guid)) return false; // Seems it's a go! return true; } } catch (Exception e) { if (e is Buddy.Coroutines.CoroutineStoppedException) throw; GarrisonButler.Warning( "[PlayerExtensions] Error while checking if LocalPlayer can disenchant an item."); GarrisonButler.Diagnostic("[PlayerExtensions] Error of type: ", e.GetType()); } return false; }
public static void DropItem(WoWItem item) { // Deleting an item is a two step process in wow, I => pick it up II => delete item on cursor item.PickUp(); // use HB api to do the picky upping Lua.DoString("DeleteCursorItem()"); StyxWoW.SleepForLagDuration(); }
private static bool CanUseEquippedItem(WoWItem item) { // Check for engineering tinkers! string itemSpell = Lua.GetReturnVal<string>("return GetItemSpell(" + item.Entry + ")",0); if (string.IsNullOrEmpty(itemSpell)) return false; return item.Usable && item.Cooldown <= 0; }
public static void UseItem(WoWItem item, bool extraSleep = false) { if (extraSleep) { // some (soulbound) items require an additional sleep to prevent a loot bug StyxWoW.SleepForLagDuration(); } Lua.DoString("UseItemByName(\"" + item.Name + "\")"); // use item via LUA StyxWoW.SleepForLagDuration(); }
public static bool IsItemIgnored(WoWItem item) { string itemNameLower = item.Name.ToLower(); uint itemId = item.Entry; foreach (var kvp in IgnoreItems) { if (kvp.Key == itemId || kvp.Value.ToLower() == itemNameLower) return true; } return false; }
/// <summary> /// (Non-Blocking) Attempts to use the specified item on the provided target. /// </summary> /// <returns>Returns true if the item was successfully used.</returns> public static async Task<bool> UseItem(WoWItem item, WoWUnit target) { if (item == null) return false; item.Use(target.Guid); Log.Equipment(string.Format("Item ({0}) used on {1} [{2}]", item.SafeName, item.IsMe ? "Me" : target.SafeName, UnitManager.GuidToUnitId(target.Guid))); await CommonCoroutines.SleepForLagDuration(); return true; }
public static bool CanImbue(WoWItem item) { if (item != null && item.ItemInfo.IsWeapon) { // during combat, only mess with imbues if they are missing if (Me.Combat && item.TemporaryEnchantment.Id != 0) return false; // check if enough time has passed since last imbue // .. guards against detecting is missing immediately after a cast but before buff appears // .. (which results in imbue cast spam) if (nextImbueAllowed > DateTime.Now) return false; switch (item.ItemInfo.WeaponClass) { case WoWItemWeaponClass.Axe: return true; case WoWItemWeaponClass.AxeTwoHand: return true; case WoWItemWeaponClass.Dagger: return true; case WoWItemWeaponClass.Fist: return true; case WoWItemWeaponClass.Mace: return true; case WoWItemWeaponClass.MaceTwoHand: return true; case WoWItemWeaponClass.Polearm: return true; case WoWItemWeaponClass.Staff: return true; case WoWItemWeaponClass.Sword: return true; case WoWItemWeaponClass.SwordTwoHand: return true; } } return false; }
public static bool HaveLifeSpirit() { if (LifeSpirit == null) { foreach (WoWItem item in Me.BagItems) { if (item.Entry == 89640) { LifeSpirit = item; return true; } } return false; } else { return true; } }
public C_WoWItem(WoWItem item) { ref_WoWItem = item; try { Entry = item.Entry; } catch { } try { Name = item.Name; } catch { Name = "Null"; } try { Guid = item.Guid; } catch { } try { BagIndex = item.BagIndex; } catch { BagIndex = -1; } try { BagSlot = item.BagSlot; } catch { BagSlot = -1; } try { StackCount = item.StackCount; } catch { StackCount = Convert.ToUInt32(1); } try { Quality = item.Quality; } catch { Quality = WoWItemQuality.Artifact; } try { Level = item.ItemInfo.Level; } catch { Level = 0; } try { RequiredLevel = item.ItemInfo.RequiredLevel; } catch { RequiredLevel = 0; } try { IsOpenable = item.IsOpenable; } catch { IsOpenable = false; } try { ConsumableClass = item.ItemInfo.ConsumableClass; } catch { ConsumableClass = WoWItemConsumableClass.None; } try { ItemClass = item.ItemInfo.ItemClass; } catch { ItemClass = WoWItemClass.Miscellaneous; } try { IsSoulbound = item.IsSoulbound; } catch { IsSoulbound = true; } try { IsAccountBound = item.IsAccountBound; } catch { IsAccountBound = true; } }
public static bool HasItem(uint itemId) { WoWItem item = FindItem(itemId); return(item != null); }
public static Composite CreateUseBandageBehavior() { return new Decorator( ret => SingularSettings.Instance.UseBandages && Me.GetPredictedHealthPercent(true) < 95 && SpellManager.HasSpell( "First Aid") && !Me.HasAura( "Recently Bandaged") && !Me.ActiveAuras.Any( a => a.Value.IsHarmful ), new PrioritySelector( new Action( ret => { bandage = FindBestBandage(); return RunStatus.Failure; }), new Decorator( ret => bandage != null && !Me.IsMoving, new Sequence( new Action(ret => UseItem(bandage)), new WaitContinue( new TimeSpan(0,0,0,0,750), ret => Me.IsCasting || Me.IsChanneling, new ActionAlwaysSucceed()), new WaitContinue(8, ret => (!Me.IsCasting && !Me.IsChanneling) || Me.HealthPercent > 99, new ActionAlwaysSucceed()), new DecoratorContinue( ret => Me.IsCasting || Me.IsChanneling, new Sequence( new Action( r => Logger.Write( "/cancel First Aid @ {0:F0}%", Me.HealthPercent )), new Action( r => SpellManager.StopCasting() ) ) ) ) ) ) ); }
private static bool HaveItem(int id) { _itemToUse = StyxWoW.Me.CarriedItems.FirstOrDefault(i => i.Entry == id); return (StyxWoW.Me.BagItems.FirstOrDefault(i => i.Entry == id) != null); }
public bool HaveManaGem() { foreach (WoWItem item in ObjectManager.GetObjectsOfType<WoWItem>(false)) { if (item.Entry == 36799) { ManaGem = item; return true; } } return false; }
private static void EquipItemIntoSlot(WoWItem item, InventorySlot slot) { EquipItem(item.BagIndex, item.BagSlot, (int)slot); }
private static void EquipItem(WoWItem item) { EquipItem(item.BagIndex, item.BagSlot, (int)item.ItemInfo.EquipSlot); }
/// <summary> </summary> private void HandleLootRoll(object sender, LuaEventArgs e) { if (!AutoEquipSettings.Instance.RollForLootInDungeons) { return; } Log("Loot roll in progress"); string rollId = e.Args[0].ToString(); string itemLink = Lua.GetReturnVal <string>("return GetLootRollItemLink(" + rollId + ")", 0); string[] splitted = itemLink.Split(':'); uint itemId; if (string.IsNullOrEmpty(itemLink) || (splitted.Length == 0 || splitted.Length < 2) || (!uint.TryParse(splitted[1], out itemId) || itemId == 0)) { Log("Parsing ItemLink for lootroll failed!"); Log("ItemLink:{0}", itemLink); return; } ItemInfo rollItemInfo = ItemInfo.FromId(itemId); if (rollItemInfo == null) { Log("Retrieving item info for roll item failed"); Log("Item Id:{0} ItemLink:{1}", itemId, itemLink); return; } bool canDisenchant = Lua.GetReturnVal <bool>("return GetLootRollItemInfo(" + rollId + ")", 7); // Otherwise we just roll greed or disenchant if (AutoEquipSettings.Instance.RollForLootDE && canDisenchant) { Log("Rolling for disenchant"); Lua.DoString("RollOnLoot(" + rollId + ", 3)"); return; } // The name of the roll item. string rollItemName = rollItemInfo.Name; // Score of the item being rolled for. float rollItemScore = _weightSet.EvaluateItem(rollItemInfo, new ItemStats(itemLink)); // Score the equipped item if any. otherwise 0 float bestEquipItemScore = float.MinValue; // The best slot InventorySlot bestSlot = InventorySlot.None; var inventorySlots = InventoryManager.GetInventorySlotsByEquipSlot(rollItemInfo.EquipSlot); foreach (InventorySlot slot in inventorySlots) { WoWItem equipped = EquippedItems[slot]; if (equipped != null) { bestEquipItemScore = _weightSet.EvaluateItem(equipped, AutoEquipSettings.Instance.IncludeEnchants); bestSlot = slot; } } if (bestEquipItemScore != float.MinValue) { Log("Equipped item in slot:{0} scored {1} while loot-roll item scored:{2}", bestSlot, bestEquipItemScore, rollItemScore); } // Check if the item is better than the currently equipped item. if (bestEquipItemScore < rollItemScore && bestSlot != InventorySlot.None) { var inventoryTypes = GetInventoryTypesForWeaponStyle(AutoEquipSettings.Instance.WeaponStyle); var miscArmorType = new[] { InventoryType.Cloak, InventoryType.Trinket, InventoryType.Neck, InventoryType.Finger, }; // Make sure we only roll need if the item is of the wanted armor class for this player (or if it's a cloak, trinket, ring or neck). bool needRollForArmor = rollItemInfo.ItemClass == WoWItemClass.Armor && (rollItemInfo.ArmorClass == _weightSet.GetWantedArmorClass() || miscArmorType.Contains(rollItemInfo.InventoryType)); // Make sure we only roll need if the item is a weapon we might use. bool needRollForWeapon = rollItemInfo.ItemClass == WoWItemClass.Weapon && inventoryTypes.Contains(rollItemInfo.EquipSlot); bool canNeed = Lua.GetReturnVal <bool>("return GetLootRollItemInfo(" + rollId + ")", 5); if ((needRollForArmor || needRollForWeapon) && canNeed) { Log("{0} scored {1} while your equiped item only scored {2} - Rolling Need", rollItemName, rollItemScore, bestEquipItemScore); Lua.DoString("RollOnLoot(" + rollId + ", 1)"); return; } } Log("Rolling Greed"); Lua.DoString("RollOnLoot(" + rollId + ", 2)"); }
private InventorySlot FindBestEquipmentSlot(IEnumerable <InventorySlot> equipSlots, out float lowestItemScore) { InventorySlot bestSlot = InventorySlot.None; float lowestEquippedItemScore = float.MaxValue; foreach (InventorySlot inventorySlot in equipSlots) { WoWItem equippedItem = EquippedItems[inventorySlot]; if (equippedItem == null) { lowestItemScore = float.MinValue; return(inventorySlot); } if (AutoEquipSettings.Instance.ProtectedSlots.Contains(inventorySlot)) { //Log(true, "I'm not equipping into equipment slot {0} as it is protected", inventorySlot); continue; } if (!EquippedItems.ContainsKey(inventorySlot)) { Log(true, "InventorySlot {0} is unknown! Please report this to MaiN.", inventorySlot); continue; } if (!AutoEquipSettings.Instance.ReplaceHeirlooms && equippedItem.Quality == WoWItemQuality.Heirloom) { //Log(false, "I'm not equipping anything into {0} as I can't replace heirloom items!", inventorySlot); continue; } // Compute the score for the current equipped item. float itemScore = _weightSet.EvaluateItem(equippedItem, AutoEquipSettings.Instance.IncludeEnchants); // Set the score to zero if the item is a two hand weapon and the weapon style doesn't match, kinda hackish but it works ;p. if (AutoEquipSettings.Instance.WeaponStyle != WeaponStyle.TwoHander && equippedItem.ItemInfo.InventoryType == InventoryType.TwoHandWeapon) { itemScore = 0; } // Set the score to zero if the item is a shield and the weapon style doesn't match, kinda hackish but it works ;p. if (AutoEquipSettings.Instance.WeaponStyle != WeaponStyle.OneHanderAndShield && equippedItem.ItemInfo.InventoryType == InventoryType.Shield) { itemScore = 0; } var inventoryType = equippedItem.ItemInfo.InventoryType; if (inventoryType == InventoryType.Weapon || inventoryType == InventoryType.TwoHandWeapon || inventoryType == InventoryType.WeaponMainHand || inventoryType == InventoryType.WeaponOffHand) { if ((FindWeaponType(equippedItem) & AutoEquipSettings.Instance.WeaponType) == 0) { itemScore = 0; } } if (itemScore < lowestEquippedItemScore) { bestSlot = inventorySlot; lowestEquippedItemScore = itemScore; } } lowestItemScore = lowestEquippedItemScore; return(bestSlot); }
/// <summary> /// The callback for EnumVisibleObjects /// </summary> private int Callback(int filter, ulong guid) { if (guid == 0) { return(0); } var ptr = Functions.GetPtrForGuid(guid); if (ptr == IntPtr.Zero) { return(0); } if (_objects.ContainsKey(guid)) { _objects[guid].Pointer = ptr; _objects[guid].CanRemove = false; } else { var objType = (Enums.WoWObjectTypes) Memory.Reader.Read <byte>(IntPtr.Add(ptr, (int)Offsets.ObjectManager.ObjType)); switch (objType) { case Enums.WoWObjectTypes.OT_CONTAINER: case Enums.WoWObjectTypes.OT_ITEM: var tmpItem = new WoWItem(guid, ptr, objType); _objects.Add(guid, tmpItem); break; case Enums.WoWObjectTypes.OT_UNIT: var owner = ptr.Add(0x8) .PointsTo() .Add(Offsets.Descriptors.SummonedByGuid) .ReadAs <ulong>(); if (Player != null && owner == Player.Guid) { if (Pet != null && Pet.Pointer == ptr) { break; } Pet = new LocalPet(guid, ptr, Enums.WoWObjectTypes.OT_UNIT); } else { var tmpUnit = new WoWUnit(guid, ptr, objType); _objects.Add(guid, tmpUnit); } break; case Enums.WoWObjectTypes.OT_PLAYER: var tmpPlayer = new WoWUnit(guid, ptr, objType); _objects.Add(guid, tmpPlayer); break; case Enums.WoWObjectTypes.OT_GAMEOBJ: var tmpGameObject = new WoWGameObject(guid, ptr, objType); _objects.Add(guid, tmpGameObject); break; } } return(1); }
public static bool IsWeapon2H(WoWItem hand) { return(hand != null && hand.ItemInfo.ItemClass == WoWItemClass.Weapon && hand.ItemInfo.InventoryType == InventoryType.TwoHandWeapon); }
/// <summary> /// Checks if an item has a gem in a given slot (0 based slot index) /// </summary> /// <param name="item">item to check</param> /// <param name="slot">0 based index</param> /// <returns>true = has a gem in that slot</returns> public static bool ItemHasGem(WoWItem item, int slot) { return(item.GetEnchantment((uint)slot + 2).Id > 0); }
private static bool ItemHasUseEffectLua(WoWItem item) { var itemSpell = Lua.GetReturnVal<string>("return GetItemSpell(" + item.Entry + ")", 0); if (itemSpell != null) { return true; } return false; }
public static bool UseTrinket(bool firstSlot) { TrinketUsage usage = firstSlot ? SingularSettings.Instance.Trinket1Usage : SingularSettings.Instance.Trinket2Usage; // If we're not going to use it, don't bother going any further. Save some performance here. if (usage == TrinketUsage.Never) { return(false); } WoWItem item = firstSlot ? StyxWoW.Me.Inventory.Equipped.Trinket1 : StyxWoW.Me.Inventory.Equipped.Trinket2; //int percent = firstSlot ? SingularSettings.Instance.FirstTrinketUseAtPercent : SingularSettings.Instance.SecondTrinketUseAtPercent; if (item == null) { return(false); } if (!CanUseEquippedItem(item)) { return(false); } bool useIt = false; switch (usage) { case TrinketUsage.OnCooldown: // We know its off cooldown... so just use it :P useIt = true; break; case TrinketUsage.OnCooldownInCombat: if (StyxWoW.Me.Combat) { useIt = true; } break; //case TrinketUsage.LowPower: // // We use the PowerPercent here, since it applies to ALL types of power. (Runic, Mana, Rage, Energy, Focus) // if (StyxWoW.Me.PowerPercent < percent) // { // useIt = true; // } // break; //case TrinketUsage.LowHealth: // if (StyxWoW.Me.HealthPercent < percent) // { // useIt = true; // } break; } if (useIt) { Logger.Write("Popping trinket " + item.Name); item.Use(); return(true); } return(false); }
public static Composite UseSlottedItem(SimpleBoolReturnDelegate extra, WoWItem slottedItem ) { return new Decorator( ret => extra(ret) && ( slottedItem != null && slottedItem.BaseAddress != 0 && slottedItem.Cooldown == 0 ), new Action(delegate{ slottedItem.Use(); Logger.CastLog(slottedItem.Name, Me.Name); } ) ); }
private static bool CanUseItem(WoWItem item) { return(item.Usable && item.Cooldown <= 0); }
/// <summary> /// just a wrapper for the real calcscore /// </summary> /// <param name="item">wowitem to calc score of</param> /// <returns></returns> public static float CalcScore(WoWItem item) { return(CalcScore(item.ItemInfo, item.GetItemStats())); }
private static void UseItem(WoWItem item) { Logger.Write("Using item: " + item.Name); item.Use(); }
public static void CastOnItem(this WoWSpell spell, WoWItem item) { using (StyxWoW.Memory.AcquireFrame()) { spell.Cast(); Lua.DoString("UseContainerItem({0}, {1})", item.BagIndex + 1, item.BagSlot + 1); } }
bool IsBlackListed(WoWItem item) { return(blacklistedItems.Contains(item.Guid)); }
private bool IsOnCooldown(WoWItem wowItem) { return((wowItem != null) && (wowItem.CooldownTimeLeft > TimeSpan.Zero)); }
protected override RunStatus Run(object context) { if (!IsDone) { if (!IsRecipe) { CheckTradeskillList(); } if (Casted >= CalculatedRepeat) { if (ObjectManager.Me.IsCasting && ObjectManager.Me.CastingSpell.Id == Entry) { SpellManager.StopCasting(); } _spamControl.Stop(); _spamControl.Reset(); Lua.Events.DetachEvent("UNIT_SPELLCAST_SUCCEEDED", OnUnitSpellCastSucceeded); IsDone = true; return(RunStatus.Failure); } // can't make recipe so stop trying. if (IsRecipe && Recipe.CanRepeatNum2 <= 0) { Professionbuddy.Debug("{0} doesn't have enough material to craft.", SpellName); IsDone = true; return(RunStatus.Failure); } if (Me.IsCasting && Me.CastingSpellId != Entry) { SpellManager.StopCasting(); } // we should confirm the last recipe in list so we don't make an axtra if (!Me.IsFlying && Casted + 1 < CalculatedRepeat || (Casted + 1 == CalculatedRepeat && (Confimed || !_spamControl.IsRunning || (_spamControl.ElapsedMilliseconds >= (_recastTime + (_recastTime / 2)) + _waitTime && !ObjectManager.Me.IsCasting)))) { if (!_spamControl.IsRunning || _spamControl.ElapsedMilliseconds >= _recastTime || (!ObjectManager.Me.IsCasting && _spamControl.ElapsedMilliseconds >= _waitTime)) { if (ObjectManager.Me.IsMoving) { WoWMovement.MoveStop(); } if (!QueueIsRunning) { Lua.Events.AttachEvent("UNIT_SPELLCAST_SUCCEEDED", OnUnitSpellCastSucceeded); QueueIsRunning = true; TreeRoot.StatusText = string.Format("Casting: {0}", IsRecipe ? Recipe.Name : Entry.ToString(CultureInfo.InvariantCulture)); } WoWSpell spell = WoWSpell.FromId((int)Entry); if (spell == null) { Professionbuddy.Err("{0}: {1}", Pb.Strings["Error_UnableToFindSpellWithEntry"], Entry); return(RunStatus.Failure); } _recastTime = spell.CastTime; Professionbuddy.Debug("Casting {0}, recast :{1}", spell.Name, _recastTime); if (CastOnItem) { WoWItem item = TargetedItem; if (item != null) { spell.CastOnItem(item); } else { Professionbuddy.Err("{0}: {1}", Pb.Strings["Error_UnableToFindItemToCastOn"], IsRecipe ? Recipe.Name : Entry.ToString(CultureInfo.InvariantCulture)); IsDone = true; } } else { spell.Cast(); } _waitTime = StyxWoW.WoWClient.Latency * 2; Confimed = false; _spamControl.Reset(); _spamControl.Start(); } } if (!IsDone) { return(RunStatus.Success); } } return(RunStatus.Failure); }
private static bool CanUseItem(WoWItem item) { return(item.Usable && item.Cooldown <= 0 && !MerchantFrame.Instance.IsVisible); }
public void ApplyToItem(WoWItem item) { ApplyToItem(item.Entry); }
public static Composite CreateThunderLordGrappleBehavior() { const int FROSTFIRE_RIDGE_ZONEID = 6720; const int THUNDERLORD_GRAPPLE_ITEM = 101677; if (!SingularSettings.Instance.ToysAllowUse) { return(new ActionAlwaysFail()); } if (SingularRoutine.CurrentWoWContext != WoWContext.Normal) { return(new ActionAlwaysFail()); } if (!Me.IsMelee()) { return(new ActionAlwaysFail()); } return(new Throttle( 15, new Decorator( req => Me.ZoneId == FROSTFIRE_RIDGE_ZONEID, new Decorator( req => MovementManager.IsClassMovementAllowed && // checks Movement and GapCloser capability flags CanUseCarriedItem(THUNDERLORD_GRAPPLE_ITEM) && Me.GotTarget() && Me.CurrentTarget.SpellDistance() >= 20 && Me.CurrentTarget.InLineOfSight && Me.IsSafelyFacing(Me.CurrentTarget) && (DateTime.UtcNow - Utilities.EventHandlers.LastNoPathFailure) > TimeSpan.FromSeconds(15), new Sequence( new Action(r => { const int THUNDERLORD_GRAPPLE_SPELL = 150258; WoWSpell grapple = WoWSpell.FromId(THUNDERLORD_GRAPPLE_SPELL); if (grapple != null && Me.CurrentTarget.SpellDistance() < grapple.MaxRange) { return RunStatus.Success; } return RunStatus.Failure; }), new Action(r => StopMoving.Now()), new Wait( TimeSpan.FromMilliseconds(500), until => !Me.IsMoving, new ActionAlwaysSucceed() ), new Action(r => { WoWItem item = FindItem(THUNDERLORD_GRAPPLE_ITEM); UseItem(item, Me.CurrentTarget); }), new Wait( 1, until => Spell.IsCastingOrChannelling(), new ActionAlwaysSucceed() ), new Action(r => Logger.WriteDebug("ThunderlordGrapple: start @ {0:F1} yds", Me.CurrentTarget.Distance)), new Wait( 3, until => !Spell.IsCastingOrChannelling(), new ActionAlwaysSucceed() ), new PrioritySelector( new Sequence( new Wait( 1, until => !Me.IsMoving || Me.CurrentTarget.IsWithinMeleeRange, new ActionAlwaysSucceed() ), new Action(r => Logger.WriteDebug("ThunderlordGrapple: ended @ {0:F1} yds", Me.CurrentTarget.Distance)) ), // allow following to Succeed so we Throttle the behavior even on failure at this point new Action(r => Logger.WriteDebug("ThunderlordGrapple: failed unexpectedly @ {0:F1} yds", Me.CurrentTarget.Distance)) ) ) ) ) )); }
protected override Composite CreateBehavior() { return(_root ?? (_root = new Decorator(ret => !_isDone, new PrioritySelector( new Decorator(ret => IsQuestComplete(), new PrioritySelector( new Decorator(ret => Me.IsOnTransport, new Action(delegate { DLog("Quest complete - cancelling Flame Ascendancy"); Lua.DoString("VehicleExit()"); StyxWoW.SleepForLagDuration(); return RunStatus.Success; }) ), new Action(delegate { _isDone = true; StyxWoW.SleepForLagDuration(); return RunStatus.Success; }) ) ), // loop waiting for target only if no buff new Decorator(ret => Target == null, new Action(delegate { StyxWoW.SleepForLagDuration(); return RunStatus.Success; }) ), // loop waiting for CurrentTarget only if no buff new Decorator(ret => Target != Me.CurrentTarget, new Action(delegate { WoWUnit target = Target; target.Target(); StyxWoW.SleepForLagDuration(); return RunStatus.Success; }) ), // use item to get buff (enter vehicle) new Decorator(ret => !Me.IsOnTransport, new Action(delegate { WoWItem item = ObjectManager.GetObjectsOfType <WoWItem>().FirstOrDefault(i => i != null && i.Entry == 42499); if (item == null) { Log("ERROR - quest item Talisman of Flame Ascendancy not in inventory"); TreeRoot.Stop(); } Log("Use: {0}", item.Name); item.Use(true); StyxWoW.SleepForLagDuration(); return RunStatus.Success; }) ), new Decorator(ret => Target.Distance > 5, new Action(delegate { DLog("Moving towards target"); Navigator.MoveTo(Target.Location); return RunStatus.Success; }) ), new Decorator(ret => Target.Distance <= 5 && Me.IsMoving, new Action(delegate { DLog("At target, so stopping"); WoWMovement.MoveStop(); return RunStatus.Success; }) ), new Decorator(ret => !StyxWoW.GlobalCooldown && !Blacklist.Contains(2), new Action(delegate { Log("Cast Flame Shield"); Lua.DoString("RunMacroText(\"/click BonusActionButton4\")"); Blacklist.Add(2, TimeSpan.FromMilliseconds(8000)); return RunStatus.Success; }) ), new Decorator(ret => !StyxWoW.GlobalCooldown && !Blacklist.Contains(1), new Action(delegate { Log("Cast Attack"); Lua.DoString("RunMacroText(\"/click BonusActionButton1\")"); Blacklist.Add(1, TimeSpan.FromMilliseconds(1500)); return RunStatus.Success; }) ), new Action(delegate { DLog("Waiting for Cooldown"); return lastStateReturn; }) ) ) )); }
public static bool HaveHealthStone() { if (HealthStone == null) { foreach (WoWItem item in Me.BagItems) { if (item.Entry == 5512) { HealthStone = item; return true; } } return false; } else { return true; } }
private bool LevelIsEnoughToDisenchant(WoWItem item) { int profLevel = ToolBox.GetProfessionLevel(Name); int itemLevel = item.GetItemInfo.ItemLevel; // Uncommon if (item.GetItemInfo.ItemRarity == 2) { if (itemLevel <= 20) { return(true); } if (itemLevel <= 25 && profLevel >= 25) { return(true); } if (itemLevel <= 30 && profLevel >= 50) { return(true); } if (itemLevel <= 35 && profLevel >= 75) { return(true); } if (itemLevel <= 40 && profLevel >= 100) { return(true); } if (itemLevel <= 45 && profLevel >= 125) { return(true); } if (itemLevel <= 50 && profLevel >= 150) { return(true); } if (itemLevel <= 55 && profLevel >= 175) { return(true); } if (itemLevel <= 60 && profLevel >= 200) { return(true); } if (itemLevel <= 99 && profLevel >= 225) { return(true); } if (itemLevel <= 120 && profLevel >= 275) { return(true); } if (itemLevel <= 150 && profLevel >= 325) { return(true); } if (profLevel >= 350) { return(true); } } // Rare if (item.GetItemInfo.ItemRarity == 2) { if (itemLevel <= 20) { return(true); } if (itemLevel <= 25 && profLevel >= 25) { return(true); } if (itemLevel <= 30 && profLevel >= 50) { return(true); } if (itemLevel <= 35 && profLevel >= 75) { return(true); } if (itemLevel <= 40 && profLevel >= 100) { return(true); } if (itemLevel <= 45 && profLevel >= 125) { return(true); } if (itemLevel <= 50 && profLevel >= 150) { return(true); } if (itemLevel <= 55 && profLevel >= 175) { return(true); } if (itemLevel <= 60 && profLevel >= 200) { return(true); } if (itemLevel <= 99 && profLevel >= 225) { return(true); } if (itemLevel <= 120 && profLevel >= 275) { return(true); } if (itemLevel <= 200 && profLevel >= 325) { return(true); } if (profLevel >= 350) { return(true); } } // Epic if (item.GetItemInfo.ItemRarity == 2) { if (itemLevel <= 89 && profLevel >= 225) { return(true); } if (itemLevel <= 92 && profLevel >= 300) { return(true); } if (itemLevel <= 151 && profLevel >= 300) { return(true); } if (itemLevel <= 277 && profLevel >= 375) { return(true); } if (profLevel >= 375) { return(true); } } Logger.LogDebug($"Item {item.Name} can't be disenchanted."); return(false); }
public bool HaveHealthPotion() { //whole idea is to make sure CurrentHealthPotion is not null, and to check once every battle. if (CurrentHealthPotion == null) { if (LastTargetHPPot == null || Me.CurrentTarget.Guid != LastTargetHPPot) //Meaning they are not the same. { LastTarget = Me.CurrentTarget.Guid; // set guid to current target. List<WoWItem> HPPot = (from obj in Me.BagItems.Where( ret => ret != null && ret.BaseAddress != null && (ret.ItemInfo.ItemClass == WoWItemClass.Consumable) && (ret.ItemInfo.ContainerClass == WoWItemContainerClass.Potion) && (ret.ItemSpells[0].ActualSpell.SpellEffect1.EffectType == WoWSpellEffectType.Heal)) select obj).ToList(); if (HPPot.Count > 0) { //on first check, set CurrentHealthPotion so we dont keep running the list looking for one, CurrentHealthPotion = HPPot.FirstOrDefault(); Logging.Write("Potion Found {0}", HPPot.FirstOrDefault().Name); return true; } } return false; } else { return true; } }
protected override async Task Run() { if (!MailFrame.Instance.IsVisible) { await OpenMailbox(); return; } if (_itemList == null) { _itemList = BuildItemList(); } if (string.IsNullOrEmpty(_mailSubject)) { _mailSubject = " "; } if (!_itemList.Any()) { if (NumberOfSlotsUsedInSendMail > 0) { await MailItems(CharacterSettings.Instance.MailRecipient, _mailSubject); } IsDone = true; PBLog.Log( "Done sending {0} via mail", ItemSelection == ItemSelectionType.Category ? string.Format( "Items that belong to category {0} and subcategory {1}", Category, SubCategory) : (ItemSelection == ItemSelectionType.IDs ? string.Format("Items that match Id of {0}", ItemID) : string.Format("Items of quality {0}", ItemQuality))); return; } MailFrame.Instance.SwitchToSendMailTab(); uint itemID = _itemList.Keys.FirstOrDefault(); WoWItem item = Me.BagItems.FirstOrDefault(i => i.Entry == itemID); _mailSubject = item != null ? item.Name : " "; PBLog.Debug("MailItem: placing {0} into a Send Mail slot", item != null ? item.Name:itemID.ToString()); if (NumberOfSlotsUsedInSendMail >= 12) { await MailItems(CharacterSettings.Instance.MailRecipient, _mailSubject); } int amountPlaced = PlaceItemInMail(itemID, _itemList[itemID]); if (amountPlaced >= 0) { // we need to wait for item split to finish if ret >= 0 await CommonCoroutines.SleepForLagDuration(); } _itemList[itemID] = amountPlaced < 0 ? 0 : _itemList[itemID] - amountPlaced; bool doneWithItem = _itemList[itemID] <= 0; if (doneWithItem) { _itemList.Remove(itemID); } }
private static bool ItemUsable(WoWItem item) { return item.Usable && item.Cooldown == 0; }
private static void EquipItem(WoWItem item) { item.UseContainerItem(); // Wait 1 second... kthx Thread.Sleep(1000); //item.Interact(); //Lua.DoString(string.Format("EquipItemByName(\"{0}\")", Lua.Escape(item.Name)), "_main.lua"); //Thread.Sleep(1000); //Lua.DoString("EquipPendingItem(0) ConfirmBindOnUse() StaticPopup_Hide(\"AUTOEQUIP_BIND\") StaticPopup_Hide(\"EQUIP_BIND\") StaticPopup_Hide(\"USE_BIND\")"); //Thread.Sleep(1000); }
protected override RunStatus Run(object context) { if (!IsDone) { WoWPoint movetoPoint = _loc; if (MailFrame.Instance == null || !MailFrame.Instance.IsVisible) { if (AutoFindMailBox || movetoPoint == WoWPoint.Zero) { _mailbox = ObjectManager.GetObjectsOfType <WoWGameObject>().Where( o => o.SubType == WoWGameObjectType.Mailbox) .OrderBy(o => o.Distance).FirstOrDefault(); } else { _mailbox = ObjectManager.GetObjectsOfType <WoWGameObject>().Where( o => o.SubType == WoWGameObjectType.Mailbox && o.Location.Distance(_loc) < 10) .OrderBy(o => o.Distance).FirstOrDefault(); } if (_mailbox != null) { movetoPoint = WoWMathHelper.CalculatePointFrom(Me.Location, _mailbox.Location, 3); } if (movetoPoint == WoWPoint.Zero) { Professionbuddy.Err(Pb.Strings["Error_UnableToFindMailbox"]); return(RunStatus.Failure); } if (movetoPoint.Distance(ObjectManager.Me.Location) > 4.5) { Util.MoveTo(movetoPoint); } else if (_mailbox != null) { _mailbox.Interact(); } return(RunStatus.Success); } // Mail Frame is open.. // item split in proceess if (_itemSplitSW.IsRunning && _itemSplitSW.ElapsedMilliseconds <= 2000) { return(RunStatus.Success); } if (_itemList == null) { _itemList = BuildItemList(); } if (_itemList.Count == 0) { //Professionbuddy.Debug("Sending any remaining items already in SendMail item slots. Mail subject will be: {0} ",_mailSubject); Lua.DoString( "for i=1,ATTACHMENTS_MAX_SEND do if GetSendMailItem(i) ~= nil then SendMail (\"{0}\",\"{1}\",'') end end ", CharacterSettings.Instance.MailRecipient.ToFormatedUTF8(), _mailSubject != null ? _mailSubject.ToFormatedUTF8() : " "); //Professionbuddy.Debug("Done sending mail"); IsDone = true; return(RunStatus.Failure); } MailFrame.Instance.SwitchToSendMailTab(); uint itemID = _itemList.Keys.FirstOrDefault(); WoWItem item = Me.BagItems.FirstOrDefault(i => i.Entry == itemID); _mailSubject = item != null ? item.Name : " "; if (string.IsNullOrEmpty(_mailSubject)) { _mailSubject = " "; } Professionbuddy.Debug("MailItem: sending {0}", itemID); int ret = MailItem(itemID, _itemList[itemID]); // we need to wait for item split to finish if ret == 0 // format indexs are MailRecipient=0, Mail subject=1 string mailToLua = string.Format(MailItemsFormat, CharacterSettings.Instance.MailRecipient.ToFormatedUTF8(), _mailSubject.ToFormatedUTF8()); var mailItemsRet = Lua.GetReturnVal <int>(mailToLua, 0); if (ret == 0 || mailItemsRet == 1) { _itemSplitSW.Reset(); _itemSplitSW.Start(); return(RunStatus.Success); } _itemList[itemID] = ret < 0 ? 0 : _itemList[itemID] - ret; bool done = _itemList[itemID] <= 0; if (done) { _itemList.Remove(itemID); } if (IsDone) { Professionbuddy.Log("Done sending {0} via mail", UseCategory ? string.Format("Items that belong to category {0} and subcategory {1}", Category, SubCategory) : string.Format("Items that match Id of {0}", ItemID)); } else { return(RunStatus.Success); } } return(RunStatus.Failure); }
bool IsBlackListed(WoWItem item) { return blacklistedItems.Contains(item.Guid); }
private static void EquipItemIntoSlot(WoWItem item, InventorySlot slot) { Lua.DoString(string.Format("EquipItemByName({0}, {1})", item.Entry, (int) slot), "_main.lua"); Thread.Sleep(1000); //Lua.DoString("EquipPendingItem(0) ConfirmBindOnUse() StaticPopup_Hide(\"AUTOEQUIP_BIND\") StaticPopup_Hide(\"EQUIP_BIND\") StaticPopup_Hide(\"USE_BIND\")"); //Thread.Sleep(1000); }
public static bool IsWeapon(WoWItem hand) { return(hand != null && hand.ItemInfo.ItemClass == WoWItemClass.Weapon); }
private List<InventorySlot> DecideEquipmentSlots(WoWItem item) { List<InventorySlot> slots = InventoryManager.GetInventorySlotsByEquipSlot(item.ItemInfo.InventoryType); if (slots.Contains(InventorySlot.SecondaryHandSlot)) { WoWItem mainHand = _equippedItems[InventorySlot.MainHandSlot]; if (mainHand != null) { InventoryType type = mainHand.ItemInfo.InventoryType; if (type == InventoryType.TwoHandWeapon) { Log(false, "I have two handed weapon equipped therefore I can't equip {0} into secondary hand slot!", item.Name); // This item takes up two slots - we have to ensure that the specific item will be checked against the main-hand. slots.Clear(); slots.Add(InventorySlot.MainHandSlot); } } } return slots; }
public virtual int GetRelicAddedIlevel(WoWItem relic, int difficultyBonus, int ilevelBonus) { int ilevel = ilevelBonus - 1472; // Emerald Nightmare relic bonus Ids: // LFR 3379 // Normal 1807 // Heroic 1805 // Mythic 1806 List <int> emeraldNightmareRaidBonusIds = new List <int>() { 3379, 1807, 1805, 1806 }; // Nighthold relic bonus Ids: // First 3 bosses // LFR 3446 // Normal 3443 // Heroic 3444 // Mythic 3445 List <int> nightholdRaidBonusIds1 = new List <int>() { 3443, 3444, 3445, 3446 }; // Middle 6 bosses // LFR 3520 // Normal 3514 // Heroic 3516 // Mythic 3518 List <int> nightholdRaidBonusIds2 = new List <int>() { 3520, 3514, 3516, 3518 }; // Guldan // LFR 3521 // Normal 3515 // Heroic 3517 // Mythic 3519 List <int> nightholdRaidBonusIds3 = new List <int>() { 3521, 3515, 3517, 3519 }; // Tomb of Sargeras bonus Ids: // LFR 3564 // Normal 3561 // Heroic 3562 // Mythic 3563 List <int> tombRaidBonusIds = new List <int>() { 3564, 3561, 3562, 3563 }; // These are raid relics, the second bonus id is the ilevel relative to normal, // but we only have the LFR ilevel, so add 15 to the base ilevel plus an amount // relative to the base ilevel at that point in the raid. if (nightholdRaidBonusIds1.Contains(difficultyBonus)) { ilevel += 15 + 5; } else if (nightholdRaidBonusIds2.Contains(difficultyBonus) || emeraldNightmareRaidBonusIds.Contains(difficultyBonus)) { ilevel += 15 + 0; } else if (nightholdRaidBonusIds3.Contains(difficultyBonus)) { ilevel += 15 - 5; } else if (tombRaidBonusIds.Contains(difficultyBonus)) { // Tomb relics have a base ilevel of 855, but the ilevel bonus is relative to ilevel 890. // Add 35 ilevels to bump the base up to 890. ilevel += 35; } return(ilevel); }
bool checkItemQuality(WoWItem item) { if (ItemQuality == DeItemQualites.Uncommon && item.Quality == WoWItemQuality.Uncommon) return true; if (ItemQuality == DeItemQualites.Rare && (item.Quality == WoWItemQuality.Uncommon || item.Quality == WoWItemQuality.Rare)) return true; if (ItemQuality == DeItemQualites.Epic && (item.Quality == WoWItemQuality.Uncommon || item.Quality == WoWItemQuality.Rare || item.Quality == WoWItemQuality.Epic)) return true; return false; }
public static bool CanProspect(this WoWItem item, int skillLevel) { // returns true if item is found in the dictionary and player meets the level requirement return(ProspectList.ContainsKey(item.Entry) && ProspectList[item.Entry] <= skillLevel); }
public static bool HaveManaGem() { foreach (WoWItem item in ObjectManager.GetObjectsOfType<WoWItem>(false).Where(item => item.Entry == 36799)) { _manaGem = item; return true; } return false; }
private static uint GetGearScore(WoWItem item) { uint iLvl = 0; try { if (item != null) iLvl = (uint)item.ItemInfo.Level; } catch { Logger.WriteDebug("GearScore: ItemInfo not available for [0] #{1}", item.Name, item.Entry ); } return iLvl; }
bool subCategoryCheck(WoWItem item) { int sub = (int)SubCategory; if (sub == -1 || sub == 0) return true; object val = item.ItemInfo.GetType().GetProperties() .FirstOrDefault(t => t.PropertyType == SubCategory.GetType()).GetValue(item.ItemInfo, null); if (val != null && (int)val == sub) return true; else return false; }
private static bool IsItemImportantToGearScore(WoWItem item) { if (item != null && item.ItemInfo != null) { switch (item.ItemInfo.InventoryType) { case InventoryType.Head: case InventoryType.Neck: case InventoryType.Shoulder: case InventoryType.Cloak: case InventoryType.Body: case InventoryType.Chest: case InventoryType.Robe: case InventoryType.Wrist: case InventoryType.Hand: case InventoryType.Waist: case InventoryType.Legs: case InventoryType.Feet: case InventoryType.Finger: case InventoryType.Trinket: case InventoryType.Relic: case InventoryType.Ranged: case InventoryType.Thrown: case InventoryType.Holdable: case InventoryType.Shield: case InventoryType.TwoHandWeapon: case InventoryType.Weapon: case InventoryType.WeaponMainHand: case InventoryType.WeaponOffHand: return true; } } return false; }
private static bool CanUseItem(WoWItem item) { return item.Usable && item.Cooldown <= 0; }
public static void CastOnItem(this WoWSpell spell, WoWItem item) { using (new FrameLock()) { spell.Cast(); Lua.DoString("UseContainerItem({0}, {1})", item.BagIndex + 1, item.BagSlot + 1); } }
private static InventoryType GetInventoryType(WoWItem item) { InventoryType typ = Styx.InventoryType.None; try { if (item != null) typ = item.ItemInfo.InventoryType; } catch { Logger.WriteDebug("InventoryType: ItemInfo not available for [0] #{1}", item.Name, item.Entry); } return typ; }
public int PutItemInGBank(uint id, int amount, uint tab) { using (StyxWoW.Memory.AcquireFrame()) { if (_queryServerSW == null) { _queryServerSW = new Stopwatch(); _queryServerSW.Start(); Lua.DoString( "for i=GetNumGuildBankTabs(), 1, -1 do QueryGuildBankTab(i) end SetCurrentGuildBankTab({0}) ", tab == 0 ? 1 : tab); PBLog.Log("Querying server for gbank info"); return(0); } if (_queryServerSW.ElapsedMilliseconds < 2000) { return(0); } if (_bankSlots == null) { _bankSlots = GetBankSlotInfo(); } var tabCnt = Lua.GetReturnVal <int>("return GetNumGuildBankTabs()", 0); var currentTab = Lua.GetReturnVal <int>("return GetCurrentGuildBankTab()", 0); var slotsInCurrentTab = _bankSlots .Where(slotI => slotI.Bag == currentTab).ToList(); WoWItem itemToDeposit = Me.CarriedItems.OrderBy(item => item.StackCount) .FirstOrDefault(item => item.Entry == id && !item.IsDisabled); if (itemToDeposit != null) { int depositAmount = amount > 0 && amount < (int)itemToDeposit.StackCount ? amount : (int)itemToDeposit.StackCount; BankSlotInfo emptySlot = slotsInCurrentTab.FirstOrDefault(slotI => slotI.StackSize == 0); BankSlotInfo partialStack = slotsInCurrentTab .FirstOrDefault( slotI => slotI.ItemID == id && slotI.MaxStackSize - slotI.StackSize >= depositAmount); if (partialStack != null || emptySlot != null) { bool slotIsEmpty = partialStack == null; int bSlotIndex = slotIsEmpty ? _bankSlots.IndexOf(emptySlot) : _bankSlots.IndexOf(partialStack); _bankSlots[bSlotIndex].StackSize += itemToDeposit.StackCount; if (slotIsEmpty) { _bankSlots[bSlotIndex].ItemID = itemToDeposit.Entry; _bankSlots[bSlotIndex].MaxStackSize = itemToDeposit.ItemInfo.MaxStackSize; } if (depositAmount == itemToDeposit.StackCount) { itemToDeposit.UseContainerItem(); } else { Lua.DoString( "SplitContainerItem({0},{1},{2}) PickupGuildBankItem({3},{4})", itemToDeposit.BagIndex + 1, itemToDeposit.BagSlot + 1, depositAmount, _bankSlots[bSlotIndex].Bag, _bankSlots[bSlotIndex].Slot); } return(depositAmount); } if (tab > 0 || currentTab == tabCnt) { PBLog.Log("Guild Tab: {0} is full", tab); return(-1); } if (tab == 0 && currentTab < tabCnt) { Lua.DoString("SetCurrentGuildBankTab({0})", currentTab + 1); return(0); } } return(-1); } }
private static void UseItem(WoWItem item) { Logger.Write( Color.DodgerBlue, "Using item: " + item.Name); item.Use(); }
public static bool IsImbuedForDPS(WoWItem item) { Imbue imb = GetImbue(item); return(imb == Imbue.Flametongue); }
public static bool IsShield(WoWItem hand) { return hand != null && hand.ItemInfo.ItemClass == WoWItemClass.Armor && hand.ItemInfo.InventoryType == InventoryType.Shield; }
protected override Composite CreateBehavior() { return(_root ?? (_root = new PrioritySelector( // check if we have finished 10 questions (marked complete) new Decorator(ret => Me.IsQuestComplete(QuestId), new PrioritySelector( new Decorator(ret => Me.HasAura("Mental Training"), new Sequence( new Action(ret => QBCLog.Info("Mental Training complete - exiting Orb")), new Action(ret => Lua.DoString("RunMacroText(\"/click OverrideActionBarButton4\")")), CreateWaitForLagDuration() ) ), new Action(ret => _isBehaviorDone = true) ) ), // if we don't have vehicle buff, use Orb of Ascension new Decorator(ret => !Me.HasAura("Mental Training"), new Sequence( new Action(delegate { QBCLog.Info("Using Orb of Ascension"); WoWItem orb = ObjectManager.GetObjectsOfType <WoWItem>().Where(u => u.Entry == 52828).FirstOrDefault(); if (orb == null) { QBCLog.Fatal("Quest item \"Orb of Ascension\" not in inventory."); } orb.Use(true); return RunStatus.Success; }), new WaitContinue(1, ret => Me.HasAura("Mental Training"), new ActionAlwaysSucceed()) ) ), // if we have YES aura 74008, then click yes new Decorator(ret => HasAura(Me, 74008), new Sequence( new Action(ret => QBCLog.Info("Answering YES")), new WaitContinue(TimeSpan.FromMilliseconds(500), ret => false, new ActionAlwaysSucceed()), new Action(ret => Lua.DoString("RunMacroText(\"/click OverrideActionBarButton1\")")), new WaitContinue(1, ret => !HasAura(Me, 74008), new ActionAlwaysSucceed()) ) ), // if we have NO aura 74009, then click no new Decorator(ret => HasAura(Me, 74009), new Sequence( new Action(ret => QBCLog.Info("Answering NO")), new WaitContinue(TimeSpan.FromMilliseconds(500), ret => false, new ActionAlwaysSucceed()), new Action(ret => Lua.DoString("RunMacroText(\"/click OverrideActionBarButton2\")")), new WaitContinue(1, ret => !HasAura(Me, 74009), new ActionAlwaysSucceed()) ) ), new Action(delegate { return RunStatus.Success; }) ) )); }