Example #1
0
        private void LoadDrops()
        {
            DropGroups = new Dictionary <string, DropGroupInfo>();
            try
            {
                //first we load the dropgroups
                using (var groupfile = new ShineReader(folder + @"\ItemDropGroup.txt"))
                {
                    var table = groupfile["ItemDropGroup"];
                    using (var reader = new DataTableReaderEx(table))
                    {
                        while (reader.Read())
                        {
                            DropGroupInfo info = DropGroupInfo.Load(reader);
                            if (DropGroups.ContainsKey(info.GroupID))
                            {
                                //Log.WriteLine(LogLevel.Warn, "Duplicate DropGroup ID found: {0}.", info.GroupID);
                                continue;
                            }
                            DropGroups.Add(info.GroupID, info);
                        }
                    }
                }

                //now we load the actual drops
                int dropcount = 0;
                using (var tablefile = new ShineReader(folder + @"\ItemDropTable.txt"))
                {
                    var table = tablefile["ItemGroup"];
                    using (var reader = new DataTableReaderEx(table))
                    {
                        while (reader.Read())
                        {
                            string  mobid = reader.GetString("MobId");
                            MobInfo mob;
                            if (MobsByName.TryGetValue(mobid, out mob))
                            {
                                mob.MinDropLevel = (byte)reader.GetInt16("MinLevel");
                                mob.MaxDropLevel = (byte)reader.GetInt16("MaxLevel");
                                for (int i = 1; i <= 45; ++i)
                                {
                                    string dropgroup = reader.GetString("DrItem" + i);
                                    if (dropgroup.Length <= 2)
                                    {
                                        continue;
                                    }
                                    DropGroupInfo group;
                                    if (DropGroups.TryGetValue(dropgroup, out group))
                                    {
                                        float    rate = reader.GetInt32("DrItem" + i + "R") / 100000f;
                                        DropInfo info = new DropInfo(group, rate);
                                        mob.Drops.Add(info);
                                        ++dropcount;
                                    }
                                    else
                                    {
                                        //this seems to happen a lot so disable this for the heck of it.
                                        // Log.WriteLine(LogLevel.Warn, "Could not find DropGroup {0}.", dropgroup);
                                    }
                                }
                            }
                            else
                            {
                                Log.WriteLine(LogLevel.Warn, "Could not find mobname: {0} for drop.", mobid);
                            }
                        }
                    }
                }
                Log.WriteLine(LogLevel.Info, "Loaded {0} DropGroups, with {1} drops in total.", DropGroups.Count, dropcount);
            }
            catch (Exception ex)
            {
                Log.WriteLine(LogLevel.Exception, "Error loading DropTable: {0}", ex);
            }
        }
Example #2
0
        private void LoadDrops()
        {
            DropGroups = new Dictionary <string, DropGroupInfo>();
            try
            {
                DataTable dropgroupinfoData = null;
                DataTable itemdroptableData = null;
                using (var dbClient = Program.DatabaseManager.GetClient())
                {
                    dropgroupinfoData = dbClient.ReadDataTable("SELECT  *FROM dropgroupinfo");
                    itemdroptableData = dbClient.ReadDataTable("SELECT  *FROM itemdroptable");
                }

                if (dropgroupinfoData != null)
                {
                    foreach (DataRow row in dropgroupinfoData.Rows)
                    {
                        var info = DropGroupInfo.Load(row);
                        if (DropGroups.ContainsKey(info.GroupID))
                        {
                            //Log.WriteLine(LogLevel.Warn, "Duplicate DropGroup ID found: {0}.", info.GroupID);
                            continue;
                        }

                        DropGroups.Add(info.GroupID, info);
                    }
                }

                var dropcount = 0;
                if (itemdroptableData != null)
                {
                    foreach (DataRow row in itemdroptableData.Rows)
                    {
                        var     mobid = (string)row["MobId"];
                        MobInfo mob;
                        if (MobsByName.TryGetValue(mobid, out mob))
                        {
                            mob.MinDropLevel = (byte)row["MinLevel"];
                            mob.MaxDropLevel = (byte)row["MaxLevel"];
                            var dropgroup = (string)row["GroupID"];
                            if (dropgroup.Length <= 2)
                            {
                                continue;
                            }
                            DropGroupInfo group;
                            if (DropGroups.TryGetValue(dropgroup, out group))
                            {
                                var rate = (float)row["Rate"];
                                var info = new DropInfo(group, rate);
                                mob.Drops.Add(info);
                                ++dropcount;
                            }
                        }

                        // else  Log.WriteLine(LogLevel.Warn, "Could not find mobname: {0} for drop.", mobid);
                    }
                }

                //first we load the dropgroups
                Log.WriteLine(LogLevel.Info, "Loaded {0} DropGroups, with {1} drops in total.", DropGroups.Count,
                              dropcount);
            }
            catch (Exception ex)
            {
                Log.WriteLine(LogLevel.Exception, "Error loading DropTable: {0}", ex);
            }
        }