Esempio n. 1
0
        public RemnantSave(string path)
        {
            if (!Directory.Exists(path))
            {
                throw new Exception(path + " does not exist.");
            }

            if (File.Exists(path + "\\profile.sav"))
            {
                this.saveType    = RemnantSaveType.Normal;
                this.profileFile = "profile.sav";
            }
            else
            {
                var winFiles = Directory.GetFiles(path, "container.*");
                if (winFiles.Length > 0)
                {
                    this.winSave  = new WindowsSave(winFiles[0]);
                    this.saveType = RemnantSaveType.WindowsStore;
                    profileFile   = winSave.Profile;
                }
                else
                {
                    throw new Exception(path + " is not a valid save.");
                }
            }
            this.savePath  = path;
            saveCharacters = RemnantCharacter.GetCharactersFromSave(this, RemnantCharacter.CharacterProcessingMode.NoEvents);
        }
        public void setMissingItems(RemnantCharacter charData)
        {
            List <RemnantItem> missingItems  = new List <RemnantItem>();
            List <RemnantItem> possibleItems = this.getPossibleItems();

            foreach (RemnantItem item in possibleItems)
            {
                if (!charData.Inventory.Contains(item.GetKey()))
                {
                    missingItems.Add(item);
                }
            }
            mItems = missingItems;
        }
Esempio n. 3
0
        public void setMissingItems(RemnantCharacter charData)
        {
            List <string> missingItems  = new List <string>();
            List <string> possibleItems = this.getPossibleItems();

            foreach (string item in possibleItems)
            {
                if (!charData.Inventory.Contains(item))
                {
                    missingItems.Add(GetCleanItemName(item));
                }
            }
            mItems = missingItems;
        }
Esempio n. 4
0
 public RemnantSave(string saveProfilePath)
 {
     if (!saveProfilePath.EndsWith("profile.sav"))
     {
         if (File.Exists(saveProfilePath + "\\profile.sav"))
         {
             saveProfilePath += "\\profile.sav";
         }
         else
         {
             throw new Exception(saveProfilePath + " is not a valid save.");
         }
     }
     else if (!File.Exists(saveProfilePath))
     {
         throw new Exception(saveProfilePath + " does not exist.");
     }
     this.profilePath = saveProfilePath;
     saveCharacters   = RemnantCharacter.GetCharactersFromSave(this.SaveFolderPath, RemnantCharacter.CharacterProcessingMode.NoEvents);
 }
Esempio n. 5
0
        public void setMissingItems(RemnantCharacter charData)
        {
            List <RemnantItem> missingItems  = new List <RemnantItem>();
            List <RemnantItem> possibleItems = this.getPossibleItems();

            foreach (RemnantItem item in possibleItems)
            {
                if (!charData.Inventory.Contains(item.GetKey()))
                {
                    missingItems.Add(item);
                }
            }
            mItems = missingItems;

            if (possibleItems.Count == 0 && !GameInfo.Events.ContainsKey(this.getKey()) && !this.getKey().Equals("TraitBook") && !this.getKey().Equals("Simulacrum"))
            {
                RemnantItem ri = new RemnantItem("/UnknownPotentialLoot");
                mItems.Add(ri);
            }
        }
Esempio n. 6
0
 public void UpdateCharacters(RemnantCharacter.CharacterProcessingMode mode)
 {
     saveCharacters = RemnantCharacter.GetCharactersFromSave(this.SaveFolderPath, mode);
 }
Esempio n. 7
0
 public void UpdateCharacters()
 {
     saveCharacters = RemnantCharacter.GetCharactersFromSave(this.SaveFolderPath);
 }
        public static List <RemnantCharacter> GetCharactersFromSave(RemnantSave remnantSave, CharacterProcessingMode mode)
        {
            List <RemnantCharacter> charData = new List <RemnantCharacter>();

            try
            {
                string   profileData = File.ReadAllText(remnantSave.SaveProfilePath);
                string[] characters  = profileData.Split(new string[] { "/Game/Characters/Player/Base/Character_Master_Player.Character_Master_Player_C" }, StringSplitOptions.None);
                for (var i = 1; i < characters.Length; i++)
                {
                    RemnantCharacter cd = new RemnantCharacter();
                    cd.Archetype = GameInfo.Archetypes["Undefined"];
                    Match archetypeMatch = new Regex(@"/Game/_Core/Archetypes/[a-zA-Z_]+").Match(characters[i - 1]);
                    if (archetypeMatch.Success)
                    {
                        string archetype = archetypeMatch.Value.Replace("/Game/_Core/Archetypes/", "").Split('_')[1];
                        if (GameInfo.Archetypes.ContainsKey(archetype))
                        {
                            cd.Archetype = GameInfo.Archetypes[archetype];
                        }
                        else
                        {
                            cd.Archetype = archetype;
                        }
                    }
                    cd.save = remnantSave;
                    List <string> saveItems = new List <string>();
                    string        charEnd   = "Character_Master_Player_C";
                    string        inventory = characters[i].Substring(0, characters[i].IndexOf(charEnd));

                    Regex           rx      = new Regex(@"/Items/Weapons(/[a-zA-Z0-9_]+)+/[a-zA-Z0-9_]+");
                    MatchCollection matches = rx.Matches(inventory);
                    foreach (Match match in matches)
                    {
                        saveItems.Add(match.Value);
                    }

                    rx      = new Regex(@"/Items/Armor/([a-zA-Z0-9_]+/)?[a-zA-Z0-9_]+");
                    matches = rx.Matches(inventory);
                    foreach (Match match in matches)
                    {
                        saveItems.Add(match.Value);
                    }

                    rx      = new Regex(@"/Items/Trinkets/(BandsOfCastorAndPollux/)?[a-zA-Z0-9_]+");
                    matches = rx.Matches(inventory);
                    foreach (Match match in matches)
                    {
                        saveItems.Add(match.Value);
                    }

                    rx      = new Regex(@"/Items/Mods/[a-zA-Z0-9_]+");
                    matches = rx.Matches(inventory);
                    foreach (Match match in matches)
                    {
                        saveItems.Add(match.Value);
                    }

                    rx      = new Regex(@"/Items/Traits/[a-zA-Z0-9_]+");
                    matches = rx.Matches(inventory);
                    foreach (Match match in matches)
                    {
                        saveItems.Add(match.Value);
                    }

                    rx      = new Regex(@"/Items/QuestItems(/[a-zA-Z0-9_]+)+/[a-zA-Z0-9_]+");
                    matches = rx.Matches(inventory);
                    foreach (Match match in matches)
                    {
                        saveItems.Add(match.Value);
                    }

                    rx      = new Regex(@"/Quests/[a-zA-Z0-9_]+/[a-zA-Z0-9_]+");
                    matches = rx.Matches(inventory);
                    foreach (Match match in matches)
                    {
                        saveItems.Add(match.Value);
                    }

                    rx      = new Regex(@"/Player/Emotes/Emote_[a-zA-Z0-9]+");
                    matches = rx.Matches(inventory);
                    foreach (Match match in matches)
                    {
                        saveItems.Add(match.Value);
                    }

                    cd.Inventory = saveItems;
                    charData.Add(cd);
                }

                if (mode == CharacterProcessingMode.All)
                {
                    string[] saves = remnantSave.WorldSaves;
                    for (int i = 0; i < saves.Length && i < charData.Count; i++)
                    {
                        charData[i].processSaveData(File.ReadAllText(saves[i]));
                    }
                }
            }
            catch (IOException ex)
            {
                if (ex.Message.Contains("being used by another process"))
                {
                    Console.WriteLine("Save file in use; waiting 0.5 seconds and retrying.");
                    System.Threading.Thread.Sleep(500);
                    charData = GetCharactersFromSave(remnantSave, mode);
                }
            }
            return(charData);
        }
Esempio n. 9
0
        //credit to /u/hzla00 for original javascript implementation
        static public void ProcessEvents(RemnantCharacter character, string eventsText, ProcessMode mode)
        {
            Dictionary <string, Dictionary <string, string> > zones      = new Dictionary <string, Dictionary <string, string> >();
            Dictionary <string, List <RemnantWorldEvent> >    zoneEvents = new Dictionary <string, List <RemnantWorldEvent> >();
            List <RemnantWorldEvent> churchEvents = new List <RemnantWorldEvent>();

            foreach (string z in GameInfo.Zones)
            {
                zones.Add(z, new Dictionary <string, string>());
                zoneEvents.Add(z, new List <RemnantWorldEvent>());
            }

            string zone = null;
            string currentMainLocation = "Fairview";
            string currentSublocation  = null;

            string          eventName = null;
            MatchCollection matches   = Regex.Matches(eventsText, "(?:/[a-zA-Z0-9_]+){3}/(([a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9_]+)|Quest_Church)");

            foreach (Match match in matches)
            {
                string eventType     = null;
                string lastEventname = eventName;
                eventName = null;

                string textLine = match.Value;
                try
                {
                    if (currentSublocation != null)
                    {
                        //Some world bosses don't have a preceding dungeon; subsequent items therefore spawn in the overworld
                        if (currentSublocation.Equals("TheRavager'sHaunt") || currentSublocation.Equals("TheTempestCourt"))
                        {
                            currentSublocation = null;
                        }
                    }
                    zone = getZone(textLine);

                    eventType = getEventType(textLine);

                    if (textLine.Contains("Overworld_Zone") || textLine.Contains("_Overworld_"))
                    {
                        //process overworld zone marker
                        currentMainLocation = textLine.Split('/')[4].Split('_')[1] + " " + textLine.Split('/')[4].Split('_')[2] + " " + textLine.Split('/')[4].Split('_')[3];
                        if (GameInfo.MainLocations.ContainsKey(currentMainLocation))
                        {
                            currentMainLocation = GameInfo.MainLocations[currentMainLocation];
                        }
                        else
                        {
                            currentMainLocation = null;
                        }
                        continue;
                    }
                    else if (textLine.Contains("Quest_Church"))
                    {
                        //process Root Mother event
                        currentMainLocation = "Chapel Station";
                        eventName           = "RootMother";
                        currentSublocation  = "Church of the Harbinger";
                    }
                    else if (eventType != null)
                    {
                        //process other events, if they're recognized by getEventType
                        eventName = textLine.Split('/')[4].Split('_')[2];
                        if (textLine.Contains("OverworldPOI"))
                        {
                            currentSublocation = null;
                        }
                        else if (!textLine.Contains("Quest_Event"))
                        {
                            if (GameInfo.SubLocations.ContainsKey(eventName))
                            {
                                currentSublocation = GameInfo.SubLocations[eventName];
                            }
                            else
                            {
                                currentSublocation = null;
                            }
                        }
                        if ("Chapel Station".Equals(currentMainLocation))
                        {
                            if (textLine.Contains("Quest_Boss"))
                            {
                                currentMainLocation = "Westcourt";
                            }
                            else
                            {
                                currentSublocation = null;
                            }
                        }
                    }

                    if (mode == ProcessMode.Adventure)
                    {
                        currentMainLocation = null;
                    }

                    if (eventName != lastEventname)
                    {
                        RemnantWorldEvent se = new RemnantWorldEvent();
                        // Replacements
                        if (eventName != null)
                        {
                            se.setKey(eventName);
                            if (GameInfo.Events.ContainsKey(eventName))
                            {
                                se.Name = GameInfo.Events[eventName];
                            }
                            else
                            {
                                se.Name = eventName;
                            }
                            se.Name = Regex.Replace(se.Name, "([a-z])([A-Z])", "$1 $2");
                        }

                        if (zone != null && eventType != null && eventName != null)
                        {
                            if (!zones[zone].ContainsKey(eventType))
                            {
                                zones[zone].Add(eventType, "");
                            }
                            if (!zones[zone][eventType].Contains(eventName))
                            {
                                zones[zone][eventType] += ", " + eventName;
                                List <string> locationList = new List <string>();
                                locationList.Add(zone);
                                if (currentMainLocation != null)
                                {
                                    locationList.Add(Regex.Replace(currentMainLocation, "([a-z])([A-Z])", "$1 $2"));
                                }
                                if (currentSublocation != null)
                                {
                                    locationList.Add(Regex.Replace(currentSublocation, "([a-z])([A-Z])", "$1 $2"));
                                }
                                se.Location = string.Join(": ", locationList);
                                se.Type     = eventType;
                                se.setMissingItems(character);
                                if (!"Chapel Station".Equals(currentMainLocation))
                                {
                                    zoneEvents[zone].Add(se);
                                }
                                else
                                {
                                    churchEvents.Insert(0, se);
                                }

                                // rings drop with the Cryptolith on Rhom
                                if (eventName.Equals("Cryptolith") && zone.Equals("Rhom"))
                                {
                                    RemnantWorldEvent ringdrop = new RemnantWorldEvent();
                                    ringdrop.Location = zone;
                                    ringdrop.setKey("SoulLink");
                                    ringdrop.Name = "Soul Link";
                                    ringdrop.Type = "Item Drop";
                                    ringdrop.setMissingItems(character);
                                    zoneEvents[zone].Add(ringdrop);
                                }
                                // beetle always spawns in Strange Pass
                                else if (eventName.Equals("BrainBug"))
                                {
                                    RemnantWorldEvent beetle = new RemnantWorldEvent();
                                    beetle.Location = se.Location;
                                    beetle.setKey("Sketterling");
                                    beetle.Name = "Sketterling";
                                    beetle.Type = "Loot Beetle";
                                    beetle.setMissingItems(character);
                                    zoneEvents[zone].Add(beetle);
                                }
                                else if (eventName.Equals("BarnSiege"))
                                {
                                    RemnantWorldEvent wardPrime = new RemnantWorldEvent();
                                    wardPrime.setKey("WardPrime");
                                    wardPrime.Name     = "Ward Prime";
                                    wardPrime.Location = "Earth: Ward Prime";
                                    wardPrime.Type     = "Quest Event";
                                    wardPrime.setMissingItems(character);
                                    zoneEvents[zone].Add(wardPrime);
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error parsing save event:");
                    Console.WriteLine("\tLine: " + textLine);
                    Console.WriteLine("\tError: " + ex.ToString());
                }
            }

            List <RemnantWorldEvent> orderedEvents = new List <RemnantWorldEvent>();

            bool churchAdded          = false;
            bool queenAdded           = false;
            bool navunAdded           = false;
            RemnantWorldEvent ward13  = new RemnantWorldEvent();
            RemnantWorldEvent hideout = new RemnantWorldEvent();
            RemnantWorldEvent undying = new RemnantWorldEvent();
            RemnantWorldEvent queen   = new RemnantWorldEvent();
            RemnantWorldEvent navun   = new RemnantWorldEvent();
            RemnantWorldEvent ward17  = new RemnantWorldEvent();

            if (mode == ProcessMode.Campaign)
            {
                ward13.setKey("Ward13");
                ward13.Name     = "Ward 13";
                ward13.Location = "Earth: Ward 13";
                ward13.Type     = "Home";
                ward13.setMissingItems(character);
                if (ward13.MissingItems.Length > 0)
                {
                    orderedEvents.Add(ward13);
                }

                hideout.setKey("FoundersHideout");
                hideout.Name     = "Founder's Hideout";
                hideout.Location = "Earth: Fairview";
                hideout.Type     = "Point of Interest";
                hideout.setMissingItems(character);
                if (hideout.MissingItems.Length > 0)
                {
                    orderedEvents.Add(hideout);
                }

                undying.setKey("UndyingKing");
                undying.Name     = "Undying King";
                undying.Location = "Rhom: Undying Throne";
                undying.Type     = "World Boss";
                undying.setMissingItems(character);

                queen.Name = "Iskal Queen";
                queen.setKey("IskalQueen");
                queen.Location = "Corsus: The Mist Fen";
                queen.Type     = "Point of Interest";
                queen.setMissingItems(character);

                navun.Name = "Fight With The Rebels";
                navun.setKey("SlaveRevolt");
                navun.Location = "Yaesha: Shrine of the Immortals";
                navun.Type     = "Siege";
                navun.setMissingItems(character);

                ward17.setKey("Ward17");
                ward17.Name     = "The Dreamer";
                ward17.Location = "Earth: Ward 17";
                ward17.Type     = "World Boss";
                ward17.setMissingItems(character);
            }

            for (int i = 0; i < zoneEvents["Earth"].Count; i++)
            {
                //if (mode == ProcessMode.Subject2923) Console.WriteLine(zoneEvents["Earth"][i].eventKey);
                if (mode == ProcessMode.Campaign && !churchAdded && zoneEvents["Earth"][i].Location.Contains("Westcourt"))
                {
                    foreach (RemnantWorldEvent rwe in churchEvents)
                    {
                        orderedEvents.Add(rwe);
                    }
                    churchAdded = true;
                }
                orderedEvents.Add(zoneEvents["Earth"][i]);
            }
            for (int i = 0; i < zoneEvents["Rhom"].Count; i++)
            {
                orderedEvents.Add(zoneEvents["Rhom"][i]);
            }
            if (mode == ProcessMode.Campaign && undying.MissingItems.Length > 0)
            {
                orderedEvents.Add(undying);
            }
            for (int i = 0; i < zoneEvents["Corsus"].Count; i++)
            {
                if (mode == ProcessMode.Campaign && !queenAdded && zoneEvents["Corsus"][i].Location.Contains("The Mist Fen"))
                {
                    if (queen.MissingItems.Length > 0)
                    {
                        orderedEvents.Add(queen);
                    }
                    queenAdded = true;
                }
                orderedEvents.Add(zoneEvents["Corsus"][i]);
            }
            for (int i = 0; i < zoneEvents["Yaesha"].Count; i++)
            {
                if (mode == ProcessMode.Campaign && !navunAdded && zoneEvents["Yaesha"][i].Location.Contains("The Scalding Glade"))
                {
                    if (navun.MissingItems.Length > 0)
                    {
                        orderedEvents.Add(navun);
                    }
                    navunAdded = true;
                }
                orderedEvents.Add(zoneEvents["Yaesha"][i]);
            }
            for (int i = 0; i < zoneEvents["Reisum"].Count; i++)
            {
                /*if (mode == ProcessMode.Campaign && !navunAdded && zoneEvents["Yaesha"][i].Location.Contains("The Scalding Glade"))
                 * {
                 *  if (navun.MissingItems.Length > 0) orderedEvents.Add(navun);
                 *  navunAdded = true;
                 * }*/
                orderedEvents.Add(zoneEvents["Reisum"][i]);
            }

            if (mode == ProcessMode.Campaign)
            {
                if (ward17.MissingItems.Length > 0)
                {
                    orderedEvents.Add(ward17);
                }
            }

            for (int i = 0; i < orderedEvents.Count; i++)
            {
                if (mode == ProcessMode.Campaign || mode == ProcessMode.Subject2923)
                {
                    character.CampaignEvents.Add(orderedEvents[i]);
                }
                else
                {
                    character.AdventureEvents.Add(orderedEvents[i]);
                }
            }

            if (mode == ProcessMode.Subject2923)
            {
                ward17.setKey("Ward17Root");
                ward17.Name     = "Harsgaard";
                ward17.Location = "Earth: Ward 17 (Root Dimension)";
                ward17.Type     = "World Boss";
                ward17.setMissingItems(character);
                character.CampaignEvents.Add(ward17);
            }
        }
        //credit to /u/hzla00 for original javascript implementation
        static public void ProcessEvents(RemnantCharacter character, string eventsText, ProcessMode mode)
        {
            Dictionary <string, Dictionary <string, string> > zones      = new Dictionary <string, Dictionary <string, string> >();
            Dictionary <string, List <RemnantWorldEvent> >    zoneEvents = new Dictionary <string, List <RemnantWorldEvent> >();
            List <RemnantWorldEvent> churchEvents = new List <RemnantWorldEvent>();

            foreach (string z in GameInfo.Zones)
            {
                zones.Add(z, new Dictionary <string, string>());
                zoneEvents.Add(z, new List <RemnantWorldEvent>());
            }

            string zone = null;
            string currentMainLocation = "Fairview";
            string currentSublocation  = null;

            string          eventName = null;
            MatchCollection matches   = Regex.Matches(eventsText, "(?:/[a-zA-Z0-9_]+){3}/(([a-zA-Z0-9]+_[a-zA-Z0-9]+_[a-zA-Z0-9_]+)|Quest_Church)");

            foreach (Match match in matches)
            {
                string eventType     = null;
                string lastEventname = eventName;
                eventName = null;

                string textLine = match.Value;
                try
                {
                    if (currentSublocation != null)
                    {
                        //Some world bosses don't have a preceding dungeon; subsequent items therefore spawn in the overworld
                        if (currentSublocation.Equals("TheRavager'sHaunt") || currentSublocation.Equals("TheTempestCourt"))
                        {
                            currentSublocation = null;
                        }
                    }
                    zone = getZone(textLine);

                    eventType = getEventType(textLine);
                    if (textLine.Contains("Overworld_Zone"))
                    {
                        //process overworld zone marker
                        currentMainLocation = textLine.Split('/')[4].Split('_')[1] + " " + textLine.Split('/')[4].Split('_')[2] + " " + textLine.Split('/')[4].Split('_')[3];
                        if (GameInfo.MainLocations.ContainsKey(currentMainLocation))
                        {
                            currentMainLocation = GameInfo.MainLocations[currentMainLocation];
                        }
                        else
                        {
                            currentMainLocation = null;
                        }
                        continue;
                    }
                    else if (textLine.Contains("Quest_Church"))
                    {
                        //process Root Mother event
                        currentMainLocation = "Chapel Station";
                        eventName           = "RootMother";
                        currentSublocation  = "Church of the Harbinger";
                    }
                    else if (eventType != null)
                    {
                        //process other events, if they're recognized by getEventType
                        eventName = textLine.Split('/')[4].Split('_')[2];
                        if (textLine.Contains("OverworldPOI"))
                        {
                            currentSublocation = null;
                        }
                        else if (!textLine.Contains("Quest_Event"))
                        {
                            if (GameInfo.SubLocations.ContainsKey(eventName))
                            {
                                currentSublocation = GameInfo.SubLocations[eventName];
                            }
                            else
                            {
                                currentSublocation = null;
                            }
                        }
                        if ("Chapel Station".Equals(currentMainLocation))
                        {
                            if (textLine.Contains("Quest_Boss"))
                            {
                                currentMainLocation = "Westcourt";
                            }
                            else
                            {
                                currentSublocation = null;
                            }
                        }
                    }

                    if (mode == ProcessMode.Adventure)
                    {
                        currentMainLocation = null;
                    }

                    if (eventName != lastEventname)
                    {
                        RemnantWorldEvent se = new RemnantWorldEvent();
                        // Replacements
                        if (eventName != null)
                        {
                            se.setKey(eventName);
                            se.Name = eventName.Replace("LizAndLiz", "TaleOfTwoLiz's").Replace("Fatty", "TheUncleanOne").Replace("WastelandGuardian", "Claviger").Replace("RootEnt", "TheEnt").Replace("Wolf", "TheRavager").Replace("RootDragon", "Singe").Replace("SwarmMaster", "Scourge").Replace("RootWraith", "Shroud").Replace("RootTumbleweed", "TheMangler").Replace("Kincaller", "Warden").Replace("Tyrant", "Thrall").Replace("Vyr", "ShadeAndShatter").Replace("ImmolatorAndZephyr", "ScaldAndSear").Replace("RootBrute", "Gorefist").Replace("SlimeHulk", "Canker").Replace("BlinkFiend", "Onslaught").Replace("Sentinel", "Raze").Replace("Penitent", "Leto'sAmulet").Replace("LastWill", "SupplyRun").Replace("SwampGuardian", "Ixillis").Replace("OldManAndConstruct", "WudAndAncientConstruct").Replace("Splitter", "Riphide").Replace("Nexus", "RootNexus").Replace("FlickeringHorror", "DreamEater").Replace("BarbTerror", "BarbedTerror").Replace("Wisp", "CircletHatchery").Replace("GunslignersRing", "Gunslinger'sRing");
                            se.Name = Regex.Replace(se.Name, "([a-z])([A-Z])", "$1 $2");
                        }

                        if (zone != null && eventType != null && eventName != null)
                        {
                            if (!zones[zone].ContainsKey(eventType))
                            {
                                zones[zone].Add(eventType, "");
                            }
                            if (!zones[zone][eventType].Contains(eventName))
                            {
                                zones[zone][eventType] += ", " + eventName;
                                List <string> locationList = new List <string>();
                                locationList.Add(zone);
                                if (currentMainLocation != null)
                                {
                                    locationList.Add(Regex.Replace(currentMainLocation, "([a-z])([A-Z])", "$1 $2"));
                                }
                                if (currentSublocation != null)
                                {
                                    locationList.Add(Regex.Replace(currentSublocation, "([a-z])([A-Z])", "$1 $2"));
                                }
                                se.Location = string.Join(": ", locationList);
                                se.Type     = eventType;
                                se.setMissingItems(character);
                                if (!"Chapel Station".Equals(currentMainLocation))
                                {
                                    zoneEvents[zone].Add(se);
                                }
                                else
                                {
                                    churchEvents.Insert(0, se);
                                }

                                // rings drop with the Cryptolith on Rhom
                                if (eventName.Equals("Cryptolith") && zone.Equals("Rhom"))
                                {
                                    RemnantWorldEvent ringdrop = new RemnantWorldEvent();
                                    ringdrop.Location = zone;
                                    ringdrop.setKey("SoulLink");
                                    ringdrop.Name = "Soul Link";
                                    ringdrop.Type = "Item Drop";
                                    ringdrop.setMissingItems(character);
                                    zoneEvents[zone].Add(ringdrop);
                                }
                                // beetle always spawns in Strange Pass
                                else if (eventName.Equals("BrainBug"))
                                {
                                    RemnantWorldEvent beetle = new RemnantWorldEvent();
                                    beetle.Location = se.Location;
                                    beetle.setKey("Sketterling");
                                    beetle.Name = "Sketterling";
                                    beetle.Type = "Loot Beetle";
                                    beetle.setMissingItems(character);
                                    zoneEvents[zone].Add(beetle);
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error parsing save event:");
                    Console.WriteLine("\tLine: " + textLine);
                    Console.WriteLine("\tError: " + ex.ToString());
                }
            }

            List <RemnantWorldEvent> orderedEvents = new List <RemnantWorldEvent>();

            bool churchAdded          = false;
            bool queenAdded           = false;
            bool navunAdded           = false;
            RemnantWorldEvent ward13  = new RemnantWorldEvent();
            RemnantWorldEvent hideout = new RemnantWorldEvent();
            RemnantWorldEvent undying = new RemnantWorldEvent();
            RemnantWorldEvent queen   = new RemnantWorldEvent();
            RemnantWorldEvent navun   = new RemnantWorldEvent();
            RemnantWorldEvent ward17  = new RemnantWorldEvent();

            if (mode == ProcessMode.Campaign)
            {
                ward13.setKey("Ward13");
                ward13.Name     = "Ward 13";
                ward13.Location = "Earth: Ward 13";
                ward13.Type     = "Home";
                ward13.setMissingItems(character);
                if (ward13.MissingItems.Length > 0)
                {
                    orderedEvents.Add(ward13);
                }

                hideout.setKey("FoundersHideout");
                hideout.Name     = "Founder's Hideout";
                hideout.Location = "Earth: Fairview";
                hideout.Type     = "Point of Interest";
                hideout.setMissingItems(character);
                if (hideout.MissingItems.Length > 0)
                {
                    orderedEvents.Add(hideout);
                }

                undying.setKey("UndyingKing");
                undying.Name     = "Undying King";
                undying.Location = "Rhom: Undying Throne";
                undying.Type     = "World Boss";
                undying.setMissingItems(character);

                queen.Name = "Iskal Queen";
                queen.setKey("IskalQueen");
                queen.Location = "Corsus: The Mist Fen";
                queen.Type     = "Point of Interest";
                queen.setMissingItems(character);

                navun.Name = "Fight With The Rebels";
                navun.setKey("SlaveRevolt");
                navun.Location = "Yaesha: Shrine of the Immortals";
                navun.Type     = "Siege";
                navun.setMissingItems(character);

                ward17.setKey("Ward17");
                ward17.Name     = "The Dreamer";
                ward17.Location = "Earth: Ward 17";
                ward17.Type     = "World Boss";
                ward17.setMissingItems(character);
            }

            for (int i = 0; i < zoneEvents["Earth"].Count; i++)
            {
                if (mode == ProcessMode.Campaign && !churchAdded && zoneEvents["Earth"][i].Location.Contains("Westcourt"))
                {
                    foreach (RemnantWorldEvent rwe in churchEvents)
                    {
                        orderedEvents.Add(rwe);
                    }
                    churchAdded = true;
                }
                orderedEvents.Add(zoneEvents["Earth"][i]);
            }
            for (int i = 0; i < zoneEvents["Rhom"].Count; i++)
            {
                orderedEvents.Add(zoneEvents["Rhom"][i]);
            }
            if (mode == ProcessMode.Campaign && undying.MissingItems.Length > 0)
            {
                orderedEvents.Add(undying);
            }
            for (int i = 0; i < zoneEvents["Corsus"].Count; i++)
            {
                if (mode == ProcessMode.Campaign && !queenAdded && zoneEvents["Corsus"][i].Location.Contains("The Mist Fen"))
                {
                    if (queen.MissingItems.Length > 0)
                    {
                        orderedEvents.Add(queen);
                    }
                    queenAdded = true;
                }
                orderedEvents.Add(zoneEvents["Corsus"][i]);
            }
            for (int i = 0; i < zoneEvents["Yaesha"].Count; i++)
            {
                if (mode == ProcessMode.Campaign && !navunAdded && zoneEvents["Yaesha"][i].Location.Contains("The Scalding Glade"))
                {
                    if (navun.MissingItems.Length > 0)
                    {
                        orderedEvents.Add(navun);
                    }
                    navunAdded = true;
                }
                orderedEvents.Add(zoneEvents["Yaesha"][i]);
            }

            if (mode == ProcessMode.Campaign)
            {
                if (ward17.MissingItems.Length > 0)
                {
                    orderedEvents.Add(ward17);
                }
            }

            for (int i = 0; i < orderedEvents.Count; i++)
            {
                if (mode == ProcessMode.Campaign)
                {
                    character.CampaignEvents.Add(orderedEvents[i]);
                }
                else
                {
                    character.AdventureEvents.Add(orderedEvents[i]);
                }
            }
        }
        public static List <RemnantCharacter> GetCharactersFromSave(string saveFolderPath, CharacterProcessingMode mode)
        {
            List <RemnantCharacter> charData = new List <RemnantCharacter>();

            try
            {
                string          profileData = File.ReadAllText(saveFolderPath + "\\profile.sav");
                MatchCollection archetypes  = new Regex(@"/Game/_Core/Archetypes/[a-zA-Z_]+").Matches(profileData);
                for (int i = 0; i < archetypes.Count; i++)
                {
                    RemnantCharacter cd = new RemnantCharacter();
                    cd.Archetype = archetypes[i].Value.Replace("/Game/_Core/Archetypes/", "").Split('_')[1];
                    cd.savePath  = saveFolderPath;
                    charData.Add(cd);
                }

                string[] inventories = profileData.Split(new string[] { "/Game/_Core/Archetypes/" }, StringSplitOptions.None);
                for (var i = 1; i < inventories.Length; i++)
                {
                    if (inventories[i].IndexOf("/Game/Characters/Player/Base/Character_Master_Player.Character_Master_Player_C") == -1)
                    {
                        continue;
                    }
                    List <string> saveItems = new List <string>();
                    string        charStart = "/Game/Characters/Player/Base/Character_Master_Player.Character_Master_Player_C";
                    string        charEnd   = "Character_Master_Player_C";
                    inventories[i] = inventories[i].Substring(inventories[i].IndexOf(charStart) + charStart.Length);
                    inventories[i] = inventories[i].Substring(0, inventories[i].IndexOf(charEnd));
                    Regex           rx      = new Regex(@"/Items/Weapons(/[a-zA-Z0-9_]+)+/[a-zA-Z0-9_]+");
                    MatchCollection matches = rx.Matches(inventories[i]);
                    foreach (Match match in matches)
                    {
                        saveItems.Add(match.Value);
                    }

                    //rx = new Regex(@"/Items/Armor/[a-zA-Z0-9_]+/[a-zA-Z0-9_]+");
                    rx      = new Regex(@"/Items/Armor/([a-zA-Z0-9_]+/)?[a-zA-Z0-9_]+");
                    matches = rx.Matches(inventories[i]);
                    foreach (Match match in matches)
                    {
                        saveItems.Add(match.Value);
                    }

                    rx      = new Regex(@"/Items/Trinkets/(BandsOfCastorAndPollux/)?[a-zA-Z0-9_]+");
                    matches = rx.Matches(inventories[i]);
                    foreach (Match match in matches)
                    {
                        saveItems.Add(match.Value);
                    }

                    rx      = new Regex(@"/Items/Mods/[a-zA-Z0-9_]+");
                    matches = rx.Matches(inventories[i]);
                    foreach (Match match in matches)
                    {
                        saveItems.Add(match.Value);
                    }

                    rx      = new Regex(@"/Items/Traits/[a-zA-Z0-9_]+");
                    matches = rx.Matches(inventories[i]);
                    foreach (Match match in matches)
                    {
                        saveItems.Add(match.Value);
                    }

                    rx      = new Regex(@"/Items/QuestItems(/[a-zA-Z0-9_]+)+/[a-zA-Z0-9_]+");
                    matches = rx.Matches(inventories[i]);
                    foreach (Match match in matches)
                    {
                        saveItems.Add(match.Value);
                    }

                    rx      = new Regex(@"/Quests/[a-zA-Z0-9_]+/[a-zA-Z0-9_]+");
                    matches = rx.Matches(inventories[i]);
                    foreach (Match match in matches)
                    {
                        saveItems.Add(match.Value);
                    }

                    rx      = new Regex(@"/Player/Emotes/Emote_[a-zA-Z0-9]+");
                    matches = rx.Matches(inventories[i]);
                    foreach (Match match in matches)
                    {
                        saveItems.Add(match.Value);
                    }
                    charData[i - 1].Inventory = saveItems;
                }

                if (mode == CharacterProcessingMode.All)
                {
                    string[] saves = Directory.GetFiles(saveFolderPath, "save_*.sav");
                    for (int i = 0; i < saves.Length && i < charData.Count; i++)
                    {
                        charData[i].processSaveData(File.ReadAllText(saves[i]));
                    }
                }
            }
            catch (IOException ex)
            {
                if (ex.Message.Contains("being used by another process"))
                {
                    Console.WriteLine("Save file in use; waiting 0.5 seconds and retrying.");
                    System.Threading.Thread.Sleep(500);
                    charData = GetCharactersFromSave(saveFolderPath, mode);
                }
            }
            return(charData);
        }
Esempio n. 12
0
 public void UpdateCharacters()
 {
     saveCharacters = RemnantCharacter.GetCharactersFromSave(this);
 }