示例#1
0
        private static void ParseFor(NpcTemplate npcTemplate)
        {
            if (npcTemplate.Level < 1
                //|| npcTemplate.Level > 12
                || npcTemplate.IsObject || npcTemplate.IsVillager)
                return;

            int fullId = npcTemplate.FullId;

            lock (DropLock)
            {
                if (Drop.ContainsKey(fullId))
                    return;

                Drop.Add(fullId, new List<int>());
            }

            int page = 1;
            string name = "";

            while (true)
            {
                string npcHtml = "";

                if (page == 1)
                    npcHtml = Utils.LoadPage("http://www.teratome.com/npc/" + fullId);
                else
                    npcHtml = Utils.LoadPage("http://www.teratome.com/npc/" + fullId + "/" + name + "/detail/page/" + page + "/tab/drops");

                if (npcHtml.Length == 0)
                    return;

                foreach (Match itemMatch in Regex.Matches(npcHtml, "<tr data-href=\"/item/([0-9]+)/"))
                    Drop[fullId].Add(int.Parse(itemMatch.Groups[1].Value));

                if (name.Length == 0)
                {
                    Match nameMatch = Regex.Match(
                        npcHtml, "<link href=\"http://www.teratome.com/npc/" + fullId + "/([^\"]+)\"");

                    name = nameMatch.Groups[1].Value;
                }

                Match match = Regex.Match(npcHtml, "<a class=\"link-next\" href=\"#drops;page:([0-9]+)\">Next");

                if (!match.Success)
                    return;

                page = int.Parse(match.Groups[1].Value);
            }
        }
示例#2
0
        private static CreatureBaseStats CalculateGameStats(NpcTemplate template)
        {
            float hpRate = (60 + template.Level * 40) / 100f;
            float fullRate = (80 + template.Level*20)/100f;
            float smallRate = (95 + template.Level*5)/100f;

            if (template.Size == NpcSize.Small)
            {
                fullRate *= 0.25f;
                smallRate *= 0.25f;
            }
            else if (template.Size == NpcSize.Large)
            {
                fullRate *= 1.75f;
                smallRate *= 1.75f;
            }

            return
                new CreatureBaseStats
                    {
                        HpBase = (int) (700*hpRate*template.Size.GetHashCode()),
                        MpBase = (int) (1000*fullRate),

                        Attack = (int) (140*fullRate),
                        Defense = (int) (40*fullRate),
                        Impact = (int)(30 * smallRate),
                        Balance = (int)(30 * smallRate),
                        CritChanse = (int) (40*smallRate),
                        CritResist = (int) (20*smallRate),
                        CritPower = 2,

                        Power = (int) (65*smallRate),
                        Endurance = (int) (50*smallRate),
                        ImpactFactor = (int) (50*smallRate),
                        BalanceFactor = (int)(50 * smallRate),
                        AttackSpeed = 100,
                        Movement = 100,

                        WeakeningResist = 40,
                        PeriodicResist = 40,
                        StunResist = 40
                    };
        }
示例#3
0
        private static void NpcTemplateExport()
        {
            List<NpcTemplate> templates = new List<NpcTemplate>();

            int BytesOfSeparation = 7860;
            int ID_Offset = 0x0107b448;

            var YBiBuffer = YBi.Decrypt(File.ReadAllBytes(DataPath + "YBi.cfg"));

            List<byte[]> list = new List<byte[]>();
            lock (YBiBuffer)
            {
                while (BitConverter.ToInt32(YBiBuffer, ID_Offset) != 0)
                {
                    long itemId = BitConverter.ToInt64(YBiBuffer, ID_Offset);
                    byte[] temp = new byte[BytesOfSeparation];
                    Buffer.BlockCopy(YBiBuffer, ID_Offset, temp, 0, BytesOfSeparation);
                    list.Add(temp);
                    ID_Offset += BytesOfSeparation;
                }
            }

            lock (list)
            {
                try
                {
                    foreach (byte[] data in list)
                    {
                        lock (data)
                        {
                            using (MemoryStream Stream = new MemoryStream(data))
                            {
                                byte[] ids = new byte[4];
                                Stream.Read(ids, 0, ids.Length);

                                byte[] names = new byte[64];
                                Stream.Read(names, 0, names.Length);

                                Stream.Position += 2;

                                byte[] levels = new byte[2];
                                Stream.Read(levels, 0, levels.Length);

                                byte[] hps = new byte[4];
                                Stream.Read(hps, 0, hps.Length);

                                byte[] descs = new byte[1024];
                                Stream.Read(descs, 0, descs.Length);

                                byte[] choice1 = new byte[4];
                                Stream.Read(choice1, 0, choice1.Length);

                                byte[] choice2 = new byte[4];
                                Stream.Read(choice2, 0, choice2.Length);

                                byte[] choice3 = new byte[4];
                                Stream.Read(choice3, 0, choice3.Length);

                                byte[] choice4 = new byte[4];
                                Stream.Read(choice4, 0, choice4.Length);

                                int NpcId = BitConverter.ToInt32(ids, 0);
                                string NpcName = Encoding.GetEncoding(EncodingName).GetString(names).Replace("\0", "");
                                int NpcLevel = BitConverter.ToInt16(levels, 0);
                                int NpcHp = BitConverter.ToInt32(hps, 0);
                                string NpcDesc = Encoding.GetEncoding(EncodingName).GetString(descs).Replace("\0", "");
                                int NpcChoice1 = BitConverter.ToInt32(choice1, 0);
                                int NpcChoice2 = BitConverter.ToInt32(choice2, 0);
                                int NpcChoice3 = BitConverter.ToInt32(choice3, 0);
                                int NpcChoice4 = BitConverter.ToInt32(choice4, 0);

                                Log.Debug("-----------------------------------------------------");
                                Log.Debug("NpcId = {0}", NpcId);
                                Log.Debug("NpcName = {0}", NpcName);
                                Log.Debug("NpcLevel = {0}", NpcLevel);
                                Log.Debug("NpcHp = {0}", NpcHp);
                                Log.Debug("NpcDesc = {0}", NpcDesc);
                                Log.Debug("NpcChoice1 = {0}", NpcChoice1);
                                Log.Debug("NpcChoice2 = {0}", NpcChoice2);
                                Log.Debug("NpcChoice3 = {0}", NpcChoice3);
                                Log.Debug("NpcChoice4 = {0}", NpcChoice4);
                                Log.Debug("-----------------------------------------------------");

                                using (var entity = new PublicDbEntities())
                                {
                                    var dbdata = entity.TBL_XWWL_NPC.Where(v => v.FLD_PID == NpcId).FirstOrDefault();

                                    if (dbdata != null)
                                    {
                                        NpcTemplate template = new NpcTemplate()
                                        {
                                            ID = NpcId,
                                            Name = NpcName,
                                            HealthPoint = NpcHp,
                                            Attack = (int)dbdata.FLD_AT,
                                            Defense = (int)dbdata.FLD_DF,
                                            Npc = (NpcId < 10000 && NpcId > 0) ? 1 : 0,
                                            Level = (int)dbdata.FLD_LEVEL,
                                            Exp = (int)dbdata.FLD_EXP,
                                            Auto = (int)dbdata.FLD_AUTO,
                                            Boss = dbdata.FLD_BOSS,
                                        };

                                        templates.Add(template);

                                        Log.Debug("Npc NpcId = {0} Name = {1}", template.ID, template.Name);
                                    }
                                    else
                                    {
                                        Log.Debug("No db data for Npc id = {0}", NpcId);
                                    }
                                }

                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log.ErrorException("NpcTemplateExport:", ex);
                }
            }

            /*using (var file = File.Create("Data/npcs.bin"))
            {
                Serializer.SerializeWithLengthPrefix<List<NpcTemplate>>(file, templates, PrefixStyle.Fixed32);
            }*/
        }