Exemplo n.º 1
0
 internal static void SetUnstuckProvider()
 {
     if (Settings.Advanced.UnstuckerEnabled)
     {
         Navigator.StuckHandler = new StuckHandler();
         Logger.Log(TrinityLogLevel.Verbose, LogCategory.UserInformation, "Using Trinity Unstucker", true);
     }
     else
     {
         Navigator.StuckHandler = new DefaultStuckHandler();
         Logger.Log(TrinityLogLevel.Verbose, LogCategory.UserInformation, "Using Default Demonbuddy Unstucker", true);
     }
 }
        private static bool UpdateCurrentTarget()
        {
            // Return true if we need to refresh objects and get a new target
            bool forceUpdate = false;

            try
            {
                Player.Position         = ZetaDia.Me.Position;
                Player.CurrentHealthPct = ZetaDia.Me.HitpointsCurrentPct;

                if (CurrentTarget != null && CurrentTarget.IsUnit && CurrentTarget.Unit != null && CurrentTarget.Unit.IsValid)
                {
                    try
                    {
                        DiaUnit unit = CurrentTarget.Unit;
                        //if (unit.HitpointsCurrent <= 0d)
                        //{
                        //    Logger.Log(TrinityLogLevel.Debug, LogCategory.Behavior, "CurrentTarget is dead, setting null");
                        //    CurrentTarget = null;
                        //    forceUpdate = true;
                        //}
                        //else
                        //{
                        CurrentTarget.Position     = unit.Position;
                        CurrentTarget.HitPointsPct = unit.HitpointsCurrentPct;
                        CurrentTarget.HitPoints    = unit.HitpointsCurrent;
                        Logger.Log(TrinityLogLevel.Debug, LogCategory.Behavior, "Updated CurrentTarget HitPoints={0:0.00} & Position={1}", CurrentTarget.HitPointsPct, CurrentTarget.Position);
                        //}
                    }
                    catch (Exception)
                    {
                        Logger.Log(TrinityLogLevel.Debug, LogCategory.Behavior, "Error updating current target information");
                        CurrentTarget = null;
                        forceUpdate   = true;
                    }
                }
                else if (CurrentTarget != null && CurrentTarget.IsUnit)
                {
                    Logger.Log(TrinityLogLevel.Debug, LogCategory.Behavior, "CurrentTarget is invalid, setting null");
                    CurrentTarget = null;
                    forceUpdate   = true;
                }
            }
            catch
            {
                Logger.Log(TrinityLogLevel.Debug, LogCategory.Behavior, "Error updating current target information");
                CurrentTarget = null;
                forceUpdate   = true;
            }
            return(forceUpdate);
        }
Exemplo n.º 3
0
            internal void UpdateFastChangingData()
            {
                ACDGuid                      = _me.ACDGuid;
                RActorGuid                   = _me.RActorGuid;
                LastUpdated                  = DateTime.UtcNow;
                IsInTown                     = DataDictionary.TownLevelAreaIds.Contains(LevelAreaId);
                IsInRift                     = DataDictionary.RiftWorldIds.Contains(WorldID);
                IsDead                       = _me.IsDead;
                IsIncapacitated              = (_me.IsFeared || _me.IsStunned || _me.IsFrozen || _me.IsBlind);
                IsRooted                     = _me.IsRooted;
                CurrentHealthPct             = _me.HitpointsCurrentPct;
                PrimaryResource              = _me.CurrentPrimaryResource;
                PrimaryResourcePct           = PrimaryResource / PrimaryResourceMax;
                PrimaryResourceMissing       = PrimaryResourceMax - PrimaryResource;
                SecondaryResource            = _me.CurrentSecondaryResource;
                SecondaryResourcePct         = SecondaryResource / SecondaryResourceMax;
                SecondaryResourceMissing     = SecondaryResourceMax - SecondaryResource;
                Position                     = _me.Position;
                Rotation                     = _me.Movement.Rotation;
                DirectionVector              = _me.Movement.DirectionVector;
                MovementSpeed                = _me.Movement.SpeedXY;
                IsMoving                     = _me.Movement.IsMoving;
                IsInCombat                   = _me.IsInCombat;
                MaxBloodShards               = 500 + ZetaDia.Me.CommonData.GetAttribute <int>(ActorAttributeType.HighestSoloRiftLevel) * 10;
                IsMaxCriticalChance          = _me.CritPercentBonusUncapped > 0;
                IsJailed                     = _me.HasDebuff(SNOPower.MonsterAffix_JailerCast);
                IsFrozen                     = _me.IsFrozen;
                ParticipatingInTieredLootRun = _me.IsParticipatingInTieredLootRun;
                TieredLootRunlevel           = _me.InTieredLootRunLevel;

                CurrentHealth = _me.HitpointsCurrent;

                HealthHistory.Add(CurrentHealth);
                while (HealthHistory.Count > 5)
                {
                    HealthHistory.RemoveAt(0);
                }

                var averageHealth = HealthHistory.Average();

                IsTakingDamage = averageHealth > CurrentHealth;
                if (IsTakingDamage)
                {
                    Logger.LogVerbose(LogCategory.Avoidance, "Taking Damage 5TickAvg={0} Current={1}", averageHealth, CurrentHealth);
                }

                // For WD Angry Chicken
                IsHidden = _me.IsHidden;
            }
Exemplo n.º 4
0
 internal static void SetBotTicksPerSecond()
 {
     // Carguy's ticks-per-second feature
     if (Settings.Advanced.TPSEnabled)
     {
         BotMain.TicksPerSecond = Settings.Advanced.TPSLimit;
         Logger.Log(TrinityLogLevel.Verbose, LogCategory.UserInformation, "Bot TPS set to {0}", Settings.Advanced.TPSLimit);
     }
     else
     {
         BotMain.TicksPerSecond = 10;
         //BotMain.TicksPerSecond = Int32.MaxValue;
         Logger.Log(TrinityLogLevel.Verbose, LogCategory.UserInformation, "Reset bot TPS to default", Settings.Advanced.TPSLimit);
     }
 }
Exemplo n.º 5
0
            protected static Composite CreateUnstuckBehavior()
            {
                return(new Decorator(ret => !IsDone,

                                     new Action(ret =>
                {
                    try
                    {
                        if (!_points.Any() || IsWithinRange(_points.First()))
                        {
                            Logger.Log(TrinityLogLevel.Debug, LogCategory.Movement, "Arrived at Destination {0} Distance={1}", _points.First().ToString(), _points.First());

                            IsDone = true;
                            return RunStatus.Failure;
                        }

                        if (ZetaDia.Me.Movement.IsMoving)
                        {
                            _lastMoving = DateTime.UtcNow;
                        }

                        // Ooooh bad bad bad - always use Navigator raycast!
                        //var rayResult = ZetaDia.Physics.Raycast(ZetaDia.Me.Position, _points.First(), NavCellFlags.AllowWalk);
                        var raycastHit = Navigator.Raycast(ZetaDia.Me.Position, _points.First());
                        var stuckResult = DateTime.UtcNow.Subtract(_lastMoving).TotalMilliseconds > 250;

                        if (stuckResult || raycastHit)
                        {
                            Logger.Log(TrinityLogLevel.Debug, LogCategory.Movement, "Discarded Location {0} Distance={1} RaycastResult={2} StuckResult={3} LocationsRemaining={4}", _points.First().ToString(), _points.First().Distance(ZetaDia.Me.Position), raycastHit, stuckResult, _points.Count - 1);
                            _points.RemoveAt(0);
                        }

                        if (_points.Any() && _points.First() != Vector3.Zero && ZetaDia.Me.Movement.MoveActor(_points.First()) == 1)
                        {
                            return RunStatus.Success;
                        }

                        IsDone = true;
                        return RunStatus.Failure;
                    }
                    catch (Exception ex)
                    {
                        Logger.LogError("Exception in UnstuckBehavior: " + ex);
                        return RunStatus.Failure;
                    }
                })
                                     ));
            }
Exemplo n.º 6
0
        public static bool CanRun()
        {
            if (!ZetaDia.IsInGame || !ZetaDia.IsInTown)
            {
                return(false);
            }

            if (!LastCanRunResult && DateTime.UtcNow.Subtract(LastCanRunCheck).TotalSeconds < 5)
            {
                return(LastCanRunResult);
            }

            Inventory.Materials.Update();

            _highest = Inventory.Materials.HighestCountMaterial(Inventory.MaterialConversionTypes);

            var settingsTypes = Trinity.Trinity.Settings.KanaisCube.GetCraftingMaterialTypes();

            if (!settingsTypes.Any())
            {
                Logger.LogVerbose("[CubeItemsToMaterials] No materials have been selected in settings", _highest.Type, _highest.TotalStackQuantity);
            }

            Logger.LogVerbose("[CubeItemsToMaterials] Selected {0} as the material with highest count - {1}", _highest.Type, _highest.TotalStackQuantity);

            var _validTypes = settingsTypes.Where(t => t != _highest.Type);

            _materials = Inventory.Materials.OfTypes(_validTypes);

            bool result = false;

            foreach (var material in _materials)
            {
                if (ConvertMaterials.CanRun(_highest.Type, material.Key, true, true))
                {
                    Logger.LogVerbose("[CubeItemsToMaterials] YES - {0} -> {1}", _highest.Type, material.Key);
                    result = true;
                }
                else
                {
                    Logger.LogVerbose("[CubeItemsToMaterials] NO - {0} -> {1}", _highest.Type, material.Key);
                }
            }

            LastCanRunCheck  = DateTime.UtcNow;
            LastCanRunResult = result;
            return(result);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Main method for selecting a power
        /// </summary>
        public static TrinityPower GetPower()
        {
            TrinityPower power;

            if (UseDestructiblePower && TryGetPower(GetDestructablesSkill(), out power))
            {
                return(power);
            }

            if (IsCurrentlyAvoiding && TryGetPower(GetAvoidanceSkill(), out power))
            {
                return(power);
            }

            if (CurrentTarget == null)
            {
                // Out of Combat Buffs
                if (!IsCurrentlyAvoiding && !Player.IsInTown && TryGetPower(GetBuffSkill(), out power))
                {
                    return(power);
                }
            }
            else
            {
                // Use Generator for the Bastians Ring Set buff
                if (!IsCurrentlyAvoiding && ShouldRefreshBastiansGeneratorBuff && TryGetPower(GetAttackGenerator(), out power))
                {
                    return(power);
                }

                // Use Spender for the Bastians Ring Set buff
                if (!IsCurrentlyAvoiding && ShouldRefreshBastiansSpenderBuff && TryGetPower(GetAttackSpender(), out power))
                {
                    return(power);
                }

                // Main ability selection
                if (TryGetPower(GetCombatPower(CombatSkillOrder), out power))
                {
                    return(power);
                }
            }

            Logger.Log(TrinityLogLevel.Verbose, LogCategory.SkillSelection, Player.ActorClass + " GetPower() Returning DefaultPower Target={0}",
                       (CurrentTarget == null) ? "Null" : CurrentTarget.InternalName);

            return(DefaultPower);
        }
Exemplo n.º 8
0
        internal static void LogUnknown(DiaObject diaObject)
        {
            if (!LogCategoryEnabled(LogCategory.UnknownObjects) || !diaObject.IsValid || !diaObject.CommonData.IsValid)
            {
                return;
            }

            // Log Object
            if (!_seenUnknownCache.ContainsKey(diaObject.ActorSNO))
            {
                Logger.Log(LogCategory.UnknownObjects, "{0} ({1}) Type={2}", diaObject.Name, diaObject.ActorSNO, diaObject.ActorType);
                _seenUnknownCache.Add(diaObject.ActorSNO, DateTime.UtcNow);
            }

            CacheMaintenance();
        }
Exemplo n.º 9
0
        private static async Task <bool> MainCombatTask()
        {
            // If we aren't in the game or a world is loading, don't do anything yet
            if (!ZetaDia.IsInGame || ZetaDia.IsLoadingWorld || !ZetaDia.Me.IsValid)
            {
                Logger.LogDebug(LogCategory.GlobalHandler, "Not in game, IsLoadingWorld, or Me is Invalid");
                return(true);
            }

            var  equippedItems       = ZetaDia.Me.Inventory.Equipped.Where(i => i.IsValid);
            bool needEmergencyRepair = false;

            //ZetaDia.Me.Inventory.Equipped.Where(i => i.ACDGuid != 0 && i.IsValid).Average(i => i.DurabilityPercent) < 0.05
            foreach (var item in equippedItems)
            {
                if (item.ACDGuid == 0)
                {
                    continue;
                }
                float durabilitySum = 0f;
                int   itemCount     = 0;
                try
                {
                    durabilitySum += item.DurabilityPercent;
                    itemCount++;
                }
                catch {
                    // Ring them bells for the chosen few who will judge the many when the game is through
                }
                if (itemCount > 0 && durabilitySum / itemCount < 0.05)
                {
                    needEmergencyRepair = true;
                }
            }

            // We keep dying because we're spawning in AoE and next to 50 elites and we need to just leave the game
            if (DateTime.UtcNow.Subtract(Trinity.LastDeathTime).TotalSeconds < 30 && !ZetaDia.IsInTown && needEmergencyRepair)
            {
                Logger.Log("Durability is zero, emergency leave game");
                ZetaDia.Service.Party.LeaveGame(true);
                await CommonCoroutines.LeaveGame("Durability is zero");

                Logger.LogDebug(LogCategory.GlobalHandler, "Recently died, durability zero");
                return(true);
            }
            return(await new Decorator(Trinity.TargetCheck, new Action(ret => Trinity.HandleTarget())).ExecuteCoroutine());
        }
Exemplo n.º 10
0
 private static void RefreshWaitTimers()
 {
     // See if we should wait for [playersetting] milliseconds for possible loot drops before continuing run
     if (ShouldWaitForLootDrop)
     {
         CurrentTarget = new TrinityCacheObject()
         {
             Position     = Player.Position,
             Type         = TrinityObjectType.Avoidance,
             Weight       = 20000,
             Distance     = 2f,
             Radius       = 2f,
             InternalName = "WaitForLootDrops"
         };
         Logger.Log(TrinityLogLevel.Debug, LogCategory.Behavior, "Waiting for loot to drop, delay: {0}ms", Settings.Combat.Misc.DelayAfterKill);
     }
 }
Exemplo n.º 11
0
        public static void DumpPlayerSkills()
        {
            if (BotMain.IsRunning)
            {
                BotMain.Stop();
            }

            using (var helper = new Helpers.ZetaCacheHelper())
            {
                HotbarSkills.Update(TrinityLogLevel.Info, LogCategory.UserInformation);

                foreach (var skill in HotbarSkills.PassiveSkills.ToList())
                {
                    Logger.Log("Passive: {0}", skill);
                }
            }
        }
Exemplo n.º 12
0
        public static void RecordSpell(TrinityPower power)
        {
            if (_historyQueue.Count >= SpellHistorySize)
            {
                _historyQueue.RemoveAt(_historyQueue.Count() - 1);
            }
            _historyQueue.Add(new SpellHistoryItem
            {
                Power          = power,
                UseTime        = DateTime.UtcNow,
                MyPosition     = Trinity.Player.Position,
                TargetPosition = power.TargetPosition
            });
            Logger.LogDebug(LogCategory.Targetting, "Recorded {0}", power);

            CacheData.AbilityLastUsed[power.SNOPower] = DateTime.UtcNow;
            Trinity.LastPowerUsed = power.SNOPower;
        }
Exemplo n.º 13
0
            private static List <Vector3> GetCirclePoints(int points, double radius, Vector3 center)
            {
                var result = new List <Vector3>();
                var slice  = 2 * Math.PI / points;

                for (var i = 0; i < points; i++)
                {
                    var angle = slice * i;
                    var newX  = (int)(center.X + radius * Math.Cos(angle));
                    var newY  = (int)(center.Y + radius * Math.Sin(angle));

                    var newpoint = new Vector3(newX, newY, center.Z);
                    result.Add(newpoint);

                    Logger.Log(TrinityLogLevel.Debug, LogCategory.Movement, "Calculated point {0}: {1}", i, newpoint.ToString());
                }
                return(result);
            }
Exemplo n.º 14
0
        public static async Task <bool> Execute(List <ItemSelectionType> types = null)
        {
            if (!CanRun())
            {
                return(true);
            }

            Logger.LogVerbose("[CubeItemsToMaterials] Getting Materials from Stash");

            if (!Inventory.Materials.HasStackQuantityOfTypes(Inventory.MaterialConversionTypes, InventorySlot.BackpackItems, 100) && !await TakeItemsFromStash.Execute(Inventory.RareUpgradeIds, 5000))
            {
                return(true);
            }

            Logger.LogVerbose("[CubeItemsToMaterials] Time to Convert some junk into delicious crafting materials.");

            if (!await MoveToAndInteract.Execute(Town.Locations.KanaisCube, Town.ActorIds.KanaisCube, 3f))
            {
                Logger.Log("[CubeItemsToMaterials] Failed to move to the cube, quite unfortunate.");
                return(true);
            }

            if (_highest.Type == InventoryItemType.None)
            {
                Logger.Log("[CubeItemsToMaterials] Error: Highest material count is unknown.");
                return(true);
            }

            foreach (var material in _materials)
            {
                if (!await ConvertMaterials.Execute(_highest.Type, material.Key))
                {
                    Logger.Log("[Cube] Failed! Finished!");
                    return(true);
                }

                await Coroutine.Sleep(100);

                await Coroutine.Yield();
            }

            Logger.LogVerbose("[Cube] CubeItemsToMaterials Finished!");
            return(true);
        }
Exemplo n.º 15
0
        internal static void Exit()
        {
            ZetaDia.Memory.Process.Kill();

            try
            {
                if (Thread.CurrentThread != Application.Current.Dispatcher.Thread)
                {
                    Application.Current.Dispatcher.Invoke(new System.Action(Exit));
                    return;
                }

                Application.Current.Shutdown();
            }
            catch (Exception ex)
            {
                Logger.Log(ex.ToString());
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Log the rubbish junk items we salvaged or sold
        /// </summary>
        internal static void LogJunkItems(CachedACDItem acdItem, GItemBaseType itemBaseType, GItemType itemType, double itemValue)
        {
            FileStream LogStream = null;

            try
            {
                string filePath = Path.Combine(FileManager.LoggingPath, "JunkLog - " + Trinity.Player.ActorClass.ToString() + ".log");
                LogStream = File.Open(filePath, FileMode.Append, FileAccess.Write, FileShare.Read);
                using (StreamWriter LogWriter = new StreamWriter(LogStream))
                {
                    if (!_loggedJunkThisStash)
                    {
                        _loggedJunkThisStash = true;
                        LogWriter.WriteLine(DateTime.Now.ToString() + ":");
                        LogWriter.WriteLine("====================");
                    }
                    string isLegendaryItem = "";
                    if (acdItem.Quality >= ItemQuality.Legendary)
                    {
                        isLegendaryItem = " {legendary item}";
                    }
                    LogWriter.WriteLine(itemBaseType.ToString() + " - " + itemType.ToString() + " '" + acdItem.RealName + "'. Score = " + itemValue.ToString("0") + isLegendaryItem);
                    if (JunkItemStatString != "")
                    {
                        LogWriter.WriteLine("  " + JunkItemStatString);
                    }
                    else
                    {
                        LogWriter.WriteLine("  (no scorable attributes)");
                    }
                    LogWriter.WriteLine("");
                }
                LogStream.Close();
            }
            catch (IOException)
            {
                Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "Fatal Error: File access error for junk log file.");
                if (LogStream != null)
                {
                    LogStream.Close();
                }
            }
        }
Exemplo n.º 17
0
        public static void LogAnimation(TrinityCacheObject cacheObject)
        {
            if (!LogCategoryEnabled(LogCategory.Animation) || cacheObject.CommonData == null || !cacheObject.CommonData.IsValid || !cacheObject.CommonData.AnimationInfo.IsValid)
            {
                return;
            }

            var state = cacheObject.CommonData.AnimationState.ToString();
            var name  = cacheObject.CommonData.CurrentAnimation.ToString();

            // Log Animation
            if (!_seenAnimationCache.ContainsKey(name))
            {
                Logger.Log(LogCategory.Animation, "{0} State={1} By: {2} ({3})", name, state, cacheObject.InternalName, cacheObject.ActorSNO);
                _seenAnimationCache.Add(name, DateTime.UtcNow);
            }

            CacheMaintenance();
        }
Exemplo n.º 18
0
        private static void ModifyTownRun(GroupComposite original)
        {
            var firstChild = original.Children.FirstOrDefault() as GroupComposite;

            if (firstChild == null)
            {
                Logger.LogVerbose("Unexpected Composite or no vendor composite found in original town run");
                return;
            }

            if (firstChild.Children.Count != 9)
            {
                return;
            }

            firstChild.InsertChild(3, new ActionRunCoroutine(async ret => await VendorHook.ExecutePreVendor()));
            // 2= Identify
            // 5= Stash
            firstChild.InsertChild(8, new ActionRunCoroutine(async ret => await VendorHook.ExecutePostVendor()));
        }
Exemplo n.º 19
0
        private static void InsertOutOfGameHooks()
        {
            const string hookName = "TreeStart";

            if (_goldInactiveComposite == null)
            {
                _goldInactiveComposite = GoldInactivity.CreateGoldInactiveLeaveGame();
            }

            if (_xpInactiveComposite == null)
            {
                _xpInactiveComposite = XpInactivity.CreateXpInactiveLeaveGame();
            }

            Logger.Log("Inserting GoldInactivity into " + hookName);
            TreeHooks.Instance.InsertHook(hookName, 0, _goldInactiveComposite);

            Logger.Log("Inserting XPInactivity into " + hookName);
            TreeHooks.Instance.InsertHook(hookName, 0, _xpInactiveComposite);
        }
Exemplo n.º 20
0
 public static Composite TownRunWrapper(Composite original)
 {
     return
         (new Sequence(
              original,
              new Action(delegate
     {
         if (!BrainBehavior.IsVendoring)
         {
             Logger.Log("TownRun complete");
             Trinity.IsReadyToTownRun = false;
             Trinity.ForceVendorRunASAP = false;
             TownRunCheckTimer.Reset();
             SendEmailNotification();
             SendMobileNotifications();
         }
         return RunStatus.Success;
     })
              ));
 }
Exemplo n.º 21
0
        public static void SetSNOPowerUseDelay(SNOPower power, double delay)
        {
            string key = "SpellDelay." + power.ToString();

            if (!V.Data.ContainsKey(key))
            {
                Logger.LogDebug("Failed to Set TVar {0} - key doesnt exist");
                return;
            }


            TVar v = V.Data[key];

            bool hasDefaultValue = v.Value == v.DefaultValue;

            if (hasDefaultValue)
            {
                // Create a new TVar (changes the default value)
                V.Set(new TVar(v.Name, delay, v.Description));
            }
        }
Exemplo n.º 22
0
        public static void ItemListTest()
        {
            Logger.Log("Starting ItemList Backpack Test");

            var backpackItems = ZetaDia.Me.Inventory.Backpack.ToList();
            var total         = backpackItems.Count;
            var stashCount    = 0;

            foreach (var acdItem in backpackItems)
            {
                Logger.Log("{0} ActorSNO={1} GameBalanceId={2}", acdItem.Name, acdItem.ActorSNO, acdItem.GameBalanceId);
                var cItem = CachedACDItem.GetCachedItem(acdItem);
                if (ItemList.ShouldStashItem(cItem, true))
                {
                    stashCount++;
                }
            }

            Logger.Log("Finished ItemList Backpack Test");

            Logger.Log("Finished - Stash {0} / {1}", stashCount, total);
        }
Exemplo n.º 23
0
        /// <summary>
        /// A list of conversion candidates from backpack
        /// </summary>
        public static List <ACDItem> GetBackPackRares(IEnumerable <ItemSelectionType> types = null)
        {
            if (types == null)
            {
                types = Trinity.Trinity.Settings.KanaisCube.GetRareUpgradeSettings();
            }

            var rares = ZetaDia.Me.Inventory.Backpack.Where(i =>
            {
                if (Inventory.InvalidItemDynamicIds.Contains(i.DynamicId))
                {
                    return(false);
                }

                if (i.ItemBaseType != ItemBaseType.Armor && i.ItemBaseType != ItemBaseType.Weapon && i.ItemBaseType != ItemBaseType.Jewelry)
                {
                    return(false);
                }

                // Both ItemQualityLevel and ItemLinkColor are unreliable, together maybe we have a chance.
                if (i.GetItemQuality() != ItemQuality.Rare4 || i.ItemQualityLevel == ItemQuality.Legendary)
                {
                    return(false);
                }

                if (i.ItemStackQuantity != 0 || !i.IsValid || i.IsDisposed)
                {
                    Logger.LogVerbose("Skipping Item - Invalid {0} Disposed={1} IsValid={2} InvalidStackQuantity={3}",
                                      i.InternalName, i.IsDisposed, i.IsValid, i.ItemStackQuantity != 0);

                    return(false);
                }

                return(types == null || types.Contains(i.GetItemSelectionType()));
            }).ToList();

            Logger.Log(LogCategory.Behavior, "[CubeRaresToLegendary] {0} Valid Rares in Backpack", rares.Count);
            return(rares);
        }
Exemplo n.º 24
0
        /// <summary>
        /// Called when user disable the plugin.
        /// </summary>
        public void OnDisabled()
        {
            _isPluginEnabled = false;

            TabUi.RemoveTab();
            BotManager.ReplaceTreeHooks();



            Navigator.PlayerMover               = new DefaultPlayerMover();
            Navigator.StuckHandler              = new DefaultStuckHandler();
            CombatTargeting.Instance.Provider   = new DefaultCombatTargetingProvider();
            LootTargeting.Instance.Provider     = new DefaultLootTargetingProvider();
            ObstacleTargeting.Instance.Provider = new DefaultObstacleTargetingProvider();
            //Navigator.SearchGridProvider = new MainGridProvider();

            GameEvents.OnPlayerDied -= TrinityOnDeath;
            BotMain.OnStop          -= TrinityBotStop;



            GameEvents.OnPlayerDied   -= TrinityOnDeath;
            GameEvents.OnGameJoined   -= TrinityOnJoinGame;
            GameEvents.OnGameLeft     -= TrinityOnLeaveGame;
            GameEvents.OnItemSold     -= ItemEvents.TrinityOnItemSold;
            GameEvents.OnItemSalvaged -= ItemEvents.TrinityOnItemSalvaged;
            GameEvents.OnItemStashed  -= ItemEvents.TrinityOnItemStashed;
            GameEvents.OnItemIdentificationRequest -= ItemEvents.TrinityOnOnItemIdentificationRequest;
            GameEvents.OnGameChanged  -= GameEvents_OnGameChanged;
            GameEvents.OnWorldChanged -= GameEvents_OnWorldChanged;

            ItemManager.Current = new LootRuleItemManager();

            Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "");
            Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "DISABLED: Trinity is now shut down...");
            Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "");
            GenericCache.Shutdown();
            GenericBlacklist.Shutdown();
        }
Exemplo n.º 25
0
        internal static void DumpItemSNOReference()
        {
            string[] names  = Enum.GetNames(typeof(SNOActor));
            int[]    values = (int[])Enum.GetValues(typeof(SNOActor));
            var      toLog  = new List <string>();

            for (int i = 0; i < names.Length; i++)
            {
                var sno  = values[i];
                var name = names[i];
                var type = TrinityItemManager.DetermineItemType(name, ItemType.Unknown);
                if (type != TrinityItemType.Unknown || DataDictionary.GoldSNO.Contains(sno) ||
                    DataDictionary.ForceToItemOverrideIds.Contains(sno) || DataDictionary.HealthGlobeSNO.Contains(sno) || Legendary.ItemIds.Contains(sno))
                {
                    toLog.Add(string.Format("{{ {0}, TrinityItemType.{1} }}, // {2}", sno, type, name));
                }
            }

            var path = WriteLinesToLog("ItemSNOReference.log", toLog, true);

            Logger.Log("Finished Dumping Item SNO Reference to {0}", path);
        }
Exemplo n.º 26
0
        /// <summary>
        /// Drop item in town and record it so we can avoid picking it up again.
        /// </summary>
        public static bool Drop(ACDItem item)
        {
            if (!ZetaDia.IsInGame || !ZetaDia.IsInTown || item.IsAccountBound)
            {
                return(false);
            }

            if (item.IsPotion || item.IsMiscItem || item.IsGem || item.IsCraftingReagent || item.IsCraftingPage)
            {
                return(false);
            }

            Logger.Log("--> Dropping {0} ({1}) in town. DynamicId={2} ", item.Name, item.ActorSNO, item.DynamicId);

            if (item.Drop())
            {
                DroppedItems.Add(item.DynamicId);
                Thread.Sleep(250);
                return(true);
            }

            return(false);
        }
Exemplo n.º 27
0
            public static void Start(List <Vector3> points = null)
            {
                if (IsRunning)
                {
                    return;
                }

                UpdateStuckAttempts();

                Logger.Log("Bot is Stuck! Attempt #{0} to fix it", Attempts);

                Timeout = Timeout <= 0 ? 15 : Timeout;

                _startTime = DateTime.UtcNow;

                _points = points ?? RandomShuffle(GetCirclePoints(20, 30, ZetaDia.Me.Position));

                RandomShuffle(_points);

                _isDone = false;

                InsertHook();
            }
Exemplo n.º 28
0
        /// <summary>
        /// This will replace the main BehaviorTree hooks for Combat, Vendoring, and Looting.
        /// </summary>
        internal static void ReplaceTreeHooks()
        {
            if (Trinity.IsPluginEnabled)
            {
                // This is the do-all-be-all god-head all encompasing piece of trinity
                StoreAndReplaceHook("Combat", new Decorator(Trinity.TargetCheck, Trinity.HandleTargetAction()));

                // We still want the main VendorRun logic, we're just going to take control of *when* this logic kicks in
                var vendorDecorator = TreeHooks.Instance.Hooks["VendorRun"][0] as Decorator;
                if (vendorDecorator != null)
                {
                    StoreAndReplaceHook("VendorRun", new Decorator(TownRun.TownRunCanRun, TownRun.TownRunWrapper(vendorDecorator.Children[0])));
                }

                // Loot tree is now empty and never runs (Loot is handled through combat)
                // This is for special out of combat handling like Horadric Cache
                Composite lootComposite = TreeHooks.Instance.Hooks["Loot"][0];
                StoreAndReplaceHook("Loot", Composites.CreateLootBehavior(lootComposite));

                if (_goldInactiveComposite == null)
                {
                    _goldInactiveComposite = GoldInactivity.CreateGoldInactiveLeaveGame();
                }

                Logger.Log("Inserting GoldInactivity into BotBehavior");
                TreeHooks.Instance.InsertHook("BotBehavior", 0, _goldInactiveComposite);
            }
            else
            {
                ReplaceHookWithOriginal("Combat");
                ReplaceHookWithOriginal("VendorRun");
                ReplaceHookWithOriginal("Loot");

                Logger.Log("Removing GoldInactivity from BotBehavior");
                TreeHooks.Instance.RemoveHook("BotBehavior", _goldInactiveComposite);
            }
        }
Exemplo n.º 29
0
        internal static void LogNewItems()
        {
            var knownIds = Legendary.ItemIds;

            using (new MemoryHelper())
            {
                if (ZetaDia.Me == null || !ZetaDia.Me.IsValid)
                {
                    Logger.Log("Not in game");
                    return;
                }

                var allItems = new List <ACDItem>();
                allItems.AddRange(ZetaDia.Me.Inventory.StashItems);
                allItems.AddRange(ZetaDia.Me.Inventory.Equipped);
                allItems.AddRange(ZetaDia.Me.Inventory.Backpack);

                if (!allItems.Any())
                {
                    return;
                }

                var newItems = allItems.Where(i => i != null && i.IsValid && i.ItemQualityLevel == ItemQuality.Legendary && (i.ItemBaseType == ItemBaseType.Jewelry || i.ItemBaseType == ItemBaseType.Armor || i.ItemBaseType == ItemBaseType.Weapon) && !knownIds.Contains(i.ActorSNO)).DistinctBy(p => p.ActorSNO).OrderBy(i => i.ItemType).ToList();

                if (!newItems.Any())
                {
                    return;
                }

                Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "------ New/Unknown Items {0} ------", newItems.Count);

                newItems.ForEach(i =>
                {
                    Logger.Log(string.Format("Item: {0}: {1} ({2})", i.ItemType, i.Name, i.ActorSNO));
                });
            }
        }
Exemplo n.º 30
0
        /// <summary>
        /// This will replace the main BehaviorTree hooks for Combat, Vendoring, and Looting.
        /// </summary>
        internal static void ReplaceTreeHooks()
        {
            if (Trinity.IsPluginEnabled)
            {
                ReplaceCombatHook();
                ReplaceVendorRunHook();
                ReplaceLootHook();
                InsertOutOfGameHooks();

                //Pulsator.OnPulse += (s, arg) => Logger.Log("Pulse!");
                //TreeHooks.Instance.InsertHook("TreeStart", 0, new Action(ret => { Logger.Log("TreeStart!"); return RunStatus.Failure; }));
                //TreeHooks.Instance.InsertHook("BotBehavior", 0, new Action(ret => { Logger.Log("BotBehavior!"); return RunStatus.Failure; }));
                //TreeHooks.Instance.InsertHook("VendorRun", 0, new Action(ret => { Logger.Log("VendorRun!"); return RunStatus.Failure; }));
            }
            else
            {
                ReplaceHookWithOriginal("Combat");
                ReplaceHookWithOriginal("VendorRun");
                ReplaceHookWithOriginal("Loot");

                Logger.Log("Removing GoldInactivity from BotBehavior");
                TreeHooks.Instance.RemoveHook("BotBehavior", _goldInactiveComposite);
            }
        }