private static bool AtMaxFight(GeoLevelController geoLevel, IGeoFactionMissionParticipant attacker) { try { if (geoLevel?.Map == null || IsAlienOrPP(attacker)) { return(false); } foreach (GeoSite site in geoLevel.Map.AllSites) { if (!(site.ActiveMission is GeoHavenDefenseMission mission)) { continue; } if (Config.No_Attack_When_Sieged_Difficulty >= difficulty && IsAlien(mission.GetEnemyFaction()) && site.Owner == attacker) { Verbo("{0} is being sieged by alien at {0}.", site.Name); return(true); } if (Config.One_Global_Attack_Difficulty >= difficulty) { Verbo("Global attack limit: {0} already under siege.", site.Name); return(true); // Rokkie and Veteran limits to 1 faction war on globe } if (Config.One_Attack_Per_Faction_Difficulty >= difficulty && mission.GetEnemyFaction() == attacker) { Verbo("Faction attack limit: {0} already sieging {1}.", attacker.GetPPName(), site.Name); return(true); // Hero and Legend limits to 1 attack per faction } } return(false); } catch (Exception ex) { return(!Error(ex)); } }
private static bool ShouldStopFight(GeoLevelController geoLevel, IGeoFactionMissionParticipant from) { try { if (Config.Stop_OneSided_War && lastAttacker != null && from == lastAttacker) { Verbo("One sided war; {0} has already attacked.", from.GetPPName()); return(true); } return(AtMaxFight(geoLevel, from)); } catch (Exception ex) { return(!Error(ex)); } }