コード例 #1
0
 private bool TownRun()
 {
     Logger.Debug("[TownRun] BrainBehavior.IsVendoring is {0}", BrainBehavior.IsVendoring);
     Logger.Debug("[TownRun] ZetaDia.Me.IsParticipatingInTieredLootRun is {0}", ZetaDia.Me.IsParticipatingInTieredLootRun);
     Logger.Debug("[TownRun] AdvDia.RiftQuest.State is {0}", AdvDia.RiftQuest.State);
     Logger.Debug("[TownRun] AdvDia.RiftQuest.Step is {0}", AdvDia.RiftQuest.Step);
     DisablePulse();
     if (BrainBehavior.IsVendoring)
     {
         return(false);
     }
     if (!_townRunInitiated)
     {
         _townRunInitiated = true;
         BrainBehavior.ForceTownrun(" We need it.", true);
         return(false);
     }
     _townRunInitiated = false;
     if (AdvDia.RiftQuest.Step == RiftStep.Completed)
     {
         State = States.WaitForRiftCountdown;
         Logger.Info("[Rift] Tick tock, tick tock...");
     }
     else
     {
         State = States.NotStarted;
         _moveToRiftStoneCoroutine.Reset();
     }
     return(false);
 }
コード例 #2
0
        public static async Task <bool> Execute()
        {
            if (Core.Settings.Items.StashTreasureBags)
            {
                return(false);
            }

            var bagsOpened = 0;

            if (Core.Player.IsInTown)
            {
                foreach (var item in InventoryManager.Backpack.ToList())
                {
                    if (item.GetRawItemType() == RawItemType.TreasureBag)
                    {
                        Core.Logger.Log($"Opening Treasure Bag {bagsOpened + 1}, Id={item.AnnId}");
                        InventoryManager.UseItem(item.AnnId);
                        bagsOpened++;
                        await Coroutine.Yield();
                    }
                }
                if (bagsOpened > 0)
                {
                    Core.Logger.Log($"Waiting for Treasure Bag loot");
                    await Coroutine.Yield();

                    BrainBehavior.ForceTownrun(nameof(OpenTreasureBags));
                    return(true);
                }
            }
            return(false);
        }
コード例 #3
0
 protected override Composite CreateBehavior()
 {
     return(new Action(ret =>
     {
         BrainBehavior.ForceTownrun("Town-run request received, will town-run at next possible moment.");
         m_IsDone = true;
     }));
 }
コード例 #4
0
ファイル: Coordination.cs プロジェクト: dachidahu/AutoFollow
 /// <summary>
 /// If the leader is currently vendoring, start a town run on this bot as well.
 /// </summary>
 public static async Task <bool> StartTownRunWithLeader()
 {
     if (AutoFollow.CurrentLeader.IsVendoring && !Player.IsVendoring)
     {
         BrainBehavior.ForceTownrun("Townrun with Leader");
         return(true);
     }
     return(false);
 }
コード例 #5
0
ファイル: RiftCoroutine.cs プロジェクト: honorbuddy/Trinity
        public static async Task <bool> RunRift(RiftType riftType,
                                                int maxLevel,
                                                int maxEmpowerLevel,
                                                bool shouldEmpower,
                                                bool runNormalUntilXP)
        {
            if (!ZetaDia.IsInGame ||
                ZetaDia.Globals.IsLoadingWorld ||
                ZetaDia.Globals.IsPlayingCutscene)
            {
                return(false);
            }

            CoroutineResult previousResult;

            if ((previousResult = await TurnInQuest()) == CoroutineResult.Running)
            {
                return(false);
            }

            if (BrainBehavior.IsVendoring &&
                previousResult != CoroutineResult.NoAction)
            {
                return(false);
            }

            // TODO: Decide if we want to run the cow level
            //if (!await ClearCowLevel())
            //    return false;

            if (!await OpenRift(
                    riftType,
                    maxLevel,
                    maxEmpowerLevel,
                    shouldEmpower,
                    runNormalUntilXP))
            {
                return(false);
            }

            if (!await ClearRift())
            {
                return(false);
            }

            if (await UpgradeGems() == CoroutineResult.Running)
            {
                return(false);
            }

            s_logger.Information("Rift done, let's force a town run...");
            BrainBehavior.ForceTownrun(nameof(RiftCoroutine));
            PreviousWorld = SNOWorld.Invalid;
            PreviousLevel = SNOLevelArea.Invalid;
            return(true);
        }
コード例 #6
0
        public override RunStatus Interact()
        {
            //Only validate if we can pickup if slots are minimum
            if (Bot.Character.Data.FreeBackpackSlots <= 8)
            {
                if (ref_DiaItem != null && ref_DiaItem.BaseAddress != IntPtr.Zero)
                {
                    if (!BrainBehavior.CanPickUpItem(ref_DiaItem))
                    {
                        TownRunManager.bFailedToLootLastItem = true;
                        BrainBehavior.ForceTownrun("No more space to pickup item");
                        return(RunStatus.Success);
                    }
                }
                else
                {
                    return(RunStatus.Success);
                }
            }

            // Force waiting for global cooldown timer or long-animation abilities
            if (Bot.Character.Class.PowerPrime.WaitLoopsBefore >= 1)
            {
                //Logger.DBLog.DebugFormat("Debug: Force waiting BEFORE Ability " + powerPrime.powerThis.ToString() + "...");
                Bot.Targeting.Cache.bWaitingForPower = true;
                if (Bot.Character.Class.PowerPrime.WaitLoopsBefore >= 1)
                {
                    Bot.Character.Class.PowerPrime.WaitLoopsBefore--;
                }
                return(RunStatus.Running);
            }
            Bot.Targeting.Cache.bWaitingForPower = false;

            if (!Bot.Targeting.Cache.ShouldCheckItemLooted)
            {
                Bot.Targeting.Cache.ShouldCheckItemLooted = true;
                Bot.Character.Data.BackPack.Update();
                if (Bot.Character.Data.BackPack.CacheItemList.ContainsKey(AcdGuid.Value))
                {
                    Bot.Targeting.Cache.CheckItemLootStackCount = Bot.Character.Data.BackPack.CacheItemList[AcdGuid.Value].ThisItemStackQuantity;
                }
            }

            // Pick the item up the usepower way, and "blacklist" for a couple of loops
            Bot.Character.Data.WaitWhileAnimating(20);
            ZetaDia.Me.UsePower(SNOPower.Axe_Operate_Gizmo, Vector3.Zero, Bot.Character.Data.iCurrentWorldID, AcdGuid.Value);
            Bot.NavigationCache.lastChangedZigZag        = DateTime.Today;
            Bot.NavigationCache.vPositionLastZigZagCheck = Vector3.Zero;



            Bot.Character.Data.WaitWhileAnimating(5, true);
            return(RunStatus.Running);
        }
コード例 #7
0
        protected override Composite CreateBehavior()
        {
            return(new Action(ret =>
            {
                if (!BrainBehavior.IsVendoring && (ZetaDia.Me.Inventory.NumFreeBackpackSlots <= SlotsUnused || Backpack.ShouldRepairItems(MinimumDurability)))
                {
                    BrainBehavior.ForceTownrun("Forcing Town Run!");
                }

                m_IsDone = true;
            }));
        }
コード例 #8
0
 /// <summary>
 /// If the leader is currently vendoring, start a town run on this bot as well.
 /// </summary>
 public static async Task <bool> StartTownRunWithLeader()
 {
     if (AutoFollow.CurrentLeader.IsVendoring && !Player.IsVendoring)
     {
         if (DateTime.UtcNow.Subtract(_lastTownRunWithLeaderTime).TotalSeconds > 5)
         {
             BrainBehavior.ForceTownrun("Townrun with Leader");
             _lastTownRunWithLeaderTime = DateTime.UtcNow;
             return(true);
         }
     }
     return(false);
 }
コード例 #9
0
ファイル: Gamble.cs プロジェクト: ysj1995/Trinity
        public static async Task <bool> Execute()
        {
            if (!ZetaDia.IsInTown)
            {
                IsDumpingShards = false;
            }

            try
            {
                while (CanRun() && (!StillSavingShards || IsDumpingShards))
                {
                    IsDumpingShards = true;
                    if ((TownInfo.Kadala.Distance > 8f || !UIElements.VendorWindow.IsVisible) && !await MoveToAndInteract.Execute(TownInfo.Kadala))
                    {
                        Core.Logger.Log("[Gamble] Failed to move to Kadala, quite unfortunate.");
                        break;
                    }

                    if (CanBuyItems)
                    {
                        await BuyItem();
                    }
                    else
                    {
                        GameUI.CloseVendorWindow();
                    }

                    if (TrinityCombat.Loot.IsBackpackFull)
                    {
                        BrainBehavior.ForceTownrun();
                    }

                    await Coroutine.Sleep(100);

                    await Coroutine.Yield();
                }
            }
            catch (Exception ex)
            {
                Core.Logger.Error("Exception in Gamble.Execute, {0}", ex);

                if (ex is CoroutineStoppedException)
                {
                    throw;
                }
            }

            GameUI.CloseVendorWindow();

            return(true);
        }
コード例 #10
0
        public override RunStatus Interact()
        {
            //Only validate if we can pickup if slots are minimum
            if (FunkyGame.Hero.FreeBackpackSlots <= 8)
            {
                if (ref_DiaItem != null && ref_DiaItem.BaseAddress != IntPtr.Zero)
                {
                    if (!Backpack.CanPickupItem(IsTwoSlot))//(!BrainBehavior.CanPickUpItem(ref_DiaItem))
                    {
                        FunkyGame.Targeting.Cache.bFailedToLootLastItem = true;
                        BrainBehavior.ForceTownrun("No more space to pickup item");
                        return(RunStatus.Success);
                    }
                }
                else
                {
                    return(RunStatus.Success);
                }
            }

            // Force waiting for global cooldown timer or long-animation abilities
            if (FunkyGame.Hero.Class.PowerPrime.WaitLoopsBefore >= 1)
            {
                //Logger.DBLog.DebugFormat("Debug: Force waiting BEFORE Ability " + powerPrime.powerThis.ToString() + "...");
                FunkyGame.Targeting.Cache.bWaitingForPower = true;
                if (FunkyGame.Hero.Class.PowerPrime.WaitLoopsBefore >= 1)
                {
                    FunkyGame.Hero.Class.PowerPrime.WaitLoopsBefore--;
                }
                return(RunStatus.Running);
            }
            FunkyGame.Targeting.Cache.bWaitingForPower = false;

            //This does the inital update of backpack so we can verify loot success during target handler
            if (!FunkyGame.Targeting.Cache.ShouldCheckItemLooted)
            {
                FunkyGame.Targeting.Cache.ShouldCheckItemLooted = true;
                Backpack.UpdateItemList();
            }

            // Pick the item up the usepower way, and "blacklist" for a couple of loops
            FunkyGame.Hero.WaitWhileAnimating(20);
            ZetaDia.Me.UsePower(SNOPower.Axe_Operate_Gizmo, Vector3.Zero, FunkyGame.Hero.CurrentWorldDynamicID, AcdGuid.Value);
            FunkyGame.Navigation.lastChangedZigZag        = DateTime.Today;
            FunkyGame.Navigation.vPositionLastZigZagCheck = Vector3.Zero;



            FunkyGame.Hero.WaitWhileAnimating(5, true);
            return(RunStatus.Running);
        }
コード例 #11
0
        public static async Task <bool> Execute()
        {
            if (!ZetaDia.IsInTown)
            {
                IsDumpingShards = false;
            }

            try
            {
                while (CanRun() && (!ShouldSaveShards || IsDumpingShards))
                {
                    IsDumpingShards = true;

                    var distance = Town.Locations.Kadala.Distance(ZetaDia.Me.Position);
                    if (distance > 8f && !await MoveToAndInteract.Execute(Town.Locations.Kadala, Town.ActorIds.Kadala, 3f))
                    {
                        Logger.Log("[Gamble] Failed to move to Kadala, quite unfortunate.");
                        break;
                    }

                    if (CanBuyItems)
                    {
                        await BuyItem();
                    }
                    else
                    {
                        Resources.GameUI.CloseVendorWindow();
                    }

                    if (!TrinityItemManager.IsAnyTwoSlotBackpackLocation)
                    {
                        BrainBehavior.ForceTownrun();
                    }

                    await Coroutine.Sleep(100);

                    await Coroutine.Yield();
                }
            }
            catch (Exception ex)
            {
                Logger.LogError("Exception in Gamble.Execute, {0}", ex);

                if (ex is CoroutineStoppedException)
                {
                    throw;
                }
            }

            return(true);
        }
コード例 #12
0
        public static void CheckShouldTownRunForGambling()
        {
            if (!ZetaDia.IsInTown)
            {
                IsDumpingShards = false;
            }

            if (Trinity.Trinity.Settings.Gambling.ShouldTownRun && ZetaDia.CPlayer.BloodshardCount >= Math.Min(Trinity.Trinity.Settings.Gambling.SaveShardsThreshold, Trinity.Trinity.Player.MaxBloodShards))
            {
                if (CanRun() && !ShouldSaveShards && !TownRun.IsTryingToTownPortal() && !BrainBehavior.IsVendoring)
                {
                    BrainBehavior.ForceTownrun("Bloodshard Spending Threshold");
                }
            }
        }
コード例 #13
0
ファイル: RiftCoroutine.cs プロジェクト: dachidahu/AutoFollow
        private bool TownRun()
        {
            Logger.Debug("[TownRun] BrainBehavior.IsVendoring is {0}", BrainBehavior.IsVendoring);
            Logger.Debug("[TownRun] ZetaDia.Me.IsParticipatingInTieredLootRun is {0}", ZetaDia.Me.IsParticipatingInTieredLootRun);
            Logger.Debug("[TownRun] AdvDia.RiftQuest.State is {0}", AdvDia.RiftQuest.State);
            Logger.Debug("[TownRun] AdvDia.RiftQuest.Step is {0}", AdvDia.RiftQuest.Step);
            DisablePulse();
            if (BrainBehavior.IsVendoring)
            {
                return(false);
            }
            if (!_townRunInitiated)
            {
                _townRunInitiated = true;
                BrainBehavior.ForceTownrun(" We need it.", true);
                return(false);
            }

            _riftCounter++;
            Logger.Info("Rifts Completed = {0}", _riftCounter);

            if (_options.RiftCount > 0 && _riftCounter >= _options.RiftCount)
            {
                Logger.Info("[Rift] Rift limit set on profile tag reached. ({0})", _options.RiftCount);
                State = States.Completed;
                return(Finished());
            }

            _townRunInitiated = false;
            if (AdvDia.RiftQuest.Step == RiftStep.Completed)
            {
                State = States.WaitForRiftCountdown;
                Logger.Info("[Rift] Tick tock, tick tock...");
            }
            else
            {
                State = States.NotStarted;
                _moveToRiftStoneCoroutine.Reset();
            }
            return(false);
        }
コード例 #14
0
        private bool TownRun()
        {
            if (BrainBehavior.IsVendoring)
            {
                return(false);
            }
            if (!_townRunInitiated)
            {
                _townRunInitiated = true;
                BrainBehavior.ForceTownrun(" We need it.", true);
            }
            if (BrainBehavior.IsVendoring)
            {
                return(false);
            }
            _townRunInitiated = false;

            State = States.MovingToTyrael;

            return(false);
        }
コード例 #15
0
ファイル: TownRunTag.cs プロジェクト: honorbuddy/Trinity
 public override async Task <bool> StartTask()
 {
     BrainBehavior.ForceTownrun(nameof(TownRunTag));
     return(true);
 }
コード例 #16
0
ファイル: DeathHandler.cs プロジェクト: honorbuddy/Trinity
        public static async Task <bool> Execute()
        {
            if (!ZetaDia.IsInGame || ZetaDia.Globals.IsLoadingWorld || !ZetaDia.Me.IsValid)
            {
                return(false);
            }

            if (Core.IsOutOfGame)
            {
                return(false);
            }

            var isDead = ZetaDia.Me.IsDead;

            if (_isDead != isDead)
            {
                if (isDead)
                {
                    _deathCounter            = LastDeathTime.Subtract(DateTime.UtcNow).TotalSeconds > 60 ? 0 : _deathCounter + 1;
                    _deathNeedRepairCounter  = LastDeathTime.Subtract(DateTime.UtcNow).TotalSeconds < 60 && EquipmentNeedsEmergencyRepair(5) ? _deathNeedRepairCounter + 1 : 0;
                    LastDeathTime            = DateTime.UtcNow;
                    _resButtonsVisibleStart  = DateTime.MinValue;
                    _resurrectButtonsVisible = false;
                    _deathLocation           = ZetaDia.Me.Position;
                    DeathsThisSession++;
                    DeathsThisSession++;

                    Core.Logger.Log("[Death] You died lol! RecentDeaths={0} RecentDeathsNeedingRepair={1}", _deathCounter, _deathNeedRepairCounter);
                }
                else
                {
                    Core.Logger.Log("[Death] No Longer Dead");

                    //if (Core.Settings.Combat.Misc.FleeInGhostMode)
                    //{
                    await MoveWhileGhosted();

                    //}

                    if (EquipmentNeedsEmergencyRepair(5))
                    {
                        BrainBehavior.ForceTownrun("[Death] Item Durability - Need to Repair");
                    }
                }
                _isDead = isDead;
            }

            if (!isDead)
            {
                return(false);
            }

            var reviveAtCorpseButton     = UIElement.FromHash(0xE3CBD66296A39588);
            var reviveAtCheckPointButton = UIElement.FromHash(0xBFAAF48BA9316742);
            var acceptRessurectionButton = UIElement.FromHash(0x712D458486D6F062);
            var reviveInTownButton       = UIElement.FromHash(0x7A2AF9C0F3045ADA);
            var needRepair            = EquipmentNeedsEmergencyRepair(5);
            var checkpointButtonReady = reviveAtCheckPointButton.IsVisible && reviveAtCheckPointButton.IsEnabled;
            var corpseButtonReady     = reviveAtCorpseButton.IsVisible && reviveAtCorpseButton.IsEnabled;
            var townButtonReady       = reviveInTownButton.IsVisible && reviveInTownButton.IsEnabled;
            var isInRift                  = GameData.RiftWorldIds.Contains(ZetaDia.Globals.WorldSnoId);
            var isInGreaterRift           = isInRift && ZetaDia.Storage.CurrentRiftType == RiftType.Greater;
            var noMoreCorpseRevives       = !isInGreaterRift && ZetaDia.Me.CommonData.CorpseResurrectionCharges == 0;
            var waitingForCorpseResurrect = ZetaDia.Globals.GameTick < ZetaDia.Me.CommonData.CorpseResurrectionAllowedGameTime;
            var deathCount                = ZetaDia.Me.CommonData.DeathCount;
            var corpseResurrectDisabled   = ZetaDia.Me.CommonData.CorpseResurrectionDisabled > 0;

            if (reviveAtCheckPointButton.IsVisible)
            {
                _resButtonsVisibleStart = DateTime.UtcNow;
            }

            var resurrectButtonsVisible = _resButtonsVisibleStart != DateTime.MinValue;

            if (resurrectButtonsVisible != _resurrectButtonsVisible)
            {
                if (resurrectButtonsVisible)
                {
                    Core.Logger.Verbose("[Death] Buttons are now visible");
                    var maxWaitTime = ZetaDia.Me.IsParticipatingInTieredLootRun ? Math.Min(deathCount * 5, 30) - 2 : 4;
                    _corpseReviveAvailableTime = new DateTime(_resButtonsVisibleStart.Ticks).Add(TimeSpan.FromSeconds(maxWaitTime));
                }
                _resurrectButtonsVisible = resurrectButtonsVisible;
            }

            var remainingTimeSecs = (_corpseReviveAvailableTime - DateTime.UtcNow).TotalSeconds;
            var resLimit          = isInGreaterRift ? 16 : 10;

            if (_deathCounter > resLimit && !ZetaDia.IsInTown && needRepair)
            {
                Core.Logger.Log("Durability is zero and {0} deaths within 60s of each other - emergency leave game", deathCount);
                ZetaDia.Service.Party.LeaveGame(true);
                await CommonCoroutines.LeaveGame("Durability is zero");

                _deathCounter = 0;
                return(true);
            }

            if (acceptRessurectionButton.IsVisible && acceptRessurectionButton.IsEnabled)
            {
                acceptRessurectionButton.Click();
            }
            else if (IsBeingRevived())
            {
                Core.Logger.Log("[Death] Waiting while being resurrected");
            }
            else if (ZetaDia.Me.IsInBossEncounter && !Core.Rift.IsInRift && IsAlivePlayerNearby)
            {
                Core.Logger.Log("[Death] Waiting because of boss fight");
            }
            else if (corpseButtonReady && !needRepair && !waitingForCorpseResurrect && !noMoreCorpseRevives && !corpseResurrectDisabled)
            {
                while (reviveAtCorpseButton.IsVisible && ZetaDia.Me.IsDead)
                {
                    Core.Logger.Log("[Death] Reviving at corpse");
                    reviveAtCorpseButton.Click();
                    await Coroutine.Sleep(1000);
                }
            }
            else if (townButtonReady && needRepair && _deathNeedRepairCounter > 4)
            {
                Core.Logger.Log("[Death] We've failed few times to resurrect at checkpoint to repair , now resurrecting in town.");
                reviveInTownButton.Click();
            }
            else if (checkpointButtonReady)
            {
                Core.Logger.Log("[Death] Reviving at checkpoint (NeedRepair={0})", needRepair);
                reviveAtCheckPointButton.Click();
            }
            else if (!corpseButtonReady && !checkpointButtonReady && townButtonReady && DateTime.UtcNow.Subtract(LastDeathTime).TotalSeconds > 45)
            {
                Core.Logger.Log("[Death] Reviving in town");
                reviveInTownButton.Click();
            }
            else
            {
                Core.Logger.Verbose("[Death] Waiting...");
            }

            await Coroutine.Sleep(250);

            return(true);
        }