internal static RunStatus GamblingMovement(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: Gambling Movement"; DiaUnit objGamblingNPC = ZetaDia.Actors.GetActorsOfType <DiaUnit>(true).FirstOrDefault <DiaUnit>(u => u.Name.StartsWith("X1_RandomItemNPC")); Vector3 vectorPlayerPosition = ZetaDia.Me.Position; Vector3 vectorGamblingPosition = Vector3.Zero; if (objGamblingNPC == null || objGamblingNPC.Distance > 50f) { vectorGamblingPosition = SafetyGambleLocation; } else { vectorGamblingPosition = objGamblingNPC.Position; } //Wait until we are not moving if (FunkyGame.GameIsInvalid) { return(RunStatus.Running); } float fDistance = Vector3.Distance(vectorPlayerPosition, vectorGamblingPosition); //Out-Of-Range... if (objGamblingNPC == null || fDistance > 12f) //|| !GilesCanRayCast(vectorPlayerPosition, vectorSalvageLocation, Zeta.Internals.SNO.NavCellFlags.AllowWalk)) { Navigator.PlayerMover.MoveTowards(vectorGamblingPosition); return(RunStatus.Running); } UIElement uie = UI.Game.BloodShardVendorMainDialog; if (!(uie != null && uie.IsValid && uie.IsVisible)) { objGamblingNPC.Interact(); return(RunStatus.Running); } //Now we need to update our item list so we can get the DynamicIDs. UpdateGambleItemList(); return(RunStatus.Success); }
internal static RunStatus SellMovement(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 Movement"; DiaUnit objSellNavigation = ZetaDia.Actors.GetActorsOfType <DiaUnit>(true).FirstOrDefault <DiaUnit>(u => u.Name.ToLower().StartsWith(VendorName)); Vector3 vectorPlayerPosition = ZetaDia.Me.Position; Vector3 vectorSellLocation = Vector3.Zero; if (objSellNavigation == null) { vectorSellLocation = SafetyVendorLocation; } else { vectorSellLocation = objSellNavigation.Position; } //Out-Of-Range... if (objSellNavigation == null) { FunkyTownRunPlugin.DBLog.InfoFormat("Vendor Obj is Null or Raycast Failed.. using Navigator to move!"); Navigator.PlayerMover.MoveTowards(vectorSellLocation); return(RunStatus.Running); } float iDistanceFromSell = Vector3.Distance(vectorPlayerPosition, vectorSellLocation); if (FunkyGame.Hero.IsMoving) { return(RunStatus.Running); } if (iDistanceFromSell > 40f) { Navigator.MoveTo(vectorSellLocation, "Vendor"); return(RunStatus.Running); } if (iDistanceFromSell > 7.5f && !UIElements.VendorWindow.IsValid) { objSellNavigation.Interact(); return(RunStatus.Running); } if (!UIElements.VendorWindow.IsVisible) { objSellNavigation.Interact(); return(RunStatus.Running); } if (!UIElements.InventoryWindow.IsVisible) { Backpack.InventoryBackPackToggle(true); return(RunStatus.Running); } return(RunStatus.Success); }
// ********************************************************************************************** // ***** Nice smooth one-at-a-time salvaging replacement ***** // ********************************************************************************************** internal static RunStatus GilesOptimisedSalvage(object ret) { DiaUnit objBlacksmith = ZetaDia.Actors.GetActorsOfType <DiaUnit>(true).FirstOrDefault <DiaUnit>(u => u.IsSalvageShortcut); Vector3 vectorPlayerPosition = ZetaDia.Me.Position; Vector3 vectorSalvageLocation = new Vector3(0f, 0f, 0f); if (objBlacksmith == null || objBlacksmith.Distance > 20f) { switch (ZetaDia.CurrentAct) { case Act.A1: vectorSalvageLocation = new Vector3(2958.418f, 2823.037f, 24.04533f); break; case Act.A2: vectorSalvageLocation = new Vector3(289.6358f, 232.1146f, 0.1f); break; case Act.A3: case Act.A4: vectorSalvageLocation = new Vector3(379.6096f, 415.6198f, 0.3321424f); break; } } else { vectorSalvageLocation = objBlacksmith.Position; } Bot.NavigationCache.RefreshMovementCache(); //Wait until we are not moving if (Bot.NavigationCache.IsMoving) { return(RunStatus.Running); } float iDistanceFromSell = Vector3.Distance(vectorPlayerPosition, vectorSalvageLocation); //Out-Of-Range... if (objBlacksmith == null || iDistanceFromSell > 12f) //|| !GilesCanRayCast(vectorPlayerPosition, vectorSalvageLocation, Zeta.Internals.SNO.NavCellFlags.AllowWalk)) { //Use our click movement Bot.NavigationCache.RefreshMovementCache(); //Wait until we are not moving to send click again.. if (Bot.NavigationCache.IsMoving) { return(RunStatus.Running); } Navigator.PlayerMover.MoveTowards(vectorSalvageLocation); return(RunStatus.Running); } if (!UIElements.SalvageWindow.IsVisible) { objBlacksmith.Interact(); return(RunStatus.Running); } if (!UIElements.InventoryWindow.IsVisible) { Bot.Character.Data.BackPack.InventoryBackPackToggle(true); return(RunStatus.Running); } iCurrentItemLoops++; if (iCurrentItemLoops < iItemDelayLoopLimit * 1.15) { return(RunStatus.Running); } iCurrentItemLoops = 0; RandomizeTheTimer(); if (Bot.Character.Data.BackPack.townRunCache.hashGilesCachedSalvageItems.Count > 0) { CacheACDItem thisitem = Bot.Character.Data.BackPack.townRunCache.hashGilesCachedSalvageItems.FirstOrDefault(); if (thisitem != null) { // Item log for cool stuff stashed GilesItemType OriginalGilesItemType = Backpack.DetermineItemType(thisitem.ThisInternalName, thisitem.ThisDBItemType, thisitem.ThisFollowerType); GilesBaseItemType thisGilesBaseType = Backpack.DetermineBaseType(OriginalGilesItemType); if (thisGilesBaseType == GilesBaseItemType.WeaponTwoHand || thisGilesBaseType == GilesBaseItemType.WeaponOneHand || thisGilesBaseType == GilesBaseItemType.WeaponRange || thisGilesBaseType == GilesBaseItemType.Armor || thisGilesBaseType == GilesBaseItemType.Jewelry || thisGilesBaseType == GilesBaseItemType.Offhand || thisGilesBaseType == GilesBaseItemType.FollowerItem) { double iThisItemValue = Backpack.ValueThisItem(thisitem, OriginalGilesItemType); Logger.LogJunkItems(thisitem, thisGilesBaseType, OriginalGilesItemType, iThisItemValue); } Bot.Game.CurrentGameStats.CurrentProfile.LootTracker.SalvagedItemLog(thisitem); ZetaDia.Me.Inventory.SalvageItem(thisitem.ThisDynamicID); } Bot.Character.Data.BackPack.townRunCache.hashGilesCachedSalvageItems.Remove(thisitem); if (Bot.Character.Data.BackPack.townRunCache.hashGilesCachedSalvageItems.Count > 0) { thisitem = Bot.Character.Data.BackPack.townRunCache.hashGilesCachedSalvageItems.FirstOrDefault(); if (thisitem != null) { return(RunStatus.Running); } } else { iCurrentItemLoops = 0; return(RunStatus.Running); } } bReachedSafety = false; bCurrentlyMoving = false; return(RunStatus.Success); }
// ********************************************************************************************** // ***** Sell Routine replacement for smooth one-at-a-time item selling and handling ***** // ********************************************************************************************** internal static RunStatus GilesOptimisedSell(object ret) { string sVendorName = ""; switch (ZetaDia.CurrentAct) { case Act.A1: sVendorName = "a1_uniquevendor_miner"; break; case Act.A2: sVendorName = "a2_uniquevendor_peddler"; break; case Act.A3: sVendorName = "a3_uniquevendor_collector"; break; case Act.A4: sVendorName = "a4_uniquevendor_collector"; break; } #region Navigation DiaUnit objSellNavigation = ZetaDia.Actors.GetActorsOfType <DiaUnit>(true).FirstOrDefault <DiaUnit>(u => u.Name.ToLower().StartsWith(sVendorName)); Vector3 vectorPlayerPosition = ZetaDia.Me.Position; Vector3 vectorSellLocation = new Vector3(0f, 0f, 0f); if (objSellNavigation == null) { switch (ZetaDia.CurrentAct) { case Act.A1: vectorSellLocation = new Vector3(2901.399f, 2809.826f, 24.04533f); break; case Act.A2: vectorSellLocation = new Vector3(295.2101f, 265.1436f, 0.1000002f); break; case Act.A3: case Act.A4: vectorSellLocation = new Vector3(410.6073f, 355.8762f, 0.1000005f); break; } } else { vectorSellLocation = objSellNavigation.Position; } float iDistanceFromSell = Vector3.Distance(vectorPlayerPosition, vectorSellLocation); //Out-Of-Range... if (objSellNavigation == null) //!GilesCanRayCast(vectorPlayerPosition, vectorSellLocation, NavCellFlags.AllowWalk)) { Logger.DBLog.InfoFormat("Vendor Obj is Null or Raycast Failed.. using Navigator to move!"); Navigator.PlayerMover.MoveTowards(vectorSellLocation); return(RunStatus.Running); } if (iDistanceFromSell > 40f) { Navigator.MoveTo(vectorSellLocation, "Vendor", true); //ZetaDia.Me.UsePower(SNOPower.Walk, vectorSellLocation, ZetaDia.Me.WorldDynamicId); return(RunStatus.Running); } if (iDistanceFromSell > 7.5f && !UIElements.VendorWindow.IsValid) { //Use our click movement Bot.NavigationCache.RefreshMovementCache(); //Wait until we are not moving to send click again.. if (Bot.NavigationCache.IsMoving) { return(RunStatus.Running); } objSellNavigation.Interact(); //ZetaDia.Me.UsePower(SNOPower.Axe_Operate_Gizmo, vectorSellLocation, ZetaDia.Me.WorldDynamicId, objSellNavigation.ACDGuid); return(RunStatus.Running); } if (!UIElements.VendorWindow.IsVisible) { objSellNavigation.Interact(); return(RunStatus.Running); } if (!UIElements.InventoryWindow.IsVisible) { Bot.Character.Data.BackPack.InventoryBackPackToggle(true); return(RunStatus.Running); } #endregion #region SellItem if (Bot.Character.Data.BackPack.townRunCache.hashGilesCachedSellItems.Count > 0) { iCurrentItemLoops++; if (iCurrentItemLoops < iItemDelayLoopLimit) { return(RunStatus.Running); } iCurrentItemLoops = 0; RandomizeTheTimer(); CacheACDItem thisitem = Bot.Character.Data.BackPack.townRunCache.hashGilesCachedSellItems.FirstOrDefault(); // Item log for cool stuff sold if (thisitem != null) { GilesItemType OriginalGilesItemType = Backpack.DetermineItemType(thisitem.ThisInternalName, thisitem.ThisDBItemType, thisitem.ThisFollowerType); GilesBaseItemType thisGilesBaseType = Backpack.DetermineBaseType(OriginalGilesItemType); if (thisGilesBaseType == GilesBaseItemType.WeaponTwoHand || thisGilesBaseType == GilesBaseItemType.WeaponOneHand || thisGilesBaseType == GilesBaseItemType.WeaponRange || thisGilesBaseType == GilesBaseItemType.Armor || thisGilesBaseType == GilesBaseItemType.Jewelry || thisGilesBaseType == GilesBaseItemType.Offhand || thisGilesBaseType == GilesBaseItemType.FollowerItem) { double iThisItemValue = Backpack.ValueThisItem(thisitem, OriginalGilesItemType); Logger.LogJunkItems(thisitem, thisGilesBaseType, OriginalGilesItemType, iThisItemValue); } Bot.Game.CurrentGameStats.CurrentProfile.LootTracker.VendoredItemLog(thisitem); ZetaDia.Me.Inventory.SellItem(thisitem.ACDItem); } if (thisitem != null) { Bot.Character.Data.BackPack.townRunCache.hashGilesCachedSellItems.Remove(thisitem); } if (Bot.Character.Data.BackPack.townRunCache.hashGilesCachedSellItems.Count > 0) { return(RunStatus.Running); } } #endregion #region BuyPotion //Check if settings for potion buy is enabled, with less than 99 potions existing! if (Bot.Settings.BuyPotionsDuringTownRun && Bot.Character.Data.iTotalPotions < Bot.Settings.Loot.MaximumHealthPotions && !PotionCheck) { //Obey the timer, so we don't buy 100 potions in 3 seconds. iCurrentItemLoops++; if (iCurrentItemLoops < iItemDelayLoopLimit) { return(RunStatus.Running); } iCurrentItemLoops = 0; RandomizeTheTimer(); //Buy Potions int BestPotionID = 0; int LastHPValue = 0; foreach (ACDItem item in ZetaDia.Me.Inventory.MerchantItems) { if (item.ItemType == ItemType.Potion && item.HitpointsGranted > LastHPValue && item.RequiredLevel <= Bot.Character.Data.iMyLevel && item.Gold < ZetaDia.Me.Inventory.Coinage) { LastHPValue = item.HitpointsGranted; BestPotionID = item.DynamicId; } } if (BestPotionID != 0) { ZetaDia.Me.Inventory.BuyItem(BestPotionID); //Update counter Bot.Character.Data.iTotalPotions++; return(RunStatus.Running); } PotionCheck = true; } else { PotionCheck = true; } #endregion if (bNeedsEquipmentRepairs) { iCurrentItemLoops++; if (iCurrentItemLoops < iItemDelayLoopLimit) { return(RunStatus.Running); } iCurrentItemLoops = 0; RandomizeTheTimer(); if (ZetaDia.Me.Inventory.Coinage < 40000) { Logger.DBLog.InfoFormat("Emergency Stop: You need repairs but don't have enough money. Stopping the bot to prevent infinite death loop."); BotMain.Stop(false, "Not enough gold to repair item(s)!"); } ZetaDia.Me.Inventory.RepairEquippedItems(); bNeedsEquipmentRepairs = false; } bCurrentlyMoving = false; bReachedSafety = false; return(RunStatus.Success); }
internal static RunStatus GilesOptimisedSalvage(object ret) { if (FunkyGame.GameIsInvalid) { ActionsChecked = false; FunkyTownRunPlugin.DBLog.InfoFormat("[Funky] Town Run Behavior Failed! (Not In Game/Invalid Actor/misc)"); return(RunStatus.Failure); } DiaUnit objBlacksmith = ZetaDia.Actors.GetActorsOfType <DiaUnit>(true).FirstOrDefault <DiaUnit>(u => u.Name.StartsWith(SalvageName)); Vector3 vectorPlayerPosition = ZetaDia.Me.Position; Vector3 vectorSalvageLocation = Vector3.Zero; //Normal distance we use to move to specific location before moving to NPC float _distanceRequired = CurrentAct != Act.A5 ? 50f : 14f; //Act 5 we want short range only! if (Vector3.Distance(vectorPlayerPosition, SafetySalvageLocation) <= 2.5f) { MovedToSafetyLocation = true; } if (objBlacksmith == null || (!MovedToSafetyLocation && objBlacksmith.Distance > _distanceRequired)) { vectorSalvageLocation = SafetySalvageLocation; } else { //MovedToSafetyLocation = true; vectorSalvageLocation = objBlacksmith.Position; } //if (vectorSalvageLocation == Vector3.Zero) // Character.FindActByLevelID(Bot.Character.Data.CurrentWorldDynamicID); //Wait until we are not moving if (FunkyGame.Hero.IsMoving) { return(RunStatus.Running); } float iDistanceFromSell = Vector3.Distance(vectorPlayerPosition, vectorSalvageLocation); //Out-Of-Range... if (objBlacksmith == null || iDistanceFromSell > 12f)//|| !GilesCanRayCast(vectorPlayerPosition, vectorSalvageLocation, Zeta.Internals.SNO.NavCellFlags.AllowWalk)) { Navigator.PlayerMover.MoveTowards(vectorSalvageLocation); return(RunStatus.Running); } if (!UIElements.SalvageWindow.IsVisible) { objBlacksmith.Interact(); return(RunStatus.Running); } if (!UIElements.InventoryWindow.IsVisible) { Backpack.InventoryBackPackToggle(true); return(RunStatus.Running); } //Delays... (so we don't salvage everything in record time) if (!Delay.Test(1.15)) { return(RunStatus.Running); } if (UIElements.SalvageAllWrapper.IsVisible) { if (UI.Game.Dialog_Confirmation_OK.IsVisible) { UI.Game.Dialog_Confirmation_OK.Click(); return(RunStatus.Running); } if (UI.Game.SalvageAllNormal.IsEnabled && UI.Game.SalvageAllNormal.IsVisible && bShouldSalvageAllNormal && townRunItemCache.SalvageItems.Any(i => i.IsSalvagable && i.ThisQuality < ItemQuality.Magic1) && !bSalvageAllNormal) { //UI.Game.SalvageAllNormal.Click(); Logger.DBLog.DebugFormat("[FunkyTownRun] Salvaging All Normal Items"); ZetaDia.Me.Inventory.SalvageItemsOfRarity(SalvageRarity.Normal); bSalvageAllNormal = true; var removalList = townRunItemCache.SalvageItems.Where(i => i.IsSalvagable && i.ThisQuality < ItemQuality.Magic1).ToList(); foreach (var cacheAcdItem in removalList) { LogSalvagedItem(cacheAcdItem); } townRunItemCache.SalvageItems = townRunItemCache.SalvageItems.Except(removalList).ToList(); return(RunStatus.Running); } if (UI.Game.SalvageAllMagical.IsEnabled && UI.Game.SalvageAllMagical.IsVisible && bShouldSalvageAllMagical && townRunItemCache.SalvageItems.Any(i => i.IsSalvagable && i.ThisQuality < ItemQuality.Rare4) && !bSalvageAllMagic) { //UI.Game.SalvageAllMagical.Click(); FunkyTownRunPlugin.DBLog.DebugFormat("[FunkyTownRun] Salvaging All Magical Items"); ZetaDia.Me.Inventory.SalvageItemsOfRarity(SalvageRarity.Magic); bSalvageAllMagic = true; var removalList = townRunItemCache.SalvageItems.Where(i => i.IsSalvagable && i.ThisQuality < ItemQuality.Rare4).ToList(); foreach (var cacheAcdItem in removalList) { LogSalvagedItem(cacheAcdItem); } townRunItemCache.SalvageItems = townRunItemCache.SalvageItems.Except(removalList).ToList(); return(RunStatus.Running); } if (UI.Game.SalvageAllRare.IsEnabled && UI.Game.SalvageAllRare.IsVisible && bShouldSalvageAllRare && townRunItemCache.SalvageItems.Any(i => i.IsSalvagable && i.ThisQuality < ItemQuality.Legendary) && !bSalvageAllRare) { //UI.Game.SalvageAllRare.Click(); FunkyTownRunPlugin.DBLog.DebugFormat("[FunkyTownRun] Salvaging All Rare Items"); ZetaDia.Me.Inventory.SalvageItemsOfRarity(SalvageRarity.Rare); bSalvageAllRare = true; var removalList = townRunItemCache.SalvageItems.Where(i => i.IsSalvagable && i.ThisQuality < ItemQuality.Legendary).ToList(); foreach (var cacheAcdItem in removalList) { LogSalvagedItem(cacheAcdItem); } townRunItemCache.SalvageItems = townRunItemCache.SalvageItems.Except(removalList).ToList(); return(RunStatus.Running); } UpdateSalvageItemList(); } if (townRunItemCache.SalvageItems.Count > 0) { CacheACDItem thisitem = townRunItemCache.SalvageItems.FirstOrDefault(); if (thisitem != null && thisitem.ACDItem != null) { LogSalvagedItem(thisitem); FunkyTownRunPlugin.DBLog.DebugFormat("[FunkyTownRun] Salvaging Individual Item {0}", thisitem.ToString()); ZetaDia.Me.Inventory.SalvageItem(thisitem.ThisDynamicID); } townRunItemCache.SalvageItems.Remove(thisitem); if (townRunItemCache.SalvageItems.Count > 0) { thisitem = townRunItemCache.SalvageItems.FirstOrDefault(); if (thisitem != null) { return(RunStatus.Running); } } else { Delay.Reset(); return(RunStatus.Running); } } return(RunStatus.Success); }