internal static bool SellValidation(string thisinternalname, int thislevel, ItemQuality thisquality, ItemType thisdbitemtype, FollowerType thisfollowertype) { PluginItemTypes thisPluginItemType = ItemFunc.DetermineItemType(thisinternalname, thisdbitemtype, thisfollowertype); PluginBaseItemTypes thisGilesBaseType = ItemFunc.DetermineBaseType(thisPluginItemType); switch (thisGilesBaseType) { case PluginBaseItemTypes.WeaponRange: case PluginBaseItemTypes.WeaponOneHand: case PluginBaseItemTypes.WeaponTwoHand: case PluginBaseItemTypes.Armor: case PluginBaseItemTypes.Offhand: case PluginBaseItemTypes.Jewelry: case PluginBaseItemTypes.FollowerItem: return(true); case PluginBaseItemTypes.Gem: case PluginBaseItemTypes.Misc: case PluginBaseItemTypes.Unknown: if (thisPluginItemType == PluginItemTypes.LegendaryCraftingMaterial) { return(true); } //Sell any plans not already stashed. return(thisdbitemtype == ItemType.CraftingPlan); } // Switch giles base item type return(false); }
public CacheBalance(CacheItem item) { try { BalanceID = item.ref_DiaItem.CommonData.GameBalanceId; _itemLevel = item.ref_DiaItem.CommonData.Level; _type = item.ref_DiaItem.CommonData.ItemType; _base = item.ref_DiaItem.CommonData.ItemBaseType; _followerType = item.ref_DiaItem.CommonData.FollowerSpecialType; _pluginType = ItemFunc.DetermineItemType(item.InternalName, _type, _followerType, item.SNOID); if (item.ItemDropType.HasValue) { _pluginBase = ItemFunc.DetermineBaseItemType(item.ItemDropType.Value); } else { _pluginBase = ItemFunc.DetermineBaseItemType(item.InternalName, item.SNOID); } _isStackable = ItemFunc.DetermineIsStackable(_pluginType, item.SNOID); if (!_isStackable) { _isTwoSlot = ItemFunc.DetermineIsTwoSlot(_pluginType); } } catch (Exception ex) { Logger.Write(LogLevel.Items, String.Format("Failed to create balance data for item {0}", item.DebugStringSimple)); } }
// dir-walk-simple - Higher Order Perl pp. 17-20 public static void Dir_Walk_Simple(string top, ItemFunc code) { code(top); if (PerlFileOps.IsDir(top)) // -d { // There is not an equivalent to Perl's opendir/readir. The line below tries to read the files and directories // in directory "top" and will throw an exception if the directory with this name doesn't exist or has some // kind of access error FileSystemInfo[] filesAndDirs; try { filesAndDirs = (new DirectoryInfo(top)).GetFileSystemInfos(); } catch (Exception e) { Console.WriteLine("Couldn't open directory {0}: {1} - skipping.", top, e.Message); return; } foreach (FileSystemInfo file in filesAndDirs) { // System.IO doesn't return aliases like "." or ".." for any GetXXX calls // so we don't need code to exclude them Dir_Walk_Simple(file.FullName, code); } } }
public DebugEntry(int snoid, string name, PluginActorType actortype, PluginGizmoType gizmotype = PluginGizmoType.None) { SNOID = snoid; Name = name; ActorType = actortype; GizmoType = gizmotype; if (ActorType == PluginActorType.Item) { DroppedItemType = ItemFunc.DetermineDroppedItemType(Name, SNOID); } }
public DebugEntry(CachedSNOEntry entry) { SNOID = entry.SNOID; Name = entry.InternalName; ActorType = entry.Actortype.HasValue ? (PluginActorType)Enum.Parse(typeof(PluginActorType), entry.Actortype.Value.ToString()) : PluginActorType.Invalid; GizmoType = entry.Gizmotype.HasValue ? (PluginGizmoType)Enum.Parse(typeof(PluginGizmoType), entry.Gizmotype.Value.ToString()) : PluginGizmoType.None; TargetType = entry.targetType.HasValue ? entry.targetType.Value : TargetType.None; if (ActorType == PluginActorType.Item) { DroppedItemType = ItemFunc.DetermineDroppedItemType(Name, SNOID); } }
// Update is called once per frame void Update() { if (isDown == false || moved == true || dragActive == true) { return; } if (Time.time - beginTime > loapPressDelay) { scroRect.vertical = false; dragActive = true; itemStartPos = rectTran.anchoredPosition; dragToItem = null; viewDragActivePos = view.position; } }
private void UpdateBackpackSlots() { Logger.DBLog.DebugFormat("Updating Backpack Slots!"); // Array for what blocks are or are not blocked for (int iRow = 0; iRow <= 5; iRow++) { for (int iColumn = 0; iColumn <= 9; iColumn++) { BackpackSlotBlocked[iColumn, iRow] = false; } } // Block off the entire of any "protected" foreach (InventorySquare iProtPage in CharacterSettings.Instance.ProtectedBagSlots) { BackpackSlotBlocked[iProtPage.Column, iProtPage.Row] = true; } // Map out all the items already in the stash foreach (ACDItem tempitem in ZetaDia.Me.Inventory.Backpack) { if (tempitem.BaseAddress != IntPtr.Zero) { //StashedItems.Add(new CacheACDItem(tempitem)); int inventoryRow = tempitem.InventoryRow; int inventoryColumn = tempitem.InventoryColumn; // Mark this slot as not-free BackpackSlotBlocked[inventoryColumn, inventoryRow] = true; // Try and reliably find out if this is a two slot item or not PluginItemTypes tempItemType = ItemFunc.DetermineItemType(tempitem.InternalName, tempitem.ItemType, tempitem.FollowerSpecialType, tempitem.ActorSNO); if (ItemFunc.DetermineIsTwoSlot(tempItemType) && inventoryRow != 5) { BackpackSlotBlocked[inventoryColumn, inventoryRow + 1] = true; } else if (ItemFunc.DetermineIsTwoSlot(tempItemType) && inventoryRow == 5) { Logger.DBLog.DebugFormat("GSError: DemonBuddy thinks this item is 2 slot even though it's at bottom row of a stash page: " + tempitem.Name + " [" + tempitem.InternalName + "] type=" + tempItemType.ToString() + " @ slot " + (inventoryRow + 1).ToString(CultureInfo.InvariantCulture) + "/" + (inventoryColumn + 1).ToString(CultureInfo.InvariantCulture)); } } } // Loop through all stash items bUpdatedStashMap = true; }
private void InitButtons() { UIGrid grid = mTopRightGrid.GetComponent <UIGrid>(); for (int i = 0; i < mTopBtnTemps.Count; i++) { ItemFunc data = mTopBtnTemps[i]; GameObject item = NGUITools.AddChild(mTopRightGrid.gameObject, btnTemp); grid.AddChild(item.transform); item.SetActive(true); item.transform.Find("Name").GetComponent <UILabel>().text = data.name.ToString(); item.transform.Find("Icon").GetComponent <UISprite>().spriteName = data.icon.ToString(); UIEventListener.Get(item).onClick = data.onClick; mTopButtons.Add(item); } }
private static void LogSalvagedItem(CacheACDItem item) { // Item log for cool stuff stashed PluginItemTypes OriginalGilesItemType = ItemFunc.DetermineItemType(item); PluginBaseItemTypes thisGilesBaseType = ItemFunc.DetermineBaseType(OriginalGilesItemType); if (thisGilesBaseType == PluginBaseItemTypes.WeaponTwoHand || thisGilesBaseType == PluginBaseItemTypes.WeaponOneHand || thisGilesBaseType == PluginBaseItemTypes.WeaponRange || thisGilesBaseType == PluginBaseItemTypes.Armor || thisGilesBaseType == PluginBaseItemTypes.Jewelry || thisGilesBaseType == PluginBaseItemTypes.Offhand || thisGilesBaseType == PluginBaseItemTypes.FollowerItem) { FunkyTownRunPlugin.LogJunkItems(item, thisGilesBaseType, OriginalGilesItemType); } if (FunkyGame.CurrentStats != null) { FunkyGame.CurrentStats.CurrentProfile.LootTracker.SalvagedItemLog(item); } }
public static bool ContainsItem(CacheItem item) { UpdateItemList(); if (item.BalanceData == null) { if (item.ItemDropType.HasValue) { var pluginBase = ItemFunc.DetermineBaseItemType(item.ItemDropType.Value); return(NewItemList.Any(i => i.BaseItemType == pluginBase)); } } else { return(NewItemList.Any(i => i.ThisBalanceID == item.BalanceData.BalanceID)); } return(NewItemList.Any(i => i.SNO == item.SNOID)); }
private GameObject GetInstance() { if (skinList.Count > 0) { return(skinList.Pop()); } GameObject cloneSkin = GameObject.Instantiate(itemSkin); UDragScroll uDrag = cloneSkin.AddComponent <UDragScroll>(); ItemFunc func = cloneSkin.AddComponent <ItemFunc>(); GameObject itemview = cloneSkin.transform.FindChild("view").gameObject; GameObject itemOffer = cloneSkin.transform.FindChild("view/Offer").gameObject; UDragScroll viewScroll = itemview.AddComponent <UDragScroll>(); viewScroll.scroRect = scroRect; UDragScroll offerScroll = itemOffer.AddComponent <UDragScroll>(); offerScroll.scroRect = scroRect; cloneSkin.SetActive(true); return(cloneSkin); }
public void RefreshDisplay(ItemData[] msgs = null, bool resetPos = false) { foreach (ItemFunc item in itemDic.Values) { skinList.Push(item.gameObject); } itemDic.Clear(); if (resetPos == true) { ResetPosition(); } if (msgs != null) { ResetHeight(msgs.Length); this.msgs = msgs; } for (int i = 0; i < this.msgs.Length; i++) { if (i < currentIndex - 6 || i > currentIndex + 20) { continue; } GameObject cloneSkin = GetInstance(); UDragScroll uDrag = cloneSkin.GetComponent <UDragScroll>(); ItemFunc func = cloneSkin.GetComponent <ItemFunc>(); cloneSkin.transform.localPosition = content.GetLocalPositionByIndex(i); uDrag.scroRect = scroRect; func.OnChange = ItemIndexChange; func.scroRect = scroRect; func.data = this.msgs[i]; func.index = i; itemDic.Add(i, func); cloneSkin.transform.SetParent(contentRect, false); cloneSkin.name = "" + func.index; cloneSkin.GetComponent <RectTransform>().SetSiblingIndex(i); } }
public void ItemIndexChange(int from, int to) { if (itemDic.ContainsKey(from) == false || itemDic.ContainsKey(to) == false) { Debug.LogWarning("ItemIndexChange Wrong :index " + from + " or " + to + " 不存在!"); return; } ItemFunc funcFrom = itemDic[from]; ItemFunc funcTo = itemDic[to]; funcFrom.index = to; funcTo.index = from; itemDic[from] = funcTo; itemDic[to] = funcFrom; ItemData fromdata = this.msgs[from]; ItemData todata = this.msgs[to]; this.msgs[from] = todata; this.msgs[to] = fromdata; RefreshDisplay(); }
IEnumerator HitAction() { renObj.sprite = spHit; renObj.color = new Color(renObj.color.r, renObj.color.g, renObj.color.b, 0.25f); yield return(new WaitForSeconds(0.125f)); renObj.color = new Color(renObj.color.r, renObj.color.g, renObj.color.b, 1.0f); renObj.sprite = sp; this.gameObject.SetActive(false); C_GAMEMANAGER.GetInstance().GetPlayer().SetCurrentEat(strObjectName); ItemFunc func = null; if (m_dicIFunc.TryGetValue(strObjectName, out func)) { if (func != null) { func(); } } }
private List <CacheACDItem> GetGemCacheACDItems(List <int> Acdguids) { List <CacheACDItem> GemList = new List <CacheACDItem>(); foreach (var item in ZetaDia.Actors.GetActorsOfType <ACDItem>().Where(item => Acdguids.Contains(item.ACDGuid))) { CacheACDItem cItem = new CacheACDItem(item); double SuccessRate = ItemFunc.GetLegendaryGemUpgradeChance(GRiftLevel, cItem.LegendaryGemRank); if (GRiftLevel - cItem.LegendaryGemRank == -7) { continue; } if (SuccessRate < FunkyBaseExtension.Settings.AdventureMode.GemUpgradingMinimumSuccessRate) { continue; } //if (SuccessRate < FunkyBaseExtension.Settings.AdventureMode.GemUpgradingMinimumSuccessRate) continue; GemList.Add(cItem); } return(GemList); }
public void StashedItemLog(CacheACDItem i) { PluginItemTypes thisPluginItemType = ItemFunc.DetermineItemType(i); if (thisPluginItemType == PluginItemTypes.InfernalKey) { Keys.Stashed++; return; } if (thisPluginItemType == PluginItemTypes.HoradricCache) { HoradricCache.Stashed++; } if (thisPluginItemType == PluginItemTypes.KeyStone) { KeyStoneFragments.Stashed += i.ThisItemStackQuantity; } switch (i.ACDItem.ItemType) { case ItemType.CraftingPage: case ItemType.CraftingPlan: case ItemType.CraftingReagent: Crafting.Stashed++; break; case ItemType.Gem: Gems.Stashed++; break; case ItemType.Amulet: case ItemType.Axe: case ItemType.Belt: case ItemType.Boots: case ItemType.Bow: case ItemType.Bracer: case ItemType.CeremonialDagger: case ItemType.Chest: case ItemType.Cloak: case ItemType.Crossbow: case ItemType.Dagger: case ItemType.Daibo: case ItemType.FistWeapon: case ItemType.FollowerSpecial: case ItemType.Flail: case ItemType.CrusaderShield: case ItemType.Gloves: case ItemType.HandCrossbow: case ItemType.Helm: case ItemType.Legs: case ItemType.Mace: case ItemType.MightyBelt: case ItemType.MightyWeapon: case ItemType.Mojo: case ItemType.Orb: case ItemType.Polearm: case ItemType.Quiver: case ItemType.Ring: case ItemType.Shield: case ItemType.Shoulder: case ItemType.Spear: case ItemType.SpiritStone: case ItemType.Staff: case ItemType.Sword: case ItemType.VoodooMask: case ItemType.Wand: case ItemType.WizardHat: if (i.ThisQuality == ItemQuality.Legendary) { Legendary.Stashed++; } else if (i.ThisQuality > ItemQuality.Magic3) { Rare.Stashed++; } else { Magical.Stashed++; } break; } }
void SetDraggedPosition(PointerEventData data) { Debug.Log("drag"); if (offset == data.position - inputStartPos) { return; } offset = data.position - inputStartPos; rectTran.anchoredPosition = itemStartPos + GetPos(offset); Vector2 org = new Vector2(rectTran.position.x + 1.8f, rectTran.position.y - 1.3f); count = Physics2D.OverlapPointNonAlloc(org, coll); if (count == 0) { return; } bool hasOldFunc = false; for (int i = 0; i < count; i++) { if (coll[i].transform.parent == null) { continue; } if (coll[i].transform.parent == this.transform) { continue; } if (dragToItem != null && dragToItem.transform == coll[i].transform.parent) { hasOldFunc = true; break; } ItemFunc func = coll[i].transform.parent.GetComponent <ItemFunc>(); if (func == null) { continue; } if (dragToItem != null) { dragToItem.goBack(dragToItem.view); } dragToItem = func; dragToItem.GoToWorldPos(dragToItem.view, viewDragActivePos); func.transform.SetSiblingIndex(50); return; } if (hasOldFunc == false) { if (dragToItem != null) { dragToItem.goBack(dragToItem.view); dragToItem = null; } } }
} // Custom stashing routine private bool BackpackStashAttempt(CacheACDItem item, out int[] XY) { XY = new[] { -1, -1 }; int iPlayerDynamicID = ZetaDia.Me.CommonData.DynamicId; int iOriginalGameBalanceId = item.ThisBalanceID; int iOriginalDynamicID = item.ThisDynamicID; int iOriginalStackQuantity = (int)item.ThisItemStackQuantity; string sOriginalItemName = item.ThisRealName; string sOriginalInternalName = item.ThisInternalName; PluginItemTypes OriginalPluginItemType = ItemFunc.DetermineItemType(item); PluginBaseItemTypes thisGilesBaseType = ItemFunc.DetermineBaseType(OriginalPluginItemType); bool bOriginalTwoSlot = item.IsTwoSlot; bool bOriginalIsStackable = item.IsStackableItem; int iAttempts; if (_dictItemStashAttempted.TryGetValue(iOriginalDynamicID, out iAttempts)) { Logger.DBLog.InfoFormat("GSError: Detected a duplicate stash attempt, DB item mis-read error, now forcing this item as a 2-slot item"); _dictItemStashAttempted[iOriginalDynamicID] = iAttempts + 1; bOriginalTwoSlot = true; bOriginalIsStackable = false; if (iAttempts > 6) { Logger.DBLog.InfoFormat("GSError: Detected an item stash loop risk, now re-mapping stash treating everything as 2-slot and re-attempting"); // Array for what blocks are or are not blocked for (int iRow = 0; iRow <= 5; iRow++) { for (int iColumn = 0; iColumn <= 9; iColumn++) { BackpackSlotBlocked[iColumn, iRow] = false; } } // Block off the entire of any "protected stash pages" foreach (InventorySquare iProtPage in CharacterSettings.Instance.ProtectedBagSlots) { BackpackSlotBlocked[iProtPage.Column, iProtPage.Row] = true; } // Map out all the items already in the stash foreach (ACDItem tempitem in ZetaDia.Me.Inventory.Backpack) { if (tempitem.BaseAddress != IntPtr.Zero) { CacheACDItem tempCacheItem = new CacheACDItem(tempitem); int inventoryRow = tempCacheItem.invRow; int inventoryColumn = tempCacheItem.invCol; // Mark this slot as not-free BackpackSlotBlocked[inventoryColumn, inventoryRow] = true; // Try and reliably find out if this is a two slot item or not //BackpackSlotBlocked[inventoryColumn, inventoryRow + 1] = true; if (inventoryRow != 5 && tempCacheItem.IsTwoSlot) { BackpackSlotBlocked[inventoryColumn, inventoryRow + 1] = true; } } } } if (iAttempts > 15) { Logger.DBLog.InfoFormat("***************************"); Logger.DBLog.InfoFormat("GSError: Emergency Stop: No matter what we tried, we couldn't prevent an infinite stash loop. Sorry. Now stopping the bot."); BotMain.Stop(); return(false); } } else { _dictItemStashAttempted.Add(iOriginalDynamicID, 1); } // Safety incase it's not actually in the backpack anymore /*if (item.InventorySlot != InventorySlot.PlayerBackpack) * { * FunkyTownRunPlugin.DBLog.InfoFormat("GSError: Diablo 3 memory read error, or item became invalid [StashAttempt-4]", true); * return false; * }*/ int iLeftoverStackQuantity; int iPointX = -1; int iPointY = -1; // First check if we can top-up any already-existing stacks in the stash if (bOriginalIsStackable) { foreach (ACDItem tempitem in ZetaDia.Me.Inventory.Backpack) { if (tempitem.BaseAddress == IntPtr.Zero) { Logger.DBLog.InfoFormat("GSError: Diablo 3 memory read error, or stash item became invalid [StashAttempt-5]"); return(false); } // Check if we combine the stacks, we won't overfill them if ((tempitem.GameBalanceId == iOriginalGameBalanceId) && (tempitem.ItemStackQuantity < tempitem.MaxStackCount)) { iLeftoverStackQuantity = (int)((tempitem.ItemStackQuantity + iOriginalStackQuantity) - tempitem.MaxStackCount); iPointX = tempitem.InventoryColumn; iPointY = tempitem.InventoryRow; // Will we have leftovers? if (iLeftoverStackQuantity <= 0) { goto FoundStashLocation; } goto HandleStackMovement; } } HandleStackMovement: if ((iPointX >= 0) && (iPointY >= 0)) { ZetaDia.Me.Inventory.MoveItem(iOriginalDynamicID, iPlayerDynamicID, InventorySlot.BackpackItems, iPointX, iPointY); } } iPointX = -1; iPointY = -1; // If it's a 2-square item, find a double-slot free if (bOriginalTwoSlot) { for (int iRow = 0; iRow <= 5; iRow++) { bool bBottomPageRow = iRow == 5; for (int iColumn = 0; iColumn <= 9; iColumn++) { // If nothing in the 1st row if (!BackpackSlotBlocked[iColumn, iRow]) { bool bNotEnoughSpace = false; // Bottom row of a page = no room if (bBottomPageRow) { bNotEnoughSpace = true; } // Already something in the stash in the 2nd row) else if (BackpackSlotBlocked[iColumn, iRow + 1]) { bNotEnoughSpace = true; } if (!bNotEnoughSpace) { iPointX = iColumn; iPointY = iRow; goto FoundStashLocation; } } } } } // 2 slot item? // Now deal with any leftover 1-slot items else { // First we try and find somewhere "sensible" for (int iRow = 0; iRow <= 5; iRow++) { bool bTopPageRow = iRow == 0; bool bBottomPageRow = (iRow == 5); for (int iColumn = 0; iColumn <= 9; iColumn++) { // Nothing in this slot if (!BackpackSlotBlocked[iColumn, iRow]) { bool bSensibleLocation = false; if (!bTopPageRow && !bBottomPageRow) { // Something above and below this slot, or an odd-numbered row, so put something here if ((BackpackSlotBlocked[iColumn, iRow + 1] && BackpackSlotBlocked[iColumn, iRow - 1]) || (iRow) % 2 != 0) { bSensibleLocation = true; } } // Top page row with something directly underneath already blocking else if (bTopPageRow) { if (BackpackSlotBlocked[iColumn, iRow + 1]) { bSensibleLocation = true; } } // Bottom page row with something directly over already blocking else { bSensibleLocation = true; } // Sensible location? Yay, stash it here! if (bSensibleLocation) { iPointX = iColumn; iPointY = iRow; // Keep looking for places if it's a stackable to try to stick it at the end if (!bOriginalIsStackable) { goto FoundStashLocation; } } } } } // Didn't find a "sensible" place, let's try and force it in absolutely anywhere if ((iPointX < 0) || (iPointY < 0)) { for (int iRow = 0; iRow <= 5; iRow++) { for (int iColumn = 0; iColumn <= 9; iColumn++) { // Nothing in this spot, we're good! if (!BackpackSlotBlocked[iColumn, iRow]) { iPointX = iColumn; iPointY = iRow; // Keep looking for places if it's a stackable to try to stick it at the end if (!bOriginalIsStackable) { goto FoundStashLocation; } } } } } } FoundStashLocation: if ((iPointX < 0) || (iPointY < 0)) { Logger.DBLog.DebugFormat("Fatal Error: No valid stash location found for '" + sOriginalItemName + "' [" + sOriginalInternalName + " - " + OriginalPluginItemType.ToString() + "]"); Logger.DBLog.InfoFormat("***************************"); Logger.DBLog.InfoFormat("GSError: Emergency Stop: You need to stash an item but no valid space could be found. Stash is full? Stopping the bot to prevent infinite town-run loop."); BotMain.Stop(true, "No Room To Stash!"); //ZetaDia.Service.Party.LeaveGame(); return(false); } // We have two valid points that are empty, move the object here! BackpackSlotBlocked[iPointX, iPointY] = true; if (bOriginalTwoSlot) { BackpackSlotBlocked[iPointX, iPointY + 1] = true; } XY = new[] { iPointX, iPointY }; return(true); } // Custom stashing routine
public override bool UpdateData() { if (ref_DiaItem == null) { try { ref_DiaItem = (DiaItem)ref_DiaObject; } catch { Logger.Write(LogLevel.Cache, "Failure to convert obj {0} to DiaItem!", InternalName); NeedsRemoved = true; BlacklistFlag = BlacklistType.Temporary; return(false); } } bool skippingCommonDataUpdates = false; //Check if item is not a misc item (requires common data) if (ItemDropType.HasValue) { var baseItemType = ItemFunc.DetermineBaseItemType(ItemDropType.Value); var isstackable = ItemFunc.DetermineIsStackable(ItemDropType.Value); IsTwoSlot = ItemFunc.DetermineIsTwoSlot(ItemDropType.Value); skippingCommonDataUpdates = (baseItemType == PluginBaseItemTypes.Misc || baseItemType == PluginBaseItemTypes.Gem || baseItemType == PluginBaseItemTypes.HealthGlobe || (FunkyBaseExtension.Settings.Loot.PickupWhiteItems == 1 && FunkyBaseExtension.Settings.Loot.PickupMagicItems == 1 && FunkyBaseExtension.Settings.Loot.PickupRareItems == 1 && FunkyBaseExtension.Settings.Loot.PickupLegendaryItems == 1)); if (!skippingCommonDataUpdates) { if (!IsStillValid()) { NeedsRemoved = true; return(false); } } } else if (!IsStillValid()) { NeedsRemoved = true; return(false); } if (targetType.Value == TargetType.Item) { #region Item //#region DynamicID //if (!DynamicID.HasValue) //{ // try // { // DynamicID = ref_DiaItem.CommonData.DynamicId; // } // catch // { // Logger.Write(LogLevel.Cache, "Failure to get Dynamic ID for {0}", InternalName); // return false; // } //} //#endregion //Gamebalance Update if (!skippingCommonDataUpdates && !BalanceID.HasValue) { try { BalanceID = ref_DiaItem.CommonData.GameBalanceId; } catch { Logger.Write(LogLevel.Cache, "Failure to get gamebalance ID for item {0}", InternalName); return(false); } } //Check if game balance needs updated #region GameBalance if (!skippingCommonDataUpdates && (BalanceData == null || BalanceData.bNeedsUpdated)) { CacheBalance thisnewGamebalance; try { thisnewGamebalance = new CacheBalance(this); } catch { Logger.Write(LogLevel.Cache, "Failure to add/update gamebalance data for item {0}", InternalName); NeedsRemoved = true; return(false); } if (BalanceData == null) { CacheIDLookup.dictGameBalanceCache.Add(BalanceID.Value, thisnewGamebalance); } else { CacheIDLookup.dictGameBalanceCache[BalanceID.Value] = thisnewGamebalance; } } #endregion //Item Quality / Recheck #region ItemQuality if (!skippingCommonDataUpdates && (!Itemquality.HasValue || ItemQualityRechecked == false)) { try { Itemquality = ref_DiaItem.CommonData.ItemQualityLevel; } catch { Logger.Write(LogLevel.Cache, "Failure to get item quality for {0}", InternalName); return(false); } if (!ItemQualityRechecked) { ItemQualityRechecked = true; } else { NeedsUpdate = false; } } #endregion //Pickup? // Now see if we actually want it #region PickupValidation if (!ShouldPickup.HasValue) { //Logger.DBLog.InfoFormat Dropped Items Here!! if (BalanceData != null && Itemquality.HasValue) { if (FunkyGame.CurrentStats != null) { FunkyGame.CurrentStats.CurrentProfile.LootTracker.DroppedItemLog(BalanceData.PluginType, Itemquality.Value); } } //Bot.Game.CurrentGameStats.CurrentProfile.LootTracker.DroppedItemLog(this); FunkyGame.ItemPickupEval(this); NeedsUpdate = false; } else { NeedsUpdate = false; } #endregion #endregion } else if (targetType.Value == TargetType.Globe || targetType.Value == TargetType.PowerGlobe) { NeedsUpdate = false; } else { #region Gold //Get gold value.. if (!GoldAmount.HasValue) { try { GoldAmount = ref_DiaItem.CommonData.GetAttribute <int>(ActorAttributeType.Gold); } catch { //Logger.Write(LogLevel.Cache, "Failure to get gold amount for gold pile!"); return(false); } } FunkyGame.Hero.UpdateCoinage = true; NeedsUpdate = false; #endregion } return(true); }
public PluginItemTypes GetGItemType(string internalName) { return(ItemFunc.DetermineItemType(internalName, _type, _followerType)); }
//Prechecks are things prior to target checks and actual target handling.. This is always called first. public virtual bool PreChecks() { // If we aren't in the game of a world is loading, don't do anything yet if (!ZetaDia.IsInGame || ZetaDia.IsLoadingWorld) { CurrentState = RunStatus.Success; return(false); } // See if we should update hotbar abilities FunkyGame.Hero.Class.SecondaryHotbarBuffPresent(); // Special pausing *AFTER* using certain powers #region PauseCheck if (Cache.bWaitingAfterPower && FunkyGame.Hero.Class.PowerPrime.WaitLoopsAfter >= 1) { if (FunkyGame.Hero.Class.PowerPrime.WaitLoopsAfter >= 1) { FunkyGame.Hero.Class.PowerPrime.WaitLoopsAfter--; } if (FunkyGame.Hero.Class.PowerPrime.WaitLoopsAfter <= 0) { Cache.bWaitingAfterPower = false; } CurrentState = RunStatus.Running; return(false); } #endregion // Update player-data cache -- Special combat call FunkyGame.Hero.Update(true); // Check for death / player being dead #region DeadCheck if (FunkyGame.Hero.dCurrentHealthPct <= 0) { //Disable OOC IDing behavior if dead! //if (ItemIdentifyBehavior.shouldPreformOOCItemIDing) ItemIdentifyBehavior.shouldPreformOOCItemIDing = false; CurrentState = RunStatus.Success; return(false); } #endregion //Herbfunk //Confirmation of item looted #region ItemLootedConfirmationCheck if (Cache.ShouldCheckItemLooted) { //Reset? if (Cache.CurrentTarget == null || Cache.CurrentTarget.targetType.HasValue && Cache.CurrentTarget.targetType.Value != TargetType.Item) { Cache.ShouldCheckItemLooted = false; return(false); } //Vendor Behavior ignore checking (Unless told that we shouldn't from town run manager) if (BrainBehavior.IsVendoring && !Cache.IgnoreVendoring) { CurrentState = RunStatus.Success; return(false); } if (FunkyGame.Hero.bIsIncapacitated) { CurrentState = RunStatus.Running; return(false); } //Count each attempt to confirm. Cache.recheckCount++; string statusText = "[Item Confirmation] Current recheck count " + Cache.recheckCount; CacheItem thisCacheItem = (CacheItem)Cache.CurrentTarget; bool LootedSuccess = false; if (thisCacheItem.BalanceID.HasValue && thisCacheItem.Itemquality.HasValue) { LootedSuccess = Backpack.ContainsItem(thisCacheItem.BalanceID.Value, thisCacheItem.Itemquality.Value); } else { LootedSuccess = Backpack.ContainsItem(thisCacheItem); } statusText += " [ItemFound=" + LootedSuccess + "]"; if (LootedSuccess) { //Logger.DBLog.Info("Item Looted Successfully!"); if (FunkyBaseExtension.Settings.Debugging.DebugStatusBar) { BotMain.StatusText = statusText; } //This is where we should manipulate information of both what dropped and what was looted. if (thisCacheItem.BalanceID.HasValue && thisCacheItem.BalanceData != null && thisCacheItem.Itemquality.HasValue) { GameEvents.FireItemLooted(Cache.CurrentTarget.AcdGuid.Value); if (FunkyGame.CurrentStats != null) { FunkyGame.CurrentStats.CurrentProfile.LootTracker.LootedItemLog(thisCacheItem.BalanceData.PluginType, thisCacheItem.BalanceData.PluginBase, thisCacheItem.Itemquality.Value); } } //Remove item from cache.. Cache.CurrentTarget.NeedsRemoved = true; //Update backpack again! Backpack.UpdateItemList(); } else { CacheItem thisObjItem = (CacheItem)Cache.CurrentTarget; statusText += " [Quality"; //Quality of the item determines the recheck attempts. ItemQuality curQuality = thisObjItem.Itemquality.HasValue ? thisObjItem.Itemquality.Value : ItemQuality.Normal; #region QualityRecheckSwitch switch (curQuality) { case ItemQuality.Inferior: case ItemQuality.Invalid: case ItemQuality.Special: case ItemQuality.Superior: case ItemQuality.Normal: case ItemQuality.Magic1: case ItemQuality.Magic2: case ItemQuality.Magic3: statusText += "<=Magical]"; //Non-Quality items get skipped quickly. if (Cache.recheckCount > 3) { Cache.reCheckedFinished = true; } break; case ItemQuality.Rare4: case ItemQuality.Rare5: case ItemQuality.Rare6: statusText += "=Rare]"; if (Cache.recheckCount > 4) { Cache.reCheckedFinished = true; } //else //bItemForcedMovement = true; break; case ItemQuality.Legendary: statusText += "=Legendary]"; if (Cache.recheckCount > 6) { Cache.reCheckedFinished = true; } //else //bItemForcedMovement = true; break; } #endregion //If we are still rechecking then use the waitAfter (powerprime Ability related) to wait a few loops. if (!Cache.reCheckedFinished) { statusText += " RECHECKING"; if (FunkyBaseExtension.Settings.Debugging.DebugStatusBar) { BotMain.StatusText = statusText; } Cache.bWaitingAfterPower = true; FunkyGame.Hero.Class.PowerPrime.WaitLoopsAfter = 3; CurrentState = RunStatus.Running; return(false); } //We Rechecked Max Confirmation Checking Count, now we check if we want to retry confirmation, or simply try once more then ignore for a few. bool stackableItem = false; if (thisObjItem.BalanceID.HasValue && thisObjItem.BalanceData != null) { stackableItem = thisCacheItem.BalanceData.IsStackable; } else if (thisObjItem.ItemDropType.HasValue) { stackableItem = ItemFunc.DetermineIsStackable(thisObjItem.ItemDropType.Value); } if (stackableItem || (curQuality > ItemQuality.Magic3)) { //Items above rare quality don't get blacklisted, just ignored for a few loops. //This will force a movement if stuck.. but 5 loops is only 750ms if (!Cache.IgnoreVendoring) //Exclude town run manager checking! { Cache.CurrentTarget.BlacklistLoops = 5; } } else { //Blacklist items below rare quality! //Cache.CurrentTarget.BlacklistFlag = BlacklistType.Temporary; //Cache.CurrentTarget.NeedsRemoved = true; Cache.CurrentTarget.BlacklistLoops = 50; } } // Now get a new target! Cache.bForceTargetUpdate = true; //Reset flag, and continue.. Cache.ShouldCheckItemLooted = false; } #endregion // See if we have been "newly rooted", to force target updates if (FunkyGame.Hero.bIsRooted && !Cache.bWasRootedLastTick) { Cache.bWasRootedLastTick = true; Cache.bForceTargetUpdate = true; } if (!FunkyGame.Hero.bIsRooted) { Cache.bWasRootedLastTick = false; } return(true); }
internal static bool StashValidation(CacheACDItem thisitem) { // Stash all unidentified items - assume we want to keep them since we are using an identifier over-ride if (thisitem.IsUnidentified) { //if (bOutputItemScores) FunkyTownRunPlugin.DBLog.InfoFormat(thisitem.ThisRealName + " [" + thisitem.ThisInternalName + "] = (autokeep unidentified items)"); return(true); } // Now look for Misc items we might want to keep PluginItemTypes TrueItemType = ItemFunc.DetermineItemType(thisitem); if (TrueItemType == PluginItemTypes.KeyStone) { //if (bOutputItemScores) FunkyTownRunPlugin.DBLog.InfoFormat(thisitem.ThisRealName + " [" + thisitem.ThisInternalName + "] [" + TrueItemType + "] = (autokeep keystone fragments)"); return(true); } if (TrueItemType == PluginItemTypes.HoradricCache) { //if (bOutputItemScores) FunkyTownRunPlugin.DBLog.InfoFormat(thisitem.ThisRealName + " [" + thisitem.ThisInternalName + "] [" + TrueItemType + "] = (autokeep cache)"); return(FunkyTownRunPlugin.PluginSettings.StashHoradricCache); } if (TrueItemType == PluginItemTypes.StaffOfHerding) { //if (bOutputItemScores) FunkyTownRunPlugin.DBLog.InfoFormat(thisitem.ThisRealName + " [" + thisitem.ThisInternalName + "] [" + TrueItemType + "] = (autokeep staff of herding)"); return(true); } if (TrueItemType == PluginItemTypes.CraftingMaterial) { //if (bOutputItemScores) FunkyTownRunPlugin.DBLog.InfoFormat(thisitem.ThisRealName + " [" + thisitem.ThisInternalName + "] [" + TrueItemType + "] = (autokeep craft materials)"); return(true); } if (TrueItemType == PluginItemTypes.CraftingPlan) { //if (bOutputItemScores) FunkyTownRunPlugin.DBLog.InfoFormat(thisitem.ThisRealName + " [" + thisitem.ThisInternalName + "] [" + TrueItemType + "] = (autokeep plans)"); return(true); } if (TrueItemType == PluginItemTypes.Emerald) { //if (bOutputItemScores) FunkyTownRunPlugin.DBLog.InfoFormat(thisitem.ThisRealName + " [" + thisitem.ThisInternalName + "] [" + TrueItemType + "] = (autokeep gems)"); return(true); } if (TrueItemType == PluginItemTypes.Amethyst) { //if (bOutputItemScores) FunkyTownRunPlugin.DBLog.InfoFormat(thisitem.ThisRealName + " [" + thisitem.ThisInternalName + "] [" + TrueItemType + "] = (autokeep gems)"); return(true); } if (TrueItemType == PluginItemTypes.Topaz) { //if (bOutputItemScores) FunkyTownRunPlugin.DBLog.InfoFormat(thisitem.ThisRealName + " [" + thisitem.ThisInternalName + "] [" + TrueItemType + "] = (autokeep gems)"); return(true); } if (TrueItemType == PluginItemTypes.Ruby) { //if (bOutputItemScores) FunkyTownRunPlugin.DBLog.InfoFormat(thisitem.ThisRealName + " [" + thisitem.ThisInternalName + "] [" + TrueItemType + "] = (autokeep gems)"); return(true); } if (TrueItemType == PluginItemTypes.Diamond) { //if (bOutputItemScores) FunkyTownRunPlugin.DBLog.InfoFormat(thisitem.ThisRealName + " [" + thisitem.ThisInternalName + "] [" + TrueItemType + "] = (autokeep gems)"); return(true); } if (TrueItemType == PluginItemTypes.LegendaryGem) { return(true); } if (TrueItemType == PluginItemTypes.RamaladnisGift) { return(true); } if (TrueItemType == PluginItemTypes.CraftTome) { //if (bOutputItemScores) FunkyTownRunPlugin.DBLog.InfoFormat(thisitem.ThisRealName + " [" + thisitem.ThisInternalName + "] [" + TrueItemType + "] = (autokeep tomes)"); return(true); } if (TrueItemType == PluginItemTypes.InfernalKey) { //if (bOutputItemScores) FunkyTownRunPlugin.DBLog.InfoFormat(thisitem.ThisRealName + " [" + thisitem.ThisInternalName + "] [" + TrueItemType + "] = (autokeep infernal key)"); return(true); } if (TrueItemType == PluginItemTypes.HealthPotion || TrueItemType == PluginItemTypes.LegendaryHealthPotion) { //if (bOutputItemScores) FunkyTownRunPlugin.DBLog.InfoFormat(thisitem.ThisRealName + " [" + thisitem.ThisInternalName + "] [" + TrueItemType + "] = (ignoring potions)"); return(false); } if (thisitem.ThisQuality >= ItemQuality.Legendary) { //if (bOutputItemScores) FunkyTownRunPlugin.DBLog.InfoFormat(thisitem.ThisRealName + " [" + thisitem.ThisInternalName + "] [" + TrueItemType + "] = (autokeep legendaries)"); return(true); } if (TrueItemType == PluginItemTypes.Dye) { return(true); } // Ok now try to do some decent item scoring based on item types //double iNeedScore = ScoreNeeded(TrueItemType); //double iMyScore = ValueThisItem(thisitem, TrueItemType); //if (bOutputItemScores) FunkyTownRunPlugin.DBLog.InfoFormat(thisitem.ThisRealName + " [" + thisitem.ThisInternalName + "] [" + TrueItemType + "] = " + iMyScore); //if (iMyScore >= iNeedScore) return true; // If we reached this point, then we found no reason to keep the item! return(false); }
private async Task <bool> BehaviorRoutine() { //Refresh Active Quests and Check that we are still in the reward step.. FunkyGame.Bounty.RefreshActiveQuests(); if (!FunkyGame.Bounty.ActiveQuests.ContainsKey(337492) || FunkyGame.Bounty.ActiveQuests[337492].Step != 34) { Logger.DBLog.Info("Active Quest no longer valid for reward!"); m_IsDone = true; return(true); } //Check if the rift key upgrade continue button is visible if (UI.ValidateUIElement(UI.Game.RiftReward_UpgradeKey_ContinueButton)) { UI.Game.RiftReward_UpgradeKey_ContinueButton.Click(); await Coroutine.Sleep(250); await Coroutine.Yield(); } if (!delayer.Test(5)) { await Coroutine.Sleep(250); await Coroutine.Yield(); } //Check if the NPC dialog is still valid if (!UI.ValidateUIElement(UI.Game.SalvageMainPage)) { Logger.DBLog.Info("Rift Reward Dialog not valid."); m_IsDone = true; return(true); } //Upgrading Gems? if (UI.Game.RiftReward_gemUpgradePane_UpgradeButton.IsVisible) { if (!delayer.Test(10)) { await Coroutine.Sleep(250); await Coroutine.Yield(); } Logger.DBLog.Info("Upgrading Gems.."); //Update our variables (UIElements of gems, number of gems, and the gem ACDItems) if (SelectableGems.Count == 0) { GRiftLevel = GetTieredLootLevel(); SelectableUIGemElements = GetGemUIElements(); int totalGemUIElements = SelectableUIGemElements.Count; SelectableUIGemElementIndexs = GetGemACDGuids(totalGemUIElements); SelectableGems = GetGemCacheACDItems(SelectableUIGemElementIndexs).OrderByDescending(i => i.LegendaryGemRank).ToList(); Logger.DBLog.DebugFormat("Total number of possible gems to upgrade {0}", SelectableGems.Count); double minSucessChance = FunkyBaseExtension.Settings.AdventureMode.GemUpgradingMinimumSuccessRate; if (FunkyBaseExtension.Settings.AdventureMode.GemUpgradeType == SettingAdventureMode.GemUpgradingType.HighestRank) { if (SelectableGems.Any(i => ItemFunc.GetLegendaryGemUpgradeChance(GRiftLevel, i.LegendaryGemRank) >= minSucessChance)) { SelectableGems = SelectableGems.Where(i => ItemFunc.GetLegendaryGemUpgradeChance(GRiftLevel, i.LegendaryGemRank) >= minSucessChance).OrderByDescending(i => i.LegendaryGemRank).ToList(); } else { SelectableGems = SelectableGems.OrderByDescending(i => i.LegendaryGemRank).ToList(); } } else if (FunkyBaseExtension.Settings.AdventureMode.GemUpgradeType == SettingAdventureMode.GemUpgradingType.LowestRank) { if (SelectableGems.Any(i => ItemFunc.GetLegendaryGemUpgradeChance(GRiftLevel, i.LegendaryGemRank) >= minSucessChance)) { SelectableGems = SelectableGems.Where(i => ItemFunc.GetLegendaryGemUpgradeChance(GRiftLevel, i.LegendaryGemRank) >= minSucessChance).OrderBy(i => i.LegendaryGemRank).ToList(); } else { SelectableGems = SelectableGems.OrderBy(i => i.LegendaryGemRank).ToList(); } } else if (FunkyBaseExtension.Settings.AdventureMode.GemUpgradeType == SettingAdventureMode.GemUpgradingType.Priority && FunkyBaseExtension.Settings.AdventureMode.GemUpgradePriorityList.Count > 0) { if (SelectableGems.Any(i => FunkyBaseExtension.Settings.AdventureMode.GemUpgradePriorityList.Contains(i.LegendaryGemType) && ItemFunc.GetLegendaryGemUpgradeChance(GRiftLevel, i.LegendaryGemRank) >= minSucessChance)) { //Select only Prioritized Gems SelectableGems = SelectableGems.Where(i => FunkyBaseExtension.Settings.AdventureMode.GemUpgradePriorityList.Contains(i.LegendaryGemType) && ItemFunc.GetLegendaryGemUpgradeChance(GRiftLevel, i.LegendaryGemRank) >= minSucessChance).ToList(); //Create new list with priority order List <CacheACDItem> PrioritizedList = new List <CacheACDItem>(); for (int i = 0; i < FunkyBaseExtension.Settings.AdventureMode.GemUpgradePriorityList.Count - 1; i++) { var LegenadryEnumValue = FunkyBaseExtension.Settings.AdventureMode.GemUpgradePriorityList[i]; if (SelectableGems.Any(item => item.LegendaryGemType == LegenadryEnumValue && ItemFunc.GetLegendaryGemUpgradeChance(GRiftLevel, item.LegendaryGemRank) >= minSucessChance)) { var acditem = SelectableGems.First(item => item.LegendaryGemType == LegenadryEnumValue && ItemFunc.GetLegendaryGemUpgradeChance(GRiftLevel, item.LegendaryGemRank) >= minSucessChance); PrioritizedList.Add(acditem); } } if (PrioritizedList.Count > 0) { SelectableGems = PrioritizedList; } } } else { if (SelectableGems.Any(i => ItemFunc.GetLegendaryGemUpgradeChance(GRiftLevel, i.LegendaryGemRank) >= minSucessChance)) { SelectableGems = SelectableGems.Where(i => ItemFunc.GetLegendaryGemUpgradeChance(GRiftLevel, i.LegendaryGemRank) >= minSucessChance).ToList(); } } Logger.DBLog.InfoFormat("Number of Gems capable of upgrading {0}", SelectableGems.Count); foreach (var gem in SelectableGems) { double successChance = ItemFunc.GetLegendaryGemUpgradeChance(GRiftLevel, gem.LegendaryGemRank); Logger.DBLog.DebugFormat("Upgrade Capable Gem {0} with Chance {1}%", gem.LegendaryGemType, (successChance * 100).ToString()); } } //Check if the upgrade button is enabled.. if not we select our gem! if (!UI.Game.RiftReward_gemUpgradePane_UpgradeButton.IsEnabled) { //Set our default upgrade to our highest ranked (thats not 0%) var upgradingGem = SelectableGems.FirstOrDefault(); int selectIndex = SelectableUIGemElementIndexs.IndexOf(upgradingGem.ACDGUID); string GemName = upgradingGem.ThisRealName + " Rank " + upgradingGem.LegendaryGemRank + " Chance " + ItemFunc.GetLegendaryGemUpgradeChance(GRiftLevel, upgradingGem.LegendaryGemRank); Logger.DBLog.InfoFormat("Upgrading Gem {0}", GemName); //Select the Gem UIElement UI.Game.RiftReward_gemUpgradePane_List.ItemsListSetSelectedItemByIndex(selectIndex); await Coroutine.Sleep(250); await Coroutine.Yield(); } else { UI.Game.RiftReward_gemUpgradePane_UpgradeButton.Click(); await Coroutine.Sleep(250); await Coroutine.Yield(); } } else { Logger.DBLog.Info("Reward Selection.."); //Click continue after selecting a reward (not used currently) if (UI.ValidateUIElement(UI.Game.RiftReward_UpgradeContinue)) { UI.Game.RiftReward_UpgradeContinue.Click(); await Coroutine.Sleep(250); await Coroutine.Yield(); } //Validate that upgrade key is enabled.. then attempt to upgrade! if (Reward == RewardType.Key && UI.Game.RiftReward_Choice_UpgradeKey.IsEnabled && ZetaDia.Me.AttemptUpgradeKeystone()) { Logger.DBLog.Info("Keystone Upgraded"); UIManager.CloseAllOpenFrames(); await Coroutine.Sleep(250); await Coroutine.Yield(); } else { //Doing Gem Upgrade.. GRiftLevel = GetTieredLootLevel(); var Gems = GetGemCacheACDItems().OrderByDescending(i => i.LegendaryGemRank).ToList(); if (Gems.Count > 0) { //Logger.DBLog.InfoFormat("Upgrading Gem {0}", Gems[0].ThisRealName); await CommonCoroutines.AttemptUpgradeGem(Gems[0].ACDItem); await Coroutine.Sleep(250); await Coroutine.Yield(); } else { Reward = RewardType.Key; await Coroutine.Sleep(250); await Coroutine.Yield(); } } } return(true); }
internal static RunStatus StashUpdate(object ret) { if (FunkyGame.GameIsInvalid) { ActionsChecked = false; FunkyTownRunPlugin.DBLog.InfoFormat("[Funky] Town Run Behavior Failed! (Not In Game/Invalid Actor/misc)"); return(RunStatus.Failure); } if (!bUpdatedStashMap) { // Array for what blocks are or are not blocked for (int iRow = 0; iRow <= 49; iRow++) { for (int iColumn = 0; iColumn <= 6; iColumn++) { GilesStashSlotBlocked[iColumn, iRow] = false; } } // Block off the entire of any "protected stash pages" foreach (int iProtPage in CharacterSettings.Instance.ProtectedStashPages) { for (int iProtRow = 0; iProtRow <= 9; iProtRow++) { for (int iProtColumn = 0; iProtColumn <= 6; iProtColumn++) { GilesStashSlotBlocked[iProtColumn, iProtRow + (iProtPage * 10)] = true; } } } // Remove rows we don't have for (int iRow = (ZetaDia.Me.NumSharedStashSlots / 7); iRow <= 49; iRow++) { for (int iColumn = 0; iColumn <= 6; iColumn++) { GilesStashSlotBlocked[iColumn, iRow] = true; } } // Map out all the items already in the stash foreach (ACDItem tempitem in ZetaDia.Me.Inventory.StashItems) { if (tempitem.BaseAddress != IntPtr.Zero) { //StashedItems.Add(new CacheACDItem(tempitem)); int inventoryRow = tempitem.InventoryRow; int inventoryColumn = tempitem.InventoryColumn; // Mark this slot as not-free GilesStashSlotBlocked[inventoryColumn, inventoryRow] = true; // Try and reliably find out if this is a two slot item or not PluginItemTypes tempItemType = ItemFunc.DetermineItemType(tempitem.InternalName, tempitem.ItemType, tempitem.FollowerSpecialType, tempitem.ActorSNO); if (ItemFunc.DetermineIsTwoSlot(tempItemType) && inventoryRow != 19 && inventoryRow != 9 && inventoryRow != 29 && inventoryRow != 39 && inventoryRow != 49) { GilesStashSlotBlocked[inventoryColumn, inventoryRow + 1] = true; } else if (ItemFunc.DetermineIsTwoSlot(tempItemType) && (inventoryRow == 19 || inventoryRow == 9 || inventoryRow == 29 || inventoryRow == 39 || inventoryRow == 49)) { FunkyTownRunPlugin.DBLog.DebugFormat("GSError: DemonBuddy thinks this item is 2 slot even though it's at bottom row of a stash page: " + tempitem.Name + " [" + tempitem.InternalName + "] type=" + tempItemType.ToString() + " @ slot " + (inventoryRow + 1).ToString(CultureInfo.InvariantCulture) + "/" + (inventoryColumn + 1).ToString(CultureInfo.InvariantCulture)); } } } // Loop through all stash items bUpdatedStashMap = true; } // Need to update the stash map? return(RunStatus.Success); }
public CacheACDItem(ACDItem item) { ACDItem = item; SNO = item.ActorSNO; ThisInternalName = item.InternalName; try { _thisLevel = item.Level; } catch (Exception ex) { Logger.Write(LogLevel.Items, "Failed to retrieve item level for {0} \r\n {1}", SimpleDebugString, ex.Message); } ItemDataEntry itemEntry; if (TheCache.ObjectIDCache.ItemDataEntries.TryGetValue(SNO, out itemEntry)) { ItemType = itemEntry.ItemType; ThisDBItemType = ItemFunc.PluginItemTypeToDBItemType(ItemType); ThisFollowerType = ItemFunc.ReturnFollowerType(ItemType); LegendaryItemType = itemEntry.LegendaryType; } else { ThisFollowerType = item.FollowerSpecialType; ThisDBItemType = item.ItemType; ItemType = ItemFunc.DetermineItemType(ThisInternalName, ThisDBItemType, ThisFollowerType); } BaseItemType = ItemFunc.DetermineBaseType(ItemType); IsStackableItem = ItemFunc.DetermineIsStackable(ItemType, SNO); IsTwoSlot = !IsStackableItem && ItemFunc.DetermineIsTwoSlot(ItemType); //Armor / Jewelery / Weapons / Offhand / Follower Items if (BaseItemType == PluginBaseItemTypes.Armor || BaseItemType == PluginBaseItemTypes.Jewelry || BaseItemType == PluginBaseItemTypes.Offhand || BaseItemType == PluginBaseItemTypes.WeaponOneHand || BaseItemType == PluginBaseItemTypes.WeaponRange || BaseItemType == PluginBaseItemTypes.WeaponTwoHand || BaseItemType == PluginBaseItemTypes.FollowerItem) { if (BaseItemType == PluginBaseItemTypes.WeaponOneHand) { ThisOneHanded = true; } else if (BaseItemType == PluginBaseItemTypes.WeaponTwoHand) { TwoHanded = true; } try { ItemStats thesestats = item.Stats; ItemStatString = thesestats.ToString(); ItemStatProperties = new ItemProperties(thesestats); if (ItemStatProperties.Sockets > 0) { SocketsFilled = item.NumSocketsFilled; } } catch (Exception ex) { Logger.Write(LogLevel.Items, "Failed to retrieve item stats {0} \r\n {1}", SimpleDebugString, ex.Message); } #region Durability try { //Durability DurabilityCurrent = item.CurrentDurability; DurabilityMax = item.MaxDurability; DurabilityPercent = item.DurabilityPercent; } catch (Exception ex) { Logger.Write(LogLevel.Items, "Failed to retrieve item durability {0} \r\n {1}", SimpleDebugString, ex.Message); } #endregion #region ItemQualityLevel try { _thisQuality = item.ItemQualityLevel; } catch (Exception ex) { Logger.Write(LogLevel.Items, "Failed to retrieve item quality {0} \r\n {1}", SimpleDebugString, ex.Message); } #endregion } else { //Gem, Misc if (ItemType == PluginItemTypes.KeyStone) { KeystoneRank = ItemFunc.GetGreaterRiftKeystoneRank(SNO); if (KeystoneRank == -1) { try { KeystoneRank = item.TieredLootRunKeyLevel; } catch (Exception ex) { Logger.DBLog.DebugFormat("Failed to get TieredLootRunKeyLevel for Keystone!{0} \r\n {1}", SimpleDebugString, ex.Message); } } } else if (BaseItemType == PluginBaseItemTypes.Gem && ItemType == PluginItemTypes.LegendaryGem) { try { LegendaryGemRank = item.JewelRank; } catch (Exception ex) { Logger.DBLog.DebugFormat("Failed to get Jewel Rank for Legendary Gem!{0} \r\n {1}", SimpleDebugString, ex.Message); } try { LegendaryGemType = (LegendaryGemTypes)Enum.Parse(typeof(LegendaryGemTypes), SNO.ToString()); } catch (Exception) { LegendaryGemType = LegendaryGemTypes.None; } } else { IsPotion = ItemType == PluginItemTypes.HealthPotion || ItemType == PluginItemTypes.LegendaryHealthPotion; if (IsPotion) { PotionType = ItemFunc.ReturnPotionType(SNO); } } #region DyeType try { _thisDyeType = item.DyeType; } catch (Exception ex) { Logger.Write(LogLevel.Items, "Failed to retrieve item dye type {0} \r\n {1}", SimpleDebugString, ex.Message); } #endregion if (IsStackableItem) { #region ItemStackQuantity try { _thisItemStackQuantity = item.ItemStackQuantity; } catch (Exception ex) { Logger.Write(LogLevel.Items, "Failed to retrieve item stack quanity {0} \r\n {1}", SimpleDebugString, ex.Message); } #endregion #region ItemStackMaxQuantity try { _maxstackquanity = item.MaxStackCount; } catch (Exception ex) { Logger.Write(LogLevel.Items, "Failed to retrieve item max stack quanity {0} \r\n {1}", SimpleDebugString, ex.Message); } #endregion } } #region GameBalanceId try { ThisBalanceID = item.GameBalanceId; } catch (Exception ex) { Logger.Write(LogLevel.Items, "Failed to retrieve item GameBalanceId {0} \r\n {1}", SimpleDebugString, ex.Message); } #endregion #region ACDGuid try { ACDGUID = item.ACDGuid; } catch (Exception ex) { Logger.Write(LogLevel.Items, "Failed to retrieve item ACDGUID {0} \r\n {1}", SimpleDebugString, ex.Message); } #endregion #region DynamicId try { ThisDynamicID = item.DynamicId; } catch (Exception ex) { Logger.Write(LogLevel.Items, "Failed to retrieve item DynamicId {0} \r\n {1}", SimpleDebugString, ex.Message); } #endregion #region Name try { _thisRealName = item.Name; } catch (Exception ex) { Logger.Write(LogLevel.Items, "Failed to retrieve item name {0} \r\n {1}", SimpleDebugString, ex.Message); } #endregion #region Gold try { _thisGoldAmount = item.Gold; } catch (Exception ex) { Logger.Write(LogLevel.Items, "Failed to retrieve item gold amount {0} \r\n {1}", SimpleDebugString, ex.Message); } #endregion if (!IsStackableItem) { #region IsUnidentified try { _isUnidentified = item.IsUnidentified; } catch (Exception ex) { Logger.Write(LogLevel.Items, "Failed to retrieve item is identified {0} \r\n {1}", SimpleDebugString, ex.Message); } #endregion } #region IsVendorBought try { _isVendorBought = item.IsVendorBought; } catch (Exception ex) { Logger.Write(LogLevel.Items, "Failed to retrieve item is vendor bought {0} \r\n {1}", SimpleDebugString, ex.Message); } #endregion #region InventoryRow/Column try { invRow = item.InventoryRow; invCol = item.InventoryColumn; } catch (Exception ex) { Logger.Write(LogLevel.Items, "Failed to retrieve item inventory row/column {0} \r\n {1}", SimpleDebugString, ex.Message); } #endregion if (itemEntry == null && !_isUnidentified && ItemType != PluginItemTypes.Unknown && _thisRealName != String.Empty) { if (FunkyBaseExtension.Settings.Debugging.DebuggingData && FunkyBaseExtension.Settings.Debugging.DebuggingDataTypes.HasFlag(DebugDataTypes.Items)) { ObjectCache.DebuggingData.CheckEntry(this); } } }
internal static RunStatus SellInteraction(object ret) { if (FunkyGame.GameIsInvalid) { ActionsChecked = false; FunkyTownRunPlugin.DBLog.InfoFormat("[Funky] Town Run Behavior Failed! (Not In Game/Invalid Actor/misc)"); return(RunStatus.Failure); } BotMain.StatusText = "Town run: Vendor Routine Interaction"; if (!UIElements.VendorWindow.IsVisible) { FunkyTownRunPlugin.DBLog.DebugFormat("[Funky] Town Run Vednor Behavior Failed! (Vendor Window not visible)"); return(RunStatus.Failure); } #region SellItem if (townRunItemCache.SellItems.Count > 0) { BotMain.StatusText = "Town run: Vendor Routine Interaction Selling Items"; if (!Delay.Test()) { return(RunStatus.Running); } CacheACDItem thisitem = townRunItemCache.SellItems.FirstOrDefault(); // Item log for cool stuff sold if (thisitem != null) { PluginItemTypes OriginalPluginItemType = ItemFunc.DetermineItemType(thisitem); PluginBaseItemTypes thisGilesBaseType = ItemFunc.DetermineBaseType(OriginalPluginItemType); if (thisGilesBaseType == PluginBaseItemTypes.WeaponTwoHand || thisGilesBaseType == PluginBaseItemTypes.WeaponOneHand || thisGilesBaseType == PluginBaseItemTypes.WeaponRange || thisGilesBaseType == PluginBaseItemTypes.Armor || thisGilesBaseType == PluginBaseItemTypes.Jewelry || thisGilesBaseType == PluginBaseItemTypes.Offhand || thisGilesBaseType == PluginBaseItemTypes.FollowerItem) { FunkyTownRunPlugin.LogJunkItems(thisitem, thisGilesBaseType, OriginalPluginItemType); } //FunkyTownRunPlugin.TownRunStats.VendoredItemLog(thisitem); if (FunkyGame.CurrentStats != null) { FunkyGame.CurrentStats.CurrentProfile.LootTracker.VendoredItemLog(thisitem); } ZetaDia.Me.Inventory.SellItem(thisitem.ACDItem); } if (thisitem != null) { townRunItemCache.SellItems.Remove(thisitem); } if (townRunItemCache.SellItems.Count > 0) { return(RunStatus.Running); } } #endregion #region BuyPotion //Check if settings for potion buy is enabled, with less than 99 potions existing! if (bBuyingPotions) { BotMain.StatusText = "Town run: Sell Routine Interaction Buying Potions"; if (PotionCount >= FunkyTownRunPlugin.PluginSettings.PotionsCount) { FunkyTownRunPlugin.DBLog.DebugFormat("[Funky] Vendor Potion Buying Finished (Potion Count Greater Than Setting) Count {0} Setting {1}", PotionCount, FunkyTownRunPlugin.PluginSettings.PotionsCount); bBuyingPotions = false; return(RunStatus.Running); } //Obey the timer, so we don't buy 100 potions in 3 seconds. if (!Delay.Test(1.5)) { return(RunStatus.Running); } //Update Dynamic ID if (PotionDynamicID == 0) { FunkyTownRunPlugin.DBLog.DebugFormat("[Funky] Vendor Potion updating Dynamic ID!"); foreach (ACDItem item in ZetaDia.Me.Inventory.MerchantItems) { if (item.IsPotion) { PotionMerchantACDItem = item; PotionDynamicID = item.DynamicId; break; } } //Check we found a potion.. if (PotionDynamicID == 0) { FunkyTownRunPlugin.DBLog.DebugFormat("[Funky] Vendor Potion Buying Finished (Failed to find Potion Dynamic ID)"); bBuyingPotions = false; } else { FunkyTownRunPlugin.DBLog.DebugFormat("[Funky] Vendor Buying Potion Dynamic ID {0}", PotionDynamicID); } return(RunStatus.Running); } //Check we have enough gold! if (PotionMerchantACDItem.Gold > ZetaDia.CPlayer.Coinage) { FunkyTownRunPlugin.DBLog.DebugFormat("[Funky] Vendor Potion Buying Finished (Not Enough Gold to buy Potions)"); bBuyingPotions = false; return(RunStatus.Running); } FunkyTownRunPlugin.DBLog.DebugFormat("[Funky] Vendor Buying Potion!"); ZetaDia.Actors.Me.Inventory.BuyItem(PotionDynamicID); //Update counter PotionCount++; return(RunStatus.Running); } #endregion if (bNeedsEquipmentRepairs) { BotMain.StatusText = "Town run: Vendor Routine Interaction Repairing"; if (!Delay.Test()) { return(RunStatus.Running); } //int playerCoinage = ZetaDia.Me.Inventory.Coinage; //int repairCost = ZetaDia.Me.Inventory.GetRepairCost(false); //if (playerCoinage > 0 && playerCoinage < repairCost) //{ // FunkyTownRunPlugin.DBLog.InfoFormat("Emergency Stop: You need repairs but don't have enough money. Current Coinage {0} -- Repair Cost {1}", playerCoinage, repairCost); // BotMain.Stop(false, "Not enough gold to repair item(s)!"); //} ZetaDia.Me.Inventory.RepairEquippedItems(); bNeedsEquipmentRepairs = false; } return(RunStatus.Success); }
internal static bool PickupItemValidation(CacheItem item) { //if (FunkyTownRunPlugin.ItemRulesEval != null) //{ // Interpreter.InterpreterAction action = FunkyTownRunPlugin.ItemRulesEval.checkPickUpItem(item.DynamicID.Value, item.BalanceData.thisItemType, item.ref_DiaItem.Name, item.InternalName, item.Itemquality.Value, item.BalanceData.iThisItemLevel, item.BalanceData.bThisOneHand, item.BalanceData.bThisTwoHand, item.BalanceID.Value, ItemEvaluationType.PickUp); // if (action== Interpreter.InterpreterAction.PICKUP) // { // return true; // } //} // Calculate giles item types and base types etc. PluginItemTypes thisPluginItemType = PluginItemTypes.Unknown; PluginBaseItemTypes thisGilesBaseType = PluginBaseItemTypes.Unknown; if (item.BalanceID.HasValue && item.BalanceData != null) { thisPluginItemType = item.BalanceData.PluginType; thisGilesBaseType = item.BalanceData.PluginBase; } else { thisPluginItemType = ItemFunc.DetermineItemType(item.InternalName, ItemType.Unknown, FollowerType.None, item.SNOID); thisGilesBaseType = ItemFunc.DetermineBaseType(thisPluginItemType); } if (thisPluginItemType == PluginItemTypes.MiscBook) { return(FunkyBaseExtension.Settings.Loot.ExpBooks); } if (thisPluginItemType == PluginItemTypes.RamaladnisGift) { return(true); } // Error logging for DemonBuddy item mis-reading ItemType gilesDBItemType = ItemFunc.PluginItemTypeToDBItemType(thisPluginItemType); if (item.BalanceID.HasValue && item.BalanceData != null && gilesDBItemType != item.BalanceData.Type) { Logger.DBLog.InfoFormat("GSError: Item type mis-match detected: Item Internal=" + item.InternalName + ". DemonBuddy ItemType thinks item type is=" + item.BalanceData.Type + ". Giles thinks item type is=" + gilesDBItemType + ". [pickup]", true); } switch (thisGilesBaseType) { case PluginBaseItemTypes.WeaponTwoHand: case PluginBaseItemTypes.WeaponOneHand: case PluginBaseItemTypes.WeaponRange: case PluginBaseItemTypes.Armor: case PluginBaseItemTypes.Offhand: case PluginBaseItemTypes.Jewelry: case PluginBaseItemTypes.FollowerItem: if (FunkyBaseExtension.Settings.Loot.PickupWhiteItems == 1 && FunkyBaseExtension.Settings.Loot.PickupMagicItems == 1 && FunkyBaseExtension.Settings.Loot.PickupRareItems == 1 && FunkyBaseExtension.Settings.Loot.PickupLegendaryItems == 1) { return(true); } if (item.Itemquality.HasValue && item.BalanceID.HasValue && item.BalanceData != null) { switch (item.Itemquality.Value) { case ItemQuality.Inferior: case ItemQuality.Normal: case ItemQuality.Superior: return(FunkyBaseExtension.Settings.Loot.PickupWhiteItems > 0 && (item.BalanceData.ItemLevel >= FunkyBaseExtension.Settings.Loot.PickupWhiteItems)); case ItemQuality.Magic1: case ItemQuality.Magic2: case ItemQuality.Magic3: return(FunkyBaseExtension.Settings.Loot.PickupMagicItems > 0 && (item.BalanceData.ItemLevel >= FunkyBaseExtension.Settings.Loot.PickupMagicItems)); case ItemQuality.Rare4: case ItemQuality.Rare5: case ItemQuality.Rare6: return(FunkyBaseExtension.Settings.Loot.PickupRareItems > 0 && (item.BalanceData.ItemLevel >= FunkyBaseExtension.Settings.Loot.PickupRareItems)); case ItemQuality.Legendary: return(FunkyBaseExtension.Settings.Loot.PickupLegendaryItems > 0 && (item.BalanceData.ItemLevel >= FunkyBaseExtension.Settings.Loot.PickupLegendaryItems)); } } return(false); case PluginBaseItemTypes.Gem: if (thisPluginItemType == PluginItemTypes.LegendaryGem) { return(true); } GemQualityTypes qualityType = ItemFunc.ReturnGemQualityType(item.SNOID, item.BalanceData != null?item.BalanceData.ItemLevel:-1); int qualityLevel = (int)qualityType; if (qualityLevel < FunkyBaseExtension.Settings.Loot.MinimumGemItemLevel || (thisPluginItemType == PluginItemTypes.Ruby && !FunkyBaseExtension.Settings.Loot.PickupGems[0]) || (thisPluginItemType == PluginItemTypes.Emerald && !FunkyBaseExtension.Settings.Loot.PickupGems[1]) || (thisPluginItemType == PluginItemTypes.Amethyst && !FunkyBaseExtension.Settings.Loot.PickupGems[2]) || (thisPluginItemType == PluginItemTypes.Topaz && !FunkyBaseExtension.Settings.Loot.PickupGems[3]) || (thisPluginItemType == PluginItemTypes.Diamond && !FunkyBaseExtension.Settings.Loot.PickupGemDiamond)) { return(false); } break; case PluginBaseItemTypes.Misc: // Note; Infernal keys are misc, so should be picked up here - we aren't filtering them out, so should default to true at the end of this function if (thisPluginItemType == PluginItemTypes.CraftingMaterial) { return(FunkyBaseExtension.Settings.Loot.PickupCraftMaterials); } if (thisPluginItemType == PluginItemTypes.LegendaryCraftingMaterial) { return(true); } if (thisPluginItemType == PluginItemTypes.CraftingPlan) { if (!FunkyBaseExtension.Settings.Loot.PickupCraftPlans) { return(false); } if (item.BalanceID.HasValue && item.BalanceData != null) { if (item.BalanceData.IsBlacksmithPlanSixProperties && !FunkyBaseExtension.Settings.Loot.PickupBlacksmithPlanSix) { return(false); } if (item.BalanceData.IsBlacksmithPlanFiveProperties && !FunkyBaseExtension.Settings.Loot.PickupBlacksmithPlanFive) { return(false); } if (item.BalanceData.IsBlacksmithPlanFourProperties && !FunkyBaseExtension.Settings.Loot.PickupBlacksmithPlanFour) { return(false); } if (item.BalanceData.IsBlacksmithPlanArchonSpaulders && !FunkyBaseExtension.Settings.Loot.PickupBlacksmithPlanArchonSpaulders) { return(false); } if (item.BalanceData.IsBlacksmithPlanArchonGauntlets && !FunkyBaseExtension.Settings.Loot.PickupBlacksmithPlanArchonGauntlets) { return(false); } if (item.BalanceData.IsBlacksmithPlanRazorspikes && !FunkyBaseExtension.Settings.Loot.PickupBlacksmithPlanRazorspikes) { return(false); } if (item.BalanceData.IsJewelcraftDesignAmulet && !FunkyBaseExtension.Settings.Loot.PickupJewelerDesignAmulet) { return(false); } if (item.BalanceData.IsJewelcraftDesignFlawlessStarGem && !FunkyBaseExtension.Settings.Loot.PickupJewelerDesignFlawlessStar) { return(false); } if (item.BalanceData.IsJewelcraftDesignMarquiseGem && !FunkyBaseExtension.Settings.Loot.PickupJewelerDesignMarquise) { return(false); } if (item.BalanceData.IsJewelcraftDesignPerfectStarGem && !FunkyBaseExtension.Settings.Loot.PickupJewelerDesignPerfectStar) { return(false); } if (item.BalanceData.IsJewelcraftDesignRadiantStarGem && !FunkyBaseExtension.Settings.Loot.PickupJewelerDesignRadiantStar) { return(false); } } } if (thisPluginItemType == PluginItemTypes.InfernalKey) { return(FunkyBaseExtension.Settings.Loot.PickupInfernalKeys); } if (thisPluginItemType == PluginItemTypes.KeyStone) { return(FunkyBaseExtension.Settings.Loot.PickupKeystoneFragments); } if (thisPluginItemType == PluginItemTypes.BloodShard) { return(Backpack.GetBloodShardCount() < 500); } // Potion filtering if (thisPluginItemType == PluginItemTypes.HealthPotion || thisPluginItemType == PluginItemTypes.LegendaryHealthPotion) { PotionTypes potionType = ItemFunc.ReturnPotionType(item.SNOID); if (potionType == PotionTypes.Regular) { if (FunkyBaseExtension.Settings.Loot.MaximumHealthPotions <= 0) { return(false); } var BestPotionToUse = Backpack.ReturnBestPotionToUse(); if (BestPotionToUse == null) { return(true); } var Potions = Backpack.ReturnRegularPotions(); if (Potions.Sum(potions => potions.ThisItemStackQuantity) >= FunkyBaseExtension.Settings.Loot.MaximumHealthPotions) { return(false); } } } break; case PluginBaseItemTypes.HealthGlobe: return(false); case PluginBaseItemTypes.Unknown: return(false); default: return(false); } // Switch giles base item type // Didn't cancel it, so default to true! return(true); }