/// <summary> /// Scans the current screen for NPCs and adds any that are not already in the bot's NPC /// list to that list. By default, this happens no more often than once every 10 seconds, /// but it can also be done on command by setting the overriding that cooldown feature. /// </summary> /// <param name="targetableSpell">Any targetable spell.</param> /// <param name="overrideCooldown">Set to true for an on-demand scan regardless of current /// cooldown.</param> /// <returns>True if a scan is performed; false if the cooldown prevented a scan.</returns> public override async Task <bool> UpdateNpcs(Spell targetableSpell, bool overrideCooldown = false) { if (!await base.UpdateNpcs(targetableSpell, overrideCooldown)) { return(false); } foreach (var npc in Npcs.Where(npc => npc.Activity.Curse == null)) { npc.Activity.Curse = new NpcDebuffActivity(Spells.KeySpells.Curse); } return(true); }
public void UpdatePotentialAddsExist() { var countAdds = Npcs.Where(c => c.IsAdd).Where(c => c.Height > ScaleHeight(2)).Count(); var MobsVisible = Npcs.Where(c => c.Height > ScaleHeight(2)).Any(); if (countAdds > 0) { PotentialAddsExist = true; LastPotentialAddsSeen = DateTime.Now; } else { if (PotentialAddsExist && (DateTime.Now - LastPotentialAddsSeen).TotalSeconds > 2) { PotentialAddsExist = false; } } }
public void StartLife() { Life = Observable.Interval(TimeSpan.FromMilliseconds(400)).Subscribe(_ => { try { if (IsSleeping) { return; } Parallel.ForEach(Monsters.Where(s => s.Life == null), monster => monster.StartLife()); Parallel.ForEach(Npcs.Where(s => s.Life == null), npc => npc.StartLife()); } catch (Exception e) { _logger.Error(e.Message, e); } }); }
public Task StartLifeAsync() { async Task LifeAsync() { try { if (IsSleeping) { return; } await Task.WhenAll(Monsters.Where(s => s.Life == null).Select(monster => monster.StartLifeAsync())).ConfigureAwait(false); await Task.WhenAll(Npcs.Where(s => s.Life == null).Select(npc => npc.StartLifeAsync())).ConfigureAwait(false); } catch (Exception e) { _logger.Error(e.Message, e); } } Life = Observable.Interval(TimeSpan.FromMilliseconds(400)).Select(_ => LifeAsync()).Subscribe(); return(Task.CompletedTask); }
public static string GetNpcDesc(int id) { var data = Npcs.Where(x => x.ID == id).ToList(); return(data.Count > 0 ? data.First().Desc : "No description"); }
public static string GetNpcName(int id) { var data = Npcs.Where(x => x.ID == id).ToList(); return(data.Count > 0 ? data.First().Name : "Unknown"); }