private static void HandlePlayerClanReplacements(Settlement settlement) { if ((settlement.IsTown && !settlement.Town.IsRebeling) || (settlement.IsVillage && !settlement.Village.Bound.Town.IsRebeling)) { foreach (Hero notable in settlement.Notables) { if (notable.CanHaveRecruits) { bool flag = false; CultureObject cultureObject = (notable.CurrentSettlement != null) ? notable.CurrentSettlement.Culture : notable.Clan.Culture; // Change cultureObject based on town's loyalty if (ATCSettings.Instance.EnableCCC) { if (settlement.IsTown) { if (MBRandom.RandomInt(0, 100) <= (ATCSettings.Instance.CCCAmount * notable.CurrentSettlement.Town.Loyalty / 100)) { cultureObject = (notable.CurrentSettlement != null) ? notable.CurrentSettlement.MapFaction.Culture : notable.Clan.Culture; } } else if (settlement.IsVillage) { if (MBRandom.RandomInt(0, 100) <= (ATCSettings.Instance.CCCAmount * notable.CurrentSettlement.Village.Bound.Town.Loyalty / 100)) { cultureObject = (notable.CurrentSettlement != null) ? notable.CurrentSettlement.MapFaction.Culture : notable.Clan.Culture; } } } CharacterObject basicTroop = cultureObject.BasicTroop; double num = (notable.IsRuralNotable && notable.Power >= 200) ? 1.0 : 0.5; float num2 = 200f; for (int i = 0; i < 6; i++) { if (MBRandom.RandomFloat < (Campaign.Current.Models.VolunteerProductionModel.GetDailyVolunteerProductionProbability(notable, i, settlement) * ATCSettings.Instance.RecruitSpawnFactor)) { if (notable.VolunteerTypes[i] == null) { notable.VolunteerTypes[i] = ATCconfig.GetReplacement("player_clan_basic", basicTroop); if (ATCSettings.Instance.DebugReplacementMsg && notable.CurrentSettlement.Culture.Name != notable.CurrentSettlement.MapFaction.Culture.Name) { SubModule.log.Add("UpdateVolunteersOfNotables -> Settlement " + notable.CurrentSettlement.Name + "(Culture: " + notable.CurrentSettlement.Culture.Name + ", Owner: " + notable.CurrentSettlement.MapFaction.Name + ") received new recruit: " + notable.VolunteerTypes[i].Name); } flag = true; } else { float num3 = num2 * num2 / (Math.Max(50f, (float)notable.Power) * Math.Max(50f, (float)notable.Power)); int level = notable.VolunteerTypes[i].Level; if (MBRandom.RandomInt((int)Math.Max(2.0, (double)((float)level * num3) * num * 1.5)) == 0 && notable.VolunteerTypes[i].UpgradeTargets != null && notable.VolunteerTypes[i].Level < 20) { if (notable.VolunteerTypes[i] == basicTroop && HeroHelper.HeroShouldGiveEliteTroop(notable)) { notable.VolunteerTypes[i] = ATCconfig.GetReplacement("player_clan_elite", cultureObject.EliteBasicTroop); flag = true; } else { notable.VolunteerTypes[i] = notable.VolunteerTypes[i].UpgradeTargets[MBRandom.RandomInt(notable.VolunteerTypes[i].UpgradeTargets.Length)]; flag = true; } } } } } if (flag) { SortVolunteers(notable.VolunteerTypes); } } } } }
private static bool IsPlayerClanConfigured() { return(ATCconfig.GetTroopConfig("player_clan_basic") != null && ATCconfig.GetTroopConfig("player_clan_elite") != null); }
private static bool IsPlayerKingdomConfigured() { return(ATCconfig.GetTroopConfig("player_kingdom_basic") != null && ATCconfig.GetTroopConfig("player_kingdom_elite") != null); }
public override void OnGameInitializationFinished(Game game) { base.OnGameInitializationFinished(game); log.Initialize(); if (Campaign.Current == null) { return; } string[] modNames = Campaign.Current.SandBoxManager.ModuleManager.ModuleNames; if (!ATCSettings.Instance.EnableModScan) { localATConfigs = Directory.GetFiles(modATCPath, "*ATC.modconfig.xml", SearchOption.AllDirectories); if (localATConfigs.Length != 0) { foreach (string file in localATConfigs) { ATCconfig.Instance.LoadXML(file); mergeConfigs = true; } } else { log.Add("ERROR: Mod Scan disabled and no *ATC.modconfig.xml found in /AdonnaysTroopChanger/Config!"); log.Add("ERROR: Either allow ATC to scan for mods in Mod Options -> Enable Mod Scan (recommended for beginners!) or create your own ATC.modconfig.xml (recommended for advanced users)."); log.Add("FATAL ERROR: ATC Disabled!"); disableATC = true; } } else { foreach (string modName in modNames) { string modPath = String.Concat(modulePath, modName, "/"); foreignConfigs = Directory.GetFiles(modPath, "*ATC.modconfig.xml", SearchOption.AllDirectories); foreach (string file in foreignConfigs) { ATCconfig.Instance.LoadXML(file); mergeConfigs = true; } } if (!mergeConfigs) { log.Add("ERROR: Mod Scan enabled but no *ATC.modconfig.xml found in any of the /Modules subfolders!"); log.Add("ERROR: Please check if your troop mods are ATC 1.2.x compatible or create your own *ATC.modconfig.xml."); log.Add("ERROR: Workaround: If the troop mod came with an 1.1.x ATC.config.xml, just rename that to ATC.modconfig.xml."); log.Add("FATAL ERROR: ATC Disabled!"); disableATC = true; } } if (SubModule.disableATC) { return; } ATCconfig.ValidateTroops(); if (mergeConfigs) { ATCconfig.Instance.SaveMergedXML(mergedFile); } }