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 TitleParser CreateKingScriptScope(ProvinceParser capital, CharacterParser chr) { var rand = Rand.Get(); Color col = Color.FromArgb(255, rand.Next(200) + 55, rand.Next(200) + 55, rand.Next(200) + 55); ScriptScope scope = new ScriptScope(); scope.Parent = LandedTitlesScript.Root; { String place = chr.Culture.dna.GetPlaceName(); String text = place; place = StarNames.SafeName(place); if (TitleManager.instance.TitleMap.ContainsKey("k_" + place)) { return(CreateKingScriptScope(capital, chr.culture)); } LanguageManager.instance.Add(place, text); scope.Name = "k_" + place; LanguageManager.instance.Add(scope.Name, text); } //scope.Kids.Add(new ScriptCommand() { Name = "rebel", Value = false }); scope.Add(new ScriptCommand() { Name = "color", Value = col }); scope.Add(new ScriptCommand() { Name = "color2", Value = col }); scope.Add(new ScriptCommand() { Name = "capital", Value = capital.id }); TitleParser title = new TitleParser(scope); AddTitle(title); // now place the counties into it... if (title.capital != 0) { title.CapitalProvince = MapManager.instance.ProvinceIDMap[title.capital]; } return(title); }
private void CreateCasusBelli(string casusBelli, CharacterParser actor, CharacterParser recipient, TitleParser title, int yearStart) { var scope = new ScriptScope("casus_belli"); scope.Add(new ScriptCommand("actor", actor.ID, scope)); scope.Add(new ScriptCommand("recipient", recipient.ID, scope)); scope.Add(new ScriptCommand("casus_belli", casusBelli, scope)); scope.Add(new ScriptCommand("landed_title", title, scope)); scope.Add(new ScriptCommand("date", yearStart.ToString() + ".1.1", scope)); warScript.Root.Add(scope); }
public Dynasty GetDynasty(CultureParser culture) { ScriptScope scope = new ScriptScope(); scope.Name = ID.ToString(); ID++; scope.Add(new ScriptCommand("name", culture.dna.GetDynastyName(), scope)); scope.Add(new ScriptCommand("culture", culture.Name, scope)); script.Root.Add(scope); var d = new Dynasty() {ID = ID - 1, Scope = scope}; DynastyMap[ID - 1] = d; culture.Dynasties.Add(d); return d; }
public TitleParser CreateDukeScriptScope(ProvinceParser capital, String name = null) { var rand = Rand.Get(); Color col = Color.FromArgb(255, rand.Next(200) + 55, rand.Next(200) + 55, rand.Next(200) + 55); ScriptScope scope = new ScriptScope(); scope.Parent = LandedTitlesScript.Root; if (name == null) { String place = capital.Title.Holder.Culture.dna.GetPlaceName(); String text = place; place = StarNames.SafeName(place); LanguageManager.instance.Add(place, text); scope.Name = "d_" + place; LanguageManager.instance.Add(scope.Name, text); } else { scope.Name = "d_" + name; } // scope.Kids.Add(new ScriptCommand() { Name = "rebel", Value = false }); scope.Add(new ScriptCommand() { Name = "color", Value = col }); scope.Add(new ScriptCommand() { Name = "color2", Value = col }); scope.Add(new ScriptCommand() { Name = "capital", Value = capital.id }); TitleParser title = new TitleParser(scope); // if (capital.Title.Culture.dna.horde) // title.Scope.Do("historical_nomad = yes"); AddTitle(title); if (title.capital != 0) { title.CapitalProvince = MapManager.instance.ProvinceIDMap[title.capital]; } // now place the counties into it... return(title); }
private void Add(TitleParser title, float mil, float cul, float eco) { String name = title.Name; int y = useYear; if (y > SimulationManager.instance.MaxYear) { y = SimulationManager.instance.MaxYear; } var group = title.TechGroup; if (title.TechGroup != null) { if (title.TechGroup.HasNamed(y.ToString())) { return; } var date = new ScriptScope((y).ToString()); date.Add(new ScriptCommand("military", mil, date)); date.Add(new ScriptCommand("economy", eco, date)); date.Add(new ScriptCommand("culture", cul, date)); title.TechGroup.Add(date); return; } if (!Groups.ContainsKey(mil)) { Groups[mil] = new TechnologyGroup(); Groups[mil].Date = new Dictionary <int, ScriptScope>(); Groups[mil].Date[y] = new ScriptScope((y).ToString()); Groups[mil].Date[y].Add(new ScriptCommand("military", mil, Groups[mil].Date[y])); Groups[mil].Date[y].Add(new ScriptCommand("economy", eco, Groups[mil].Date[y])); Groups[mil].Date[y].Add(new ScriptCommand("culture", cul, Groups[mil].Date[y])); Groups[mil].Titles = new ScriptScope("titles"); Groups[mil].Titles.Add("\t\t" + name); Script.Root.AllowDuplicates = true; var tech = new ScriptScope("technology"); Script.Root.Add(tech); tech.Add(Groups[mil].Titles); tech.Add(Groups[mil].Date[y]); title.TechGroup = Groups[mil].Titles.Parent; } else { if (!Groups[mil].Titles.Children.Contains("\t\t" + name)) { Groups[mil].Titles.Add("\t\t" + name); title.TechGroup = Groups[mil].Titles.Parent; } } }
private void CreateStart(List <CharacterParser> attackers, List <CharacterParser> defenders, int yearStart) { var scope = new ScriptScope(yearStart + ".1.1"); foreach (var characterParser in attackers) { scope.Add(new ScriptCommand("add_attacker", characterParser.ID, scope)); } foreach (var characterParser in defenders) { scope.Add(new ScriptCommand("add_defender", characterParser.ID, scope)); } warScript.Root.Add(scope); }
public void AddTraitSprite(String name, String relFilename) { var scope = new ScriptScope(); scope.Name = "spriteType"; scope.Do(@" name = ""GFX_trait_" + name + @" texturefile = " + relFilename + @" noOfFrames = 1 norefcount = yes effectFile = ""gfx/FX/buttonstate.lua""" ); spriteTypes.Add(scope); }
public void Init() { Scope = new ScriptScope("technology"); Titles = new ScriptScope("titles"); Scope.Add(Titles); }
public void AddReligiousTraits(ReligionParser religion) { string relName = religion.Name; string relLangName = religion.LanguageName; last.Do(@" sympathy_" + religion.Name + @" = { opposites = { zealous } potential = { NOT = { religion_group = " + religion.Group.Name + @" } } same_opinion_if_same_religion = 5 customizer = no random = no male_insult = INSULT_LOVER_OF_HEATHENS female_insult = INSULT_LOVER_OF_HEATHENS male_insult_adj = INSULT_UNPRINCIPLED female_insult_adj = INSULT_UNPRINCIPLED child_insult_adj = INSULT_STUPID" ); last.Do(@" secretly_" + religion.Name + @" = { is_visible = { OR = { character = FROM society_member_of = secret_religious_society_" + religion.Name + @" AND = { is_close_relative = FROM trait = secretly_" + religion.Name + @" } } } same_opinion = 15 random = no customizer = no ai_zeal = -50 } }" ); ScriptScope c = (ScriptScope)last.Children[last.Children.Count - 1]; var op = new ScriptScope("opposites"); c.Add(op); opposites.Add(op); AddTrait("secretly_" + relName, "bastard.dds"); AddTrait("sympathy_" + relName, "bastard.dds"); }
public TitleParser CreateKingScriptScope(ProvinceParser capital, String name = null) { var rand = Rand.Get(); Color col = Color.FromArgb(255, rand.Next(200) + 55, rand.Next(200) + 55, rand.Next(200) + 55); ScriptScope scope = new ScriptScope(); scope.Parent = LandedTitlesScript.Root; if (name == null) { scope.Name = "k_" + capital.Title.Name.Substring(2); } else { scope.Name = "k_" + name; } //scope.Kids.Add(new ScriptCommand() { Name = "rebel", Value = false }); scope.Add(new ScriptCommand() { Name = "color", Value = col }); scope.Add(new ScriptCommand() { Name = "color2", Value = col }); scope.Add(new ScriptCommand() { Name = "capital", Value = capital.id }); TitleParser title = new TitleParser(scope); AddTitle(title); // now place the counties into it... if (title.capital != 0) { title.CapitalProvince = MapManager.instance.ProvinceIDMap[title.capital]; } return(title); }
public ScriptScope GetNewCreatedCharacter() { var scope = new ScriptScope(); scope.Name = CharacterParser.IDMax.ToString(); scope.Add("name", "urda"); scope.Add("culture", "urtru"); scope.Add("religion", "urtru"); var born = scope.AddScope("1.1.1"); var died = scope.AddScope("3.1.1"); born.Add("birth", "1.1.1"); died.Add("death", "3.1.1"); return(scope); }
public ScriptScope GetNewCreatedCharacter() { var scope = new ScriptScope(); scope.Name = CharacterParser.IDMax.ToString(); scope.Add("name", "Bob"); scope.Add("culture", "norse"); scope.Add("religion", "pagan"); var born = scope.AddScope("730.1.1"); var died = scope.AddScope("790.1.1"); born.Add("birth", "730.1.1"); died.Add("death", "790.1.1"); //scope.SetChild(CharactersScript.Root); return(scope); }
public Dynasty GetDynasty(CultureParser culture) { ScriptScope scope = new ScriptScope(); scope.Name = ID.ToString(); ID++; scope.Add(new ScriptCommand("name", culture.dna.GetDynastyName(), scope)); scope.Add(new ScriptCommand("culture", culture.Name, scope)); script.Root.Add(scope); var d = new Dynasty() { ID = ID - 1, Scope = scope }; DynastyMap[ID - 1] = d; culture.Dynasties.Add(d); return(d); }
public void SetValue(String name, object value) { if (!scope.ChildrenMap.ContainsKey(name)) { var c = new ScriptCommand(name, value, scope); scope.Add(c); } else { (scope.ChildrenMap[name] as ScriptCommand).Value = value; } }
private ScriptScope Copy() { ScriptScope newS = new ScriptScope(); newS.Name = Name; foreach (var child in Children) { if (child is ScriptScope) { newS.Add(((ScriptScope)child).Copy()); } if (child is ScriptCommand) { var c = ((ScriptCommand)child).Copy(); newS.Add(c); } } return(newS); }
public void Save() { Script s = new Script(); s.Name = Globals.ModDir + "events\\gen_" + name + "_events.txt"; s.Root = new ScriptScope(); s.Root.Add(new ScriptCommand("namespace", nameSpace, s.Root)); foreach (var scriptScope in Events) { scriptScope.Value.Name = "character_event"; s.Root.Add(scriptScope.Value); } s.Save(); s = new Script(); s.Name = Globals.ModDir + "decisions\\gen_" + name + "_decisions.txt"; s.Root = new ScriptScope(); ScriptScope ss = new ScriptScope(); s.Root.Add(ss); ss.Name = "decisions"; // s.Root.Add(new ScriptCommand("namespace", nameSpace, s.Root)); foreach (var scriptScope in Decisions) { ScriptScope e = new ScriptScope(); scriptScope.Value.Name = scriptScope.Key; ss.Add(scriptScope.Value); } s.Save(); s = new Script(); s.Name = Globals.ModDir + "common\\traits\\03_zz_gen_" + name + "_traits.txt"; s.Root = new ScriptScope(); // s.Root.Add(new ScriptCommand("namespace", nameSpace, s.Root)); foreach (var scriptScope in Traits) { scriptScope.Value.Name = scriptScope.Key; s.Root.Add(scriptScope.Value); } s.Save(); }
public void Save() { foreach (var cultureParser in CultureManager.instance.AllCultures) { if (cultureParser.Governments.Count == 0) { var gov = GovernmentManager.instance.CreateNewGovernment(cultureParser); } foreach (var government in cultureParser.Governments) { if (government.cultureAllow.Count == 0) { government.cultureAllow.Add(cultureParser.Name); } } if (!Government.cultureDone.Contains(cultureParser.Name)) { cultureParser.Governments.Add(GovernmentManager.instance.CreateNewGovernment(cultureParser)); } } if (!Directory.Exists(Globals.ModDir + "gfx\\interface\\")) Directory.CreateDirectory(Globals.ModDir + "gfx\\interface\\"); var files = Directory.GetFiles(Globals.ModDir + "gfx\\interface\\"); foreach (var file in files) { File.Delete(file); } foreach (var government in governments) { switch (government.type) { case "nomadic": try { File.Copy(Globals.GameDir + "gfx\\interface\\government_icon_nomadic.dds", Globals.ModDir + "gfx\\interface\\government_icon_" + government.name.Replace("government_", "") + ".dds"); } catch (Exception) { } SpriteManager.instance.AddGovernment(government); break; case "tribal": try { File.Copy(Globals.GameDir + "gfx\\interface\\government_icon_tribal.dds", Globals.ModDir + "gfx\\interface\\government_icon_" + government.name.Replace("government_", "") + ".dds"); } catch (Exception) { } SpriteManager.instance.AddGovernment(government); break; case "feudal": try { File.Copy(Globals.GameDir + "gfx\\interface\\government_icon_feudal.dds", Globals.ModDir + "gfx\\interface\\government_icon_" + government.name.Replace("government_", "") + ".dds"); } catch (Exception) { } SpriteManager.instance.AddGovernment(government); break; case "theocracy": try { File.Copy(Globals.GameDir + "gfx\\interface\\government_icon_theocracy.dds", Globals.ModDir + "gfx\\interface\\government_icon_" + government.name.Replace("government_", "") + ".dds"); } catch (Exception) { } SpriteManager.instance.AddGovernment(government); break; case "republic": try { File.Copy(Globals.GameDir + "gfx\\interface\\government_icon_republic.dds", Globals.ModDir + "gfx\\interface\\government_icon_" + government.name.Replace("government_", "") + ".dds"); } catch (Exception) { } SpriteManager.instance.AddGovernment(government); break; } } Script s = new Script(); s.Name = Globals.ModDir + "common\\governments\\nomadic_governments.txt"; s.Root = new ScriptScope(); var scope = new ScriptScope(); scope.Name = "nomadic_governments"; s.Root.Add(scope); foreach (var government in governments) { if (government.type == "nomadic" && government.cultureAllow.Count > 0) { var g = new ScriptScope(); g.Name = government.name; government.Save(g); scope.Add(g); } } s.Save(); s = new Script(); s.Name = Globals.ModDir + "common\\governments\\feudal_governments.txt"; s.Root = new ScriptScope(); scope = new ScriptScope(); scope.Name = "feudal_governments"; s.Root.Add(scope); foreach (var government in governments) { if (government.type == "feudal" && government.cultureAllow.Count > 0) { var g = new ScriptScope(); g.Name = government.name; government.Save(g); scope.Add(g); } } s.Save(); s = new Script(); s.Name = Globals.ModDir + "common\\governments\\theocracy_governments.txt"; s.Root = new ScriptScope(); scope = new ScriptScope(); scope.Name = "theocracy_governments"; s.Root.Add(scope); foreach (var government in governments) { if (government.type == "theocracy" && government.cultureAllow.Count > 0) { var g = new ScriptScope(); g.Name = government.name; government.Save(g); scope.Add(g); } } s.Save(); s = new Script(); s.Name = Globals.ModDir + "common\\governments\\republic_governments.txt"; s.Root = new ScriptScope(); scope = new ScriptScope(); scope.Name = "republic_governments"; s.Root.Add(scope); foreach (var government in governments) { if (government.type == "republic" && government.cultureAllow.Count > 0) { var g = new ScriptScope(); g.Name = government.name; government.Save(g); scope.Add(g); } } s.Save(); s = new Script(); s.Name = Globals.ModDir + "common\\governments\\tribal_governments.txt"; s.Root = new ScriptScope(); scope = new ScriptScope(); scope.Name = "tribal_governments"; s.Root.Add(scope); foreach (var government in governments) { if (government.type == "tribal" && government.cultureAllow.Count > 0) { var g = new ScriptScope(); g.Name = government.name; government.Save(g); scope.Add(g); } } s.Save(); }
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 Save() { return; foreach (var cultureParser in CultureManager.instance.AllCultureGroups) { if (cultureParser.Governments.Count == 0) { // var gov = GovernmentManager.instance.CreateNewGovernment(cultureParser.Cultures[0]); } if (!cultureDone.Contains(cultureParser.Name)) { var g = GovernmentManager.instance.CreateNewGovernment(cultureParser.Cultures[0]); cultureParser.Governments.Add(g); } foreach (var government in cultureParser.Governments) { if (government.cultureGroupAllow.Count == 0) { government.cultureGroupAllow.Add(cultureParser.Name); } } } if (!Directory.Exists(Globals.ModDir + "gfx\\interface\\")) { Directory.CreateDirectory(Globals.ModDir + "gfx\\interface\\"); } var files = Directory.GetFiles(Globals.ModDir + "gfx\\interface\\"); foreach (var file in files) { File.Delete(file); } foreach (var government in governments) { try { File.Copy(Globals.GameDir + "gfx\\interface\\government_icon_republic.dds", Globals.ModDir + "gfx\\interface\\government_icon_" + government.name.Replace("_government", "republic_government") + ".dds"); File.Copy(Globals.GameDir + "gfx\\interface\\government_icon_feudal.dds", Globals.ModDir + "gfx\\interface\\government_icon_" + government.name.Replace("_government", "feudal_government") + ".dds"); File.Copy(Globals.GameDir + "gfx\\interface\\government_icon_tribal.dds", Globals.ModDir + "gfx\\interface\\government_icon_" + government.name.Replace("_government", "tribal_government") + ".dds"); File.Copy(Globals.GameDir + "gfx\\interface\\government_icon_nomadic.dds", Globals.ModDir + "gfx\\interface\\government_icon_" + government.name.Replace("_government", "nomadic_government") + ".dds"); File.Copy(Globals.GameDir + "gfx\\interface\\government_icon_theocracy.dds", Globals.ModDir + "gfx\\interface\\government_icon_" + government.name.Replace("_government", "theocracy_government") + ".dds"); } catch (Exception) { } } Script s = new Script(); var scope = new ScriptScope(); /* * s.Name = Globals.ModDir + "common\\governments\\nomadic_governments.txt"; * * s.Root = new ScriptScope(); * * scope.Name = "nomadic_governments"; * s.Root.Add(scope); * foreach (var government in governments) * { * if (government.cultureAllow.Count > 0) * { * { * government.SetType("nomadic"); * * var g = new ScriptScope(); * g.Name = government.name.Replace("_government", government.type+"_government"); * var last = government.name; * government.name = g.Name; * LanguageManager.instance.Add(g.Name, * CultureManager.instance.CultureMap[government.cultureAllow[0]].dna.GetUniqueMaleName()); * government.SetType("nomadic"); * * government.Save(g); * scope.Add(g); * government.name = last; * } * * } * } * * s.Save(); */ s = new Script(); s.Name = Globals.ModDir + "common\\governments\\feudal_governments.txt"; s.Root = new ScriptScope(); scope = new ScriptScope(); scope.Name = "feudal_governments"; s.Root.Add(scope); foreach (var government in governments) { if (government.cultureGroupAllow.Count > 0) { government.SetType("feudal"); var g = new ScriptScope(); g.Name = government.name.Replace("_government", government.type + "_government"); var last = government.name; government.name = g.Name; LanguageManager.instance.Add(g.Name, CultureManager.instance.CultureGroupMap[government.cultureGroupAllow[0]].Cultures[0].dna.GetUniqueMaleName()); government.SetType("feudal"); government.Save(g); scope.Add(g); government.name = last; } } s.Save(); s = new Script(); s.Name = Globals.ModDir + "common\\governments\\theocracy_governments.txt"; s.Root = new ScriptScope(); scope = new ScriptScope(); scope.Name = "theocracy_governments"; s.Root.Add(scope); foreach (var government in governments) { if (government.cultureGroupAllow.Count > 0) { government.SetType("theocracy"); var g = new ScriptScope(); g.Name = government.name.Replace("_government", government.type + "_government"); var last = government.name; government.name = g.Name; LanguageManager.instance.Add(g.Name, CultureManager.instance.CultureGroupMap[government.cultureGroupAllow[0]].Cultures[0].dna.GetUniqueMaleName()); government.SetType("theocracy"); government.Save(g); scope.Add(g); government.name = last; } } s.Save(); s = new Script(); s.Name = Globals.ModDir + "common\\governments\\republic_governments.txt"; s.Root = new ScriptScope(); scope = new ScriptScope(); scope.Name = "republic_governments"; s.Root.Add(scope); foreach (var government in governments) { if (government.cultureGroupAllow.Count > 0) { government.SetType("republic"); var g = new ScriptScope(); g.Name = government.name.Replace("_government", government.type + "_government"); var last = government.name; government.name = g.Name; LanguageManager.instance.Add(g.Name, CultureManager.instance.CultureGroupMap[government.cultureGroupAllow[0]].Cultures[0].dna.GetUniqueMaleName()); government.SetType("republic"); government.Save(g); scope.Add(g); government.name = last; } } s.Save(); s = new Script(); s.Name = Globals.ModDir + "common\\governments\\tribal_governments.txt"; s.Root = new ScriptScope(); scope = new ScriptScope(); scope.Name = "tribal_governments"; s.Root.Add(scope); foreach (var government in governments) { if (government.cultureGroupAllow.Count > 0) { government.SetType("tribal"); var g = new ScriptScope(); g.Name = government.name.Replace("_government", government.type + "_government"); var last = government.name; government.name = g.Name; SpriteManager.instance.AddGovernment(government); LanguageManager.instance.Add(g.Name, CultureManager.instance.CultureGroupMap[government.cultureGroupAllow[0]].Cultures[0].dna.GetUniqueMaleName()); government.SetType("tribal"); government.Save(g); scope.Add(g); government.name = last; } } s.Save(); }
public void Save() { foreach (var cultureParser in CultureManager.instance.AllCultures) { if (cultureParser.Governments.Count == 0) { var gov = GovernmentManager.instance.CreateNewGovernment(cultureParser); } foreach (var government in cultureParser.Governments) { if (government.cultureAllow.Count == 0) { government.cultureAllow.Add(cultureParser.Name); } } if (!Government.cultureDone.Contains(cultureParser.Name)) { cultureParser.Governments.Add(GovernmentManager.instance.CreateNewGovernment(cultureParser)); } } if (!Directory.Exists(Globals.ModDir + "gfx\\interface\\")) { Directory.CreateDirectory(Globals.ModDir + "gfx\\interface\\"); } var files = Directory.GetFiles(Globals.ModDir + "gfx\\interface\\"); foreach (var file in files) { File.Delete(file); } foreach (var government in governments) { switch (government.type) { case "nomadic": try { File.Copy(Globals.GameDir + "gfx\\interface\\government_icon_nomadic.dds", Globals.ModDir + "gfx\\interface\\government_icon_" + government.name.Replace("government_", "") + ".dds"); } catch (Exception) { } SpriteManager.instance.AddGovernment(government); break; case "tribal": try { File.Copy(Globals.GameDir + "gfx\\interface\\government_icon_tribal.dds", Globals.ModDir + "gfx\\interface\\government_icon_" + government.name.Replace("government_", "") + ".dds"); } catch (Exception) { } SpriteManager.instance.AddGovernment(government); break; case "feudal": try { File.Copy(Globals.GameDir + "gfx\\interface\\government_icon_feudal.dds", Globals.ModDir + "gfx\\interface\\government_icon_" + government.name.Replace("government_", "") + ".dds"); } catch (Exception) { } SpriteManager.instance.AddGovernment(government); break; case "theocracy": try { File.Copy(Globals.GameDir + "gfx\\interface\\government_icon_theocracy.dds", Globals.ModDir + "gfx\\interface\\government_icon_" + government.name.Replace("government_", "") + ".dds"); } catch (Exception) { } SpriteManager.instance.AddGovernment(government); break; case "republic": try { File.Copy(Globals.GameDir + "gfx\\interface\\government_icon_republic.dds", Globals.ModDir + "gfx\\interface\\government_icon_" + government.name.Replace("government_", "") + ".dds"); } catch (Exception) { } SpriteManager.instance.AddGovernment(government); break; } } Script s = new Script(); s.Name = Globals.ModDir + "common\\governments\\nomadic_governments.txt"; s.Root = new ScriptScope(); var scope = new ScriptScope(); scope.Name = "nomadic_governments"; s.Root.Add(scope); foreach (var government in governments) { if (government.type == "nomadic" && government.cultureAllow.Count > 0) { var g = new ScriptScope(); g.Name = government.name; government.Save(g); scope.Add(g); } } s.Save(); s = new Script(); s.Name = Globals.ModDir + "common\\governments\\feudal_governments.txt"; s.Root = new ScriptScope(); scope = new ScriptScope(); scope.Name = "feudal_governments"; s.Root.Add(scope); foreach (var government in governments) { if (government.type == "feudal" && government.cultureAllow.Count > 0) { var g = new ScriptScope(); g.Name = government.name; government.Save(g); scope.Add(g); } } s.Save(); s = new Script(); s.Name = Globals.ModDir + "common\\governments\\theocracy_governments.txt"; s.Root = new ScriptScope(); scope = new ScriptScope(); scope.Name = "theocracy_governments"; s.Root.Add(scope); foreach (var government in governments) { if (government.type == "theocracy" && government.cultureAllow.Count > 0) { var g = new ScriptScope(); g.Name = government.name; government.Save(g); scope.Add(g); } } s.Save(); s = new Script(); s.Name = Globals.ModDir + "common\\governments\\republic_governments.txt"; s.Root = new ScriptScope(); scope = new ScriptScope(); scope.Name = "republic_governments"; s.Root.Add(scope); foreach (var government in governments) { if (government.type == "republic" && government.cultureAllow.Count > 0) { var g = new ScriptScope(); g.Name = government.name; government.Save(g); scope.Add(g); } } s.Save(); s = new Script(); s.Name = Globals.ModDir + "common\\governments\\tribal_governments.txt"; s.Root = new ScriptScope(); scope = new ScriptScope(); scope.Name = "tribal_governments"; s.Root.Add(scope); foreach (var government in governments) { if (government.type == "tribal" && government.cultureAllow.Count > 0) { var g = new ScriptScope(); g.Name = government.name; government.Save(g); scope.Add(g); } } s.Save(); }
private void DoLine(Script script, string line) { bool skipping = false; String origline = line; lineNum++; if (line.Trim().Length == 0) { return; } if (line.Trim().StartsWith("#")) { return; } if (skipping) { if (line.Contains("}")) { skipping = false; } return; } if (line.Trim().StartsWith("{")) { return; } if (line.Contains("#")) { line = line.Split('#')[0].Trim(); } if (line.Contains("=")) { string[] sp = line.Split('='); string name = sp[0].Trim(); if (line.Trim().StartsWith("data")) { int gdfg = 0; } if (!(line.Contains("{") || sp[1].Trim().Length == 0)) { string value = sp[1].Trim(); while (value.EndsWith("}")) { value = value.Substring(0, value.Length - 1).Trim(); } if (sp.Length > 2) { } if (value.Contains("[")) { if (sp.Count() > 2) { } value = sp[1].Replace("[", ""); object val = GetValueFromString(value); current.Add(new ScriptCommand() { Name = name, Value = val, AlwaysQuote = true }); } else { object val = GetValueFromString(value); current.Add(new ScriptCommand() { Name = name, Value = val }); } } else if (!line.StartsWith("}")) { if (line.Contains("{") && line.Contains("}")) { string sname = line.Split('=')[0].Trim(); if (sname == "color" || sname == "color2") { object val = GetValueFromString(line.Split('{', '}')[1].Trim()); current.Add(new ScriptCommand() { Name = name, Value = val }); return; } var s = new ScriptScope() { Name = name }; s.Parent = current; scopeStack.Push(current); current.Add(s); current = s; int st = line.IndexOf('{'); int en = line.LastIndexOf('}'); String strip = line.Substring(st + 1, en - (st + 1)); bool bDone = false; if (strip.Contains("{") && strip.Contains("=")) { int brace = strip.IndexOf("{"); int eq = strip.IndexOf("="); String between = strip.Substring(eq + 1, brace - eq - 1); if (between.Trim().Length > 0) { String[] sp2 = strip.Split(new[] { ' ', '\t' }); List <String> lines = new List <string>(); foreach (var s1 in sp2) { if (s1.Trim().Length == 0) { continue; } bool hasSomethingElse = false; if (s1.Contains("}")) { String s2 = s1.Trim(); String str = ""; for (int index = 0; index < s2.Length; index++) { var c = s2[index]; if (c == '}') { if (str.Trim().Length > 0) { lines.Add(str.Trim()); } lines.Add("}"); str = ""; } else { hasSomethingElse = true; str += c.ToString(); } } } } List <String> comp = new List <string>(); for (int index = 0; index < lines.Count - 1; index++) { var line1 = lines[index]; if (lines[index + 1] == "{") { String tot = ""; for (int ii = index + 2; ii < lines.Count; ii++) { tot += lines[ii]; } if (tot.Contains("6032")) { } DoLine(script, tot.Substring(0, tot.Length)); } if (line1 == "=") { comp.Add(lines[index - 1] + " " + lines[index] + " " + lines[index + 1]); } } foreach (var l in comp) { DoLine(script, l.Trim()); } } else { DoLine(script, strip.Trim()); } } else { { String[] sp2 = strip.Split(new[] { ' ', '\t' }); List <string> lines = new List <string>(); foreach (var s1 in sp2) { if (s1.Trim().Length == 0) { continue; } lines.Add(s1.Trim()); } List <String> comp = new List <string>(); for (int index = 0; index < lines.Count - 1; index++) { var line1 = lines[index]; if (line1 == "=") { comp.Add(lines[index - 1] + " " + lines[index] + " " + lines[index + 1]); } } foreach (var l in comp) { DoLine(script, l.Trim()); } } // DoLine(script, strip.Trim()); } current = scopeStack.Pop(); return; } string sname2 = line.Split('=')[0].Trim(); ScriptScope scope = new ScriptScope(); scope.Parent = current; scope.Name = sname2; scopeStack.Push(current); current.Add(scope); current = scope; current.Name = name; } } else if (line.Trim().StartsWith("}")) { current = scopeStack.Pop(); line = line.Trim().Substring(1); DoLine(script, line); } else { current.Data += origline + "\n"; } }
private ScriptScope Copy() { ScriptScope newS = new ScriptScope(); newS.Name = Name; foreach (var child in Children) { if (child is ScriptScope) { newS.Add(((ScriptScope)child).Copy()); } if (child is ScriptCommand) { var c = ((ScriptCommand) child).Copy(); newS.Add(c); } } return newS; }
public void HandleTech(CharacterParser chr) { return; var provinces = chr.GetAllProvinces(); foreach (var provinceParser in provinces) { if (provinceParser.economicTechPoints > holdingCost) { bool bTribal = false; if (provinceParser.government == "tribal") { bTribal = true; } if (bTribal) { // work toward feudalism... provinceParser.economicTechPoints -= holdingCost; provinceParser.baronies[0].level++; if (provinceParser.baronies[0].level >= 5) { ScriptScope thing = new ScriptScope(); String barName = provinceParser.baronies[0].title; thing.Name = SimulationManager.instance.Year + ".4.1"; bool done = false; if (numMerchantRepublics < maxMerchantRepublics) { if (provinceParser.Adjacent.Where(p => !p.land && p.Range.Y - p.Range.X > 10).Any() && provinceParser.Title.Liege != null && provinceParser.Title.Liege.Rank == 2 && provinceParser.Title.Liege.CapitalProvince == provinceParser) { if (Rand.Next(4) == 0) { provinceParser.republic = true; thing.Add(new ScriptCommand() { Name = barName, Value = "city" }); done = true; provinceParser.government = "republic"; numMerchantRepublics++; { var chosen = provinceParser.Title.Liege; chosen.Holder.GiveTitleSoft(provinceParser.Title); chosen.CapitalProvince = provinceParser; //chosen.Holder.GiveTitleSoft(provinceParser.Title); //if (provinceParser.Title.Liege != chosen) // chosen.Holder.GiveTitleSoft(provinceParser.Title.Liege); chosen.DoSetLiegeEvent(null); chosen.government = "republic"; provinceParser.Title.government = "republic"; chosen.Scope.Do(@" dignity = 200 # Never want the Republic of Venice to change primary title allow = { is_republic = yes } "); { ScriptScope thingTit = new ScriptScope(); thingTit.Name = SimulationManager.instance.Year + ".4.1"; ScriptScope thingTit3 = new ScriptScope(); thingTit3.Name = SimulationManager.instance.Year + ".4.1"; chosen.titleScripts.Add(thingTit); provinceParser.Title.titleScripts.Add(thingTit3); thingTit.Add(new ScriptCommand() { Name = "law", Value = "succ_patrician_elective" }); thingTit3.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 = chosen.Culture.dna.GetPlaceName(); var sname = StarNames.SafeName(name); while (LanguageManager.instance.Get(sname) != null) { name = chosen.Culture.dna.GetPlaceName(); sname = StarNames.SafeName(name); } chosen.republicdynasties.Add(chosen.Holder.Dynasty.ID); for (int x = 0; x < 4; x++) { Dynasty d = DynastyManager.instance.GetDynasty(chosen.Culture); if (!TitleManager.instance.dynastiesWithPalaces.Contains(d.ID)) { var barony = TitleManager.instance.CreateBaronyScriptScope(null, chosen.Culture); TitleManager.instance.Titles.Add(barony); barony.government = "republicpalace"; barony.republicdynasty = d.ID; barony.culture = chosen.culture; barony.PalaceLocation = provinceParser; barony.republicreligion = chosen.Holder.religion; barony.DoSetLiegeEvent(chosen); var cr = SimulationManager.instance.AddCharacterForTitle(barony, true, false, d); //chosen.Holder.GiveTitleSoft(barony); chosen.Holder.Dynasty.palace = barony; TitleManager.instance.dynastiesWithPalaces.Add(d.ID); chosen.palaces.Add(barony); if (barony.Rank == 0 && barony.government == "republicpalace") { ScriptScope thingTit2 = new ScriptScope(); thingTit2.Name = SimulationManager.instance.Year + ".4.1"; thingTit2.Add(new ScriptCommand() { Name = "holding_dynasty", Value = barony.republicdynasty }); //thing.Add(new ScriptCommand() { Name = "liege", Value = title.republicdynasty }); if (barony.Scope.Find("culture") == null) { barony.Scope.Add(new ScriptCommand() { Name = "culture", Value = chosen.culture }); barony.Scope.Add(new ScriptCommand() { Name = "religion", Value = chosen.Holder.religion }); } barony.titleScripts.Add(thingTit2); } } } if (!TitleManager.instance.dynastiesWithPalaces.Contains(chosen.Holder.Dynasty.ID)) { var barony = TitleManager.instance.CreateBaronyScriptScope(null, chosen.Culture); TitleManager.instance.Titles.Add(barony); barony.government = "republicpalace"; barony.republicdynasty = chosen.Holder.Dynasty.ID; barony.culture = chosen.culture; barony.republicreligion = chosen.Holder.religion; barony.DoSetLiegeEvent(chosen); barony.PalaceLocation = provinceParser; chosen.Holder.GiveTitleSoft(barony); chosen.Holder.Dynasty.palace = barony; chosen.palaces.Add(barony); TitleManager.instance.dynastiesWithPalaces.Add(chosen.Holder.Dynasty.ID); if (barony.Rank == 0 && barony.government == "republicpalace") { ScriptScope thingTit2 = new ScriptScope(); thingTit2.Name = SimulationManager.instance.Year + ".4.1"; thingTit2.Add(new ScriptCommand() { Name = "holding_dynasty", Value = barony.republicdynasty }); //thing.Add(new ScriptCommand() { Name = "liege", Value = title.republicdynasty }); if (barony.Scope.Find("culture") == null) { barony.Scope.Add(new ScriptCommand() { Name = "culture", Value = chosen.culture }); barony.Scope.Add(new ScriptCommand() { Name = "religion", Value = chosen.Holder.religion }); } barony.titleScripts.Add(thingTit2); } } } } if (chosen.Liege != null && chosen.Liege.Rank > chosen.Rank) { thingTit.Add(new ScriptCommand() { Name = "liege", Value = chosen.Liege.Name }); } } } } } } if (!done) { thing.Add(new ScriptCommand() { Name = barName, Value = "castle" }); provinceParser.government = "feudalism"; } provinceParser.militaryTechPoints = 0; provinceParser.dateScripts.Add(thing); if (provinceParser.Title.Holder == chr) { chr.PrimaryTitle.government = "feudalism"; } } } else if (provinceParser.militaryTechPoints > holdingCost) { if (provinceParser.ActiveBaronies < provinceParser.max_settlements) { provinceParser.militaryTechPoints -= holdingCost; ProvinceParser.Barony b = provinceParser.GetLastEnabledBarony(); if (b.level >= 2) { List <String> choices = new List <string>(); b = provinceParser.GetNextBarony(); if (provinceParser.CastleCount == 0) { choices.Add("castle"); } if (provinceParser.TownCount == 0) { choices.Add("city"); } if (provinceParser.TempleCount == 0) { choices.Add("temple"); } if (choices.Count == 0) { choices.Add("castle"); choices.Add("city"); choices.Add("temple"); } { b.enabled = true; b.type = choices[Rand.Next(choices.Count)]; ScriptScope thing = new ScriptScope(); String barName = b.title; thing.Name = SimulationManager.instance.Year + ".4.1"; thing.Add(new ScriptCommand() { Name = barName, Value = b.type }); provinceParser.dateScripts.Add(thing); } } else { b.level++; } } } } } }
public TitleParser CreateEmpireScriptScope(ProvinceParser capital, CharacterParser chr) { var rand = Rand.Get(); Color col = Color.FromArgb(255, rand.Next(200) + 55, rand.Next(200) + 55, rand.Next(200) + 55); ScriptScope scope = new ScriptScope(); scope.Parent = LandedTitlesScript.Root; { String place = chr.Culture.dna.GetPlaceName(); String text = place; place = StarNames.SafeName(place); LanguageManager.instance.Add(place, text); scope.Name = "e_" + place; LanguageManager.instance.Add(scope.Name, text); } //scope.Kids.Add(new ScriptCommand() { Name = "rebel", Value = false }); scope.Add(new ScriptCommand() { Name = "color", Value = col }); scope.Add(new ScriptCommand() { Name = "color2", Value = col }); scope.Add(new ScriptCommand() { Name = "capital", Value = capital.id }); TitleParser title = new TitleParser(scope); AddTitle(title); // now place the counties into it... if (title.capital != 0) title.CapitalProvince = MapManager.instance.ProvinceIDMap[title.capital]; return title; }
public TitleParser CreateKingScriptScope(ProvinceParser capital, String name = null) { var rand = Rand.Get(); Color col = Color.FromArgb(255, rand.Next(200) + 55, rand.Next(200) + 55, rand.Next(200) + 55); ScriptScope scope = new ScriptScope(); scope.Parent = LandedTitlesScript.Root; if (name == null) scope.Name = "k_" + capital.Title.Name.Substring(2); else scope.Name = "k_" + name; //scope.Kids.Add(new ScriptCommand() { Name = "rebel", Value = false }); scope.Add(new ScriptCommand() { Name = "color", Value = col }); scope.Add(new ScriptCommand() { Name = "color2", Value = col }); scope.Add(new ScriptCommand() { Name = "capital", Value = capital.id }); TitleParser title = new TitleParser(scope); AddTitle(title); // now place the counties into it... if (title.capital != 0) title.CapitalProvince = MapManager.instance.ProvinceIDMap[title.capital]; return title; }
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 ScriptScope GetNewCreatedCharacter() { var scope = new ScriptScope(); scope.Name = CharacterParser.IDMax.ToString(); scope.Add("name", "Bob"); scope.Add("culture", "norse"); scope.Add("religion", "pagan"); var born = scope.AddScope("730.1.1"); var died = scope.AddScope("790.1.1"); born.Add("birth", "730.1.1"); died.Add("death", "790.1.1"); //scope.SetChild(CharactersScript.Root); return scope; }
public TitleParser CreateDukeScriptScope(ProvinceParser capital, String name = null) { var rand = Rand.Get(); Color col = Color.FromArgb(255, rand.Next(200) + 55, rand.Next(200) + 55, rand.Next(200) + 55); ScriptScope scope = new ScriptScope(); scope.Parent = LandedTitlesScript.Root; if (name == null) { String place = capital.Title.Holder.Culture.dna.GetPlaceName(); String text = place; place = StarNames.SafeName(place); LanguageManager.instance.Add(place, text); scope.Name = "d_" + place; LanguageManager.instance.Add(scope.Name, text); } else scope.Name = "d_" + name; // scope.Kids.Add(new ScriptCommand() { Name = "rebel", Value = false }); scope.Add(new ScriptCommand() { Name = "color", Value = col }); scope.Add(new ScriptCommand() { Name = "color2", Value = col }); scope.Add(new ScriptCommand() { Name = "capital", Value = capital.id }); TitleParser title = new TitleParser(scope); // if (capital.Title.Culture.dna.horde) // title.Scope.Do("historical_nomad = yes"); AddTitle(title); if (title.capital != 0) title.CapitalProvince = MapManager.instance.ProvinceIDMap[title.capital]; // now place the counties into it... return title; }