Example #1
0
        static void Main(string[] args)
        {
            Utility.WriteExeDetails();

            Console.WriteLine("Loading npc strings ...");
            Utility.LoadNpcStrings(root);

            Console.WriteLine("Loading monster strings ...");
            Utility.LoadMonsterStrings(root);

            Console.WriteLine("Loading level strings ...");
            Utility.LoadLevelStrings(root);

            Console.WriteLine("Loading client airline ...");
            Utility.LoadClientAirline(root);

            Console.WriteLine("Loading client airports ...");
            Utility.LoadClientAirports(root);

            Console.WriteLine("Loading client npcs ...");
            Utility.LoadClientNpcs(root);

            var teleporter_templates = Utility.AirlineIndex.getClientAirlines();

            NpcTeleporterTemplates outputFile = new NpcTeleporterTemplates();
            outputFile.teleporter_templates = new List<TeleporterTemplate>();

            foreach (var teleporter in teleporter_templates) {
                var template = new TeleporterTemplate();

                // Some client_airline's do not have teleporter data, Skip
                if (teleporter.airline_list == null) continue;

                // Get Npc object that handles teleporter
                Npc npc = Utility.ClientNpcIndex.getTeleportNpcFromString(teleporter.name);
                // Some Special In zone teleporters in main cities do not have airport crossreference
                if (npc == null) npc = getSpecialNpc(teleporter.name);

                template.npc_id = npc != null ? npc.id : -1;
                template.name = npc != null ? Utility.NpcStringIndex.GetString(npc.desc) != npc.desc ? Utility.NpcStringIndex.GetString(npc.desc) : Utility.MonsterStringIndex.GetString(npc.desc) : "Missing Npc Data";
                template.teleportId = teleporter.id;

                // Create New Element and List of Teleport Locations
                template.locations = new Locations();
                template.locations.telelocation = new List<TeleLocation>();

                // Add Data from Client for Each Location
                foreach (var location in teleporter.airline_list.getAirlineData()) {
                    TeleLocation telelocation = new TeleLocation();
                    telelocation.loc_id = Utility.AirportIndex[location.airport_name];
                    telelocation.description = Utility.LevelStringIndex.GetString("STR_" + location.airport_name);
                    telelocation.name = location.airport_name; // Ignored Field used as reference when parsing Teleport Locations
                    telelocation.price = location.fee;
                    telelocation.pricePvp = location.pvpon_fee;
                    telelocation.required_quest = location.required_quest;
                    telelocation.type = location.flight_path_group_id == 0 ? TeleporterType.REGULAR : TeleporterType.FLIGHT;
                    if (telelocation.type == TeleporterType.FLIGHT) {
                        telelocation.teleportid = (location.flight_path_group_id * 1000) + 1;
                    }

                    template.locations.telelocation.Add(telelocation);
                }

                outputFile.teleporter_templates.Add(template);
            }

            Console.WriteLine("Writing npc_teleporter.xml ...");

            // Reorder Templates
            outputFile.teleporter_templates = outputFile.teleporter_templates.OrderBy(n => n.teleportId).ToList<TeleporterTemplate>();

            string outputPath = Path.Combine(root, @".\output");
            if (!Directory.Exists(outputPath))
                Directory.CreateDirectory(outputPath);

            var settings = new XmlWriterSettings() {
                CheckCharacters = false,
                CloseOutput = false,
                Indent = true,
                IndentChars = "\t",
                NewLineChars = "\n",
                Encoding = new UTF8Encoding(false)
            };

            try {
                using (var fs = new FileStream(Path.Combine(outputPath, "npc_teleporter.xml"),
                                         FileMode.Create, FileAccess.Write))
                using (var writer = XmlWriter.Create(fs, settings)) {
                    XmlSerializer ser = new XmlSerializer(typeof(NpcTeleporterTemplates));
                    ser.Serialize(writer, outputFile);
                }
            }
            catch (Exception ex) {
                Debug.Print(ex.ToString());
            }

            Console.WriteLine("Writing npc_teleporter.xml Done!");

            Console.WriteLine("Parse Teleport Location Data? (y/n) ");
            var answer = Console.ReadLine();
            if (answer.Trim() == "y") {
                TeleportParse teleportParser = new TeleportParse();
                teleportParser.parseTeleportLocations(outputFile);
            }
        }
Example #2
0
        public void parseTeleportLocations(NpcTeleporterTemplates npc_teleporters)
        {
            Console.WriteLine("Starting Teleport Parse ...");

            Console.WriteLine("Loading level strings ...");
            Utility.LoadLevelStrings(root);

            Console.WriteLine("Loading original teleport_location.xml ...");
            Utility.LoadOriginalTeleporterLocationTemplate(root);

            //Unused for now
            //Console.WriteLine("Loading source_sphere.csv ...");
            //DataSet source_sphere = loadExcelData();

            TeleporterLocationTemplates outputFile = new TeleporterLocationTemplates();
            outputFile.teleloc_templates = new List<TeleporterLocationTemplate>();

            // Create IEnumerable<NpcTeleporterTemplate> of passed templates
            var teleporters = npc_teleporters.teleporter_templates.Where(n => n.teleportId != 0);

            // Create List of loca_id that have already been processed
            List<int> processed = new List<int>();

            // Parse location for each template
            foreach (var teleport in teleporters) {
                var locations = teleport.locations.telelocation.Where(n => n.loc_id != 0);

                foreach (var location in locations) {
                    TeleporterLocationTemplate template = new TeleporterLocationTemplate();

                    // Skip if location already added
                    if (processed.Contains(location.loc_id)) continue;

                    // Get Old Template if it exists
                    TeleporterLocationTemplate original_template = Utility.OriginalTeleporterLocationTemplate[location.loc_id];

                    // Use original info if it exists in teleport_location.xml until more definitive info on x,y,z
                    if (original_template != null) {
                        template.loc_id = original_template.loc_id;
                        template.mapid = original_template.mapid;
                        template.name = original_template.name;
                        template.posX = original_template.posX;
                        template.posY = original_template.posY;
                        template.posZ = original_template.posZ;
                        template.heading = original_template.heading;
                        template.type = location.type == TeleporterType.REGULAR ? "REGULAR" : "FLIGHT";
                    }
                    else {
                        template.loc_id = location.loc_id;
                        //template.mapid = getMapIdFromString(Utility.AirlineIndex[teleport.teleportId]);
                        template.mapid = getMapIdFromString(Utility.AirportIndex[location.loc_id]);
                        template.name = location.description;
                        template.type = location.type == TeleporterType.REGULAR ? "REGULAR" : "FLIGHT";

                        // Some trickery to get spawn point from mission file
                        if (template.type != "FLIGHT") {
                            string[] split = location.name.Split('_');

                            // Special cases where map name is shortened
                            if (split[0].StartsWith("HLFP")) split[0] = "HLFP";
                            if (split[0].StartsWith("HDFP")) split[0] = "HDFP";
                            switch (split[0]) {
                                case "HLFP": split[0] = "housing_lf_personal"; break;
                                case "HDFP": split[0] = "housing_df_personal"; break;
                            }

                            Point point = getPointFromLevelData(split[0], location.name);

                            template.posX = point.x;
                            template.posY = point.y;
                            template.posZ = point.z;
                            template.heading = point.heading;

                            if (template.posX == 1) {
                                template.posX = 1;
                            }

                        }
                    }

                    if (!processed.Contains(template.loc_id) && template.loc_id != 0) {
                        processed.Add(template.loc_id);
                        outputFile.teleloc_templates.Add(template);
                    }
                }
            }

            // Reorder Templates
            outputFile.teleloc_templates = outputFile.teleloc_templates.OrderBy(n => n.loc_id).ToList<TeleporterLocationTemplate>();

            string outputPath = Path.Combine(root, @".\output");
            if (!Directory.Exists(outputPath))
                Directory.CreateDirectory(outputPath);

            var settings = new XmlWriterSettings() {
                CheckCharacters = false,
                CloseOutput = false,
                Indent = true,
                IndentChars = "\t",
                NewLineChars = "\n",
                Encoding = new UTF8Encoding(false)
            };

            using (var fs = new FileStream(Path.Combine(outputPath, "teleport_location.xml"), FileMode.Create, FileAccess.Write))
            using (var writer = XmlWriter.Create(fs, settings)) {
                XmlSerializer ser = new XmlSerializer(typeof(TeleporterLocationTemplates));
                ser.Serialize(writer, outputFile);
            }
        }
Example #3
0
        static void Main(string[] args)
        {
            Utility.WriteExeDetails();

            Console.WriteLine("Loading npc strings ...");
            Utility.LoadNpcStrings(root);

            Console.WriteLine("Loading monster strings ...");
            Utility.LoadMonsterStrings(root);

            Console.WriteLine("Loading level strings ...");
            Utility.LoadLevelStrings(root);

            Console.WriteLine("Loading client airline ...");
            Utility.LoadClientAirline(root);

            Console.WriteLine("Loading client airports ...");
            Utility.LoadClientAirports(root);

            Console.WriteLine("Loading client npcs ...");
            Utility.LoadClientNpcs(root);

            var teleporter_templates = Utility.AirlineIndex.getClientAirlines();

            NpcTeleporterTemplates outputFile = new NpcTeleporterTemplates();

            outputFile.teleporter_templates = new List <TeleporterTemplate>();

            foreach (var teleporter in teleporter_templates)
            {
                var template = new TeleporterTemplate();

                // Some client_airline's do not have teleporter data, Skip
                if (teleporter.airline_list == null)
                {
                    continue;
                }

                // Get Npc object that handles teleporter
                Npc npc = Utility.ClientNpcIndex.getTeleportNpcFromString(teleporter.name);
                // Some Special In zone teleporters in main cities do not have airport crossreference
                if (npc == null)
                {
                    npc = getSpecialNpc(teleporter.name);
                }

                template.npc_id = npc != null ? npc.id : -1;
                template.name   = npc != null?Utility.NpcStringIndex.GetString(npc.desc) != npc.desc ? Utility.NpcStringIndex.GetString(npc.desc) : Utility.MonsterStringIndex.GetString(npc.desc) : "Missing Npc Data";

                template.teleportId = teleporter.id;

                // Create New Element and List of Teleport Locations
                template.locations = new Locations();
                template.locations.telelocation = new List <TeleLocation>();

                // Add Data from Client for Each Location
                foreach (var location in teleporter.airline_list.getAirlineData())
                {
                    TeleLocation telelocation = new TeleLocation();
                    telelocation.loc_id         = Utility.AirportIndex[location.airport_name];
                    telelocation.description    = Utility.LevelStringIndex.GetString("STR_" + location.airport_name);
                    telelocation.name           = location.airport_name;           // Ignored Field used as reference when parsing Teleport Locations
                    telelocation.price          = location.fee;
                    telelocation.pricePvp       = location.pvpon_fee;
                    telelocation.required_quest = location.required_quest;
                    telelocation.type           = location.flight_path_group_id == 0 ? TeleporterType.REGULAR : TeleporterType.FLIGHT;
                    if (telelocation.type == TeleporterType.FLIGHT)
                    {
                        telelocation.teleportid = (location.flight_path_group_id * 1000) + 1;
                    }


                    template.locations.telelocation.Add(telelocation);
                }

                outputFile.teleporter_templates.Add(template);
            }

            Console.WriteLine("Writing npc_teleporter.xml ...");

            // Reorder Templates
            outputFile.teleporter_templates = outputFile.teleporter_templates.OrderBy(n => n.teleportId).ToList <TeleporterTemplate>();

            string outputPath = Path.Combine(root, @".\output");

            if (!Directory.Exists(outputPath))
            {
                Directory.CreateDirectory(outputPath);
            }

            var settings = new XmlWriterSettings()
            {
                CheckCharacters = false,
                CloseOutput     = false,
                Indent          = true,
                IndentChars     = "\t",
                NewLineChars    = "\n",
                Encoding        = new UTF8Encoding(false)
            };

            try {
                using (var fs = new FileStream(Path.Combine(outputPath, "npc_teleporter.xml"),
                                               FileMode.Create, FileAccess.Write))
                    using (var writer = XmlWriter.Create(fs, settings)) {
                        XmlSerializer ser = new XmlSerializer(typeof(NpcTeleporterTemplates));
                        ser.Serialize(writer, outputFile);
                    }
            }
            catch (Exception ex) {
                Debug.Print(ex.ToString());
            }

            Console.WriteLine("Writing npc_teleporter.xml Done!");

            Console.WriteLine("Parse Teleport Location Data? (y/n) ");
            var answer = Console.ReadLine();

            if (answer.Trim() == "y")
            {
                TeleportParse teleportParser = new TeleportParse();
                teleportParser.parseTeleportLocations(outputFile);
            }
        }
Example #4
0
        public void parseTeleportLocations(NpcTeleporterTemplates npc_teleporters)
        {
            Console.WriteLine("Starting Teleport Parse ...");

            Console.WriteLine("Loading level strings ...");
            Utility.LoadLevelStrings(root);

            Console.WriteLine("Loading original teleport_location.xml ...");
            Utility.LoadOriginalTeleporterLocationTemplate(root);

            //Unused for now
            //Console.WriteLine("Loading source_sphere.csv ...");
            //DataSet source_sphere = loadExcelData();

            TeleporterLocationTemplates outputFile = new TeleporterLocationTemplates();

            outputFile.teleloc_templates = new List <TeleporterLocationTemplate>();

            // Create IEnumerable<NpcTeleporterTemplate> of passed templates
            var teleporters = npc_teleporters.teleporter_templates.Where(n => n.teleportId != 0);

            // Create List of loca_id that have already been processed
            List <int> processed = new List <int>();

            // Parse location for each template
            foreach (var teleport in teleporters)
            {
                var locations = teleport.locations.telelocation.Where(n => n.loc_id != 0);

                foreach (var location in locations)
                {
                    TeleporterLocationTemplate template = new TeleporterLocationTemplate();

                    // Skip if location already added
                    if (processed.Contains(location.loc_id))
                    {
                        continue;
                    }

                    // Get Old Template if it exists
                    TeleporterLocationTemplate original_template = Utility.OriginalTeleporterLocationTemplate[location.loc_id];

                    // Use original info if it exists in teleport_location.xml until more definitive info on x,y,z
                    if (original_template != null)
                    {
                        template.loc_id  = original_template.loc_id;
                        template.mapid   = original_template.mapid;
                        template.name    = original_template.name;
                        template.posX    = original_template.posX;
                        template.posY    = original_template.posY;
                        template.posZ    = original_template.posZ;
                        template.heading = original_template.heading;
                        template.type    = location.type == TeleporterType.REGULAR ? "REGULAR" : "FLIGHT";
                    }
                    else
                    {
                        template.loc_id = location.loc_id;
                        //template.mapid = getMapIdFromString(Utility.AirlineIndex[teleport.teleportId]);
                        template.mapid = getMapIdFromString(Utility.AirportIndex[location.loc_id]);
                        template.name  = location.description;
                        template.type  = location.type == TeleporterType.REGULAR ? "REGULAR" : "FLIGHT";

                        // Some trickery to get spawn point from mission file
                        if (template.type != "FLIGHT")
                        {
                            string[] split = location.name.Split('_');

                            // Special cases where map name is shortened
                            if (split[0].StartsWith("HLFP"))
                            {
                                split[0] = "HLFP";
                            }
                            if (split[0].StartsWith("HDFP"))
                            {
                                split[0] = "HDFP";
                            }
                            switch (split[0])
                            {
                            case "HLFP": split[0] = "housing_lf_personal"; break;

                            case "HDFP": split[0] = "housing_df_personal"; break;
                            }

                            Point point = getPointFromLevelData(split[0], location.name);

                            template.posX    = point.x;
                            template.posY    = point.y;
                            template.posZ    = point.z;
                            template.heading = point.heading;

                            if (template.posX == 1)
                            {
                                template.posX = 1;
                            }
                        }
                    }

                    if (!processed.Contains(template.loc_id) && template.loc_id != 0)
                    {
                        processed.Add(template.loc_id);
                        outputFile.teleloc_templates.Add(template);
                    }
                }
            }

            // Reorder Templates
            outputFile.teleloc_templates = outputFile.teleloc_templates.OrderBy(n => n.loc_id).ToList <TeleporterLocationTemplate>();

            string outputPath = Path.Combine(root, @".\output");

            if (!Directory.Exists(outputPath))
            {
                Directory.CreateDirectory(outputPath);
            }

            var settings = new XmlWriterSettings()
            {
                CheckCharacters = false,
                CloseOutput     = false,
                Indent          = true,
                IndentChars     = "\t",
                NewLineChars    = "\n",
                Encoding        = new UTF8Encoding(false)
            };

            using (var fs = new FileStream(Path.Combine(outputPath, "teleport_location.xml"), FileMode.Create, FileAccess.Write))
                using (var writer = XmlWriter.Create(fs, settings)) {
                    XmlSerializer ser = new XmlSerializer(typeof(TeleporterLocationTemplates));
                    ser.Serialize(writer, outputFile);
                }
        }