public Dynasty GetDynasty(CultureParser culture) { ScriptScope scope = new ScriptScope(); scope.Name = ID.ToString(); ID++; do { Name = culture.dna.GetDynastyName(); } while (Name == null || Name.Trim().Length == 0); var nameScope = new ScriptCommand("name", Name, scope); scope.Add(nameScope); scope.Add(new ScriptCommand("culture", culture.Name, scope)); script.Root.Add(scope); var d = new Dynasty() { ID = ID - 1, Scope = scope, NameScope = nameScope }; d.Color = Color.FromArgb(255, Rand.Next(200) + 55, Rand.Next(200) + 55, Rand.Next(200) + 55); DynastyMap[ID - 1] = d; culture.Dynasties.Add(d); return(d); }
public void Mutate(ReligionParser rel, CultureParser culture, int nChanges) { this.dna = culture.dna; this.ai_convert_other_group = rel.ai_convert_other_group; this.max_consorts = rel.max_consorts; this.max_wives = rel.max_wives; this.religious_clothing_head = rel.religious_clothing_head; this.religious_clothing_priest = rel.religious_clothing_priest; this.allow_looting = rel.allow_looting; this.allow_rivermovement = rel.allow_rivermovement; this.allow_viking_invasion = rel.allow_viking_invasion; this.autocephaly = rel.autocephaly; this.bs_marriage = rel.bs_marriage; this.can_call_crusade = rel.can_call_crusade; this.can_excommunicate = rel.can_excommunicate; this.can_grant_claim = rel.can_grant_claim; this.can_grant_divorce = rel.can_grant_divorce; this.can_have_antipopes = rel.can_have_antipopes; this.can_hold_temples = rel.can_hold_temples; this.can_retire_to_monastery = rel.can_retire_to_monastery; this.divine_blood = rel.divine_blood; this.female_temple_holders = rel.female_temple_holders; this.hasLeader = rel.hasLeader; this.has_heir_designation = rel.has_heir_designation; this.investiture = rel.investiture; this.matrilineal_marriages = rel.matrilineal_marriages; this.pacifist = rel.pacifist; this.pc_marriage = rel.pc_marriage; this.peace_prestige_loss = rel.peace_prestige_loss; this.polytheism = rel.polytheism; this.priests_can_inherit = rel.priests_can_inherit; this.psc_marriage = rel.psc_marriage; high_god_name = rel.high_god_name; devil = rel.devil; priest = rel.priest; gods.AddRange(rel.gods); int r = Rand.Next(255); int g = Rand.Next(255); int b = Rand.Next(255); r = rel.r; g = rel.g; b = rel.b; switch (Rand.Next(3)) { case 0: r += Rand.Next(-45, 45); g += Rand.Next(-25, 25); b += Rand.Next(-15, 15); break; case 1: g += Rand.Next(-45, 45); r += Rand.Next(-25, 25); b += Rand.Next(-15, 15); break; case 2: b += Rand.Next(-45, 45); g += Rand.Next(-25, 25); r += Rand.Next(-15, 15); break; } if (r > 255) { r = 255; } if (g > 255) { g = 255; } if (b > 255) { b = 255; } if (r < 0) { r = 0; } if (g < 0) { g = 0; } if (b < 0) { b = 0; } for (int n = 0; n < nChanges; n++) { MakeChange(); } DoReligionScope(high_god_name, devil, priest, scripture_name, crusade_name, culture.dna, r, g, b); }
private void DoRandomSmallChange() { { switch (Rand.Next(11)) { case 0: founder_named_dynasties = !founder_named_dynasties; break; case 1: dynasty_title_names = !dynasty_title_names; break; case 2: baron_titles_hidden = !baron_titles_hidden; break; case 3: count_titles_hidden = !count_titles_hidden; break; case 4: dukes_called_kings = !dukes_called_kings; break; case 5: from_dynasty_prefix = ConstructWord(2, 3); break; case 6: this.female_patronym = ConstructWord(3, 4).ToLower(); this.male_patronym = ConstructWord(3, 4).ToLower(); if (Rand.Next(10) == 0) { this.female_patronym = ConstructWord(3, 4); this.male_patronym = ConstructWord(3, 4); } break; case 7: // Change place format { this.placeFormat = null; } break; case 8: WordFormats.RemoveAt(Rand.Next(WordFormats.Count)); WordFormats.Add(CommonWordFormats[Rand.Next(CommonWordFormats.Count)]); break; case 9: tribal = !tribal; break; case 10: // for (int n = 0; n < 3; n++) { switch (Rand.Next(6)) { case 0: empTitle = ConstructWord(2, 5); empTitle = LanguageManager.instance.AddSafe(empTitle); break; case 1: kingTitle = ConstructWord(2, 5); kingTitle = LanguageManager.instance.AddSafe(kingTitle); break; case 2: dukeTitle = ConstructWord(2, 5); dukeTitle = LanguageManager.instance.AddSafe(dukeTitle); break; case 3: countTitle = ConstructWord(2, 5); countTitle = LanguageManager.instance.AddSafe(countTitle); break; case 4: baronTitle = ConstructWord(2, 5); baronTitle = LanguageManager.instance.AddSafe(baronTitle); break; case 5: mayorTitle = ConstructWord(2, 8); mayorTitle = LanguageManager.instance.AddSafe(mayorTitle); break; } } break; } } if (culture != null) { culture.DoDetailsForCulture(); } }
public void DoReligiousEquivelents() { if (!SaveReligions) { return; } if (AllReligionGroups.Count == 1) { return; } AllReligionGroups.Sort(SortByBelievers); if (AllReligionGroups.Count >= 6) { this.ChristianGroupSub = AllReligionGroups[Rand.Next(AllReligionGroups.Count) / 2]; this.ChristianGroupSub.Name = this.ChristianGroupSub.Scope.Name; AllReligionGroups.Remove(ChristianGroupSub); this.MuslimGroupSub = AllReligionGroups[Rand.Next(AllReligionGroups.Count) / 2]; this.MuslimGroupSub.Name = this.MuslimGroupSub.Scope.Name; AllReligionGroups.Remove(MuslimGroupSub); this.IndianGroupSub = AllReligionGroups[Rand.Next(AllReligionGroups.Count) / 2]; this.IndianGroupSub.Name = this.IndianGroupSub.Scope.Name; AllReligionGroups.Remove(IndianGroupSub); this.ZoroGroupSub = AllReligionGroups[Rand.Next(AllReligionGroups.Count) / 2]; ZoroGroupSub.Name = this.ZoroGroupSub.Scope.Name; AllReligionGroups.Remove(ZoroGroupSub); this.PaganGroupSub = AllReligionGroups[Rand.Next(AllReligionGroups.Count) / 2]; PaganGroupSub.Name = this.PaganGroupSub.Scope.Name; AllReligionGroups.Remove(PaganGroupSub); this.JewGroupSub = AllReligionGroups[Rand.Next(AllReligionGroups.Count) / 2]; JewGroupSub.Name = this.JewGroupSub.Scope.Name; AllReligionGroups.Remove(JewGroupSub); // prevent the following groups from being the same while (ZoroGroupSub == MuslimGroupSub) { ZoroGroupSub = AllReligionGroups[Rand.Next(AllReligionGroups.Count)]; } while (ChristianGroupSub == MuslimGroupSub) { ChristianGroupSub = AllReligionGroups[Rand.Next(AllReligionGroups.Count)]; } while (JewGroupSub == MuslimGroupSub) { JewGroupSub = AllReligionGroups[Rand.Next(AllReligionGroups.Count)]; } } else { if (AllReligionGroups.Count > 3) { this.ChristianGroupSub = AllReligionGroups[Rand.Next(AllReligionGroups.Count / 2)]; this.ChristianGroupSub.Name = this.ChristianGroupSub.Scope.Name; AllReligionGroups.Remove(ChristianGroupSub); this.MuslimGroupSub = AllReligionGroups[Rand.Next(AllReligionGroups.Count / 2)]; this.MuslimGroupSub.Name = this.MuslimGroupSub.Scope.Name; AllReligionGroups.Remove(MuslimGroupSub); } else { this.ChristianGroupSub = AllReligionGroups[Rand.Next(AllReligionGroups.Count)]; this.ChristianGroupSub.Name = this.ChristianGroupSub.Scope.Name; this.MuslimGroupSub = AllReligionGroups[Rand.Next(AllReligionGroups.Count)]; this.MuslimGroupSub.Name = this.MuslimGroupSub.Scope.Name; } this.IndianGroupSub = AllReligionGroups[Rand.Next(AllReligionGroups.Count)]; this.IndianGroupSub.Name = this.IndianGroupSub.Scope.Name; this.ZoroGroupSub = AllReligionGroups[Rand.Next(AllReligionGroups.Count)]; ZoroGroupSub.Name = this.ZoroGroupSub.Scope.Name; this.PaganGroupSub = AllReligionGroups[Rand.Next(AllReligionGroups.Count)]; PaganGroupSub.Name = this.PaganGroupSub.Scope.Name; this.JewGroupSub = AllReligionGroups[Rand.Next(AllReligionGroups.Count)]; JewGroupSub.Name = this.JewGroupSub.Scope.Name; // prevent the following groups from being the same while (ZoroGroupSub == MuslimGroupSub) { ZoroGroupSub = AllReligionGroups[Rand.Next(AllReligionGroups.Count)]; } while (ChristianGroupSub == MuslimGroupSub) { ChristianGroupSub = AllReligionGroups[Rand.Next(AllReligionGroups.Count)]; } while (JewGroupSub == MuslimGroupSub) { JewGroupSub = AllReligionGroups[Rand.Next(AllReligionGroups.Count)]; } } this.ChristianGroupSub.Religions.Sort(SortByBelieversReligion); this.CatholicSub = this.ChristianGroupSub.Religions[0]; // this.CatholicSub.Name = this.CatholicSub.Scope.Name; this.OrthodoxSub = this.ChristianGroupSub.Religions[1]; // this.OrthodoxSub.Name = this.OrthodoxSub.Scope.Name; this.MuslimGroupSub.Religions.Sort(SortByBelieversReligion); this.SunniEquiv = this.MuslimGroupSub.Religions[0]; // this.SunniEquiv.Name = this.SunniEquiv.Scope.Name; this.ShiiteEquiv = this.MuslimGroupSub.Religions[1]; // this.ShiiteEquiv.Name = this.ShiiteEquiv.Scope.Name; while (IndianGroupSub.Religions.Count < 3) { this.IndianGroupSub = AllReligionGroups[Rand.Next(AllReligionGroups.Count)]; // this.IndianGroupSub.Name = this.IndianGroupSub.Scope.Name; } { this.HinduEquiv = this.IndianGroupSub.Religions[0]; // this.HinduEquiv.Name = this.HinduEquiv.Scope.Name; this.BuddhistEquiv = this.IndianGroupSub.Religions[1]; // this.BuddhistEquiv.Name = this.BuddhistEquiv.Scope.Name; this.JainEquiv = this.IndianGroupSub.Religions[2]; // this.JainEquiv.Name = this.JainEquiv.Scope.Name; } this.PaganGroupSub.Religions.Sort(SortByBelieversReligion); this.NorseSub = this.PaganGroupSub.Religions[0]; // this.NorseSub.Name = this.NorseSub.Scope.Name; this.NorseReformSub = this.PaganGroupSub.Religions[1]; // this.NorseReformSub.Name = this.NorseSub.Scope.Name; foreach (var religionParser in PaganGroupSub.Religions) { religionParser.polytheism = true; religionParser.hasLeader = false; } foreach (var religionParser in this.ChristianGroupSub.Religions) { religionParser.hasLeader = true; } this.NorseSub.allow_viking_invasion = true; this.NorseSub.allow_looting = true; this.JainEquiv.pacifist = false; this.JainEquiv.can_call_crusade = true; this.HinduEquiv.pacifist = true; this.HinduEquiv.can_call_crusade = false; this.BuddhistEquiv.pacifist = true; this.BuddhistEquiv.can_call_crusade = false; foreach (var religionParser in AllReligions) { religionParser.RedoReligionScope(); } }
public void RandomReligionProperties() { this.divine_blood = Rand.Next(2) == 0;; this.female_temple_holders = Rand.Next(2) == 0; this.priests_can_inherit = Rand.Next(2) == 0; matrilineal_marriages = Rand.Next(4) != 0; bool warLike = Rand.Next(2) == 0; if (Rand.Next(2) == 0) { Resilience = Rand.Next(2); } else { Resilience = Rand.Next(5); } if (warLike) { this.allow_looting = true; this.allow_viking_invasion = true; this.can_call_crusade = true; if (Rand.Next(2) == 0) { this.peace_prestige_loss = true; } } else { if (Rand.Next(5) == 0) { this.pacifist = true; } if (Rand.Next(2) == 0) { this.can_call_crusade = false; } } this.polytheism = Rand.Next(2) == 0; // this.polytheism = true; if (polytheism) { this.hasLeader = false;//Rand.Next(3) == 0; } else { this.hasLeader = true; } this.can_grant_claim = Rand.Next(3) != 0; this.can_grant_divorce = Rand.Next(2) != 0; this.can_excommunicate = Rand.Next(2) != 0; this.can_hold_temples = Rand.Next(3) != 0; this.can_retire_to_monastery = Rand.Next(2) != 0; this.can_have_antipopes = Rand.Next(2) != 0 && hasLeader; this.autocephaly = false;//Rand.Next(3) == 0; investiture = Rand.Next(2) == 0 && hasLeader; this.icon = Rand.Next(52) + 1; this.heresy_icon = Rand.Next(52) + 1; if (Rand.Next(2) == 0) { this.ai_convert_other_group = 0; } else { this.ai_convert_other_group = 2; } this.has_heir_designation = Rand.Next(4) == 0; if (Rand.Next(2) == 0) { if (Rand.Next(2) == 0) { max_consorts = 1 + Rand.Next(5); } else { { max_wives = 2 + Rand.Next(4); } } } if (Rand.Next(6) == 0) { this.bs_marriage = true; if (Rand.Next(3) == 0) { this.pc_marriage = true; } } religious_clothing_head = Rand.Next(4); religious_clothing_priest = Rand.Next(4); }
public Module CreateReligionPhilosophy(String nameSpace, String religion, List <SchoolInfo> schools) { Module m = new Module(); m.name = religion + "_philosophies"; m.nameSpace = nameSpace; String eventID = ""; int n = 1; var schoolss = new List <SchoolTypes>(Schools); foreach (var school in schools) { ScriptScope decision = new ScriptScope(); ScriptScope trait = new ScriptScope(); int nn = Rand.Next(schoolss.Count); var schooldata = schoolss[nn]; schoolss.RemoveAt(nn); String otherSchools = ""; foreach (var schoolInfo in schools) { if (schoolInfo.Name == school.Name) { continue; } otherSchools += StarNames.SafeName(schoolInfo.Name) + "\n\r"; } String rname = LanguageManager.instance.Get(religion); ScriptScope ev = new ScriptScope(); eventID = nameSpace + "." + n; String eventDesc = eventID + "desc"; TraitManager.instance.AddTrait(StarNames.SafeName(school.Name)); LanguageManager.instance.Add(StarNames.SafeName(school.Name), school.Name); LanguageManager.instance.Add("embrace_" + StarNames.SafeName(school.Name), "Embrace " + school.Name); LanguageManager.instance.Add("embrace_" + StarNames.SafeName(school.Name) + "_desc", "You embrace " + school.Name + ", a philosophy of " + rname + " that promotes " + schooldata.principles + @". Members of the opposing philosophies will disapprove."); LanguageManager.instance.Add(StarNames.SafeName(school.Name) + "_desc", "Follows the school of " + school.Name + ", a philosophy of " + rname + " that promotes " + schooldata.principles + @"."); LanguageManager.instance.Add(eventDesc, "You have embraced the " + school.Name + " philosophy of " + rname); LanguageManager.instance.Add("embrace_" + StarNames.SafeName(school.Name) + "_desc", "Praise " + ReligionManager.instance.ReligionMap[religion].high_god_name + ", " + school.Name + " is the way!"); LanguageManager.instance.Add("embrace_" + StarNames.SafeName(school.Name) + "_event_desc", "You embrace " + school.Name + ", a philosophy of " + rname + " that promotes " + schooldata.principles + @". Members of the opposing philosophies will disapprove."); ev.Do(@" id = " + eventID + @" desc = " + eventDesc + @" picture = GFX_evt_kaaba border = GFX_event_normal_frame_religion is_triggered_only = yes hide_from = yes option = { name = " + "embrace_" + StarNames.SafeName(school.Name) + "_desc" + @" add_trait = " + StarNames.SafeName(school.Name) + @" } "); decision.Do(@" potential = { has_dlc = ""Sons of Abraham"" religion = " + religion + @" NOT = { OR = { } } is_ruler = yes age = 16 prisoner = no } allow = { piety = 50 } effect = { add_trait = " + StarNames.SafeName(school.Name) + @" character_event = { id = " + eventID + @" tooltip = " + "embrace_" + StarNames.SafeName(school.Name) + "_event_desc" + @" } } revoke_allowed = { always = no } ai_will_do = { factor = 1 modifier = { factor = " + schooldata.ZealousMod + @" trait = zealous } modifier = { factor = " + schooldata.CynicalMod + @" trait = cynical } modifier = { factor = 1.2 liege = { trait = " + StarNames.SafeName(school.Name) + @" } } modifier = { factor = 0.05 # Slow it down } } "); trait.Do(@" opposites = { " + otherSchools + @" } " + schooldata.effectString + @" customizer = no random = no opposite_opinion = -20 same_opinion = 20 religious = yes "); n++; m.Decisions["embrace_" + StarNames.SafeName(school.Name)] = decision; m.Events["embrace_" + StarNames.SafeName(school.Name)] = ev; m.Traits[StarNames.SafeName(school.Name)] = trait; } return(m); }
public CharacterParser FindPreviousOwner(CharacterParser prevOwner, List <CharacterParser> prevOwners, int year) { List <CharacterParser> choices = new List <CharacterParser>(); List <CharacterParser> choicesDyn = new List <CharacterParser>(); if (prevOwner == null) { return(null); } CultureParser cul = prevOwner.Culture; for (int index = 0; index < Characters.Count; index++) { var characterParser = Characters[index]; if (characterParser.isFemale) { continue; } if (prevOwners.Contains(characterParser)) { continue; } if (year <= characterParser.YearOfBirth) { continue; } if (year >= characterParser.YearOfDeath) { continue; } if (characterParser.Culture != cul) { continue; } if (characterParser.Father == null) { continue; } if (prevOwner != null) { if (prevOwner == characterParser) { continue; } } if (prevOwner.Dynasty != characterParser.Dynasty) { choices.Add(characterParser); } else { choicesDyn.Add(characterParser); } } if (Rand.Next(6) != 0 && choicesDyn.Count > 0) { return(choicesDyn[Rand.Next(choicesDyn.Count)]); } if (choices.Count > 0) { return(choices[Rand.Next(choices.Count)]); } return(null); }
public void CalculateCulturesProper() { foreach (var cultureGroupParser in AllCultureGroups) { if (cultureGroupParser.Name == "norse") { continue; } if (cultureGroupParser.Provinces.Count == 0) { continue; } var province = cultureGroupParser.Provinces[Rand.Next(cultureGroupParser.Provinces.Count)]; List <ProvinceParser> target = new List <ProvinceParser>(); target.Add(province); target.AddRange(province.Adjacent.Where(p => p.land == true && p.title != null)); for (int x = 0; x < 8; x++) { var toAdd = new List <ProvinceParser>(); target.ForEach(p => toAdd.AddRange(p.Adjacent.Where(pp => pp.land && pp.title != null && !target.Contains(pp)))); target.AddRange(toAdd); } HashSet <ProvinceParser> toDo = new HashSet <ProvinceParser>(target); foreach (var provinceParser in toDo) { provinceParser.Culture = cultureGroupParser.Cultures[0]; if (provinceParser.Culture.Group.ReligionGroup != null) { provinceParser.Religion = provinceParser.Culture.Group.ReligionGroup.Religions[0]; } else { provinceParser.Religion = ReligionManager.instance.AllReligions[0]; } } } for (int index = 0; index < AllCultureGroups.Count; index++) { var cultureGroupParser = AllCultureGroups[index]; if (cultureGroupParser.Provinces.Count < 20) { bool possible = true; while (cultureGroupParser.Provinces.Count > 0 && possible) { for (int i = 0; i < cultureGroupParser.Provinces.Count; i++) { var provinceParser = cultureGroupParser.Provinces[i]; var difcul = provinceParser.Adjacent.Where( p => p.Culture != provinceParser.Culture && p.Culture != null); if (!difcul.Any()) { if (i == cultureGroupParser.Provinces.Count - 1) { possible = false; } continue; } var list = new List <ProvinceParser>(difcul); provinceParser.Culture = list[Rand.Next(list.Count)].Culture; provinceParser.Religion = list[Rand.Next(list.Count)].Religion; break; } } } if (cultureGroupParser.Provinces.Count == 0) { AllCultureGroups.Remove(cultureGroupParser); Script.Root.Remove(cultureGroupParser.Scope); CultureMap.Remove(cultureGroupParser.Cultures[0].Name); AllCultures.Remove(cultureGroupParser.Cultures[0]); foreach (var characterParser in CharacterManager.instance.Characters) { if (characterParser.culture == cultureGroupParser.Cultures[0].Name) { characterParser.culture = AllCultures[AllCultures.Count - 1].Name; } } foreach (var value in DynastyManager.instance.DynastyMap.Values) { if ((string)(value.Scope.Children[1] as ScriptCommand).Value == cultureGroupParser.Cultures[0].Name) { (value.Scope.Children[1] as ScriptCommand).Value = AllCultures[AllCultures.Count - 1].Name; } } index--; } } allowMultiCultureGroups = true; for (int index = 0; index < AllCultureGroups.Count; index++) { var cultureGroupParser = AllCultureGroups[index]; var provinces = new List <ProvinceParser>(cultureGroupParser.Provinces); // Now do the same for cultures... var mainCulture = cultureGroupParser.Cultures[0]; int size = cultureGroupParser.Provinces.Count; if (size <= 4) { size = 2; } else if (size < 12) { size = 4; } else if (size < 24) { size = 5; } else if (size < 32) { size = 6; } else if (size < 40) { size = 7; } else { size = 8; } for (int c = 0; c < size; c++) { if (provinces.Count == 0) { break; } var start = provinces[Rand.Next(provinces.Count)]; if (!CultureManager.instance.CultureMap.ContainsKey(mainCulture.Name)) { mainCulture = cultureGroupParser.Cultures[cultureGroupParser.Cultures.Count - 1]; } if (!CultureMap.ContainsKey(mainCulture.Name)) { CultureMap[mainCulture.Name] = mainCulture; } start.Culture = BranchCulture(mainCulture.Name); var newC = start.Culture; List <ProvinceParser> target = new List <ProvinceParser>(); target.Add(start); target.AddRange(start.Adjacent.Where(p => provinces.Contains(p))); int s = 1; if (size > 8) { s = 2; } if (size > 15) { s = 3; } for (int x = 0; x < s; x++) { var toAdd = new List <ProvinceParser>(); target.ForEach(p => toAdd.AddRange(p.Adjacent.Where(pp => pp.land && pp.title != null))); target.AddRange(toAdd); } HashSet <ProvinceParser> toDo = new HashSet <ProvinceParser>(target); foreach (var provinceParser in toDo) { provinceParser.Culture = newC; provinces.Remove(provinceParser); } } } // Create big religion groups covering multiple culture groups foreach (var religionGroupParser in ReligionManager.instance.AllReligionGroups) { var cgenum = AllCultureGroups.Where(cg => cg.ReligionGroup == religionGroupParser); var cultureGroupList = new List <CultureGroupParser>(cgenum); int n = Rand.Next(5) + 4; for (int x = 0; x < n; x++) { var adjacentProv = new List <ProvinceParser>(); var adjacent = new HashSet <CultureGroupParser>(); cultureGroupList.ForEach(g => g.Provinces.ForEach(p => adjacentProv.AddRange(p.Adjacent.Where(pa => pa.land && pa.title != null && pa.Culture != null && pa.Culture.Group != g)))); adjacentProv.ForEach(p => adjacent.Add(p.Culture.Group)); if (adjacent.Count > 0) { List <CultureGroupParser> list = new List <CultureGroupParser>(adjacent); var chosen = list[Rand.Next(list.Count)]; chosen.ReligionGroup = religionGroupParser; chosen.Provinces.ForEach(p => p.Religion = religionGroupParser.Religions[0]); } } } // Cut out small ones // Now find the biggest two and make them bigger... ReligionGroupParser biggest = null; ReligionGroupParser second = null; for (int index = 0; index < ReligionManager.instance.AllReligionGroups.Count; index++) { var religionGroupParser = ReligionManager.instance.AllReligionGroups[index]; if (religionGroupParser.Provinces.Count < 50) { while (religionGroupParser.Provinces.Count > 0) { bool possible = true; while (religionGroupParser.Provinces.Count > 0 && possible) { for (int i = 0; i < religionGroupParser.Provinces.Count; i++) { var provinceParser = religionGroupParser.Provinces[i]; var difcul = provinceParser.Adjacent.Where( p => p.Religion != provinceParser.Religion && p.Religion != null); if (!difcul.Any()) { if (i == religionGroupParser.Provinces.Count - 1) { possible = false; } continue; } var list = new List <ProvinceParser>(difcul); provinceParser.Religion = list[Rand.Next(list.Count)].Religion; break; } } if (!possible) { var provinceParser = religionGroupParser.Provinces[0]; var list = MapManager.instance.Provinces.Where( p => p.land && p.title != null && p.Religion.Group != religionGroupParser).ToList(); distanceTest = provinceParser; list.Sort(SortByDistance); provinceParser.Religion = list[0].Religion; provinceParser.Culture.Group.ReligionGroup = list[0].Religion.Group; } } } if (religionGroupParser.Provinces.Count == 0) { ReligionManager.instance.AllReligionGroups.Remove(religionGroupParser); System.Console.Out.WriteLine(religionGroupParser.Religions[0].Name + " removed"); religionGroupParser.Scope.Remove(religionGroupParser.Religions[0].Scope); ReligionManager.instance.Script.Root.Remove(religionGroupParser.Scope); ReligionManager.instance.ReligionMap.Remove(religionGroupParser.Religions[0].Name); ReligionManager.instance.AllReligions.Remove(religionGroupParser.Religions[0]); foreach (var characterParser in CharacterManager.instance.Characters) { if (characterParser.religion == religionGroupParser.Religions[0].Name) { characterParser.religion = ReligionManager.instance.AllReligions[ReligionManager.instance.AllReligions.Count - 1].Name; } } index--; } } ReligionManager.instance.AllReligionGroups.Sort(ReligionManager.instance.SortByBelievers); biggest = ReligionManager.instance.AllReligionGroups[0]; if (ReligionManager.instance.AllReligionGroups.Count > 1) { second = ReligionManager.instance.AllReligionGroups[1]; } for (int index = 0; index < ReligionManager.instance.AllReligionGroups.Count; index++) { var religionGroup = ReligionManager.instance.AllReligionGroups[index]; var provinces = new List <ProvinceParser>(religionGroup.Provinces); // Now do the same for cultures... var mainReligion = religionGroup.Religions[0]; int size = religionGroup.Provinces.Count; if (size <= 4) { size = 1; } else if (size < 12) { size = 1; } else if (size < 32) { size = 2; } else { size = 3; } if (biggest == religionGroup || second == religionGroup) { size = 3; } for (int c = 0; c < size; c++) { if (provinces.Count == 0) { break; } var start = provinces[Rand.Next(provinces.Count)]; start.Religion = ReligionManager.instance.BranchReligion(mainReligion.Name, start.Culture.Name); var newC = start.Religion; List <ProvinceParser> target = new List <ProvinceParser>(); target.Add(start); target.AddRange(start.Adjacent.Where(p => provinces.Contains(p))); int s = 2; if (size > 16) { s = 3; } if (size > 32) { s = 4; } if (biggest == religionGroup || second == religionGroup) { if (c <= 2) { s += 2; } } for (int x = 0; x < s; x++) { var toAdd = new List <ProvinceParser>(); target.ForEach(p => toAdd.AddRange(p.Adjacent.Where(pp => pp.land && pp.title != null && pp.Religion.Group == start.Religion.Group))); target.AddRange(toAdd); } HashSet <ProvinceParser> toDo = new HashSet <ProvinceParser>(target); foreach (var provinceParser in toDo) { provinceParser.Religion = newC; provinces.Remove(provinceParser); } } } for (int index = 0; index < ReligionManager.instance.AllReligionGroups.Count; index++) { var religionParser = ReligionManager.instance.AllReligionGroups[index]; if (religionParser.Provinces.Count == 0) { ReligionManager.instance.AllReligionGroups.Remove(religionParser); index--; continue; } religionParser.TryFillHolySites(); } for (int index = 0; index < ReligionManager.instance.AllReligions.Count; index++) { var religionParser = ReligionManager.instance.AllReligions[index]; if (religionParser.Provinces.Count == 0) { System.Console.Out.WriteLine(religionParser.Name + " removed"); if (religionParser.Scope.Name == "enuique") { } ReligionManager.instance.AllReligions.Remove(religionParser); ReligionManager.instance.ReligionMap.Remove(religionParser.Name); religionParser.Group.Scope.Remove(religionParser.Scope); index--; continue; } religionParser.TryFillHolySites(); } foreach (var characterParser in CharacterManager.instance.Characters) { if (characterParser.Titles.Count > 0) { if (characterParser.PrimaryTitle.Rank == 2) { characterParser.culture = characterParser.PrimaryTitle.SubTitles.First().Value.Owns[0].Culture.Name; characterParser.religion = characterParser.PrimaryTitle.SubTitles.First().Value.Owns[0].Religion.Name; } else { characterParser.culture = characterParser.PrimaryTitle.Owns[0].Culture.Name; characterParser.religion = characterParser.PrimaryTitle.Owns[0].Religion.Name; } foreach (var titleParser in characterParser.Titles) { titleParser.culture = characterParser.culture; } } } var l = MapManager.instance.Provinces.Where(p => p.title != null).ToList(); foreach (var provinceParser in l) { provinceParser.initialReligion = provinceParser.Religion.Name; provinceParser.initialCulture = provinceParser.Culture.Name; } foreach (var religionParser in ReligionManager.instance.AllReligions) { if (religionParser.Provinces.Count > 0) { ReligionManager.instance.ReligionMap[religionParser.Name] = religionParser; } if (religionParser.Provinces.Count > 0 && (religionParser.hasLeader || religionParser.autocephaly)) { religionParser.DoLeader(religionParser.Provinces[Rand.Next(religionParser.Provinces.Count)]); } } }
public void SaveTitles() { foreach (var titleParser in Titles) { if (titleParser.Name == "b_sasaka") { int gfdg = 0; } if (titleParser.culture == null) { if (titleParser.Dejure != null) { titleParser.culture = titleParser.Dejure.culture; } else { titleParser.culture = "urtru"; } } if (titleParser.Rank > 1 && titleParser.Scope.Find("capital") == null) { } var p = titleParser.GetAllProvinces(); bool bFound = false; foreach (var provinceParser in p) { if (provinceParser.id == titleParser.capital) { bFound = true; break; } } if (!bFound && p.Count > 0) { var ca = p[Rand.Next(p.Count)]; titleParser.capital = ca.id; var cap = (titleParser.Scope.Find("capital") as ScriptCommand); if (cap == null) { titleParser.Scope.Add(new ScriptCommand("capital", ca.id, titleParser.Scope)); } else { cap.Value = ca.id; } titleParser.CapitalProvince = ca; if (titleParser.Holder != null) { titleParser.Holder.GiveTitleSoftPlusIntermediate(titleParser.CapitalProvince.Title); } } int h = 0; foreach (var child in titleParser.Scope.Children) { ScriptScope scope = child as ScriptScope; } String tit = titleParser.Culture.dna.kingTitle; switch (titleParser.Rank) { case 0: tit = titleParser.Culture.dna.baronTitle; break; case 1: tit = titleParser.Culture.dna.countTitle; break; case 2: tit = titleParser.Culture.dna.dukeTitle; break; case 3: tit = titleParser.Culture.dna.kingTitle; break; case 4: tit = titleParser.Culture.dna.empTitle; break; } if (titleParser.Rank > 0) { if (!titleParser.Scope.HasNamed("culture")) { titleParser.Scope.Add(new ScriptCommand() { Name = "culture", Value = titleParser.culture }); } } if (tit == null) { } if (tit != null && tit.Trim().Length > 0) { if (!titleParser.Scope.HasNamed("title_female") && !titleParser.Scope.HasNamed("title")) { titleParser.Scope.Do( @" title=" + tit + @" title_female=" + tit + @" " ); } } } if (!Directory.Exists(Globals.ModDir + "history\\titles\\")) { Directory.CreateDirectory(Globals.ModDir + "history\\titles\\"); } var files = Directory.GetFiles(Globals.ModDir + "history\\titles\\"); foreach (var file in files) { File.Delete(file); } for (int index = 0; index < Titles.Count; index++) { var title = Titles[index]; if (title.Name == "b_sasaka") { } if (!title.Active && title.Rank > 0) { continue; } if (title.Religious) { } Script titleScript = ScriptLoader.instance.Load(Globals.GameDir + "history\\titles\\" + title.Name + ".txt"); titleScript.Root.Clear(); /* ScriptScope thing = new ScriptScope(); * thing.Name = "1.1.1"; * titleScript.Root.SetChild(thing);*/ /* * if (title.government == "republic") * { * thing.Add(new ScriptCommand() {Name = "law", Value = "succ_patrician_elective"}); * // if (title.Liege != null && title.Rank == 0 && title.TopmostTitle.government == "republic") * { * // if (title.Liege.Owns[0].baronies[0].title == title.Name) * { * var name = title.Culture.dna.GetPlaceName(); * var sname = StarNames.SafeName(name); * while (LanguageManager.instance.Get(sname) != null) * { * name = title.Culture.dna.GetPlaceName(); * sname = StarNames.SafeName(name); * } * if (!dynastiesWithPalaces.Contains(title.Holder.Dynasty.ID)) * { * var barony = TitleManager.instance.CreateBaronyScriptScope(null, title.Culture); * Titles.Add(barony); * barony.government = "republicpalace"; * barony.republicdynasty = title.Holder.Dynasty.ID; * barony.culture = title.culture; * barony.republicreligion = title.Holder.religion; * barony.Liege = title; * title.Holder.GiveTitleSoft(barony); * dynastiesWithPalaces.Add(title.Holder.Dynasty.ID); * * } * } * } * } */ if (title.Liege != null && title.Liege.Rank > title.Rank) { // thing.Add(new ScriptCommand() {Name = "liege", Value = title.Liege.Name}); } /* if (title.Rank == 0 && title.government == "republicpalace") * { * * thing.Add(new ScriptCommand() { Name = "holding_dynasty", Value = title.republicdynasty }); * //thing.Add(new ScriptCommand() { Name = "liege", Value = title.republicdynasty }); * if (title.Scope.Find("culture") == null) * { * title.Scope.Add(new ScriptCommand() { Name = "culture", Value = title.culture }); * title.Scope.Add(new ScriptCommand() { Name = "religion", Value = title.republicreligion }); * * } * }*/ // titleScript.Root.SetChild(thing); foreach (var scriptScope in title.titleScripts) { int v = 2; if (!scriptScope.FromVanilla) { while (titleScript.Root.HasNamed(scriptScope.Name)) { var indexOf = scriptScope.Name.LastIndexOf(".");//(v - 1)); scriptScope.Name = scriptScope.Name.Substring(0, indexOf) + "." + v; v++; } } titleScript.Root.SetChild(scriptScope); } /* TitleParser lastLiege = null; * foreach (var heldDate in title.heldDates) * { * ScriptScope thing = new ScriptScope(); * thing.Name = heldDate.date+".1.1"; * titleScript.Root.SetChild(thing); * if (title.Culture.dna.horde) * thing.Add(new ScriptCommand() { Name = "historical_nomad", Value = true }); * * if (title.Liege != null && title.Liege.Rank > title.Rank && title.Liege != lastLiege) * { * thing.Add(new ScriptCommand() { Name = "liege", Value = title.Liege.Name }); * lastLiege = title.Liege; * } * * // if (title.Holder != null) * { * thing.Add(new ScriptCommand() { Name = "holder", Value = heldDate.chrid }); * * // title.Holder.MakeAlive(); * } * * } * /* { * * { * ScriptScope thing = new ScriptScope(); * thing.Name = "1.1.1"; * titleScript.Root.SetChild(thing); * if (title.Culture.dna.horde) * thing.Add(new ScriptCommand() { Name = "historical_nomad", Value = true }); * * if (title.Liege != null) * { * thing.Add(new ScriptCommand() { Name = "liege", Value = title.Liege.Name }); * * } * * if (title.Holder != null) * { * thing.Add(new ScriptCommand() { Name = "holder", Value = title.Holder.ID }); * * // title.Holder.MakeAlive(); * } * else if (title.SubTitles.Count > 0 && title.Rank >= 2 && title.Holder == null) * { * * thing.Add(new ScriptCommand() { Name = "holder", Value = title.SubTitles.Values.ToArray()[0].Holder.ID }); * // title.SubTitles.Values.ToArray()[0].Holder.MakeAlive(); * } * thing = new ScriptScope(); * thing.Name = SimulationManager.instance.Year + ".1.1"; * titleScript.Root.SetChild(thing); * if (title.CurrentHolder != null) * { * thing.Add(new ScriptCommand() { Name = "holder", Value = title.CurrentHolder.ID }); * * } * * * } * * * } */ titleScript.Save(); } }
public void MakeChange() { switch (Rand.Next(18)) { case 0: { bool warLike = Rand.Next(2) == 0; if (Rand.Next(2) == 0) { Resilience = Rand.Next(2); } else { Resilience = Rand.Next(5); } if (warLike) { allow_looting = true; allow_viking_invasion = true; can_call_crusade = true; if (Rand.Next(2) == 0) { peace_prestige_loss = true; } } else { if (Rand.Next(5) == 0) { pacifist = true; } if (Rand.Next(2) == 0) { can_call_crusade = false; } } } break; case 1: can_grant_claim = Rand.Next(3) != 0; break; case 2: can_grant_divorce = Rand.Next(2) != 0; break; case 3: can_excommunicate = Rand.Next(2) != 0; break; case 4: can_hold_temples = Rand.Next(3) != 0; break; case 5: can_retire_to_monastery = Rand.Next(2) != 0; break; case 6: can_have_antipopes = Rand.Next(2) != 0 && hasLeader; break; case 7: investiture = Rand.Next(2) == 0 && hasLeader; break; case 8: if (Rand.Next(2) == 0) { ai_convert_other_group = 0; } else { ai_convert_other_group = 2; } break; case 9: has_heir_designation = Rand.Next(4) == 0; break; case 10: if (max_wives == 1 && max_consorts == 3) { if (Rand.Next(2) == 0) { max_wives = 4; max_consorts = 0; } else { max_wives = 1; max_consorts = 0; } } else if (max_wives == 4 && max_consorts == 0) { if (Rand.Next(2) == 0) { max_wives = 1; max_consorts = 3; } else { max_wives = 1; max_consorts = 0; } } else if (max_wives == 1 && max_consorts == 0) { if (Rand.Next(2) == 0) { max_wives = 4; max_consorts = 0; } else { max_wives = 1; max_consorts = 3; } } break; case 11: if (Rand.Next(6) == 0) { bs_marriage = !bs_marriage; if (bs_marriage) { divine_blood = true; } if (Rand.Next(3) == 0) { pc_marriage = bs_marriage; } } break; case 12: matrilineal_marriages = !matrilineal_marriages; break; case 13: divine_blood = !divine_blood; break; case 14: female_temple_holders = !female_temple_holders; break; case 15: priests_can_inherit = !priests_can_inherit; break; case 16: uses_decadence = !uses_decadence; break; case 17: uses_jizya_tax = !uses_jizya_tax; break; } }
public void DoDetailsForCulture() { dna.culture = this; if (dna.portraitPool.Count == 0) { int c = 1; String cul = GetRandomCultureGraphics(); for (int i = 0; i < c; i++) { dna.portraitPool.Add(cul); cul = GetRelatedCultureGfx(cul); } } String portrait = ""; foreach (var p in dna.portraitPool) { portrait += p + " "; } int r = Rand.Next(255); int g = Rand.Next(255); int b = Rand.Next(255); r = Group.r; g = Group.g; b = Group.b; switch (Rand.Next(3)) { case 0: r += Rand.Next(-45, 45); g += Rand.Next(-25, 25); b += Rand.Next(-15, 15); break; case 1: g += Rand.Next(-45, 45); r += Rand.Next(-25, 25); b += Rand.Next(-15, 15); break; case 2: b += Rand.Next(-45, 45); g += Rand.Next(-25, 25); r += Rand.Next(-15, 15); break; } if (r > 255) { r = 255; } if (g > 255) { g = 255; } if (b > 255) { b = 255; } if (r < 0) { r = 0; } if (g < 0) { g = 0; } if (b < 0) { b = 0; } this.r = r; this.g = g; this.b = b; ScopeCultureDetails(); }
public void DoLeader(ProvinceParser capital) { String popeName = StarNames.SafeName(StarNames.Generate(10000000)); LanguageManager.instance.Add(popeName, StarNames.Generate(10000000)); PopeName = popeName; TitleParser title = null; bool bNew = false; ReligiousHeadTitle = null; if (ReligiousHeadTitle == null) { bNew = true; switch (Rand.Next(8)) { case 0: case 1: case 2: case 3: title = TitleManager.instance.CreateKingScriptScope(capital, Name); break; case 4: title = TitleManager.instance.CreateEmpireScriptScope(capital, Name); break; case 5: case 6: case 7: title = TitleManager.instance.CreateDukeScriptScope(capital, Name); break; } ReligiousHeadTitle = title; } ReligiousHeadTitle.Religious = true; ReligiousHeadTitle.Active = true; ReligiousHeadTitle.religion = Name; TitleManager.instance.ReligiousTitles.Add(ReligiousHeadTitle); if (bNew) { var ch = SimulationManager.instance.AddCharacterForTitle(ReligiousHeadTitle, true); ch.religion = Name; ch.UpdateCultural(); } String religious_names = ""; for (int n = 0; n < 40; n++) { religious_names = CultureManager.instance.CultureMap[ReligiousHeadTitle.Holder.culture].dna.GetMaleName() + " "; } ReligiousHeadTitle.Scope.Do(@" title = """ + popeName + @""" foa = ""POPE_FOA"" short_name = " + (Rand.Next(2) == 0 ? "yes" : "no") + @" location_ruler_title = " + (Rand.Next(2) == 0 ? "yes" : "no") + @" landless = " + (bNew ? "yes" : "no") + @" controls_religion = """ + Name + @""" religion = """ + Name + @""" primary = yes dynasty_title_names = no "); LanguageManager.instance.Add(ReligiousHeadTitle.Name, this.LanguageName); }
public void NewReligionProperties() { // Symbol / group icon = Rand.Next(52) + 1; heresy_icon = Rand.Next(52) + 1; // Women female_temple_holders = Rand.Next(2) == 0; matrilineal_marriages = Rand.Next(4) != 0; // Polygyny if (Rand.Next(3) == 0) { if (Rand.Next(2) == 0) { //Concubinage max_consorts = 3; max_wives = 1; } else { //Polygamy max_consorts = 0; max_wives = 4; } } else { //Strict monogamy max_consorts = 0; max_wives = 1; } // Incest if (cousin_marriage) { divine_blood = Rand.Next(4) == 0; if (divine_blood) { // Uncle + niece psc_marriage = true; // Father + daughter pc_marriage = true; // Brother + sister bs_marriage = true; } } else { psc_marriage = false; pc_marriage = false; bs_marriage = false; } // Priestly inheritance if (Rand.Next(2) == 0) { priests_can_inherit = true; can_retire_to_monastery = false; can_hold_temples = true; } else { priests_can_inherit = false; can_retire_to_monastery = true; can_hold_temples = false; } // War bool warlike = Rand.Next(4) != 0; if (Rand.Next(2) == 0) { Resilience = Rand.Next(2); } else { Resilience = Rand.Next(5); } if (warlike) { allow_looting = true; allow_viking_invasion = true; if (Rand.Next(2) == 0) { peace_prestige_loss = true; } } else { if (Rand.Next(5) == 0) { pacifist = true; } if (Rand.Next(2) == 0) { can_call_crusade = false; } } // Priestly raiments religious_clothing_head = Rand.Next(4); religious_clothing_priest = Rand.Next(4); // Religious headship & powers polytheism = Rand.Next(2) == 0; if (polytheism) { hasLeader = Rand.Next(3) != 0; } else { hasLeader = true; } can_grant_claim = Rand.Next(3) != 0; can_grant_divorce = Rand.Next(2) != 0; can_excommunicate = Rand.Next(2) != 0; autocephaly = Rand.Next(3) == 0; if (hasLeader) { can_call_crusade = Rand.Next(2) == 0; can_have_antipopes = Rand.Next(2) != 0; investiture = Rand.Next(2) == 0; } // Conversion & heresy if (Rand.Next(2) == 0) { ai_convert_other_group = 0; } else { ai_convert_other_group = 2; } // Heir designation has_heir_designation = Rand.Next(4) == 0; }
private void generateFromDraw_Click(object sender, EventArgs e) { generateDrawn.Enabled = true; int ow = 1; int oh = 1; int w = 3072; int h = 2048; if (mapvlarge.Checked) { w = 4096; } if (maplarge.Checked) { w = 3200; } if (mapnorm.Checked) { w = 3072; } if (mapsmall.Checked) { w = 2048; } { Bitmap bmp = new Bitmap(w / 2, h / 2, PixelFormat.Format24bppRgb); Bitmap bmp2 = new Bitmap(w / 2, h / 2, PixelFormat.Format24bppRgb); LockBitmap lbmp2 = new LockBitmap(bmp2); LockBitmap lbmp = new LockBitmap(bmp); float deltaX = w / (float)preview.Width; float deltaY = h / (float)preview.Height; lbmp.LockBits(); lbmp2.LockBits(); landProxyBitmap.LockBits(); mountainProxyBitmap.LockBits(); for (int x = 0; x < bmp.Width; x++) { for (int y = 0; y < bmp.Height; y++) { float dx = mountainProxyBitmap.Width / (float)bmp.Width; float dy = mountainProxyBitmap.Height / (float)bmp.Height; var col = mountainProxyBitmap.GetPixel((int)(x * dx), (int)(y * dy)); var col2 = landProxyBitmap.GetPixel((int)(x * dx), (int)(y * dy)); int xx = x; int yy = y; if (col.R > 0 && col.A > 0) { lbmp.SetPixel(xx, yy, Color.White); } else { lbmp.SetPixel(xx, yy, Color.Black); } if (col2.R != 69 && col2.A > 0) { lbmp2.SetPixel(xx, yy, Color.White); } else { lbmp2.SetPixel(xx, yy, Color.Black); } } } lbmp2.UnlockBits(); lbmp.UnlockBits(); landProxyBitmap.UnlockBits(); mountainProxyBitmap.UnlockBits(); /* Graphics g = Graphics.FromImage(bmp); * * foreach (var drawCommand in MountainCommands) * { * var r = new Rectangle(drawCommand.Point.X - drawCommand.Radius, drawCommand.Point.Y - drawCommand.Radius, * drawCommand.Radius * 2, drawCommand.Radius * 2); * * Rectangle rect = new Rectangle((int)(r.X * deltaX), (int)(r.Y * deltaY), (int)((r.Right * deltaX) - (r.Left * deltaX)), (int)((r.Bottom * deltaY) - r.Top * deltaY)); * * g.FillEllipse(a, rect); * } */ int rand = 32; if (randMed.Checked) { rand = 32; } if (randHigh.Checked) { rand = 32; } ow = bmp.Width; oh = bmp.Height; lbmp.ResizeImage(ow / rand, oh / rand); lbmp.ResizeImage(ow * 2, oh * 2); mountainBitmap = lbmp.Source; rand = 8; BitmapSelect.Randomness = 0.75f; if (randMed.Checked) { rand = 16; BitmapSelect.Randomness = 1f; } if (randHigh.Checked) { rand = 64; BitmapSelect.Randomness = 1f; } if (randMin.Checked) { rand = 2; BitmapSelect.Randomness = 0.5f; } ow = bmp2.Width; oh = bmp2.Height; lbmp2.ResizeImage(ow / rand, oh / rand); lbmp2.ResizeImage(ow * 2, oh * 2); landBitmap = lbmp2.Source; } map = new GeneratedTerrainMap(); int seed = Rand.Next(1000000); LockBitmap lBit = new LockBitmap(landBitmap); LockBitmap mBit = new LockBitmap(mountainBitmap); map.Init(ow / 4, oh / 4, lBit, lBit, mBit, seed); lBit.UnlockBits(); mBit.UnlockBits(); DrawnSeed = seed; landBitmap = map.Map.Source; landBitmapOut = lBit.Source; mountainBitmap = mBit.Source; preview.Invalidate(); }
internal static string GetRandomCultureGraphics(CultureGroupParser group = null) { if (group != null) { if (Rand.Next(3) == 0) { switch (group.chosenGfx) { case "norsegfx": case "germangfx": case "frankishgfx": case "westerngfx": case "saxongfx": case "italiangfx": case "celticgfx": case "mongolgfx": return(wh[Rand.Next(gfx.Count())]); break; case "ugricgfx": case "turkishgfx": case "muslimgfx": case "persiangfx": case "cumangfx": case "arabicgfx": case "andalusiangfx": case "africangfx": case "mesoamericangfx": case "indiangfx": return(bl[Rand.Next(gfx.Count())]); break; } } else { switch (group.chosenGfx) { case "norsegfx": case "germangfx": case "frankishgfx": case "westerngfx": case "saxongfx": case "italiangfx": case "celticgfx": case "mongolgfx": return(bl[Rand.Next(gfx.Count())]); break; case "ugricgfx": case "turkishgfx": case "muslimgfx": case "persiangfx": case "cumangfx": case "arabicgfx": case "andalusiangfx": case "africangfx": case "mesoamericangfx": case "indiangfx": return(wh[Rand.Next(gfx.Count())]); break; } } } return(gfx[Rand.Next(gfx.Count())]); }
public void SaveTitles() { foreach (var titleParser in Titles) { if (titleParser.culture == null) { continue; } String tit = titleParser.Culture.dna.kingTitle; switch (titleParser.Rank) { case 0: tit = titleParser.Culture.dna.baronTitle; break; case 1: tit = titleParser.Culture.dna.countTitle; break; case 2: tit = titleParser.Culture.dna.dukeTitle; break; case 3: tit = titleParser.Culture.dna.kingTitle; break; case 4: tit = titleParser.Culture.dna.empTitle; break; } titleParser.Scope.Add(new ScriptCommand() { Name = "culture", Value = titleParser.culture }); titleParser.Scope.Do( @" title=" + tit + @" title_female=" + tit + @" " ); } foreach (var religionParser in ReligionManager.instance.AllReligions) { if (religionParser.Believers.Count > 0 && religionParser.hasLeader) { religionParser.DoLeader(religionParser.Believers[Rand.Next(religionParser.Believers.Count)]); } } if (!Directory.Exists(Globals.ModDir + "history\\titles\\")) { Directory.CreateDirectory(Globals.ModDir + "history\\titles\\"); } var files = Directory.GetFiles(Globals.ModDir + "history\\titles\\"); foreach (var file in files) { File.Delete(file); } foreach (var title in Titles) { if (!title.Active) { continue; } if (title.Religious) { } Script titleScript = ScriptLoader.instance.Load(Globals.GameDir + "history\\titles\\" + title + ".txt"); titleScript.Root.Clear(); { if (titleScript.Root.HasNamed("767.1.1")) { titleScript.Root.Delete("767.1.1"); titleScript.Root.Delete("768.1.1"); } { ScriptScope thing = new ScriptScope(); thing.Name = "767.1.1"; titleScript.Root.SetChild(thing); if (title.Culture.dna.horde) { thing.Add(new ScriptCommand() { Name = "historical_nomad", Value = true }); } if (title.Liege != null) { thing.Add(new ScriptCommand() { Name = "liege", Value = title.Liege.Name }); } if (title.Holder != null) { thing.Add(new ScriptCommand() { Name = "holder", Value = title.Holder.ID }); // title.Holder.MakeAlive(); } else if (title.SubTitles.Count > 0 && title.Rank >= 2 && title.Holder == null) { thing.Add(new ScriptCommand() { Name = "holder", Value = title.SubTitles.Values.ToArray()[0].Holder.ID }); // title.SubTitles.Values.ToArray()[0].Holder.MakeAlive(); } thing = new ScriptScope(); thing.Name = "768.1.1"; titleScript.Root.SetChild(thing); if (title.CurrentHolder != null) { thing.Add(new ScriptCommand() { Name = "holder", Value = title.CurrentHolder.ID }); } } } titleScript.Save(); } }
public void FillCharacter(CharacterParser characterParser, CharacterParser.PrimaryTrait trait) { List <string> exclude = new List <string>(); List <ScriptScope> choicesL = new List <ScriptScope>(); Dictionary <string, ScriptScope> choices = new Dictionary <string, ScriptScope>(); Dictionary <string, ScriptScope> choicesEducation = new Dictionary <string, ScriptScope>(); foreach (var script in loaded) { foreach (var rootChild in script.Root.Children) { ScriptScope testTrait = rootChild as ScriptScope; if (testTrait.TestBoolean("education")) { choicesEducation[testTrait.Name] = (testTrait); } else { choices[testTrait.Name] = (testTrait); choicesL.Add(testTrait); } } break; } List <ScriptScope> eduChoices = new List <ScriptScope>(); foreach (var scriptScope in choicesEducation) { string eduTrait = scriptScope.Value.GetString("attribute"); string test = trait.ToString(); if (test == eduTrait) { eduChoices.Add(scriptScope.Value); } } var choice = eduChoices[Rand.Next(eduChoices.Count)]; characterParser.Scope.Add(new ScriptCommand("trait", choice.Name, characterParser.Scope)); exclude.Add("twin"); int numTraits = Rand.Next(3, 8); for (int x = 0; x < numTraits; x++) { var ch = choicesL[Rand.Next(choices.Count)]; if (exclude.Contains(ch.Name) || ch.TestBoolean("is_illness")) { x--; continue; } if (ch.ChildrenMap.ContainsKey("opposites")) { var opp = ch.ChildrenMap["opposites"] as ScriptScope; var split = opp.Data.Split(' '); foreach (var s in split) { exclude.Add(s.Trim()); } } characterParser.Scope.Add(new ScriptCommand("trait", ch.Name, characterParser.Scope)); } }
private void CreateKingdomsFromDuchies() { List <TitleParser> duchies = new List <TitleParser>(); List <TitleParser> done = new List <TitleParser>(); for (int index = 0; index < TitleManager.instance.Titles.Count; index++) { var titleParser = TitleManager.instance.Titles[index]; if (titleParser.Rank == 2) { duchies.Add(titleParser); } } for (int index = 0; index < duchies.Count; index++) { var duchie = duchies[index]; int kingSize = Rand.Next(4 * 4, 16 * 4); var results = duchie.Holder.GetProvinceGroup(kingSize, null); if (results.Count < 4 * 4) { continue; } List <TitleParser> kingdomDuchies = new List <TitleParser>(); foreach (var provinceParser in results) { if (!provinceParser.land) { continue; } if (provinceParser.title == null) { continue; } if (provinceParser.Title.Liege != null) { var liege = provinceParser.Title.Liege; if (liege.Holder != null && liege.Rank == 2 && liege.Holder.PrimaryTitle.Rank == 2) { if (!kingdomDuchies.Contains(liege) && !done.Contains(liege)) { kingdomDuchies.Add(liege); } } } } if (kingdomDuchies.Count < 3) { continue; } foreach (var kingdomDuchy in kingdomDuchies) { int i = duchies.IndexOf(kingdomDuchy); duchies.Remove(kingdomDuchy); if (i < index) { index--; } } done.AddRange(kingdomDuchies); var chr = SimulationManager.instance.AddCharacter(duchie.Holder.culture, duchie.Holder.religion); var title = TitleManager.instance.CreateKingScriptScope(duchie.CapitalProvince, chr); chr.GiveTitle(title); foreach (var kingdomDuchy in kingdomDuchies) { title.AddSub(kingdomDuchy); } var list = title.GetAllProvinces(); int num = Math.Min(5, list.Count / 2); chr.GiveTitleAsHolder(list[0].Title.Liege); foreach (var value in list[0].Title.Liege.SubTitles.Values) { chr.GiveTitleAsHolder(value); } var count = chr.UsurpCountTitle(); if (count == null) { continue; } while (count.Liege != null && count.Liege.Rank > count.Rank) { count = count.Liege; chr.GiveTitleAsHolder(count); } } }
public void Save() { if (!Directory.Exists(Globals.ModDir + "decisions\\")) { Directory.CreateDirectory(Globals.ModDir + "decisions\\"); } var files = Directory.GetFiles(Globals.ModDir + "decisions\\"); foreach (var file in files) { File.Delete(file); } if (!Directory.Exists(Globals.ModDir + "events\\")) { Directory.CreateDirectory(Globals.ModDir + "events\\"); } files = Directory.GetFiles(Globals.ModDir + "events\\"); foreach (var file in files) { File.Delete(file); } if (!Directory.Exists(Globals.ModDir + "common\\traits\\")) { Directory.CreateDirectory(Globals.ModDir + "common\\traits\\"); } files = Directory.GetFiles(Globals.ModDir + "common\\traits\\"); foreach (var file in files) { File.Delete(file); } foreach (var religionParser in ReligionManager.instance.AllReligions) { if (religionParser.Believers.Count == 0) { continue; } if (Rand.Next(4) != 0) { continue; } /* * if (Rand.Next(4) != 0) * { * var module = CreateReligionPhilosophy(religionParser.Name, religionParser.Name, new List<SchoolInfo>() * { * new SchoolInfo() {Name = religionParser.Believers[0].GetCurrentHolder().Culture.dna.GetPlaceName()}, * new SchoolInfo() {Name = religionParser.Believers[0].GetCurrentHolder().Culture.dna.GetPlaceName()}, * }); * module.Save(); * } * else * { * var module = CreateReligionPhilosophy(religionParser.Name, religionParser.Name, new List<SchoolInfo>() * { * new SchoolInfo() {Name = religionParser.Believers[0].GetCurrentHolder().Culture.dna.GetPlaceName()}, * new SchoolInfo() {Name = religionParser.Believers[0].GetCurrentHolder().Culture.dna.GetPlaceName()}, * new SchoolInfo() {Name = religionParser.Believers[0].GetCurrentHolder().Culture.dna.GetPlaceName()}, * }); * module.Save(); * } */ } }
private void CreateEmpiresFromKingdoms() { List <TitleParser> kingdoms = new List <TitleParser>(); List <TitleParser> done = new List <TitleParser>(); for (int index = 0; index < TitleManager.instance.Titles.Count; index++) { var titleParser = TitleManager.instance.Titles[index]; if (titleParser.Rank == 3) { kingdoms.Add(titleParser); } } for (int index = 0; index < kingdoms.Count; index++) { var kingdom = kingdoms[index]; if (kingdom.Holder == null) { continue; } if (kingdom.Liege != null) { continue; } int kingSize = Rand.Next(4 * 4 * 4 * 4, 8 * 8 * 8 * 8); var results = kingdom.Holder.GetProvinceGroup(kingSize, null); List <TitleParser> kingdomDuchies = new List <TitleParser>(); foreach (var provinceParser in results) { if (!provinceParser.land) { continue; } if (provinceParser.title == null) { continue; } if (provinceParser.Title.Liege != null) { var liege = provinceParser.Title.Liege; if (liege.Rank == 2) { liege = liege.Liege; } if (liege != null && liege.Rank == 3) { if (!kingdomDuchies.Contains(liege) && liege.LandedTitlesCount > 8 && !done.Contains(liege)) { kingdomDuchies.Add(liege); done.Add(liege); } } } if (kingdomDuchies.Count > 6) { break; } } if (kingdomDuchies.Count < 4) { continue; } if (done.Count > kingdomDuchies.Count) { return; } foreach (var kingdomDuchy in kingdomDuchies) { int i = kingdoms.IndexOf(kingdomDuchy); kingdoms.Remove(kingdomDuchy); if (i < index) { index--; } } kingdoms.AddRange(kingdomDuchies); var chr = SimulationManager.instance.AddCharacter(kingdom.Holder.culture, kingdom.Holder.religion); var title = TitleManager.instance.CreateEmpireScriptScope(kingdom.CapitalProvince, chr); chr.GiveTitle(title); foreach (var kingdomDuchy in kingdomDuchies) { title.AddSub(kingdomDuchy); } var count = chr.UsurpCountTitle(); if (count == null) { continue; } while (count.Liege != null && count.Liege.Rank > count.Rank) { count = count.Liege; chr.GiveTitleAsHolder(count); } } }
public CharacterParser FindUnlandedMan(int year, string religion, string culture) { List <CharacterParser> choices = new List <CharacterParser>(); if (Rand.Next(8) != 0) { return(CharacterManager.instance.CreateNewCharacter(null, false, SimulationManager.instance.Year - 16, religion, culture)); } for (int index = 0; index < AliveCharacters.Count; index++) { var characterParser = AliveCharacters[index]; if (characterParser.isFemale) { continue; } if (year < characterParser.YearOfBirth + 16) { continue; } if (year > characterParser.YearOfBirth + 65) { continue; } if (year > characterParser.YearOfDeath) { continue; } if (characterParser.Father == null) { continue; } if (characterParser.religion != religion) { continue; } if (characterParser.culture != culture) { continue; } if (characterParser.PrimaryTitle != null) { continue; } if (characterParser.Titles.Count > 0) { continue; } choices.Add(characterParser); if (choices.Count > 30) { break; } } if (choices.Count > 0) { return(choices[Rand.Next(choices.Count)]); } return(null); }
private static void FixupDuchies() { List <TitleParser> orphans = new List <TitleParser>(); foreach (var titleParser in TitleManager.instance.Titles) { if (titleParser.Rank == 1 && titleParser.Liege == null) { orphans.Add(titleParser); } } for (int index = 0; index < orphans.Count; index++) { var titleParser = orphans[index]; int smallest = 10000000; TitleParser title = null; foreach (var provinceParser in titleParser.Owns[0].Adjacent) { if (provinceParser.title == null) { continue; } if (provinceParser.Title.Liege != null) { var liege = provinceParser.Title.Liege; int c = liege.SubTitles.Count; if (smallest > c) { smallest = c; title = liege; } } } if (title != null) { title.AddSub(titleParser); orphans.Remove(titleParser); index--; } } orphans.Clear(); foreach (var titleParser in TitleManager.instance.Titles) { if (titleParser.Rank == 2) { List <TitleParser> titles = new List <TitleParser>(titleParser.SubTitles.Values); for (int index = 0; index < titles.Count; index++) { var value = titles[index]; for (int i = index + 1; i < titles.Count; i++) { var value2 = titles[i]; if (value.Owns.Count == 0) { continue; } if (!value.Adjacent(value2)) { if (!orphans.Contains(value2)) { orphans.Add(value2); } continue; } } } } } for (int index = 0; index < orphans.Count; index++) { var titleParser = orphans[index]; int smallest = 10000000; TitleParser title = null; foreach (var provinceParser in titleParser.Owns[0].Adjacent) { if (provinceParser.title == null) { continue; } if (provinceParser.Title.Liege != null) { var liege = provinceParser.Title.Liege; int c = liege.SubTitles.Count; if (smallest > c) { smallest = c; title = liege; } } } if (title != null) { title.AddSub(titleParser); orphans.Remove(titleParser); index--; } } orphans.Clear(); foreach (var titleParser in TitleManager.instance.Titles) { if (titleParser.Rank == 2) { if (titleParser.SubTitles.Count > 0) { orphans.Add(titleParser); } } } // now wo do the regions... List <TitleParser> forRegion = new List <TitleParser>(); for (int index = 0; index < orphans.Count; index++) { var titleParser = orphans[index]; int kingSize = Rand.Next(10 * 10); var results = titleParser.Holder.GetProvinceGroup(kingSize, null); foreach (var provinceParser in results) { if (provinceParser.Title != null && provinceParser.Title.Liege != null && provinceParser.Title.Liege.Rank == 2) { if (!forRegion.Contains(provinceParser.Title.Liege)) { forRegion.Add(provinceParser.Title.Liege); } } } foreach (var parser in forRegion) { if (orphans.Contains(parser)) { int index2 = orphans.IndexOf(parser); if (index2 <= index) { index--; } orphans.Remove(parser); } } String name = forRegion[0].Culture.dna.GetPlaceName(); RegionManager.instance.AddRegion(name, forRegion); forRegion.Clear(); } }
public void DoLeader(ProvinceParser capital) { String popeName = StarNames.SafeName(StarNames.Generate(10000000)); LanguageManager.instance.Add(popeName, StarNames.Generate(10000000)); TitleParser title = null; switch (Rand.Next(3)) { case 0: title = TitleManager.instance.CreateKingScriptScope(capital, Name); break; case 1: title = TitleManager.instance.CreateEmpireScriptScope(capital, Name); break; case 2: title = TitleManager.instance.CreateDukeScriptScope(capital, Name); break; } ReligiousHeadTitle = title; ReligiousHeadTitle.Religious = true; ReligiousHeadTitle.Active = true; // ch.UpdateCultural(); var ch = SimulationManager.instance.AddCharacterForTitle(ReligiousHeadTitle, true); ch.religion = Name; ch.UpdateCultural(); var liege = ReligiousHeadTitle.CapitalProvince.Title; if (Rand.Next(3) == 0) { ch.GiveTitle(ReligiousHeadTitle.CapitalProvince.Title); } String religious_names = ""; for (int n = 0; n < 40; n++) { religious_names = CultureManager.instance.CultureMap[ch.culture].dna.GetMaleName() + " "; } title.Scope.Do(@" title = """ + popeName + @""" foa = ""POPE_FOA"" short_name = yes location_ruler_title = yes landless = yes controls_religion = """ + Name + @""" religion = """ + Name + @""" primary = yes dynasty_title_names = no male_names = { " + religious_names + @" } "); LanguageManager.instance.Add(title.Name, this.LanguageName); }
public void AssignAndSave() { if (!Directory.Exists(Globals.ModDir + "gfx\\flags\\")) { Directory.CreateDirectory(Globals.ModDir + "gfx\\flags\\"); } var files = Directory.GetFiles(Globals.ModDir + "gfx\\flags\\"); foreach (var file in files) { File.Delete(file); } files = Directory.GetFiles(Globals.GameDir + "gfx\\flags\\"); Bitmap bmp = new Bitmap(2048, 2048); bmpList.Add(bmp); // LockBitmap lbmp = new LockBitmap(bmp); String filename = "gfx\\flags\\flagfiles.txt"; // Directory.CreateDirectory(Globals.UserDir + "gfx\\flags\\"); filename = Globals.UserDir + filename; int x = 0; int y = 0; int w = 76; List <String> filenames = new List <string>(files); int n = 0; int sheets = 0; foreach (var titleParser in TitleManager.instance.Titles) { if (titleParser.Rank < 1) { continue; } SolidBrush b = new SolidBrush(Color.FromArgb(255, Rand.Next(255), Rand.Next(255), Rand.Next(255))); Graphics g = Graphics.FromImage(bmp); int xx = x * w; int yy = y * w; int i = Rand.Next(filenames.Count); String str = filenames[i]; Bitmap flag = DevIL.DevIL.LoadBitmap(str); g.DrawImage(flag, new Rectangle(xx, yy, w, w)); DevIL.DevIL.SaveBitmap(Globals.ModDir + "gfx\\flags\\" + titleParser.Name + ".tga", flag); b.Dispose(); //filenames.RemoveAt(i); } // bmp.Save(Globals.UserDir + "gfx\\flags\\flagfiles_" + sheets + ".tga"); }
public void MakeChange() { switch (Rand.Next(24)) { case 0: { bool warLike = Rand.Next(2) == 0; if (Rand.Next(2) == 0) { Resilience = Rand.Next(2); } else { Resilience = Rand.Next(5); } if (warLike) { this.allow_looting = true; this.allow_viking_invasion = true; this.can_call_crusade = true; if (Rand.Next(2) == 0) { this.peace_prestige_loss = true; } } else { if (Rand.Next(5) == 0) { this.pacifist = true; } if (Rand.Next(2) == 0) { this.can_call_crusade = false; } } } break; case 1: this.can_grant_claim = Rand.Next(3) != 0; break; case 2: this.can_grant_divorce = Rand.Next(2) != 0; break; case 3: this.can_excommunicate = Rand.Next(2) != 0; break; case 4: this.can_hold_temples = Rand.Next(3) != 0; break; case 5: this.can_retire_to_monastery = Rand.Next(2) != 0; break; case 6: this.can_have_antipopes = Rand.Next(2) != 0 && hasLeader; break; case 7: investiture = Rand.Next(2) == 0 && hasLeader; break; case 8: if (Rand.Next(2) == 0) { this.ai_convert_other_group = 0; } else { this.ai_convert_other_group = 2; } break; case 9: this.has_heir_designation = Rand.Next(4) == 0; break; case 10: if (Rand.Next(2) == 0) { if (Rand.Next(2) == 0) { max_consorts = 1 + Rand.Next(5); } else { { max_wives = 2 + Rand.Next(4); } } } break; case 11: if (Rand.Next(6) == 0) { this.bs_marriage = true; if (Rand.Next(3) == 0) { this.pc_marriage = true; } } break; case 12: religious_clothing_head = Rand.Next(4); religious_clothing_priest = Rand.Next(4); break; case 13: high_god_name = dna.GetGodName(); break; case 14: devil = dna.GetGodName(); break; case 15: scripture_name = dna.GetGodName(); break; case 16: crusade_name = dna.GetGodName(); break; case 17: priest = dna.GetGodName(); break; case 18: matrilineal_marriages = !matrilineal_marriages; break; case 19: this.divine_blood = Rand.Next(2) == 0;; break; case 20: this.female_temple_holders = !female_temple_holders; break; case 21: this.priests_can_inherit = !priests_can_inherit; break; case 22: this.uses_decadence = !uses_decadence; break; case 23: this.uses_jizya_tax = !uses_jizya_tax; break; } }
public void Init() { // Scope.Clear(); String fx = Group.chosenGfx; if (Group.chosenGfx == null) { fx = Group.Scope.Scopes[0].Data; } int r = Rand.Next(255); int g = Rand.Next(255); int b = Rand.Next(255); r = Group.r; g = Group.g; b = Group.b; switch (Rand.Next(3)) { case 0: r += Rand.Next(-45, 45); g += Rand.Next(-25, 25); b += Rand.Next(-15, 15); break; case 1: g += Rand.Next(-45, 45); r += Rand.Next(-25, 25); b += Rand.Next(-15, 15); break; case 2: b += Rand.Next(-45, 45); g += Rand.Next(-25, 25); r += Rand.Next(-15, 15); break; } if (r > 255) { r = 255; } if (g > 255) { g = 255; } if (b > 255) { b = 255; } if (r < 0) { r = 0; } if (g < 0) { g = 0; } if (b < 0) { b = 0; } Scope.Do(@" color = { " + r + " " + g + " " + b + @" } "); }
private void DoRandomChange() { switch (Rand.Next(4)) { case 0: // replace 1/3 of the Start words and replace with random dna culture.... { int count = CommonStartNames.Count / 2; WordFormats.Clear(); ReplaceStartNames(count); { wordsForLand.Clear(); int c = wordsForLand.Count / 2; int create = 3; for (int n = 0; n < create; n++) { String a = ""; a = ConstructWord(2 * wordLengthBias, 4 * wordLengthBias); if (!wordsForLand.Contains(a)) { wordsForLand.Add(a); continue; } } } } break; case 1: { int count = CommonEndNames.Count / 2; ReplaceEndNames(count); WordFormats.Clear(); { wordsForLand.Clear(); int c = wordsForLand.Count / 2; int create = 3; for (int n = 0; n < create; n++) { String a = ""; a = ConstructWord(2 * wordLengthBias, 4 * wordLengthBias); if (!wordsForLand.Contains(a)) { wordsForLand.Add(a); continue; } } } } break; case 2: // replace 1/3 of the words for land { WordFormats.Clear(); if (portraitPool.Count == 0) { return; } int x = Rand.Next(portraitPool.Count); var por = portraitPool[x]; portraitPool.RemoveAt(x); portraitPool.Add(culture.GetRelatedCultureGfx(por)); if (Rand.Next(6) == 0) { if (portraitPool.Count == 1) { portraitPool.Add(culture.GetRelatedCultureGfx(por)); } else if (portraitPool.Count == 2) { portraitPool.RemoveAt(Rand.Next(2)); } } if (Rand.Next(6) == 0) { portraitPool.RemoveAt(0); portraitPool.Add(CultureParser.GetRandomCultureGraphics()); } } break; case 3: // for(int n=0;n<3;n++) { // switch (Rand.Next(6)) { // case 0: empTitle = ConstructWord(2, 5); empTitle = LanguageManager.instance.AddSafe(empTitle); // break; // case 1: kingTitle = ConstructWord(2, 5); kingTitle = LanguageManager.instance.AddSafe(kingTitle); // break; // case 2: dukeTitle = ConstructWord(2, 5); dukeTitle = LanguageManager.instance.AddSafe(dukeTitle); // break; // case 3: countTitle = ConstructWord(2, 5); countTitle = LanguageManager.instance.AddSafe(countTitle); // break; // case 4: baronTitle = ConstructWord(2, 5); baronTitle = LanguageManager.instance.AddSafe(baronTitle); // break; // case 5: mayorTitle = ConstructWord(2, 5); mayorTitle = LanguageManager.instance.AddSafe(mayorTitle); // break; } } break; } if (culture != null) { culture.DoDetailsForCulture(); } }
public void DoDetailsForCulture() { Scope.Clear(); dna.culture = this; if (dna.portraitPool.Count == 0) { int c = Rand.Next(2) + 1; String cul = GetRandomCultureGraphics(); for (int i = 0; i < c; i++) { dna.portraitPool.Add(cul); cul = GetRelatedCultureGfx(cul); } } String portrait = ""; foreach (var p in dna.portraitPool) { portrait += p + " "; } int r = Rand.Next(255); int g = Rand.Next(255); int b = Rand.Next(255); r = Group.r; g = Group.g; b = Group.b; switch (Rand.Next(3)) { case 0: r += Rand.Next(-45, 45); g += Rand.Next(-25, 25); b += Rand.Next(-15, 15); break; case 1: g += Rand.Next(-45, 45); r += Rand.Next(-25, 25); b += Rand.Next(-15, 15); break; case 2: b += Rand.Next(-45, 45); g += Rand.Next(-25, 25); r += Rand.Next(-15, 15); break; } if (r > 255) { r = 255; } if (g > 255) { g = 255; } if (b > 255) { b = 255; } if (r < 0) { r = 0; } if (g < 0) { g = 0; } if (b < 0) { b = 0; } Scope.Do(@" color = { " + r + " " + g + " " + b + @" } graphical_cultures = { " + portrait + @" } male_names = { " + dna.GetMaleNameBlock() + @" } female_names = { " + dna.GetFemaleNameBlock() + @" } dukes_called_kings = " + (dna.dukes_called_kings ? "yes" : "no") + @" baron_titles_hidden = " + (dna.baron_titles_hidden ? "yes" : "no") + @" count_titles_hidden = " + (dna.count_titles_hidden ? "yes" : "no") + @" horde = " + (dna.horde ? "yes" : "no") + @" founder_named_dynasties = " + (dna.founder_named_dynasties ? "yes" : "no") + @" dynasty_title_names = " + (dna.dynasty_title_names ? "yes" : "no") + @" from_dynasty_prefix = [" + '"' + dna.from_dynasty_prefix + '"' + @" male_patronym = " + (dna.male_patronym) + @" female_patronym = " + (dna.female_patronym) + @" prefix = " + (dna.patronym_prefix ? "yes" : "no") + @" # The patronym is added as a suffix # Chance of male children being named after their paternal or maternal grandfather, or their father. Sum must not exceed 100. pat_grf_name_chance = 25 mat_grf_name_chance = 0 father_name_chance = 25 # Chance of female children being named after their paternal or maternal grandmother, or their mother. Sum must not exceed 100. pat_grm_name_chance = 10 mat_grm_name_chance = 25 mother_name_chance = 25 modifier = default_culture_modifier allow_looting = " + (dna.allow_looting ? "yes" : "no") + @" seafarer = " + (dna.seafarer ? "yes" : "no") + @" "); }
public void AssignAndSave() { if (!Directory.Exists(Globals.ModDir + "gfx\\flags\\")) { Directory.CreateDirectory(Globals.ModDir + "gfx\\flags\\"); } var files = Directory.GetFiles(Globals.ModDir + "gfx\\flags\\"); foreach (var file in files) { File.Delete(file); } files = Directory.GetFiles(Globals.GameDir + "gfx\\flags\\"); Bitmap bmp = new Bitmap(2048, 2048); bmpList.Add(bmp); int x = 0; int y = 0; int w = 76; List <String> filenames = new List <string>(files); int n = 0; int sheets = 0; foreach (var titleParser in TitleManager.instance.Titles) { if (titleParser.Rank < 1) { continue; } SolidBrush b = new SolidBrush(Color.FromArgb(255, Rand.Next(255), Rand.Next(255), Rand.Next(255))); Graphics g = Graphics.FromImage(bmp); int xx = x * w; int yy = y * w; int i = Rand.Next(filenames.Count); String str = filenames[i]; if (File.Exists(Globals.ModDir + "gfx\\flags\\" + titleParser.Name + ".tga")) { File.Delete(Globals.ModDir + "gfx\\flags\\" + titleParser.Name + ".tga"); } File.Copy(str, Globals.ModDir + "gfx\\flags\\" + titleParser.Name + ".tga"); b.Dispose(); } foreach (var titleParser in TitleManager.instance.mercs) { SolidBrush b = new SolidBrush(Color.FromArgb(255, Rand.Next(255), Rand.Next(255), Rand.Next(255))); Graphics g = Graphics.FromImage(bmp); int xx = x * w; int yy = y * w; int i = Rand.Next(filenames.Count); String str = filenames[i]; if (File.Exists(Globals.ModDir + "gfx\\flags\\" + titleParser + ".tga")) { File.Delete(Globals.ModDir + "gfx\\flags\\" + titleParser + ".tga"); } File.Copy(str, Globals.ModDir + "gfx\\flags\\" + titleParser + ".tga"); b.Dispose(); } }
public Dynasty GetDynasty(int id, string name, string culture, string religion, ScriptScope scope) { ID = id; Name = name; var nameScope = scope.ChildrenMap["name"] as ScriptCommand; script.Root.Add(scope); var d = new Dynasty() { ID = ID, Scope = scope, NameScope = nameScope }; d.Color = Color.FromArgb(255, Rand.Next(200) + 55, Rand.Next(200) + 55, Rand.Next(200) + 55); DynastyMap[ID] = d; return(d); }