public override void Run(IGameContext context) { // Has the user decided that we should approach targets? if (context.Config.IsApproachEnabled) { // Move to target if out of melee range. context.API.Navigator.DistanceTolerance = context.Config.MeleeDistance; context.API.Navigator.GotoNPC(context.Target.Id, context.Config.IsObjectAvoidanceEnabled, context.Config.IsThirdPersonCombatEnabled); } // Face mob. context.API.Navigator.FaceHeading(context.Target.Position); // Target mob if not currently targeted. Player.SetTarget(context.API, context.Target); // Has the user decided we should engage in battle. if (context.Config.IsEngageEnabled) { if (!context.API.Player.Status.Equals(Status.Fighting) && context.Target.Distance < 25) { context.API.Windower.SendString(Constants.AttackTarget); } } }
public void UseTargetedActions(IEnumerable <BattleAbility> actions, IUnit target) { if (actions == null) { throw new ArgumentNullException(nameof(actions)); } if (target == null) { throw new ArgumentNullException(nameof(target)); } foreach (var action in actions) { MoveIntoActionRange(target, action); _fface.Navigator.FaceHeading(target.Position); Player.SetTarget(_fface, target); _fface.Navigator.Reset(); TimeWaiter.Pause(100); if (ResourceHelper.IsSpell(action.Ability.AbilityType)) { CastSpell(action); } else { CastAbility(action); } action.Usages++; action.LastCast = DateTime.Now.AddSeconds(action.Recast); TimeWaiter.Pause(Config.Instance.GlobalCooldown); } }
public override void Run(IGameContext context) { // Target mob if not currently targeted. Player.SetTarget(context.API, context.Target); // Has the user decided that we should approach targets? if (context.Config.IsApproachEnabled) { // Move to target if out of melee range. var path = context.NavMesh.FindPathBetween(context.API.Player.Position, context.Target.Position); if (path.Count > 0) { if (path.Count > 1) { context.API.Navigator.DistanceTolerance = 0.5; } else { context.API.Navigator.DistanceTolerance = context.Config.MeleeDistance; } while (path.Count > 0 && path.Peek().Distance(context.API.Player.Position) <= context.API.Navigator.DistanceTolerance) { path.Dequeue(); } if (path.Count > 0) { var node = path.Peek(); float deltaX = node.X - context.API.Player.Position.X; float deltaY = node.Y - context.API.Player.Position.Y; float deltaZ = node.Z - context.API.Player.Position.Z; context.API.Follow.SetFollowCoords(deltaX, deltaY, deltaZ); } else { context.API.Navigator.FaceHeading(context.Target.Position); context.API.Follow.Reset(); // Has the user decided we should engage in battle. if (context.Config.IsEngageEnabled) { if (!context.API.Player.Status.Equals(Status.Fighting) && context.Target.Distance < 25) { context.API.Windower.SendString(Constants.AttackTarget); } } } } } else { // Face mob. context.API.Navigator.FaceHeading(context.Target.Position); } }
public override void Run(IGameContext context) { // Target mob if not currently targeted. Player.SetTarget(context.API, context.Target); // Has the user decided that we should approach targets? if (context.Config.IsApproachEnabled) { // Move to target if out of melee range. var path = context.NavMesh.FindPathBetween(context.API.Player.Position, context.Target.Position); // Has the user decided we should engage in battle. if (context.Target.Distance <= 25 && context.Config.IsEngageEnabled) { Player.Engage(context.API); } if (context.Target.Distance <= Config.Instance.MeleeDistance) { context.API.Navigator.FaceHeading(context.Target.Position, false); context.API.Navigator.Reset(); } else if (path.Count > 0) { context.API.Navigator.DistanceTolerance = 3.0; while (path.Count > 0 && path.Peek().Distance(context.API.Player.Position) <= context.API.Navigator.DistanceTolerance) { path.Dequeue(); } if (path.Count > 0) { if (path.Peek().Distance(context.Target.Position) <= Config.Instance.MeleeDistance || context.API.Player.Position.Distance(context.Target.Position) <= Config.Instance.MeleeDistance) { context.API.Navigator.DistanceTolerance = Config.Instance.MeleeDistance; } context.API.Navigator.GotoNPC(context.Target.Id, path.Peek(), true); } else { context.API.Navigator.GotoNPC(context.Target.Id, context.Target.Position, false); } } } }
public override void Run(IGameContext context) { // First get the first mob by distance. var mobs = context.Units.Where(x => x.IsValid).ToList(); mobs = TargetPriority.Prioritize(mobs).ToList(); var lastTarget = context.Target; // Set our new target at the end so that we don't accidentally cast on a new target. var target = mobs.FirstOrDefault() ?? new NullUnit(); if (target.IsValid && lastTarget != target) { context.Target = target; // FIXME: if random path is set, do not reset? make this configurable? context.Config.Route.ResetCurrentWaypoint(); LogViewModel.Write("Now targeting " + context.Target.Name + " : " + context.Target.Id); } Player.SetTarget(context.API, target); }