GUnit FindBestTarget() { if (target == null || ppather.IsBlacklisted(target)) UpdateTimer.ForceReady(); else { if (!target.IsValid || target.IsDead) UpdateTimer.ForceReady(); } if (UpdateTimer.IsReady) { GPlayer[] players = GObjectList.GetPlayers(); float[] playerScore = new float[players.Length]; float best_score = 0; GPlayer best_player = null; for (int i = 0; i < players.Length; i++) { GPlayer player = players[i]; if (!player.IsSameFaction || ppather.IsBlacklisted(player) || player == GContext.Main.Me || player.Health < 0.05) { playerScore[i] = -100f; } else { for (int j = 0; j < players.Length; j++) { if (players[j].IsSameFaction && players[j] != GContext.Main.Me && players[j] != player && players[j].Health > 0.05) { double d = players[j].GetDistanceTo(player); if (d < 30) { playerScore[i] += 30f - (float)d; } } } } if (playerScore[i] > best_score) { best_player = player; best_score = playerScore[i]; } } if (best_score > 50) { target = best_player; if (target != null) PPather.WriteLine("follow player " + target.Name + " score " + best_score); } else target = null; UpdateTimer.Reset(); } return target; }
GUnit FindMobToPull() { // Find stuff to pull GUnit closest = null; // only assist players //GMonster[] monsters = GObjectList.GetMonsters(); GPlayer[] players = GObjectList.GetPlayers(); List <GUnit> units = new List <GUnit>(); //units.AddRange(monsters); units.AddRange(players); float me_z = GContext.Main.Me.Location.Z; foreach (GUnit cur in units) { GUnit unit = cur.Target; if (cur.Reaction != GReaction.Friendly || !cur.IsInCombat || unit == null) { continue; } if (!unit.IsDead && unit.Reaction != GReaction.Friendly && unit.IsInCombat && unit.DistanceToSelf < Distance && !ppather.IsBlacklisted(unit) && !PPather.IsStupidItem(unit)) { Location ml = new Location(unit.Location); float dz = (float)Math.Abs(ml.Z - me_z); if (dz < 30.0f) { if (PPather.world.IsUnderwaterOrInAir(ml)) { PPather.WriteLine(unit.Name + " is underwater or flying"); ppather.Blacklist(unit); } else { if (closest == null || unit.DistanceToSelf < closest.DistanceToSelf) { closest = unit; } } } } } //PPather.WriteLine("Returning unit: " + (closest == null ? "null" : closest.Name)); return(closest); }
public GPlayer GetClosestPlayer() { GPlayer[] plys = GObjectList.GetPlayers(); GPlayer ClosestPlayer = null; foreach (GPlayer p in plys) { if (p != Me) { if (ClosestPlayer == null || p.GetDistanceTo(Me) < ClosestPlayer.GetDistanceTo(Me)) { ClosestPlayer = p; } } } return(ClosestPlayer); }
const int CHECKFORHUB = 6; //If more than 5 players around we are probably in a hub public bool CheckFollowers() { bool found; TimeSpan telapsed; if (AlertTime <= 0 && LogoutTime <= 0) { return(false); //User does not want us to do follower logout } //if only 1 is 0 we will act accordingly GPlayer[] PlayerList = GObjectList.GetPlayers(); if (PlayerList.Length < CHECKFORHUB) //Only detect followers if we are not in a hub { foreach (GPlayer temp in PlayerList) { found = false; if (temp != GContext.Main.Me) //Make sure the potential follower is not my soul { foreach (Follower tempf in Followers) { if (temp.GUID == tempf.player.GUID) { found = true; telapsed = DateTime.Now - tempf.firstseen; //Total time follower has been in range if (telapsed.TotalMinutes > LogoutTime && LogoutTime > 0) { PPather.WriteLine("Detection: Followed by " + tempf.player.Name + " for too long. Stopping Glide."); return(true); } else if (telapsed.TotalMinutes > AlertTime && AlertTime > 0) { AlertFollower(tempf); tempf.alerted = true; //Don't play alert sound for this player again } tempf.lastseen = DateTime.Now; } } if (found == false) { Followers.Add(new Follower(temp)); // Add new follower to list PPather.WriteLine("Detection: New friend: " + temp.Name + ": " + temp.PlayerRace + " " + temp.PlayerClass); } } } } for (int i = Followers.Count - 1; i >= 0; i--) { telapsed = DateTime.Now - Followers[i].lastseen; if (telapsed.TotalMinutes > TIMEOUT) // Test to see if follower has moved along { PPather.WriteLine("Detection: Removing friend: " + Followers[i].player.Name); Followers.RemoveAt(i); } } return(false); }
public virtual GUnit FindMobToPull() { // Find stuff to pull GUnit closest = null; GMonster[] monsters = GObjectList.GetMonsters(); GPlayer[] players = /*doPvp ? */ GObjectList.GetPlayers() /* new GPlayer[] { }*/; // maybe use GObjectList.GetUnits() instead List <GUnit> units = new List <GUnit>(); units.AddRange(monsters); units.AddRange(players); float me_z = GContext.Main.Me.Location.Z; foreach (GUnit unit in units) { //PPather.WriteLine( // string.Format("Considering {0}, D={1}, P={2}, R={3}, TM={4}, TP={5}, BL={6}, V={7}", // unit.Name, // unit.IsDead.ToString()[0], // unit.IsPlayer.ToString()[0], // unit.Reaction.ToString()[0], // unit.IsTargetingMe.ToString()[0], // unit.IsTargetingMyPet.ToString()[0], // ppather.IsBlacklisted(unit).ToString()[0], // IsValidTarget(unit).ToString()[0])); if (!unit.IsDead && unit.Reaction != GReaction.Friendly && ((unit.IsPlayer || !((GMonster)unit).IsTagged) || unit.IsTargetingMe || unit.IsTargetingMyPet) && unit.DistanceToSelf < Distance && !ppather.IsBlacklisted(unit) && IsValidTarget(unit) && !IsPet(players, unit) && !PPather.IsStupidItem(unit)) { if (skipMobsWithAdds) { List <GMonster> closeUnits = ppather.CheckForMobsAtLoc(unit.Location, addsDistance); if (closeUnits.Count >= addsCount) { continue; } } Location ml = new Location(unit.Location); float dz = (float)Math.Abs(ml.Z - me_z); if (dz < 30.0f) { if (PPather.world.IsUnderwaterOrInAir(ml)) { PPather.WriteLine(unit.Name + " is underwater or flying"); ppather.Blacklist(unit); } else { // replace closest if unit is closer but do not replace closest if // closest is a player and unit is not a player if (closest == null || (unit.DistanceToSelf < closest.DistanceToSelf && (!closest.IsPlayer || unit.IsPlayer))) { closest = unit; } } } } } //PPather.WriteLine("Returning unit: " + (closest == null ? "null" : closest.Name)); return(closest); }