Exemple #1
0
        public static CachedACDItem GetCachedItem(ACDItem item)
        {
            CachedACDItem cItem = new CachedACDItem(item.Stats)
            {
                AcdItem           = item,
                InternalName      = item.InternalName,
                RealName          = item.Name,
                Level             = item.Level,
                Quality           = item.ItemQualityLevel,
                GoldAmount        = item.Gold,
                BalanceID         = item.GameBalanceId,
                DynamicID         = item.DynamicId,
                OneHanded         = item.IsOneHand,
                TwoHanded         = item.IsTwoHand,
                DyeType           = item.DyeType,
                DBItemType        = item.ItemType,
                DBBaseType        = item.ItemBaseType,
                FollowerType      = item.FollowerSpecialType,
                IsUnidentified    = item.IsUnidentified,
                ItemStackQuantity = item.ItemStackQuantity,
                Row                 = item.InventoryRow,
                Column              = item.InventoryColumn,
                ItemLink            = item.ItemLink,
                TrinityItemType     = Trinity.DetermineItemType(item.InternalName, item.ItemType, item.FollowerSpecialType),
                TrinityItemBaseType = Trinity.DetermineBaseType(Trinity.DetermineItemType(item.InternalName, item.ItemType, item.FollowerSpecialType))
            };

            cItem.ComputeUpgrade();

            return(cItem);
        }
Exemple #2
0
        /// <summary>
        /// Re-reads the active assigned skills and runes from thoe hotbar
        /// </summary>
        internal static void RefreshHotbar()
        {
            using (new PerformanceLogger("RefreshHotbar"))
            {
                // Update Hotbar Skills first
                HotbarSkills.Update();

                SpellTracker.RefreshCachedSpells();

                if (!Trinity.GetHasBuff(SNOPower.Wizard_Archon) && !Player.IsHidden)
                {
                    Trinity.hashCachedPowerHotbarAbilities = new List <SNOPower>(Trinity.Hotbar);
                }
            }

            // Monk Seven Sided Strike: Sustained Attack
            if (Player.ActorClass == ActorClass.Monk && HotbarSkills.AssignedSkills.Any(s => s.Power == SNOPower.Monk_SevenSidedStrike && s.RuneIndex == 3))
            {
                CombatBase.SetSNOPowerUseDelay(SNOPower.Monk_SevenSidedStrike, 17000);
            }

            if (Player.ActorClass == ActorClass.Witchdoctor && HotbarSkills.PassiveSkills.Contains(SNOPower.Witchdoctor_Passive_GraveInjustice))
            {
                CombatBase.SetSNOPowerUseDelay(SNOPower.Witchdoctor_SoulHarvest, 1000);
                CombatBase.SetSNOPowerUseDelay(SNOPower.Witchdoctor_SpiritWalk, 1000);
                CombatBase.SetSNOPowerUseDelay(SNOPower.Witchdoctor_Horrify, 1000);
                CombatBase.SetSNOPowerUseDelay(SNOPower.Witchdoctor_Gargantuan, 20000);
                CombatBase.SetSNOPowerUseDelay(SNOPower.Witchdoctor_SummonZombieDog, 20000);
                CombatBase.SetSNOPowerUseDelay(SNOPower.Witchdoctor_GraspOfTheDead, 500);
                CombatBase.SetSNOPowerUseDelay(SNOPower.Witchdoctor_SpiritBarrage, 2000);
                CombatBase.SetSNOPowerUseDelay(SNOPower.Witchdoctor_Locust_Swarm, 2000);
                CombatBase.SetSNOPowerUseDelay(SNOPower.Witchdoctor_Haunt, 2000);
                CombatBase.SetSNOPowerUseDelay(SNOPower.Witchdoctor_Hex, 3000);
                CombatBase.SetSNOPowerUseDelay(SNOPower.Witchdoctor_MassConfusion, 15000);
                CombatBase.SetSNOPowerUseDelay(SNOPower.Witchdoctor_FetishArmy, 20000);
                CombatBase.SetSNOPowerUseDelay(SNOPower.Witchdoctor_BigBadVoodoo, 20000);
            }
            if (Player.ActorClass == ActorClass.Barbarian && HotbarSkills.PassiveSkills.Contains(SNOPower.Barbarian_Passive_BoonOfBulKathos))
            {
                CombatBase.SetSNOPowerUseDelay(SNOPower.Barbarian_Earthquake, 90500);
                CombatBase.SetSNOPowerUseDelay(SNOPower.Barbarian_CallOfTheAncients, 90500);
                CombatBase.SetSNOPowerUseDelay(SNOPower.Barbarian_WrathOfTheBerserker, 90500);
            }
        }
Exemple #3
0
        public static CachedACDItem GetCachedItem(ACDItem item)
        {
            try
            {
                if (!item.IsValid)
                {
                    return(default(CachedACDItem));
                }

                CachedACDItem cItem = new CachedACDItem(item.Stats)
                {
                    AcdItem           = item,
                    InternalName      = item.InternalName,
                    RealName          = item.Name,
                    Level             = item.Level,
                    Quality           = item.ItemQualityLevel,
                    GoldAmount        = item.Gold,
                    BalanceID         = item.GameBalanceId,
                    DynamicID         = item.DynamicId,
                    OneHanded         = item.IsOneHand,
                    TwoHanded         = item.IsTwoHand,
                    DyeType           = item.DyeType,
                    DBItemType        = item.ItemType,
                    DBBaseType        = item.ItemBaseType,
                    FollowerType      = item.FollowerSpecialType,
                    IsUnidentified    = item.IsUnidentified,
                    ItemStackQuantity = item.ItemStackQuantity,
                    Row                 = item.InventoryRow,
                    Column              = item.InventoryColumn,
                    ItemLink            = item.ItemLink,
                    TrinityItemType     = Trinity.DetermineItemType(item.InternalName, item.ItemType, item.FollowerSpecialType),
                    TrinityItemBaseType = Trinity.DetermineBaseType(Trinity.DetermineItemType(item.InternalName, item.ItemType, item.FollowerSpecialType))
                };

                cItem.ComputeUpgrade();
                return(cItem);
            }
            catch (Exception ex)
            {
                Logger.LogError("Error getting CachedItem {0}", ex.Message);
                return(default(CachedACDItem));
            }
        }
        internal static void SetProfileInWindowTitle()
        {
            if (DateTime.UtcNow.Subtract(_lastProfileCheck).TotalMilliseconds < 1000)
            {
                return;
            }

            _lastProfileCheck = DateTime.UtcNow;

            if (ProfileManager.CurrentProfile != null)
            {
                string fileName = Path.GetFileName(ProfileManager.CurrentProfile.Path);

                if (ProfileManager.CurrentProfile != null && ProfileManager.CurrentProfile.Name != null)
                {
                    Trinity.SetWindowTitle(Trinity.CurrentProfileName + " " + fileName);
                }
                else if (ProfileManager.CurrentProfile != null && string.IsNullOrWhiteSpace(ProfileManager.CurrentProfile.Name))
                {
                    Trinity.SetWindowTitle(fileName);
                }
            }
        }
Exemple #5
0
        public static float GetAvoidanceHealth(AvoidanceType type, float defaultValue)
        {
            // Monks with Serenity up ignore all AOE's
            if (Trinity.Player.ActorClass == ActorClass.Monk && Trinity.Hotbar.Contains(SNOPower.Monk_Serenity) && Trinity.GetHasBuff(SNOPower.Monk_Serenity))
            {
                // Monks with serenity are immune
                defaultValue *= V.F("Monk.Avoidance.Serenity");
                Logger.Log(TrinityLogLevel.Debug, LogCategory.Avoidance, "Ignoring avoidance as a Monk with Serenity");
            }
            // Witch doctors with spirit walk available and not currently Spirit Walking will subtly ignore ice balls, arcane, desecrator & plague cloud
            if (Trinity.Player.ActorClass == ActorClass.Witchdoctor && Trinity.Hotbar.Contains(SNOPower.Witchdoctor_SpiritWalk) && Trinity.GetHasBuff(SNOPower.Witchdoctor_SpiritWalk))
            {
                if (type == AvoidanceType.IceBall || type == AvoidanceType.Arcane || type == AvoidanceType.Desecrator || type == AvoidanceType.PlagueCloud)
                {
                    // Ignore ICE/Arcane/Desc/PlagueCloud altogether with spirit walk up or available
                    defaultValue *= V.F("WitchDoctor.Avoidance.SpiritWalk");
                    Logger.Log(TrinityLogLevel.Debug, LogCategory.Avoidance, "Ignoring avoidance as a WitchDoctor with Spirit Walk");
                }
            }
            // Remove ice balls if the barbarian has wrath of the berserker up, and reduce health from most other SNO avoidances
            if (Trinity.Player.ActorClass == ActorClass.Barbarian &&
                Trinity.Settings.Combat.Barbarian.IgnoreAvoidanceInWOTB &&
                Trinity.Hotbar.Contains(SNOPower.Barbarian_WrathOfTheBerserker) &&
                Trinity.GetHasBuff(SNOPower.Barbarian_WrathOfTheBerserker))
            {
                switch (type)
                {
                case AvoidanceType.IceBall:
                    defaultValue *= V.F("Barbarian.Avoidance.WOTB.IceBall");
                    break;

                case AvoidanceType.Arcane:
                    defaultValue *= V.F("Barbarian.Avoidance.WOTB.Arcane");
                    break;

                case AvoidanceType.Desecrator:
                    defaultValue *= V.F("Barbarian.Avoidance.WOTB.Desecrator");
                    break;

                case AvoidanceType.Belial:
                    defaultValue = V.F("Barbarian.Avoidance.WOTB.Belial");
                    break;

                case AvoidanceType.PoisonTree:
                    defaultValue = V.F("Barbarian.Avoidance.WOTB.PoisonTree");
                    break;

                case AvoidanceType.BeastCharge:
                    defaultValue = V.F("Barbarian.Avoidance.WOTB.BeastCharge");
                    break;

                case AvoidanceType.MoltenCore:
                    defaultValue = V.F("Barbarian.Avoidance.WOTB.MoltenCore");
                    break;

                default:
                    defaultValue *= V.F("Barbarian.Avoidance.WOTB.Other");
                    break;
                }
            }

            IAvoidanceHealth avoidanceHealth = null;

            switch (Trinity.Player.ActorClass)
            {
            case ActorClass.Barbarian:
                avoidanceHealth = Trinity.Settings.Combat.Barbarian;
                break;

            case ActorClass.Crusader:
                avoidanceHealth = Trinity.Settings.Combat.Crusader;
                break;

            case ActorClass.Monk:
                avoidanceHealth = Trinity.Settings.Combat.Monk;
                break;

            case ActorClass.Wizard:
                avoidanceHealth = Trinity.Settings.Combat.Wizard;
                break;

            case ActorClass.Witchdoctor:
                avoidanceHealth = Trinity.Settings.Combat.WitchDoctor;
                break;

            case ActorClass.DemonHunter:
                avoidanceHealth = Trinity.Settings.Combat.DemonHunter;
                break;
            }

            if (avoidanceHealth != null)
            {
                switch (type)
                {
                case AvoidanceType.Arcane:
                    return(avoidanceHealth.AvoidArcaneHealth);

                case AvoidanceType.AzmoFireball:
                    return(avoidanceHealth.AvoidAzmoFireBallHealth);

                case AvoidanceType.AzmodanBody:
                    return(avoidanceHealth.AvoidAzmoBodiesHealth);

                case AvoidanceType.AzmodanPool:
                    return(avoidanceHealth.AvoidAzmoPoolsHealth);

                case AvoidanceType.BeastCharge:
                    return(1);

                case AvoidanceType.BeeWasp:
                    return(avoidanceHealth.AvoidBeesWaspsHealth);

                case AvoidanceType.Belial:
                    return(avoidanceHealth.AvoidBelialHealth);

                case AvoidanceType.ButcherFloorPanel:
                    return(avoidanceHealth.AvoidButcherFloorPanelHealth);

                case AvoidanceType.Desecrator:
                    return(avoidanceHealth.AvoidDesecratorHealth);

                case AvoidanceType.DiabloMeteor:
                    return(avoidanceHealth.AvoidDiabloMeteorHealth);

                case AvoidanceType.DiabloPrison:
                    return(avoidanceHealth.AvoidDiabloPrisonHealth);

                case AvoidanceType.DiabloRingOfFire:
                    return(avoidanceHealth.AvoidDiabloRingOfFireHealth);

                case AvoidanceType.FireChains:
                    return(0.8f);

                case AvoidanceType.FrozenPulse:
                    return(avoidanceHealth.AvoidFrozenPulseHealth);

                case AvoidanceType.GhomGas:
                    return(avoidanceHealth.AvoidGhomGasHealth);

                case AvoidanceType.Grotesque:
                    return(avoidanceHealth.AvoidGrotesqueHealth);

                case AvoidanceType.IceBall:
                    return(avoidanceHealth.AvoidIceBallsHealth);

                case AvoidanceType.IceTrail:
                    return(avoidanceHealth.AvoidIceTrailHealth);

                case AvoidanceType.Orbiter:
                    return(avoidanceHealth.AvoidOrbiterHealth);

                case AvoidanceType.MageFire:
                    return(avoidanceHealth.AvoidMageFireHealth);

                case AvoidanceType.MaghdaProjectille:
                    return(avoidanceHealth.AvoidMaghdaProjectilleHealth);

                case AvoidanceType.MoltenBall:
                    return(avoidanceHealth.AvoidMoltenBallHealth);

                case AvoidanceType.MoltenCore:
                    return(avoidanceHealth.AvoidMoltenCoreHealth);

                case AvoidanceType.MoltenTrail:
                    return(avoidanceHealth.AvoidMoltenTrailHealth);

                case AvoidanceType.Mortar:
                    return(0.25f);

                case AvoidanceType.PlagueCloud:
                    return(avoidanceHealth.AvoidPlagueCloudHealth);

                case AvoidanceType.PlagueHand:
                    return(avoidanceHealth.AvoidPlagueHandsHealth);

                case AvoidanceType.PoisonEnchanted:
                    return(avoidanceHealth.AvoidPoisonEnchantedHealth);

                case AvoidanceType.PoisonTree:
                    return(avoidanceHealth.AvoidPoisonTreeHealth);

                case AvoidanceType.ShamanFire:
                    return(avoidanceHealth.AvoidShamanFireHealth);

                case AvoidanceType.Thunderstorm:
                    return(avoidanceHealth.AvoidThunderstormHealth);

                case AvoidanceType.Wormhole:
                    return(avoidanceHealth.AvoidWormholeHealth);

                case AvoidanceType.ZoltBubble:
                    return(avoidanceHealth.AvoidZoltBubbleHealth);

                case AvoidanceType.ZoltTwister:
                    return(avoidanceHealth.AvoidZoltTwisterHealth);

                default:
                {
                    //Logger.Log(TrinityLogLevel.Error, LogCategory.Avoidance, "Unknown Avoidance type in Health Switch! {0}", type.ToString());
                    return(defaultValue);
                }
                }
            }
            return(defaultValue);
        }
 public Trinity()
 {
     _instance = this;
     Helpers.PluginCheck.CheckAndInstallTrinityRoutine();
 }
Exemple #7
0
        /// <summary>
        /// Find fresh targets, start main BehaviorTree if needed, cast any buffs needed etc.
        /// </summary>
        /// <param name="ret"></param>
        /// <returns></returns>
        internal static bool TargetCheck(object ret)
        {
            using (new PerformanceLogger("TargetCheck"))
            {
                // If we aren't in the game or a world is loading, don't do anything yet
                if (!ZetaDia.IsInGame || !ZetaDia.Me.IsValid || ZetaDia.IsLoadingWorld)
                {
                    return(false);
                }

                // 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.Me.Inventory.Equipped.Any() &&
                    ZetaDia.Me.Inventory.Equipped.Average(i => i.DurabilityPercent) < 0.05 && !ZetaDia.IsInTown)
                {
                    Logger.Log("Durability is zero, emergency leave game");
                    ZetaDia.Service.Party.LeaveGame(true);
                    Thread.Sleep(11000);
                    return(false);
                }

                if (ZetaDia.Me.IsDead)
                {
                    return(false);
                }

                if (GoldInactivity.Instance.GoldInactive())
                {
                    BotMain.PauseWhile(GoldInactivity.Instance.GoldInactiveLeaveGame);
                    return(false);
                }

                if (!HotbarRefreshTimer.IsRunning)
                {
                    HotbarRefreshTimer.Start();
                }

                if (!HasMappedPlayerAbilities || HotbarRefreshTimer.ElapsedMilliseconds > 1000 || ShouldRefreshHotbarAbilities)
                {
                    PlayerInfoCache.RefreshHotbar();
                    // Pick an appropriate health set etc. based on class
                    switch (Player.ActorClass)
                    {
                    case ActorClass.Barbarian:
                        PlayerEmergencyHealthPotionLimit = Settings.Combat.Barbarian.PotionLevel;
                        _playerEmergencyHealthGlobeLimit = Settings.Combat.Barbarian.HealthGlobeLevel;
                        CombatBase.PlayerKiteDistance    = Settings.Combat.Barbarian.KiteLimit;
                        CombatBase.PlayerKiteMode        = Config.Combat.KiteMode.Never;
                        break;

                    case ActorClass.Crusader:
                        PlayerEmergencyHealthPotionLimit = Settings.Combat.Crusader.PotionLevel;
                        _playerEmergencyHealthGlobeLimit = Settings.Combat.Crusader.HealthGlobeLevel;
                        CombatBase.PlayerKiteDistance    = 0;
                        CombatBase.PlayerKiteMode        = Config.Combat.KiteMode.Never;
                        break;

                    case ActorClass.Monk:
                        PlayerEmergencyHealthPotionLimit = Settings.Combat.Monk.PotionLevel;
                        _playerEmergencyHealthGlobeLimit = Settings.Combat.Monk.HealthGlobeLevel;
                        // Monks never kite :)
                        CombatBase.PlayerKiteDistance = 0;
                        CombatBase.PlayerKiteMode     = Config.Combat.KiteMode.Never;
                        break;

                    case ActorClass.Wizard:
                        PlayerEmergencyHealthPotionLimit = Settings.Combat.Wizard.PotionLevel;
                        _playerEmergencyHealthGlobeLimit = Settings.Combat.Wizard.HealthGlobeLevel;
                        CombatBase.PlayerKiteDistance    = Settings.Combat.Wizard.KiteLimit;
                        CombatBase.PlayerKiteMode        = Config.Combat.KiteMode.Always;
                        break;

                    case ActorClass.Witchdoctor:
                        PlayerEmergencyHealthPotionLimit = Settings.Combat.WitchDoctor.PotionLevel;
                        _playerEmergencyHealthGlobeLimit = Settings.Combat.WitchDoctor.HealthGlobeLevel;
                        CombatBase.PlayerKiteDistance    = Settings.Combat.WitchDoctor.KiteLimit;
                        CombatBase.PlayerKiteMode        = Config.Combat.KiteMode.Always;
                        break;

                    case ActorClass.DemonHunter:
                        PlayerEmergencyHealthPotionLimit = Settings.Combat.DemonHunter.PotionLevel;
                        _playerEmergencyHealthGlobeLimit = Settings.Combat.DemonHunter.HealthGlobeLevel;
                        CombatBase.PlayerKiteDistance    = Settings.Combat.DemonHunter.KiteLimit;
                        CombatBase.PlayerKiteMode        = Settings.Combat.DemonHunter.KiteMode;
                        break;
                    }
                }
                // Clear target current and reset key variables used during the target-handling function

                //CurrentTarget = null;
                DontMoveMeIAmDoingShit = false;
                _timesBlockedMoving    = 0;
                IsAlreadyMoving        = false;
                lastMovementCommand    = DateTime.MinValue;
                _isWaitingForPower     = false;
                _isWaitingAfterPower   = false;
                _isWaitingForPotion    = false;
                wasRootedLastTick      = false;

                ClearBlacklists();

                using (new PerformanceLogger("TargetCheck.RefreshCache"))
                {
                    // Refresh Cache if needed
                    RefreshDiaObjectCache();
                }

                // We have a target, start the target handler!
                if (CurrentTarget != null)
                {
                    _isWholeNewTarget       = true;
                    DontMoveMeIAmDoingShit  = true;
                    _shouldPickNewAbilities = true;
                    return(true);
                }

                // if we just opened a horadric cache, wait around to open it
                if (DateTime.UtcNow.Subtract(Composites.LastFoundHoradricCache).TotalSeconds < 5)
                {
                    return(true);
                }

                using (new PerformanceLogger("TargetCheck.OOCPotion"))
                {
                    // Pop a potion when necessary
                    if (Player.CurrentHealthPct <= PlayerEmergencyHealthPotionLimit)
                    {
                        Trinity.UsePotionIfNeeded();
                    }
                }
                _statusText = "[Trinity] No more targets - DemonBuddy/profile management is now in control";

                if (Settings.Advanced.DebugInStatusBar && _resetStatusText)
                {
                    _resetStatusText   = false;
                    BotMain.StatusText = _statusText;
                }

                // Nothing to do... do we have some maintenance we can do instead, like out of combat buffing?

                if (DateTime.UtcNow.Subtract(lastMaintenanceCheck).TotalMilliseconds > 150)
                {
                    using (new PerformanceLogger("TargetCheck.OOCBuff"))
                    {
                        lastMaintenanceCheck = DateTime.UtcNow;

                        bool isLoopingAnimation = ZetaDia.Me.LoopingAnimationEndTime > 0;

                        if (!isLoopingAnimation && !IsReadyToTownRun && !ForceVendorRunASAP)
                        {
                            BarbarianCombat.AllowSprintOOC = true;
                            DisableOutofCombatSprint       = false;

                            powerBuff = AbilitySelector(false, true, false);

                            if (powerBuff.SNOPower != SNOPower.None)
                            {
                                Logger.Log(TrinityLogLevel.Verbose, LogCategory.Behavior, "Using OOC Buff: {0}", powerBuff.SNOPower.ToString());
                                if (powerBuff.WaitTicksBeforeUse > 0)
                                {
                                    BotMain.PauseFor(new TimeSpan(0, 0, 0, 0, (int)powerBuff.WaitBeforeUseDelay));
                                }
                                ZetaDia.Me.UsePower(powerBuff.SNOPower, powerBuff.TargetPosition, powerBuff.TargetDynamicWorldId, powerBuff.TargetACDGUID);
                                LastPowerUsed = powerBuff.SNOPower;
                                CacheData.AbilityLastUsed[powerBuff.SNOPower] = DateTime.UtcNow;
                                if (powerBuff.WaitTicksAfterUse > 0)
                                {
                                    BotMain.PauseFor(new TimeSpan(0, 0, 0, 0, (int)powerBuff.WaitAfterUseDelay));
                                }
                            }
                        }
                        else if (isLoopingAnimation)
                        {
                            _keepKillRadiusExtendedForSeconds = 20;
                            _timeKeepKillRadiusExtendedUntil  = DateTime.UtcNow.AddSeconds(_keepKillRadiusExtendedForSeconds);
                        }
                    }
                }
                CurrentTarget = null;

                if ((Trinity.ForceVendorRunASAP || Trinity.IsReadyToTownRun) && TownRun.TownRunTimerRunning())
                {
                    Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "Waiting for town run timer (Target Check)", true);
                    return(true);
                }

                // Ok let DemonBuddy do stuff this loop, since we're done for the moment
                //DbHelper.Log(TrinityLogLevel.Verbose, LogCategory.GlobalHandler, sStatusText);

                return(false);
            }
        }
        /// <summary>
        /// Log the nice items we found and stashed
        /// </summary>
        internal static void LogGoodItems(CachedACDItem acdItem, GItemBaseType itemBaseType, GItemType itemType, double itemValue)
        {
            FileStream LogStream = null;

            try
            {
                string filePath = Path.Combine(FileManager.LoggingPath, "StashLog - " + Trinity.Player.ActorClass.ToString() + ".log");
                LogStream = File.Open(filePath, FileMode.Append, FileAccess.Write, FileShare.Read);

                //TODO : Change File Log writing
                using (StreamWriter LogWriter = new StreamWriter(LogStream))
                {
                    if (!_loggedAnythingThisStash)
                    {
                        _loggedAnythingThisStash = true;
                        LogWriter.WriteLine(DateTime.Now.ToString() + ":");
                        LogWriter.WriteLine("====================");
                    }
                    string sLegendaryString        = "";
                    bool   shouldSendNotifications = false;
                    if (acdItem.Quality >= ItemQuality.Legendary)
                    {
                        if (!Trinity.Settings.Notification.LegendaryScoring)
                        {
                            shouldSendNotifications = true;
                        }
                        else if (Trinity.Settings.Notification.LegendaryScoring && Trinity.CheckScoreForNotification(itemBaseType, itemValue))
                        {
                            shouldSendNotifications = true;
                        }
                        if (shouldSendNotifications)
                        {
                            NotificationManager.AddNotificationToQueue(acdItem.RealName + " [" + itemType.ToString() +
                                                                       "] (Score=" + itemValue.ToString() + ". " + ValueItemStatString + ")",
                                                                       ZetaDia.Service.Hero.Name + " new legendary!", ProwlNotificationPriority.Emergency);
                        }
                        sLegendaryString = " {legendary item}";

                        // Change made by bombastic
                        Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "+=+=+=+=+=+=+=+=+ LEGENDARY FOUND +=+=+=+=+=+=+=+=+");
                        Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "+  Name:       {0} ({1})", acdItem.RealName, itemType);
                        Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "+  Score:       {0:0}", itemValue);
                        Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "+  Attributes: {0}", ValueItemStatString);
                        Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+");
                    }
                    else
                    {
                        // Check for non-legendary notifications
                        shouldSendNotifications = Trinity.CheckScoreForNotification(itemBaseType, itemValue);
                        if (shouldSendNotifications)
                        {
                            NotificationManager.AddNotificationToQueue(acdItem.RealName + " [" + itemType.ToString() + "] (Score=" + itemValue.ToString() + ". " + ValueItemStatString + ")", ZetaDia.Service.Hero.Name + " new item!", ProwlNotificationPriority.Emergency);
                        }
                    }
                    if (shouldSendNotifications)
                    {
                        NotificationManager.EmailMessage.AppendLine(itemBaseType.ToString() + " - " + itemType.ToString() + " '" + acdItem.RealName + "'. Score = " + Math.Round(itemValue).ToString() + sLegendaryString)
                        .AppendLine("  " + ValueItemStatString)
                        .AppendLine();
                    }
                    LogWriter.WriteLine(itemBaseType.ToString() + " - " + itemType.ToString() + " '" + acdItem.RealName + "'. Score = " + Math.Round(itemValue).ToString() + sLegendaryString);
                    LogWriter.WriteLine("  " + ValueItemStatString);
                    LogWriter.WriteLine("");
                }
                LogStream.Close();
            }
            catch (IOException)
            {
                Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "Fatal Error: File access error for stash log file.");
                if (LogStream != null)
                {
                    LogStream.Close();
                }
            }
        }
Exemple #9
0
 public Trinity()
 {
     _instance = this;
     PluginCheck.CheckAndInstallTrinityRoutine();
 }
Exemple #10
0
        public CachedACDItem(
            ACDItem acdItem,
            string internalName,
            string realName,
            int level,
            ItemQuality quality,
            int goldAmount,
            int balanceId,
            int dynamicId,
            float dps,
            bool oneHanded,
            bool twoHanded,
            DyeType dyeType,
            ItemType itemType,
            ItemBaseType itembasetype,
            FollowerType followerType,
            bool unidentified,
            int stackQuantity,
            ItemStats itemStats)
        {
            AcdItem           = acdItem;
            InternalName      = internalName;
            RealName          = realName;
            Level             = level;
            Quality           = quality;
            GoldAmount        = goldAmount;
            BalanceID         = balanceId;
            DynamicID         = dynamicId;
            WeaponDPS         = dps;
            OneHanded         = oneHanded;
            TwoHanded         = twoHanded;
            DyeType           = dyeType;
            DBItemType        = itemType;
            DBBaseType        = itembasetype;
            FollowerType      = followerType;
            IsUnidentified    = unidentified;
            ItemStackQuantity = stackQuantity;

            Dexterity                      = itemStats.Dexterity;
            Intelligence                   = itemStats.Intelligence;
            Strength                       = itemStats.Strength;
            Vitality                       = itemStats.Vitality;
            LifePercent                    = itemStats.LifePercent;
            LifeOnHit                      = itemStats.LifeOnHit;
            LifeSteal                      = itemStats.LifeSteal;
            HealthPerSecond                = itemStats.HealthPerSecond;
            MagicFind                      = itemStats.MagicFind;
            GoldFind                       = itemStats.GoldFind;
            MovementSpeed                  = itemStats.MovementSpeed;
            PickUpRadius                   = itemStats.PickUpRadius;
            Sockets                        = itemStats.Sockets;
            CritPercent                    = itemStats.CritPercent;
            CritDamagePercent              = itemStats.CritDamagePercent;
            AttackSpeedPercent             = itemStats.AttackSpeedPercent;
            MinDamage                      = itemStats.MinDamage;
            MaxDamage                      = itemStats.MaxDamage;
            BlockChance                    = itemStats.BlockChance;
            Thorns                         = itemStats.Thorns;
            ResistAll                      = itemStats.ResistAll;
            ResistArcane                   = itemStats.ResistArcane;
            ResistCold                     = itemStats.ResistCold;
            ResistFire                     = itemStats.ResistFire;
            ResistHoly                     = itemStats.ResistHoly;
            ResistLightning                = itemStats.ResistLightning;
            ResistPhysical                 = itemStats.ResistPhysical;
            ResistPoison                   = itemStats.ResistPoison;
            WeaponDamagePerSecond          = itemStats.WeaponDamagePerSecond;
            ArmorBonus                     = itemStats.ArmorBonus;
            MaxDiscipline                  = itemStats.MaxDiscipline;
            MaxMana                        = itemStats.MaxMana;
            ArcaneOnCrit                   = itemStats.ArcaneOnCrit;
            ManaRegen                      = itemStats.ManaRegen;
            GlobeBonus                     = itemStats.HealthGlobeBonus;
            HatredRegen                    = itemStats.HatredRegen;
            MaxFury                        = itemStats.MaxFury;
            SpiritRegen                    = itemStats.SpiritRegen;
            MaxSpirit                      = itemStats.MaxSpirit;
            HealthPerSpiritSpent           = itemStats.HealthPerSpiritSpent;
            MaxArcanePower                 = itemStats.MaxArcanePower;
            DamageReductionPhysicalPercent = itemStats.DamageReductionPhysicalPercent;
            ArmorTotal                     = itemStats.ArmorTotal;
            Armor = itemStats.Armor;
            //FireDamagePercent = itemStats.FireDamagePercent;
            //LightningDamagePercent = itemStats.LightningDamagePercent;
            //ColdDamagePercent = itemStats.ColdDamagePercent;
            //PoisonDamagePercent = itemStats.PoisonDamagePercent;
            //ArcaneDamagePercent = itemStats.ArcaneDamagePercent;
            //HolyDamagePercent = itemStats.HolyDamagePercent;
            HealthGlobeBonus       = itemStats.HealthGlobeBonus;
            WeaponAttacksPerSecond = itemStats.WeaponAttacksPerSecond;
            WeaponMaxDamage        = itemStats.WeaponMaxDamage;
            WeaponMinDamage        = itemStats.WeaponMinDamage;

            TrinityItemType     = Trinity.DetermineItemType(internalName, itemType, followerType);
            TrinityItemBaseType = Trinity.DetermineBaseType(TrinityItemType);

            ComputeUpgrade();
        }
Exemple #11
0
 internal static void TrinityOnOnItemIdentificationRequest(object sender, ItemIdentifyRequestEventArgs e)
 {
     e.IgnoreIdentification = !Trinity.ItemRulesIdentifyValidation(e.Item);
 }
Exemple #12
0
        private bool TrinitySalvage(ACDItem item)
        {
            CachedACDItem cItem = CachedACDItem.GetCachedItem(item);

            if (cItem.AcdItem.IsVendorBought)
            {
                return(false);
            }

            // Vanity Items
            if (DataDictionary.VanityItems.Any(i => item.InternalName.StartsWith(i)))
            {
                return(false);
            }

            GItemType     trinityItemType     = Trinity.DetermineItemType(cItem.InternalName, cItem.DBItemType, cItem.FollowerType);
            GItemBaseType trinityItemBaseType = Trinity.DetermineBaseType(trinityItemType);

            // Take Salvage Option corresponding to ItemLevel
            SalvageOption salvageOption = GetSalvageOption(cItem.Quality);

            // Stashing Whites
            if (Trinity.Settings.Loot.TownRun.StashWhites && cItem.Quality < ItemQuality.Magic1)
            {
                return(false);
            }

            // Stashing Blues
            if (Trinity.Settings.Loot.TownRun.StashBlues && cItem.Quality > ItemQuality.Superior && cItem.Quality < ItemQuality.Rare4)
            {
                return(false);
            }

            if (cItem.Quality >= ItemQuality.Legendary && salvageOption == SalvageOption.InfernoOnly && cItem.Level >= 60)
            {
                return(true);
            }

            switch (trinityItemBaseType)
            {
            case GItemBaseType.WeaponRange:
            case GItemBaseType.WeaponOneHand:
            case GItemBaseType.WeaponTwoHand:
            case GItemBaseType.Armor:
            case GItemBaseType.Offhand:
                return((cItem.Level >= 61 && salvageOption == SalvageOption.InfernoOnly) || salvageOption == SalvageOption.All);

            case GItemBaseType.Jewelry:
                return((cItem.Level >= 59 && salvageOption == SalvageOption.InfernoOnly) || salvageOption == SalvageOption.All);

            case GItemBaseType.FollowerItem:
                return((cItem.Level >= 60 && salvageOption == SalvageOption.InfernoOnly) || salvageOption == SalvageOption.All);

            case GItemBaseType.Gem:
            case GItemBaseType.Misc:
            case GItemBaseType.Unknown:
                return(false);

            default:
                return(false);
            }
        }
Exemple #13
0
        public bool ShouldStashItem(ACDItem item, ItemEvaluationType evaluationType)
        {
            ItemEvents.ResetTownRun();

            if (Current.ItemIsProtected(item))
            {
                return(false);
            }

            // Vanity Items
            if (DataDictionary.VanityItems.Any(i => item.InternalName.StartsWith(i)))
            {
                return(false);
            }

            if (Trinity.Settings.Loot.ItemFilterMode == ItemFilterMode.DemonBuddy)
            {
                return(ItemManager.Current.ShouldStashItem(item));
            }

            CachedACDItem cItem = CachedACDItem.GetCachedItem(item);

            // Now look for Misc items we might want to keep
            GItemType     tItemType = cItem.TrinityItemType;     // DetermineItemType(cItem.InternalName, cItem.DBItemType, cItem.FollowerType);
            GItemBaseType tBaseType = cItem.TrinityItemBaseType; // DetermineBaseType(trinityItemType);

            bool isEquipment = (tBaseType == GItemBaseType.Armor ||
                                tBaseType == GItemBaseType.Jewelry ||
                                tBaseType == GItemBaseType.Offhand ||
                                tBaseType == GItemBaseType.WeaponOneHand ||
                                tBaseType == GItemBaseType.WeaponRange ||
                                tBaseType == GItemBaseType.WeaponTwoHand);

            if (cItem.TrinityItemType == GItemType.HoradricCache && Trinity.Settings.Loot.TownRun.OpenHoradricCaches)
            {
                Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0} [{1}] = (ignoring Horadric Cache)", cItem.RealName, cItem.InternalName);
                return(false);
            }

            // Stash all unidentified items - assume we want to keep them since we are using an identifier over-ride
            if (cItem.IsUnidentified)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0} [{1}] = (autokeep unidentified items)", cItem.RealName, cItem.InternalName);
                }
                return(true);
            }
            if (tItemType == GItemType.StaffOfHerding)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    Logger.Log(TrinityLogLevel.Info, LogCategory.ItemValuation, "{0} [{1}] [{2}] = (autokeep staff of herding)", cItem.RealName, cItem.InternalName, tItemType);
                }
                return(true);
            }
            if (tItemType == GItemType.CraftingMaterial)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    Logger.Log(TrinityLogLevel.Info, LogCategory.ItemValuation, "{0} [{1}] [{2}] = (autokeep craft materials)", cItem.RealName, cItem.InternalName, tItemType);
                }
                return(true);
            }

            if (tItemType == GItemType.Emerald || tItemType == GItemType.Amethyst || tItemType == GItemType.Topaz || tItemType == GItemType.Ruby || tItemType == GItemType.Diamond)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    Logger.Log(TrinityLogLevel.Info, LogCategory.ItemValuation, "{0} [{1}] [{2}] = (autokeep gems)", cItem.RealName, cItem.InternalName, tItemType);
                }
                return(true);
            }
            if (tItemType == GItemType.CraftTome)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    Logger.Log(TrinityLogLevel.Info, LogCategory.ItemValuation, "{0} [{1}] [{2}] = (autokeep tomes)", cItem.RealName, cItem.InternalName, tItemType);
                }
                return(true);
            }
            if (tItemType == GItemType.InfernalKey)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0} [{1}] [{2}] = (autokeep infernal key)", cItem.RealName, cItem.InternalName, tItemType);
                }
                return(true);
            }
            if (tItemType == GItemType.HealthPotion)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    Logger.Log(TrinityLogLevel.Info, LogCategory.ItemValuation, "{0} [{1}] [{2}] = (ignoring potions)", cItem.RealName, cItem.InternalName, tItemType);
                }
                return(false);
            }

            if (tItemType == GItemType.CraftingPlan && cItem.Quality >= ItemQuality.Legendary)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0} [{1}] [{2}] = (autokeep legendary plans)", cItem.RealName, cItem.InternalName, tItemType);
                }
                return(true);
            }

            if (Trinity.Settings.Loot.ItemFilterMode == ItemFilterMode.TrinityWithItemRules)
            {
                Interpreter.InterpreterAction action = Trinity.StashRule.checkItem(item, evaluationType);

                if (evaluationType == ItemEvaluationType.Keep)
                {
                    Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0} [{1}] [{2}] = (" + action + ")", cItem.AcdItem.Name, cItem.AcdItem.InternalName, cItem.AcdItem.ItemType);
                }
                switch (action)
                {
                case Interpreter.InterpreterAction.KEEP:
                    return(true);

                case Interpreter.InterpreterAction.TRASH:
                    return(false);

                case Interpreter.InterpreterAction.SCORE:
                    break;
                }
            }

            if (tItemType == GItemType.CraftingPlan)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0} [{1}] [{2}] = (autokeep plans)", cItem.RealName, cItem.InternalName, tItemType);
                }
                return(true);
            }

            // Stashing Whites, auto-keep
            if (Trinity.Settings.Loot.TownRun.StashWhites && isEquipment && cItem.Quality <= ItemQuality.Superior)
            {
                Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0} [{1}] [{2}] = (stashing whites)", cItem.RealName, cItem.InternalName, tItemType);
                return(true);
            }
            // Else auto-trash
            if (cItem.Quality <= ItemQuality.Superior && (isEquipment || cItem.TrinityItemBaseType == GItemBaseType.FollowerItem))
            {
                Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0} [{1}] [{2}] = (trash whites)", cItem.RealName, cItem.InternalName, tItemType);
                return(false);
            }

            // Stashing blues, auto-keep
            if (Trinity.Settings.Loot.TownRun.StashBlues && isEquipment && cItem.Quality >= ItemQuality.Magic1 && cItem.Quality <= ItemQuality.Magic3)
            {
                Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0} [{1}] [{2}] = (stashing blues)", cItem.RealName, cItem.InternalName, tItemType);
                return(true);
            }
            // Else auto trash
            if (cItem.Quality >= ItemQuality.Magic1 && cItem.Quality <= ItemQuality.Magic3 && (isEquipment || cItem.TrinityItemBaseType == GItemBaseType.FollowerItem))
            {
                Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0} [{1}] [{2}] = (trashing blues)", cItem.RealName, cItem.InternalName, tItemType);
                return(false);
            }

            // Force salvage Rares
            if (Trinity.Settings.Loot.TownRun.ForceSalvageRares && cItem.Quality >= ItemQuality.Rare4 && cItem.Quality <= ItemQuality.Rare6 && (isEquipment || cItem.TrinityItemBaseType == GItemBaseType.FollowerItem))
            {
                Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0} [{1}] [{2}] = (force salvage rare)", cItem.RealName, cItem.InternalName, tItemType);
                return(false);
            }

            if (cItem.Quality >= ItemQuality.Legendary)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0} [{1}] [{2}] = (autokeep legendaries)", cItem.RealName, cItem.InternalName, tItemType);
                }
                return(true);
            }

            // Ok now try to do some decent item scoring based on item types
            double iNeedScore = Trinity.ScoreNeeded(item.ItemBaseType);
            double iMyScore   = ItemValuation.ValueThisItem(cItem, tItemType);

            if (evaluationType == ItemEvaluationType.Keep)
            {
                Logger.Log(TrinityLogLevel.Verbose, LogCategory.ItemValuation, "{0} [{1}] [{2}] = {3}", cItem.RealName, cItem.InternalName, tItemType, iMyScore);
            }
            if (iMyScore >= iNeedScore)
            {
                return(true);
            }

            // If we reached this point, then we found no reason to keep the item!
            return(false);
        }