override public string Preform() { if (!Utils.GetMyHolders().Any() || !game.GetMyCapsules().Any() || !game.GetAllMotherships().Any()) { if (Main.mines.Count > 0 && game.GetMyMotherships().Any()) { var sailLocation = Utils.GetMyHolders().OrderBy(h => h.Distance(pirate)).First().Location; return(Utils.GetPirateStatus(pirate, "Sailing to rendezvous point, " + Sailing.SafeSail(pirate, sailLocation))); } return(Utils.GetPirateStatus(pirate, "Is idle.")); } var holders = Utils.GetMyHolders().OrderBy(h => h.Distance(pirate)); var cloestHolder = holders.First(); foreach (Pirate holder in Utils.GetMyHolders().OrderBy(h => h.Distance(pirate))) { var nearestShip = Utils.OrderByDistance(game.GetMyMotherships().ToList(), holder.Location).First(); if (!pirate.CanPush(holder)) { var sailLocation = Utils.GetMyHolders().OrderBy(h => h.Distance(pirate)).First().Location; return(Utils.GetPirateStatus(pirate, "Sailing towards holder, " + Sailing.SafeSail(pirate, sailLocation))); } var threats = game.GetEnemyLivingPirates().Where(t => t.PushReloadTurns > 2 && t.Distance(nearestShip) < pirate.Distance(nearestShip) * 1.5).OrderBy(nearestShip.Distance); // Checks if the holder can be pushed directly onto the ship bool caseI = holder.Distance(nearestShip) - game.MothershipUnloadRange <= pirate.PushDistance + holder.MaxSpeed; bool caseII = false; if (threats.Any() && threats.First().Distance(nearestShip) > holder.Distance(nearestShip)) { caseII = holder.Distance(nearestShip) - threats.First().Distance(nearestShip) < pirate.PushRange; } var holderLocAfterPush = holder.GetLocation().Towards(nearestShip, pirate.PushDistance + holder.MaxSpeed / 2); bool caseIII_PI = threats.Any() && threats.First().Distance(nearestShip) < holder.Distance(nearestShip); bool caseIII_PII = threats.Any() && threats.First().PushRange < holderLocAfterPush.Distance(threats.First()); bool ImminentDeath = game.GetEnemyLivingPirates().Count(t => holder.InRange(t, holder.MaxSpeed + t.PushRange) && t.PushReloadTurns <= 1) >= holder.NumPushesForCapsuleLoss; if (ImminentDeath && !caseI && holder.MaxSpeed * 10 < holder.Distance(nearestShip)) { var safest = Sailing.SafestCloestLocation(holder.Location, nearestShip.Location, 2, true, pirate); pirate.Push(holder, safest); Main.piratesPushed.Add(holder); Main.didTurn.Add(pirate.Id); if (!Main.didTurn.Contains(holder.Id)) { holder.Push(pirate, safest); Main.piratesPushed.Add(pirate); Main.didTurn.Add(holder.Id); } return(Utils.GetPirateStatus(pirate, "Moved away from danger zone")); } bool caseIII = threats.Any() && caseIII_PI && caseIII_PII && ImminentDeath; game.Debug(caseI + " || " + caseII + " || " + caseIII + " +| IMD: " + ImminentDeath); if (caseI || caseIII) { if (Utils.GetMyHolders().Count() > 1) { var secondHolder = Utils.GetMyHolders().First(h => h.Id != holder.Id); if (!Main.didTurn.Contains(holder.Id) && holder.CanPush(secondHolder) && !Main.piratesPushed.Contains(secondHolder) && secondHolder.Distance(nearestShip) - nearestShip.UnloadRange < pirate.PushDistance + secondHolder.MaxSpeed) { holder.Push(secondHolder, nearestShip); Main.piratesPushed.Add(secondHolder); pirate.Push(holder, nearestShip); Main.piratesPushed.Add(holder); if (!Main.didTurn.Contains(secondHolder.Id) && holder.NumPushesForCapsuleLoss > 2 && secondHolder.CanPush(holder)) { secondHolder.Push(holder, nearestShip); Main.piratesPushed.Add(holder); } Main.didTurn.Add(holder.Id); Main.didTurn.Add(pirate.Id); return(Utils.GetPirateStatus(pirate, "Pushed holder to the motherShip while the holder boosted another holder")); } } if (!Main.didTurn.Contains(holder.Id)) { holder.Sail(nearestShip); Main.didTurn.Add(holder.Id); } pirate.Push(holder, nearestShip); Main.didTurn.Add(pirate.Id); Main.piratesPushed.Add(holder); return(Utils.GetPirateStatus(pirate, "Pushed holder directly to ship")); } Main.holdersPaired.Add(holder); return(Utils.GetPirateStatus(pirate, "Sailing towards paired holder, " + Sailing.SafeSail(pirate, holder.Location))); } return("Did nothing"); }