Exemple #1
0
        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();
            }
        }
Exemple #2
0
        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 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);
        }
Exemple #4
0
        public TitleParser CreateDukeScriptScope(ProvinceParser capital, String name = null)
        {
            if (capital.title == "c_keysay")
            {
            }
            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);


                if (TitleManager.instance.TitleMap.ContainsKey("d_" + place))
                {
                    return(CreateDukeScriptScope(capital, name));
                }

                LanguageManager.instance.Add(place, text);
                scope.Name = "d_" + place;
                LanguageManager.instance.Add(scope.Name, text);
            }
            else
            {
                scope.Name = "d_" + name;
                if (TitleManager.instance.TitleMap.ContainsKey(scope.Name))
                {
                    return(CreateDukeScriptScope(capital));
                }
            }

            //  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);
        }