/// <summary> /// Creates a move behind target behavior. If it cannot fully navigate will move to target location /// </summary> /// <remarks> /// Created 2/12/2011. /// </remarks> /// <param name="requirements">Aditional requirments.</param> /// <returns>.</returns> public static Composite CreateMoveBehindTargetBehavior(SimpleBooleanDelegate requirements) { return(new Decorator( ret => { if (StyxWoW.Me.CurrentMap.IsBattleground || !requirements(ret) || Spell.IsCastingOrChannelling() || Group.MeIsTank) { return false; } var currentTarget = StyxWoW.Me.CurrentTarget; if (currentTarget == null || currentTarget.MeIsSafelyBehind || !currentTarget.IsAlive || BossList.AvoidRearBosses.Contains(currentTarget.Entry)) { return false; } return currentTarget.Stunned || currentTarget.CurrentTarget != StyxWoW.Me; }, new PrioritySelector( ctx => CalculatePointBehindTarget(), new Decorator( req => Navigator.CanNavigateFully(StyxWoW.Me.Location, (WoWPoint)req, 4), new Sequence( new Action(ret => Logging.WriteDiagnostic("MoveBehind: behind {0} @ {1:F1} yds", StyxWoW.Me.CurrentTarget.SafeName(), StyxWoW.Me.CurrentTarget.Distance)), //Logger.WriteDebug(Color.White, "MoveBehind: behind {0} @ {1:F1} yds", StyxWoW.Me.CurrentTarget.SafeName(), StyxWoW.Me.CurrentTarget.Distance)), new Action(behindPoint => Navigator.MoveTo((WoWPoint)behindPoint)), new Action(behindPoint => StopMoving.AtLocation((WoWPoint)behindPoint)) ) ) ) )); }
/// <summary> /// Creates the ensure movement stopped behavior. if no range specified, will stop immediately. if range given, will stop if within range yds of current target /// </summary> /// <remarks> /// Created 5/1/2011. /// </remarks> /// <returns>.</returns> public static Composite CreateEnsureMovementStoppedBehavior(float range = float.MaxValue, UnitSelectionDelegate onUnit = null, string reason = null) { if (range == float.MaxValue) { return(new Decorator( ret => StyxWoW.Me.IsMoving, new Sequence( new Action(ret => Logging.WriteDiagnostic("EnsureMovementStopped: stopping! {0}", reason ?? "")), //Logger.WriteDebug(Color.White, "EnsureMovementStopped: stopping! {0}", reason ?? "")), new Action(ret => StopMoving.Now()) ) )); } if (onUnit == null) { onUnit = del => StyxWoW.Me.CurrentTarget; } return(new Decorator( ret => StyxWoW.Me.IsMoving && (onUnit(ret) == null || onUnit(ret).Distance < range), new Sequence( new Action(ret => Logging.WriteDiagnostic("EnsureMovementStopped: stopping because {0}", onUnit(ret) == null ? "No CurrentTarget" : string.Format("target @ {0:F1} yds, stop range: {1:F1}", onUnit(ret).Distance, range))), //Logger.WriteDebug(Color.White, "EnsureMovementStopped: stopping because {0}", onUnit(ret) == null ? "No CurrentTarget" : string.Format("target @ {0:F1} yds, stop range: {1:F1}", onUnit(ret).Distance, range))), new Action(ret => StopMoving.Now()) ) )); }
/// <summary> /// Creates ensure movement stopped if within melee range behavior. /// </summary> /// <returns></returns> public static Composite CreateEnsureMovementStoppedWithinMelee() { return(new Decorator( ret => StyxWoW.Me.IsMoving && InMoveToMeleeStopRange(StyxWoW.Me.CurrentTarget), new Sequence( new Action(ret => Logging.WriteDiagnostic("EnsureMovementStoppedWithinMelee: stopping because {0}", !StyxWoW.Me.GotTarget ? "No CurrentTarget" : string.Format("target at {0:F1} yds", StyxWoW.Me.CurrentTarget.Distance))), //Logger.WriteDebug(Color.White, "EnsureMovementStoppedWithinMelee: stopping because {0}", !StyxWoW.Me.GotTarget ? "No CurrentTarget" : string.Format("target at {0:F1} yds", StyxWoW.Me.CurrentTarget.Distance))), new Action(ret => StopMoving.Now()) ) )); }
public static Composite CreateMoveToUnitBehavior(UnitSelectionDelegate onUnit, float range, float stopAt = float.MinValue) { return(new Decorator( ret => onUnit != null && onUnit(ret) != null && onUnit(ret).Distance > range, new Sequence( new Action(ret => Logging.WriteDiagnostic("MoveToUnit: moving within {0:F1} yds of {1} @ {2:F1} yds", range, onUnit(ret).SafeName(), onUnit(ret).Distance)), //Logger.WriteDebug(Color.White, "MoveToUnit: moving within {0:F1} yds of {1} @ {2:F1} yds", range, onUnit(ret).SafeName(), onUnit(ret).Distance)), new Action(ret => Navigator.MoveTo(onUnit(ret).Location)), new Action(ret => StopMoving.InRangeOfUnit(onUnit(ret), stopAt == float.MinValue ? range : stopAt)), new ActionAlwaysFail() ) )); }
public static Composite CreateMoveToLosBehavior(UnitSelectionDelegate toUnit) { return(new Decorator( ret => toUnit != null && toUnit(ret) != null && !toUnit(ret).IsMe && !InLineOfSpellSight(toUnit(ret)), new Sequence( new Action(ret => Logging.WriteDiagnostic("MoveToLoss: moving to LoSS of {0} @ {1:F1} yds", toUnit(ret).SafeName(), toUnit(ret).Distance)), //Logger.WriteDebug(Color.White, "MoveToLoss: moving to LoSS of {0} @ {1:F1} yds", toUnit(ret).SafeName(), toUnit(ret).Distance)), new Action(ret => Navigator.MoveTo(toUnit(ret).Location)), new Action(ret => StopMoving.InLosOfUnit(toUnit(ret))) ) )); }
/// <summary> /// Creates a move to location behavior. Will return RunStatus.Success if it has reached the location, or stopped in range. Best used at the end of a rotation. /// </summary> /// <remarks> /// Created 5/1/2011. /// </remarks> /// <param name = "location">The location.</param> /// <param name = "stopInRange">true to stop in range.</param> /// <param name = "range">The range.</param> /// <returns>.</returns> public static Composite CreateMoveToLocationBehavior(LocationRetriever location, bool stopInRange, DynamicRangeRetriever range) { // Do not f**k with this. It will ensure we stop in range if we're supposed to. // Otherwise it'll stick to the targets ass like flies on dog shit. // Specifying a range of, 2 or so, will ensure we're constantly running to the target. Specifying 0 will cause us to spin in circles around the target // or chase it down like mad. (PVP oriented behavior) return(new PrioritySelector( new Decorator( // Give it a little more than 1/2 a yard buffer to get it right. CTM is never 'exact' on where we land. So don't expect it to be. ret => stopInRange && StyxWoW.Me.Location.Distance(location(ret)) < range(ret), new PrioritySelector( CreateEnsureMovementStoppedBehavior(), // In short; if we're not moving, just 'succeed' here, so we break the tree. new Action(ret => RunStatus.Success) ) ), new Action(ret => Navigator.MoveTo(location(ret))), new Action(ret => StopMoving.InRangeOfLocation(location(ret), range(ret))) )); }
/// <summary> /// Creates a move to melee range behavior. Tests .IsWithinMeleeRange so we know whether WoW thinks /// we are within range, which is more important than our distance calc. For players keep moving /// until 2 yds away so we stick to them in pvp /// </summary> /// <param name="stopInRange"></param> /// <returns></returns> public static Composite CreateMoveToMeleeBehavior(bool stopInRange) { #if OLD_MELEE_MOVE return(new Decorator( ret => !MovementManager.IsMovementDisabled, new PrioritySelector( new Decorator( ret => stopInRange && InMoveToMeleeStopRange(StyxWoW.Me.CurrentTarget), new PrioritySelector( CreateEnsureMovementStoppedWithinMelee(), new Action(ret => RunStatus.Success) ) ), new Decorator( ret => StyxWoW.Me.CurrentTarget != null && StyxWoW.Me.CurrentTarget.IsValid, new Sequence( new Action(ret => Logger.WriteDebug(Color.White, "MoveToMelee: towards {0} @ {1:F1} yds", StyxWoW.Me.CurrentTarget.SafeName(), StyxWoW.Me.CurrentTarget.Distance)), new Action(ret => Navigator.MoveTo(StyxWoW.Me.CurrentTarget.Location)), new Action(ret => StopMoving.InMeleeRangeOfUnit(StyxWoW.Me.CurrentTarget, and => InMoveToMeleeStopRange(StyxWoW.Me.CurrentTarget))), new ActionAlwaysFail() ) ) ) )); #else return(new Decorator( ret => StyxWoW.Me.CurrentTarget != null && !StyxWoW.Me.CurrentTarget.IsWithinMeleeRange, new Sequence( new Action(ret => { MoveResult res = Navigator.MoveTo(StyxWoW.Me.CurrentTarget.Location); Logging.WriteDiagnostic("MoveToMelee({0}): towards {1} @ {2:F1} yds", res.ToString(), StyxWoW.Me.CurrentTarget.SafeName(), StyxWoW.Me.CurrentTarget.Distance); //Logger.WriteDebug(Color.White, "MoveToMelee({0}): towards {1} @ {2:F1} yds", res.ToString(), StyxWoW.Me.CurrentTarget.SafeName(), StyxWoW.Me.CurrentTarget.Distance); }), new Action(ret => StopMoving.InMeleeRangeOfUnit(StyxWoW.Me.CurrentTarget)), new ActionAlwaysFail() ) )); #endif }
private static bool CheckMoving() { if (Target.Distance >= 3 && Target.IsMoving && !Me.MovementInfo.MovingForward) { //WoWMovement.Move(WoWMovement.MovementDirection.Forward); Navigator.MoveTo(StyxWoW.Me.CurrentTarget.Location); return(true); } if (Target.Distance < 3 && Target.IsMoving && Me.MovementInfo.MovingForward) { //WoWMovement.MoveStop(WoWMovement.MovementDirection.Forward); StopMoving.InMeleeRangeOfUnit(StyxWoW.Me.CurrentTarget); return(true); } if ((Me.MovementInfo.MovingStrafeRight || Me.MovementInfo.MovingStrafeLeft) && Me.CurrentTarget.Distance > 5) { StopMovement(false, false, true, true); } return(false); }