// public static List<RiftStats> DisposedRifts = new List<RiftStats>(); // public static RiftType RiftType; public void StartRift(Enigma.D3.Quest Quest) { RiftType = (RiftType)Quest.x000_QuestSnoId; RiftIsActive = true; CurrentRift = new Rift.RiftStats { StartTick = Quest.x004_CreationTick, Started = DateTime.Now.AddSeconds(-((GameManager.Instance.GameTicks - Quest.x004_CreationTick) / 60)), RiftType = this.RiftType, RiftLevel = -1, Legendary = new List <int>(), Levels = 1, Boss = -1, Difficulty = (Difficulty)GameManagerAccountHelper.Current.DiabloIII.ObjectManager.Storage.x004, }; if (GameManagerAccountHelper.Current.DiabloIII.ObjectManager.Storage._x05C != -1) // GR { CurrentRift.RiftLevel = (GameManagerAccountHelper.Current.DiabloIII.ObjectManager.Storage._x05C + 1); CurrentRift.Difficulty = Difficulty.GreaterRift; TownHelper.UpdateStash(); //RiftType = RiftType.GreaterRift; } Account = GameManagerAccountHelper.Current; SetTimer(); }
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); }
private bool NotStarted() { if (!_experienceTracker.IsStarted) { _experienceTracker.Start(); } SafeZerg.Instance.DisableZerg(); if (_RiftType == RiftType.Greater) { _level = RiftData.GetGreaterRiftLevel(); } if (_runningNephalemInsteadOfGreaterRift && AdvDia.StashAndBackpackItems.Any(i => i.IsValid && i.ActorSNO == RiftData.GreaterRiftKeySNO)) { _level = RiftData.GetGreaterRiftLevel(); _RiftType = RiftType.Greater; _runningNephalemInsteadOfGreaterRift = false; return(false); } if (AdvDia.RiftQuest.State == QuestState.NotStarted && _RiftType == RiftType.Greater && !AdvDia.StashAndBackpackItems.Any(i => i.IsValid && i.ActorSNO == RiftData.GreaterRiftKeySNO)) { if (PluginSettings.Current.GreaterRiftRunNephalem) { _level = -1; _RiftType = RiftType.Nephalem; _runningNephalemInsteadOfGreaterRift = true; return(false); } else { Logger.Error("You have no Greater Rift Keys. Stopping the bot."); BotMain.Stop(); return(true); } } _currentWorldDynamicId = AdvDia.CurrentWorldDynamicId; if (AdvDia.RiftQuest.State == QuestState.InProgress && RiftData.RiftWorldIds.Contains(AdvDia.CurrentWorldId)) { State = States.SearchingForExitPortal; return(false); } State = AdvDia.CurrentWorldId == ExplorationData.ActHubWorldIds[Act.A1] ? States.InTown : States.GoingToAct1Hub; if (AdvDia.RiftQuest.State == QuestState.NotStarted) { ScenesStorage.Reset(); RiftData.EntryPortals.Clear(); _currentWorldDynamicId = 0; _previusWorldDynamicId = 0; _bossLocation = Vector3.Zero; _nextLevelPortalLocation = Vector3.Zero; _holyCowLocation = Vector3.Zero; _holyCowEventCompleted = false; _possiblyCowLevel = false; } return(false); }
public RiftCoroutine(RiftType RiftType) { _RiftType = RiftType; if (RiftType == RiftType.Nephalem) { _level = -1; } else { _level = RiftData.GetGreaterRiftLevel(); } }
public RiftCoroutine(RiftType RiftType, RiftOptions options = null) { _RiftType = RiftType; if (RiftType == RiftType.Nephalem) { _level = -1; } else { _level = RiftData.GetGreaterRiftLevel(); } _id = Guid.NewGuid(); _options = options ?? new RiftOptions(); }
private bool NotStarted() { if(!_experienceTracker.IsStarted) _experienceTracker.Start(); SafeZerg.Instance.DisableZerg(); if (_RiftType == RiftType.Greater) { _level = RiftData.GetGreaterRiftLevel(); } if (_runningNephalemInsteadOfGreaterRift && AdvDia.StashAndBackpackItems.Any(i => i.IsValid && i.ActorSnoId == RiftData.GreaterRiftKeySNO)) { _level = RiftData.GetGreaterRiftLevel(); _RiftType = RiftType.Greater; _runningNephalemInsteadOfGreaterRift = false; return false; } if (AdvDia.RiftQuest.State == QuestState.NotStarted && _RiftType == RiftType.Greater && !AdvDia.StashAndBackpackItems.Any(i => i.IsValid && i.ActorSnoId == RiftData.GreaterRiftKeySNO)) { if (PluginSettings.Current.GreaterRiftRunNephalem) { _level = -1; _RiftType = RiftType.Nephalem; _runningNephalemInsteadOfGreaterRift = true; return false; } else { Logger.Error("You have no Greater Rift Keys. Stopping the bot."); BotMain.Stop(); return true; } } _currentWorldDynamicId = AdvDia.CurrentWorldDynamicId; if (AdvDia.RiftQuest.State == QuestState.InProgress && RiftData.RiftWorldIds.Contains(AdvDia.CurrentWorldId)) { State = States.SearchingForExitPortal; return false; } State = AdvDia.CurrentWorldId == ExplorationData.ActHubWorldIds[Act.A1] ? States.InTown : States.GoingToAct1Hub; if (AdvDia.RiftQuest.State == QuestState.NotStarted) { ScenesStorage.Reset(); RiftData.EntryPortals.Clear(); _currentWorldDynamicId = 0; _previusWorldDynamicId = 0; _bossLocation = Vector3.Zero; _nextLevelPortalLocation = Vector3.Zero; _holyCowLocation = Vector3.Zero; _holyCowEventCompleted = false; _possiblyCowLevel = false; } return false; }
public override void OnThink() { base.OnThink(); if (!Hidden && IsStealthing) { IsStealthing = false; } if (Utility.RandomDouble() < .01 && DateTime.UtcNow > m_NextAIChangeAllowed) { Effects.PlaySound(Location, Map, GetAngerSound()); switch (Utility.RandomMinMax(1, 5)) { case 1: DictCombatTargetingWeight[CombatTargetingWeight.Player] = 0; DictCombatTargetingWeight[CombatTargetingWeight.Closest] = 0; DictCombatTargetingWeight[CombatTargetingWeight.HighestHitPoints] = 0; DictCombatTargetingWeight[CombatTargetingWeight.LowestHitPoints] = 0; break; case 2: DictCombatTargetingWeight[CombatTargetingWeight.Player] = 10; DictCombatTargetingWeight[CombatTargetingWeight.Closest] = 0; DictCombatTargetingWeight[CombatTargetingWeight.HighestHitPoints] = 0; DictCombatTargetingWeight[CombatTargetingWeight.LowestHitPoints] = 0; break; case 3: DictCombatTargetingWeight[CombatTargetingWeight.Player] = 0; DictCombatTargetingWeight[CombatTargetingWeight.Closest] = 10; DictCombatTargetingWeight[CombatTargetingWeight.HighestHitPoints] = 0; DictCombatTargetingWeight[CombatTargetingWeight.LowestHitPoints] = 0; break; case 4: DictCombatTargetingWeight[CombatTargetingWeight.Player] = 0; DictCombatTargetingWeight[CombatTargetingWeight.Closest] = 0; DictCombatTargetingWeight[CombatTargetingWeight.HighestHitPoints] = 10; DictCombatTargetingWeight[CombatTargetingWeight.LowestHitPoints] = 0; break; case 5: DictCombatTargetingWeight[CombatTargetingWeight.Player] = 0; DictCombatTargetingWeight[CombatTargetingWeight.Closest] = 0; DictCombatTargetingWeight[CombatTargetingWeight.HighestHitPoints] = 0; DictCombatTargetingWeight[CombatTargetingWeight.LowestHitPoints] = 10; break; } Combatant = null; m_NextAIChangeAllowed = DateTime.UtcNow + NextAIChangeDelay; return; } if (Utility.RandomDouble() < 0.05 && DateTime.UtcNow > m_NextVanishAllowed && !Hidden) { if (Combatant != null) { double stationaryDuration = 3; RiftType riftType = RiftType.Normal; double randomValue = Utility.RandomDouble(); if (randomValue <= .33) { stationaryDuration = 3; riftType = RiftType.Normal; } else if (randomValue <= .66) { stationaryDuration = 8; riftType = RiftType.EnergyBolts; } else { stationaryDuration = 13; riftType = RiftType.SpawnRiftlings; } CantWalk = true; Frozen = true; AIObject.NextMove = DateTime.UtcNow + TimeSpan.FromSeconds(2); LastSwingTime = DateTime.UtcNow + TimeSpan.FromSeconds(2); NextSpellTime = NextSpellTime + TimeSpan.FromSeconds(2); NextCombatHealActionAllowed = NextCombatHealActionAllowed + TimeSpan.FromSeconds(2); NextCombatSpecialActionAllowed = NextCombatSpecialActionAllowed + TimeSpan.FromSeconds(2); NextCombatEpicActionAllowed = NextCombatEpicActionAllowed + TimeSpan.FromSeconds(2); m_NextVanishAllowed = DateTime.UtcNow + NextVanishDelay; Effects.PlaySound(Location, Map, 0x5CE); Effects.SendLocationParticles(EffectItem.Create(Location, Map, TimeSpan.FromSeconds(0.5)), 6899, 10, 30, 1108, 0, 5029, 0); for (int a = 0; a < 2; a++) { Timer.DelayCall(TimeSpan.FromSeconds(a * 1), delegate { if (this == null) { return; } if (!Alive || Deleted) { return; } CantWalk = true; Frozen = true; PlaySound(GetIdleSound()); Animate(6, 4, 1, true, false, 0); }); } Point3D location = Location; Point3D riftLocation = Location; Map map = Map; Timer.DelayCall(TimeSpan.FromSeconds(1), delegate { if (this == null) { return; } if (!Alive || Deleted) { return; } Effects.SendLocationParticles(EffectItem.Create(location, map, TimeSpan.FromSeconds(0.5)), 3546, 10, 150, 1108, 0, 5029, 0); }); Timer.DelayCall(TimeSpan.FromSeconds(2), delegate { if (this == null) { return; } if (!Alive || Deleted) { return; } CantWalk = false; Frozen = false; if (SpecialAbilities.VanishAbility(this, stationaryDuration, true, 0x5C8, 4, 8, true, m_BackupLocations)) { PublicOverheadMessage(MessageType.Regular, 0, false, "*disappears into the rift*"); } AIObject.NextMove = AIObject.NextMove + TimeSpan.FromSeconds(stationaryDuration); NextSpellTime = DateTime.UtcNow + TimeSpan.FromSeconds(stationaryDuration); List <Mobile> m_PossibleMobiles = new List <Mobile>(); IPooledEnumerable mobilesInArea; double spawnPercent = (double)intervalCount / (double)totalIntervals; switch (riftType) { case RiftType.Normal: break; case RiftType.EnergyBolts: m_PossibleMobiles = new List <Mobile>(); mobilesInArea = map.GetMobilesInRange(riftLocation, 15); foreach (Mobile mobile in mobilesInArea) { if (mobile == null) { continue; } if (mobile == this) { continue; } if (mobile.Map != map) { continue; } if (!mobile.Alive) { continue; } if (!mobile.CanBeDamaged()) { continue; } if (mobile.AccessLevel > AccessLevel.Player) { continue; } bool validTarget = false; PlayerMobile pm_Target = mobile as PlayerMobile; BaseCreature bc_Target = mobile as BaseCreature; if (pm_Target != null) { validTarget = true; } if (bc_Target != null) { if (bc_Target.Controlled && bc_Target.ControlMaster is PlayerMobile) { validTarget = true; } } if (validTarget) { m_PossibleMobiles.Add(mobile); } } mobilesInArea.Free(); int boltCount = 10 + (int)(Math.Ceiling(25 * spawnPercent)); if (boltCount > 35) { boltCount = 35; } for (int a = 0; a < boltCount; a++) { Timer.DelayCall(TimeSpan.FromSeconds(a * .2), delegate { if (this == null) { return; } if (Deleted || !Alive) { return; } m_PossibleMobiles = new List <Mobile>(); mobilesInArea = map.GetMobilesInRange(riftLocation, 15); foreach (Mobile mobile in mobilesInArea) { if (mobile == null) { continue; } if (mobile == this) { continue; } if (mobile.Map != map) { continue; } if (!mobile.Alive) { continue; } if (!mobile.CanBeDamaged()) { continue; } if (mobile.AccessLevel > AccessLevel.Player) { continue; } if (mobile.Hidden) { continue; } bool validTarget = false; PlayerMobile pm_Target = mobile as PlayerMobile; BaseCreature bc_Target = mobile as BaseCreature; if (pm_Target != null) { validTarget = true; } if (bc_Target != null) { if (bc_Target.Controlled && bc_Target.ControlMaster is PlayerMobile) { validTarget = true; } } if (!InLOS(mobile)) { continue; } m_PossibleMobiles.Add(mobile); } mobilesInArea.Free(); if (m_PossibleMobiles.Count == 0) { return; } Mobile target = m_PossibleMobiles[Utility.RandomMinMax(0, m_PossibleMobiles.Count - 1)]; Effects.PlaySound(riftLocation, map, 0x5C6); IEntity effectStartLocation = new Entity(Serial.Zero, new Point3D(riftLocation.X, riftLocation.Y, riftLocation.Z + 8), map); IEntity effectEndLocation = new Entity(Serial.Zero, new Point3D(target.Location.X, target.Location.Y, target.Location.Z + 6), map); Effects.SendMovingEffect(effectStartLocation, effectEndLocation, 0x36D4, 5, 0, false, false, 2614, 0); double distance = this.GetDistanceToSqrt(target.Location); double destinationDelay = (double)distance * .10; Timer.DelayCall(TimeSpan.FromSeconds(destinationDelay), delegate { if (this == null) { return; } if (!this.Alive || this.Deleted) { return; } if (target == null) { return; } if (!target.Alive || target.Deleted) { return; } Effects.PlaySound(Location, map, 0x5CF); int damage = Utility.RandomMinMax(5, 15); if (target is BaseCreature) { damage = (int)((double)damage * 1.5); } AOS.Damage(target, damage, 0, 100, 0, 0, 0); new Blood().MoveToWorld(target.Location, target.Map); IEntity locationEntity = new Entity(Serial.Zero, new Point3D(target.Location.X, target.Location.Y, target.Location.Z + 5), map); Effects.SendLocationParticles(locationEntity, Utility.RandomList(0x36BD, 0x36BF, 0x36CB, 0x36BC), 30, 7, 2614, 0, 5044, 0); }); }); } break; case RiftType.SpawnRiftlings: List <BaseCreature> m_CreaturesToMove = new List <BaseCreature>(); m_PossibleMobiles = new List <Mobile>(); mobilesInArea = map.GetMobilesInRange(riftLocation, 20); foreach (Mobile mobile in mobilesInArea) { if (mobile == null) { continue; } if (mobile == this) { continue; } if (mobile.Map != map) { continue; } if (!mobile.Alive) { continue; } if (!mobile.CanBeDamaged()) { continue; } if (mobile.AccessLevel > AccessLevel.Player) { continue; } bool validTarget = false; PlayerMobile pm_Target = mobile as PlayerMobile; BaseCreature bc_Target = mobile as BaseCreature; if (pm_Target != null) { validTarget = true; } if (bc_Target != null) { if (bc_Target.Controlled && bc_Target.ControlMaster is PlayerMobile) { validTarget = true; } } m_PossibleMobiles.Add(mobile); } mobilesInArea.Free(); int riftlingCount = 2 + (int)(Math.Ceiling(6 * spawnPercent)); Timer.DelayCall(TimeSpan.FromSeconds(2), delegate { if (this == null) { return; } if (!Alive || Deleted) { return; } for (int a = 0; a < riftlingCount; a++) { double randomCreature = Utility.RandomDouble(); if (randomCreature <= .30) { Imp riftling = new Imp(); riftling.Hue = 2615; riftling.Tameable = false; riftling.Name = "an impish riftling"; riftling.CorpseNameOverride = "an impish riftling corpse"; riftling.BossMinion = true; riftling.MoveToWorld(riftLocation, map); m_Creatures.Add(riftling); m_CreaturesToMove.Add(riftling); } else if (randomCreature <= .60) { MongbatLord riftling = new MongbatLord(); riftling.Hue = 2615; riftling.Tameable = false; riftling.Name = "a bat-like riftling"; riftling.CorpseNameOverride = "a bat-like riftling corpse"; riftling.BossMinion = true; riftling.MoveToWorld(riftLocation, map); m_Creatures.Add(riftling); m_CreaturesToMove.Add(riftling); } else if (randomCreature <= .80) { Gazer riftling = new Gazer(); riftling.Hue = 2615; riftling.Tameable = false; riftling.Name = "a gazing riftling"; riftling.CorpseNameOverride = "a gazing riftling corpse"; riftling.BossMinion = true; riftling.MoveToWorld(riftLocation, map); m_Creatures.Add(riftling); m_CreaturesToMove.Add(riftling); } else { Aboleth riftling = new Aboleth(); riftling.Hue = 2615; riftling.Tameable = false; riftling.Name = "a strange riftling"; riftling.CorpseNameOverride = "a strange riftling corpse"; riftling.BossMinion = true; riftling.MoveToWorld(riftLocation, map); m_Creatures.Add(riftling); m_CreaturesToMove.Add(riftling); } } Timer.DelayCall(TimeSpan.FromSeconds(.5), delegate { if (this == null) { return; } if (!Alive || Deleted) { return; } foreach (BaseCreature creature in m_CreaturesToMove) { if (creature == null) { continue; } if (!creature.Alive || creature.Deleted) { continue; } if (creature.AIObject == null) { continue; } creature.AIObject.WalkRandom(0, 1, 2); Effects.SendLocationParticles(EffectItem.Create(creature.Location, creature.Map, TimeSpan.FromSeconds(0.5)), 14201, 10, 20, 2614, 0, 5029, 0); } }); }); break; } }); } } }
public static async Task <bool> OpenRift(RiftType riftType, int maxLevel, int maxEmpowerLevel, bool shouldEmpower, bool runNormalUntilXP) { if (IsRiftPortalOpen) { return(IsRiftPortalOpen); } var riftKeys = CurrentRiftKeyCount; if (riftType == RiftType.Greater && riftKeys <= PluginSettings.Current.MinimumKeys && !PluginSettings.Current.GreaterRiftRunNephalem) { s_logger.Error($"[{nameof(OpenRift)}] You have no Greater Rift Keys. Stopping the bot."); BotMain.Stop(); return(false); } s_logger.Debug($"[{nameof(OpenRift)}] I have {riftKeys} rift keys."); if (await EnsureIsInTown() == CoroutineResult.Running) { return(false); } if (riftKeys <= PluginSettings.Current.MinimumKeys) { riftType = RiftType.Nephalem; } // TODO: Figure out why there is that check against that magic. var maximizeXp = runNormalUntilXP && riftType == RiftType.Greater && ZetaDia.Me.RestExperience <5000000000 && ZetaDia.Me.RestExperience> -1; if (maximizeXp) { riftType = RiftType.Nephalem; } var level = Math.Min(riftType == RiftType.Greater ? RiftData.GetGreaterRiftLevel() : -1, maxLevel); var isEmpowered = riftType == RiftType.Greater && shouldEmpower && level <= maxEmpowerLevel && RiftData.EmpoweredRiftCost.TryGetValue(level, out var empoweredCost) && ZetaDia.Storage.PlayerDataManager.ActivePlayerData.Coinage >= (empoweredCost + PluginSettings.Current.MinimumGold); DiaGizmo lrs = LootRunSwitch; if (lrs == null) { await CommonCoroutines.MoveTo(ZetaDia.Actors.GetActorsOfType <DiaGizmo>() .Where(g => g.Distance > 10f) .OrderByDescending(g => g.Distance) .FirstOrDefault()); return(false); } if (!s_experienceTracker.IsStarted) { s_experienceTracker.Start(); } if (await CommonCoroutines.MoveAndInteract( lrs, () => UIElements.RiftDialog.IsVisible) == CoroutineResult.Running) { return(false); } ZetaDia.Me.OpenRift(level, isEmpowered); return(await Coroutine.Wait(TimeSpan.FromSeconds(2), () => IsRiftPortalOpen)); }