Wheredidigo
Community Developer
- Joined
- Dec 15, 2013
- Messages
- 417
Here is the code that freezes my game client when it gets to it:
Any help figuring out why it's freezing my client would be greatly appreciated.
Code:
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
using Clio.Utilities;
using DestinyPlugin.Utilities;
using ff14bot;
using ff14bot.BotBases;
using ff14bot.Helpers;
using ff14bot.Managers;
using ff14bot.Navigation;
using ff14bot.Objects;
using NeoGaia.ConnectionHandler;
namespace DestinyPlugin.Logic
{
internal class Patrol : LogicBase
{
#region BaseClass Implementation
protected override bool NeedToStart
{
get
{
return Core.Me.IsAlive && Settings.Instance.Patrol && BotManager.Current.EnglishName == "Fate Bot" &&
!FatesAreAvailable() &&
PatrolTargetAvailable && !Core.Me.InCombat && Core.Me.CurrentTarget == null;
}
}
protected override async Task<bool> Start()
{
Logger.Log("No Fates within the current settings are available. Starting to Patrol now.");
var target = FindTarget();
if (Poi.Current.Type != PoiType.Kill)
{
Poi.Clear("Clearing Poi so we can find and kill a new target.");
Poi.Current = new Poi(target, PoiType.Kill);
}
if (Poi.Current.BattleCharacter != null)
{
if (Poi.Current.BattleCharacter.ObjectId != target.ObjectId)
{
Poi.Current = new Poi(target, PoiType.Kill);
}
}
while (Core.Me.Distance(target.Location) > RoutineManager.Current.PullRange + target.CombatReach + Core.Me.CombatReach)
{
Navigator.MoveTo(target.Location);
await CarefulSleep.Sleep(500);
}
if (Core.Me.Distance(target.Location) < 15f)
{
target.Target();
}
return true;
}
#endregion
#region Helpers
private static bool FatesAreAvailable()
{
var activeFates =
FateManager.ActiveFates.Where(
x =>
x.Level >= (Core.Me.ClassLevel - Settings.Instance.MinLevel) &&
x.Level <= (Core.Me.ClassLevel + Settings.Instance.MaxLevel) &&
!FatebotSettings.Instance.BlackListedFates.Contains(x.Name)
).ToList();
var monsterSlayingFates = new List<FateData>();
var bossFates = new List<FateData>();
var escortFates = new List<FateData>();
if (Settings.Instance.MonsterSlayingEnabled)
{
monsterSlayingFates = activeFates.Where(x => x.IsValid && x.Icon == FateIconType.Battle).ToList();
}
if (Settings.Instance.BossEnabled)
{
bossFates =
activeFates.Where(
x =>
x.IsValid && x.Icon == FateIconType.Boss &&
x.Progress >= Settings.Instance.BossPercentRequired).ToList();
}
if (Settings.Instance.EscortEnabled)
{
escortFates =
activeFates.Where(
x => x.IsValid && (x.Icon == FateIconType.ProtectNPC || x.Icon == FateIconType.ProtectNPC2))
.ToList();
}
var availableFates = monsterSlayingFates.Union(bossFates.Union(escortFates));
return availableFates.Any();
}
private static BattleCharacter FindTarget()
{
return GameObjectManager.GetObjectsOfType<BattleCharacter>()
.Where(x => !Settings.Instance.BlackListMobNames.Contains(x.EnglishName)
&& x.CanAttack
&& !x.IsDead
&& x.IsTargetable
&& x.IsVisible
&& !x.TappedByOther
&& x.FateId == 0
&& x.ClassLevel >= (Core.Me.ClassLevel - Settings.Instance.MinLevel)
&& x.ClassLevel <= (Core.Me.ClassLevel + Settings.Instance.MaxLevel)
&& x.MaxHealth < (Core.Player.MaxHealth*5))
.OrderBy(x => Core.Me.Distance(x.Location))
.FirstOrDefault();
}
private static bool PatrolTargetAvailable
{
get
{
var target = FindTarget();
return target != null;
}
}
#endregion
}
}
Any help figuring out why it's freezing my client would be greatly appreciated.