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; }
public static void ReadyItemCacheTimer() { curItemCacheTimer.ForceReady(); }