/// <summary> /// Switches the player to attack mode on the current unit /// </summary> public static void Engage(IMemoryAPI fface) { if (!fface.Player.Status.Equals(Status.Fighting)) { fface.Windower.SendString(Constants.AttackTarget); } }
/// <summary> /// Makes the character stop resting /// </summary> public static void Stand(IMemoryAPI fface) { if (fface.Player.Status.Equals(Status.Healing)) { fface.Windower.SendString(Constants.RestingOff); Thread.Sleep(50); } }
public UnitService(IMemoryAPI fface) { _fface = fface; // Create the UnitArray Units = Enumerable.Range(0, UnitArrayMax) .Select(x => new Unit(_fface, x)).ToList(); }
public static void SetTarget(IMemoryAPI fface, Unit target) { if (!Config.Instance.EnableTabTargeting) { SetTargetUsingMemory(fface, target); } else { SetTargetByTabbing(fface, target); } }
public Unit(IMemoryAPI fface, int id) { // Set this unit's session data. _fface = fface; // Set the internal id. Id = id; // Set the NPC information. _npc = _fface.NPC; }
/// <summary> /// Filters out unusable buffing abilities. /// </summary> /// <param name="fface"></param> /// <param name="action"></param> /// <returns></returns> public static bool BuffingFilter(IMemoryAPI fface, BattleAbility action) { var actionContext = new ActionContext { MemoryAPI = fface, BattleAbility = action }; var actionRules = new BuffingActionRules(); return actionRules.IsValid(actionContext); }
public static void SetSession(IMemoryAPI fface) { if (fface == null) return; // Save fface Instance FFACE = fface; // Create a new game engine to control our character. GameEngine = new GameEngine(FFACE); OnSessionSet?.Invoke(fface); }
public FiniteStateMachine(IMemoryAPI fface) { //Create the states AddState(new DeadState(fface) { Priority = 6 }); AddState(new ZoneState(fface) { Priority = 6 }); AddState(new SetTargetState(fface) { Priority = 6 }); AddState(new SetFightingState(fface) { Priority = 6 }); AddState(new FollowState(fface) { Priority = 5 }); AddState(new RestState(fface) { Priority = 2 }); AddState(new ApproachState(fface) { Priority = 0 }); AddState(new BattleState(fface) { Priority = 3 }); AddState(new WeaponskillState(fface) { Priority = 2 }); AddState(new PullState(fface) { Priority = 4 }); AddState(new StartState(fface) { Priority = 5 }); AddState(new TravelState(fface) { Priority = 1 }); AddState(new HealingState(fface) { Priority = 2 }); AddState(new EndState(fface) { Priority = 3 }); AddState(new StartEngineState(fface) { Priority = Constants.MaxPriority }); _states.ForEach(x => x.Enabled = true); }
/// <summary> /// Checks whether a spell or ability can be recasted. /// </summary> /// <param name="fface"></param> /// <param name="ability"></param> /// <returns></returns> public static bool IsRecastable(IMemoryAPI fface, Ability ability) { var recast = 0; // No recast time on weaponskills. if (ability.AbilityType == AbilityType.Weaponskill) return true; // No recast for ranged attacks. if (AbilityType.Range.HasFlag(ability.AbilityType)) return true; // If a spell get spell recast if (ResourceHelper.IsSpell(ability.AbilityType)) { recast = fface.Timer.GetSpellRecast(ability.Index); } // if ability get ability recast. if (ResourceHelper.IsAbility(ability.AbilityType)) { recast = fface.Timer.GetAbilityRecast(ability.Id); } return recast <= 0; }
/// <summary> /// Filters out unusable targeted abilities. /// </summary> /// <param name="fface"></param> /// <param name="action"></param> /// <param name="unit"></param> /// <returns></returns> public static bool TargetedFilter(IMemoryAPI fface, BattleAbility action, Unit unit) { // Does not pass the base criteria for casting. if (!BuffingFilter(fface, action)) return false; // Target HP Checks Enabled. if (action.TargetLowerHealth != 0 || action.TargetUpperHealth != 0) { // Target Upper Health Check if (unit.HppCurrent > action.TargetUpperHealth) return false; // Target Lower Health Check if (unit.HppCurrent < action.TargetLowerHealth) return false; } // Target Name Checks Enabled. if (!string.IsNullOrWhiteSpace(action.TargetName)) { // Target Name Check. if (!Regex.IsMatch(unit.Name, action.TargetName, RegexOptions.IgnoreCase)) return false; } return true; }
private void ViewModelBase_OnSessionSet(IMemoryAPI fface) { _recorder = new PathRecorder(fface); _recorder.OnPositionAdded += _recorder_OnPositionAdded; }
public Executor(IMemoryAPI fface) { _fface = fface; }
public SummonTrustsState(IMemoryAPI fface) : base(fface) { Executor = new Executor(fface); }
public ZoneState(IMemoryAPI fface) : base(fface) { Zone = fface.Player.Zone; }
public RestState(IMemoryAPI fface) : base(fface) { _units = new UnitService(fface); }
/// <summary> /// Returns true if a mob is attackable by the player based on the various settings in the /// Config class. /// </summary> /// <param name="fface"></param> /// <param name="mob"></param> /// <returns></returns> public static bool MobFilter(IMemoryAPI fface, Unit mob) { // Function to use to filter surrounding mobs by. General Mob Filtering Criteria if (fface == null) return false; if (mob == null) return false; // Mob not active if (!mob.IsActive) return false; // INFO: fixes trying to attack dead mob problem. Mob is dead if (mob.IsDead) return false; // Mob not rendered on screen. if (!mob.IsRendered) return false; // Type is not mob if (!mob.NpcType.Equals(NpcType.Mob)) return false; // Mob is out of range if (!(mob.Distance < Config.Instance.DetectionDistance)) return false; if (mob.IsPet) return false; // If any unit is within the wander distance then the if (Config.Instance.Route.Waypoints.Any()) { if (!(Config.Instance.Route.Waypoints.Any(waypoint => Distance(mob, waypoint) <= Config.Instance.WanderDistance))) return false; } // Mob too high out of reach. if (mob.YDifference > Config.Instance.HeightThreshold) return false; // User Specific Filtering // Performs a case insensitve match on the mob's name. If any part of the mob's name is // in the ignored list, we will not attack it. if (MatchAny(mob.Name, Config.Instance.IgnoredMobs, RegexOptions.IgnoreCase)) return false; // Kill aggro if aggro's checked regardless of target's list but follows the ignored list. if (mob.HasAggroed && Config.Instance.AggroFilter) return true; // There is a target's list but the mob is not on it. if (!MatchAny(mob.Name, Config.Instance.TargetedMobs, RegexOptions.IgnoreCase) && Config.Instance.TargetedMobs.Any()) return false; // Mob on our targets list or not on our ignore list. // Kill the creature if it has aggroed and aggro is checked. if (mob.HasAggroed && Config.Instance.AggroFilter) return true; // Kill the creature if it is claimed by party and party is checked. if (mob.PartyClaim && Config.Instance.PartyFilter) return true; // Kill the creature if it's not claimed and unclaimed is checked. if (!mob.IsClaimed && Config.Instance.UnclaimedFilter) return true; // Kill the creature if it's claimed and we we don't have claim but // claim is checked. //FIX: Temporary fix until player.serverid is fixed. if (mob.IsClaimed && Config.Instance.ClaimedFilter) return true; // Kill only mobs that we have claim on. return mob.ClaimedId == fface.PartyMember[0].ServerID; }
public ApproachState(IMemoryAPI fface) : base(fface) { }
public CombatState(IMemoryAPI fface) : base(fface) { }
public StartEngineState(IMemoryAPI fface) : base(fface) { }
public Executor(IMemoryAPI fface) { _fface = fface; _caster = new Caster(fface); }
public BattleState(IMemoryAPI fface) : base(fface) { _executor = new Executor(fface); }
/// <summary> /// Filters out unusable buffing abilities. /// </summary> /// <param name="fface"></param> /// <param name="action"></param> /// <returns></returns> public static bool BuffingFilter(IMemoryAPI fface, BattleAbility action) { // Return if not enabled. if (!action.IsEnabled) { return(false); } // Name Check if (string.IsNullOrWhiteSpace(action.Name)) { return(false); } // MP Check if (action.Ability.MpCost > fface.Player.MPCurrent) { return(false); } // TP Check if (action.Ability.TpCost > fface.Player.TPCurrent) { return(false); } // Usage Limit Check. if (action.UsageLimit != 0) { if (action.Usages > action.UsageLimit) { return(false); } } // Recast Check if (!AbilityUtils.IsRecastable(fface, action.Ability)) { return(false); } // Limiting Status Effect Check for Spells. if (ResourceHelper.IsSpell(action.Ability.AbilityType)) { if (ProhibitEffects.ProhibitEffectsSpell.Intersect(fface.Player.StatusEffects).Any()) { return(false); } } // Limiting Status Effect Check for Abilities. if (ResourceHelper.IsAbility(action.Ability.AbilityType)) { if (ProhibitEffects.ProhibitEffectsAbility.Intersect(fface.Player.StatusEffects).Any()) { return(false); } } // Player HP Checks Enabled. if (action.PlayerLowerHealth != 0 || action.PlayerUpperHealth != 0) { // Player Upper HP Check if (fface.Player.HPPCurrent > action.PlayerUpperHealth) { return(false); } // Player Lower HP Check if (fface.Player.HPPCurrent < action.PlayerLowerHealth) { return(false); } } // Status Effect Checks Enabled if (!string.IsNullOrWhiteSpace(action.StatusEffect)) { var hasEffect = fface.Player.StatusEffects.Any(effect => Regex.IsMatch(effect.ToString(), action.StatusEffect.Replace(" ", "_"), RegexOptions.IgnoreCase)); // Contains Effect Check if (hasEffect && !action.TriggerOnEffectPresent) { return(false); } // Missing EFfect Check if (!hasEffect && action.TriggerOnEffectPresent) { return(false); } } // Check if action's recast period has passed. if (action.Recast != 0) { if (action.LastCast > DateTime.Now) { return(false); } } return(true); }
public StartEngineState(IMemoryAPI fface) : base(fface) { }
public DeadState(IMemoryAPI fface) : base(fface) { }
public FiniteStateMachine(IMemoryAPI fface) { //Create the states AddComponent(new TrackPlayerState(fface) { Priority = 6 }); AddComponent(new DeadState(fface) { Priority = 6 }); AddComponent(new ZoneState(fface) { Priority = 6 }); AddComponent(new SetTargetState(fface) { Priority = 6 }); AddComponent(new SetFightingState(fface) { Priority = 6 }); AddComponent(new FollowState(fface) { Priority = 5 }); AddComponent(new RestState(fface) { Priority = 2 }); AddComponent(new ApproachState(fface) { Priority = 0 }); AddComponent(new BattleState(fface) { Priority = 3 }); AddComponent(new WeaponskillState(fface) { Priority = 2 }); AddComponent(new PullState(fface) { Priority = 4 }); AddComponent(new StartState(fface) { Priority = 5 }); AddComponent(new TravelState(fface) { Priority = 1 }); AddComponent(new HealingState(fface) { Priority = 2 }); AddComponent(new EndState(fface) { Priority = 3 }); AddComponent(new StartEngineState(fface) { Priority = Constants.MaxPriority }); _components.ForEach(x => x.Enabled = true); }
public TravelState(IMemoryAPI fface, IConfigFactory configFactory) : base(fface) { _configFactory = configFactory; }
public StartState(IMemoryAPI fface) : base(fface) { Executor = new Executor(fface); }
public GameEngine(IMemoryAPI fface) { _fface = fface; _stateMachine = new FiniteStateMachine(fface); _playerMonitor = new PlayerMonitor(fface); }
public ZoneState(IMemoryAPI fface) : base(fface) { _zone = fface.Player.Zone; }
public FiniteStateMachine(IMemoryAPI fface) { _fface = fface; _context = new GameContext(fface); //Create the states AddState(new DeadState() { Priority = 7 }); AddState(new ZoneState() { Priority = 7 }); AddState(new SetTargetState() { Priority = 7 }); AddState(new SetFightingState() { Priority = 7 }); AddState(new FollowState() { Priority = 5 }); AddState(new RestState() { Priority = 2 }); AddState(new SummonTrustsState() { Priority = 6 }); AddState(new ApproachState() { Priority = 0 }); AddState(new BattleState() { Priority = 3 }); AddState(new WeaponskillState() { Priority = 2 }); AddState(new PullState() { Priority = 4 }); AddState(new StartState() { Priority = 5 }); AddState(new TravelState() { Priority = 1 }); AddState(new HealingState() { Priority = 2 }); AddState(new EndState() { Priority = 3 }); AddState(new StartEngineState() { Priority = Constants.MaxPriority }); _states.ForEach(x => x.Enabled = true); }
public StartState(IMemoryAPI fface) : base(fface) { Executor = new Executor(fface); }
/// <summary> /// Filters out unusable buffing abilities. /// </summary> /// <param name="fface"></param> /// <param name="action"></param> /// <param name="units"></param> /// <returns></returns> public static IEnumerable <Result> ValidateBuffingAction( IMemoryAPI fface, BattleAbility action, ICollection <IUnit> units) { // Return if not enabled. if (!action.IsEnabled) { yield return(Result.Fail("Must be enabled")); } // Name Check if (string.IsNullOrWhiteSpace(action.Name)) { yield return(Result.Fail("Must have name")); } // MP Check if (action.Ability.MpCost > fface.Player.MPCurrent) { yield return(Result.Fail("Not enough mp")); } // TP Check if (action.Ability.TpCost > fface.Player.TPCurrent) { yield return(Result.Fail("Not enough tp")); } // MP Range var mpReserve = new Range(action.MPReserveLow, action.MPReserveHigh); if (!mpReserve.InRange(fface.Player.MPPCurrent) && !mpReserve.NotSet()) { yield return(Result.Fail("Outside mp reserve range")); } // TP Range var tpReserve = new Range(action.TPReserveLow, action.TPReserveHigh); if (!tpReserve.InRange(fface.Player.TPCurrent) && !tpReserve.NotSet()) { yield return(Result.Fail("Outside tp reserve range")); } // Usage Limit Check. if (action.UsageLimit != 0) { if (action.Usages > action.UsageLimit) { yield return(Result.Fail("Max uses reached")); } } // Recast Check if (!AbilityUtils.IsRecastable(fface, action.Ability)) { yield return(Result.Fail("Not recastable")); } // Limiting Status Effect Check for Spells. if (ResourceHelper.IsSpell(action.Ability.AbilityType)) { if (ProhibitEffects.ProhibitEffectsSpell.Intersect(fface.Player.StatusEffects).Any()) { yield return(Result.Fail("Status effect blocking spell")); } } // Limiting Status Effect Check for Abilities. if (ResourceHelper.IsAbility(action.Ability.AbilityType)) { if (ProhibitEffects.ProhibitEffectsAbility.Intersect(fface.Player.StatusEffects).Any()) { yield return(Result.Fail("Status effect blocking ability")); } } // Player HP Checks Enabled. if (action.PlayerLowerHealth != 0 || action.PlayerUpperHealth != 0) { // Player Upper HP Check if (fface.Player.HPPCurrent > action.PlayerUpperHealth) { yield return(Result.Fail("Player health too high")); } // Player Lower HP Check if (fface.Player.HPPCurrent < action.PlayerLowerHealth) { yield return(Result.Fail("Player health too low")); } } // Status Effect Checks Enabled if (!string.IsNullOrWhiteSpace(action.StatusEffect)) { var hasEffect = fface.Player.StatusEffects.Any(effect => Regex.IsMatch(effect.ToString(), action.StatusEffect.Replace(" ", "_"), RegexOptions.IgnoreCase)); // Contains Effect Check if (hasEffect && !action.TriggerOnEffectPresent) { yield return(Result.Fail("Player missing status effect")); } // Missing EFfect Check if (!hasEffect && action.TriggerOnEffectPresent) { yield return(Result.Fail("Player contains status effect")); } } // Check if action's recast period has passed. if (action.Recast != 0) { if (action.LastCast > DateTime.Now) { yield return(Result.Fail("Recast period not reached")); } } // Do not cast trust magic with aggro. var isTrustMagic = action.Ability.Type == "Trust"; var hasAggro = units.Any(x => x.HasAggroed); if (isTrustMagic && hasAggro) { yield return(Result.Fail("Cannot use trust magic with aggro")); } }
public EndState(IMemoryAPI fface) : base(fface) { _executor = new Executor(fface); }
protected BaseState(IMemoryAPI fface) { this.fface = fface; }
public Player(IMemoryAPI memoryAPI) { _memoryAPI = memoryAPI; _unitService = new UnitService(memoryAPI); }
private static void SetTargetUsingMemory(IMemoryAPI fface, IUnit target) { fface.Target.SetNPCTarget(target.Id); fface.Windower.SendString(Constants.SetTargetCursor); }
public SetTargetState(IMemoryAPI fface) : base(fface) { _units = new UnitService(fface); }
public static void StopRunning(IMemoryAPI fface) { fface.Navigator.Reset(); TimeWaiter.Pause(100); }
public TravelState(IMemoryAPI fface) : base(fface) { }
public PlayerMovementTracker(IMemoryAPI fface) { _fface = fface; }
public Executor(IMemoryAPI fface) { _fface = fface; }
public CombatState(IMemoryAPI fface) : base(fface) { }
public FollowState(IMemoryAPI fface) : base(fface) { this.UnitService = new UnitService(fface); }
public TrackPlayerState(IMemoryAPI fface) : base(fface) { }
public WeaponskillState(IMemoryAPI fface) : base(fface) { _executor = new Executor(fface); }
public SetFightingState(IMemoryAPI fface) : base(fface) { }
protected BaseState(IMemoryAPI fface) { this.fface = fface; }
/// <summary> /// Returns true if a mob is attackable by the player based on the various settings in the /// Config class. /// </summary> /// <param name="fface"></param> /// <param name="mob"></param> /// <returns></returns> public static bool MobFilter(IMemoryAPI fface, IUnit mob) { // Function to use to filter surrounding mobs by. General Mob Filtering Criteria if (fface == null) { return(false); } if (mob == null) { return(false); } // Mob not active if (!mob.IsActive) { return(false); } // INFO: fixes trying to attack dead mob problem. Mob is dead if (mob.IsDead) { return(false); } // Mob not rendered on screen. if (!mob.IsRendered) { return(false); } // Type is not mob if (!mob.NpcType.Equals(NpcType.Mob)) { return(false); } // Mob is out of range if (!(mob.Distance < Config.Instance.DetectionDistance)) { return(false); } if (mob.IsPet) { return(false); } // If any unit is within the wander distance then the if (Config.Instance.Route.Waypoints.Any()) { if (!(Config.Instance.Route.Waypoints.Any(waypoint => Distance(mob, waypoint) <= Config.Instance.WanderDistance))) { return(false); } } // Mob too high out of reach. if (mob.YDifference > Config.Instance.HeightThreshold) { return(false); } // User Specific Filtering // Performs a case insensitve match on the mob's name. If any part of the mob's name is // in the ignored list, we will not attack it. if (MatchAny(mob.Name, Config.Instance.IgnoredMobs, RegexOptions.IgnoreCase)) { return(false); } // Kill aggro if aggro's checked regardless of target's list but follows the ignored list. if (mob.HasAggroed && Config.Instance.AggroFilter) { return(true); } // There is a target's list but the mob is not on it. if (!MatchAny(mob.Name, Config.Instance.TargetedMobs, RegexOptions.IgnoreCase) && Config.Instance.TargetedMobs.Any()) { return(false); } // Mob on our targets list or not on our ignore list. // Kill the creature if it has aggroed and aggro is checked. if (mob.HasAggroed && Config.Instance.AggroFilter) { return(true); } // Kill the creature if it is claimed by party and party is checked. if (mob.PartyClaim && Config.Instance.PartyFilter) { return(true); } // Kill the creature if it's not claimed and unclaimed is checked. if (!mob.IsClaimed && Config.Instance.UnclaimedFilter) { return(true); } // Kill the creature if it's claimed and we we don't have claim but // claim is checked. //FIX: Temporary fix until player.serverid is fixed. if (mob.IsClaimed && Config.Instance.ClaimedFilter) { return(true); } // Kill only mobs that we have claim on. return(mob.ClaimedId == fface.PartyMember[0].ServerID); }
public Executor(IMemoryAPI fface) { _fface = fface; _caster = new Caster(fface); }
public GameEngine(IMemoryAPI fface) { _fface = fface; _stateMachine = new FiniteStateMachine(fface); }
public RestState(IMemoryAPI fface) : base(fface) { _units = new UnitService(fface); }
public PlayerMonitor(IMemoryAPI memory) { _movementTracker = new PlayerMovementTracker(memory); }
public ApproachState(IMemoryAPI fface) : base(fface) { }
public HealingState(IMemoryAPI fface) : base(fface) { _executor = new Executor(fface); }
public PlayerMonitor(IMemoryAPI memory) { _movementTracker = new PlayerMovementTracker(memory); }
public Caster(IMemoryAPI fface) { _fface = fface; }
/// <summary> /// Create a new <see cref="PathRecorder"/> with saving and /// loading features. /// </summary> /// <param name="memory"></param> public PathRecorder(IMemoryAPI memory) { _memory = memory; _recorder = new Timer(1000); _recorder.Elapsed += RouteRecorder_Tick; }
public DeadState(IMemoryAPI fface) : base(fface) { }
public FollowState(IMemoryAPI fface) : base(fface) { this.UnitService = new UnitService(fface); }
/// <summary> /// Create a new <see cref="PathRecorder"/> with saving and /// loading features. /// </summary> /// <param name="memory"></param> public PathRecorder(IMemoryAPI memory) { _memory = memory; _recorder = new Timer(1000); _recorder.Elapsed += RouteRecorder_Tick; }