Пример #1
0
        public CashShop()
        {
            CashShopItemTemplate t = new CashShopItemTemplate();

            t.ClientID = 1080001;
            t.Item     = ItemTable.getInstance().getItem(22000);
            t.Category = 5;
            CashShopItem item = new CashShopItem(t);

            item.Count = 1;
            item.Price = 250;
            _items.Add(item.Template.ClientID, item);

            CashShopItemTemplate t2 = new CashShopItemTemplate();

            t2.ClientID = 1080039;
            t2.Item     = ItemTable.getInstance().getItem(22057);
            t2.Category = 5;
            CashShopItem item2 = new CashShopItem(t2);

            item2.Count = 1;
            item2.Price = 600;

            _items.Add(item2.Template.ClientID, item2);
        }
Пример #2
0
        private void load()
        {
            _shops = new SortedList <int, ND_shop>();

            Teleports = new NDTeleport();

            ItemTable itable = ItemTable.getInstance();

            {
                XElement xml = XElement.Parse(File.ReadAllText(@"scripts\buylists.xml"));
                foreach (var shops in xml.Elements("shops"))
                {
                    foreach (var shopp in shops.Elements("shop"))
                    {
                        ND_shop shop = new ND_shop();
                        shop.id  = int.Parse(shopp.Element("npc").Value);
                        shop.mod = double.Parse(shopp.Element("mod").Value);

                        foreach (var selllist in shopp.Elements("selllist"))
                        {
                            ND_shopList slist = new ND_shopList();
                            slist.id = short.Parse(selllist.Attribute("id").Value);

                            string items = selllist.Element("item").Value;
                            items = items.Replace("\n", "").Replace(" ", "");

                            foreach (string i in items.Split(','))
                            {
                                ItemTemplate it = itable.getItem(Convert.ToInt32(i));
                                if (it != null)
                                {
                                    slist.items.Add(new ND_shopItem(it));
                                }
                                else
                                {
                                    CLogger.error("NpcData: cant find item to trade " + i + " on npc " + shop.id);
                                }
                            }

                            shop.lists.Add(slist.id, slist);
                        }

                        _shops.Add(shop.id, shop);
                    }
                }
            }

            CLogger.info("NpcData: loaded " + _shops.Count + " merchants.");
            //CLogger.info("NpcData: loaded " + _mults.Count + " multisell lists.");
        }
Пример #3
0
        public void Initialize()
        {
            FileInfo file = new FileInfo(@"scripts\npc_vid.txt");

            using (StreamReader sreader = file.OpenText())
            {
                while (!sreader.EndOfStream)
                {
                    string line = sreader.ReadLine();
                    if (line.Length == 0 || line.StartsWith("#"))
                    {
                        continue;
                    }

                    string[] pt = line.Split('\t');

                    NpcVid vid = new NpcVid();
                    vid.cl = pt[0];

                    for (byte ord = 1; ord < pt.Length; ord++)
                    {
                        string parameter = pt[ord];
                        string value     = parameter.Substring(parameter.IndexOf('{') + 1); value = value.Remove(value.Length - 1);

                        switch (parameter.Split('{')[0].ToLower())
                        {
                        case "coll":
                            vid.radius = Convert.ToDouble(value.Split(' ')[0]);
                            vid.height = Convert.ToDouble(value.Split(' ')[1]);
                            break;

                        case "spd":
                            vid.minspd = Convert.ToInt32(value.Split(' ')[0]);
                            vid.maxspd = Convert.ToInt32(value.Split(' ')[1]);
                            break;
                        }
                    }

                    npcVids.Add(vid.cl, vid);
                }
            }

            file = new FileInfo(@"scripts\npcdata.txt");
            using (StreamReader sreader = file.OpenText())
            {
                while (!sreader.EndOfStream)
                {
                    string line = sreader.ReadLine();
                    if (line.Length == 0 || line.StartsWith("#"))
                    {
                        continue;
                    }

                    string[] pt = line.Split('\t');

                    NpcTemplate template = new NpcTemplate();
                    template.NpcId = Convert.ToInt32(pt[0]);
                    try
                    {
                        template.Category = (TObjectCategory)Enum.Parse(typeof(TObjectCategory), pt[1]);
                    }
                    catch (Exception)
                    {
                        CLogger.error("Npc category was not found " + pt[1]);
                        continue;
                    }

                    try
                    {
                        if (npcVids.ContainsKey(pt[2].Split('.')[1]))
                        {
                            NpcVid vid = npcVids[pt[2].Split('.')[1]];
                            template.CollisionRadius = vid.radius;
                            template.CollisionHeight = vid.height;
                        }
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("err2 in #" + template.NpcId + " '" + pt[2] + "'");
                    }

                    for (byte ord = 3; ord < pt.Length; ord++)
                    {
                        string parameter = pt[ord];
                        string value     = "";
                        if (parameter.Length == 0)
                        {
                            continue;
                        }

                        try
                        {
                            value = parameter.Substring(parameter.IndexOf('{') + 1); value = value.Remove(value.Length - 1);
                        }
                        catch (Exception)
                        {
                            Console.WriteLine("err in #" + template.NpcId + " '" + parameter + "'");
                        }

                        switch (parameter.Split('{')[0].ToLower())
                        {
                        case "level":
                            template.Level = Convert.ToByte(value);
                            break;

                        case "exp":
                            template.exp = Convert.ToInt64(value);
                            break;

                        case "ex_crt_effect":
                            template.ex_crt_effect = Convert.ToInt32(value);
                            break;

                        case "unique":
                            template.unique = Convert.ToInt32(value);
                            break;

                        case "s_npc_prop_hp_rate":
                            template.s_npc_prop_hp_rate = Convert.ToDouble(value);
                            break;

                        case "race":
                            template.Race = (TObjectRace)Enum.Parse(typeof(TObjectRace), value);
                            break;

                        case "sex":
                            template.Sex = (TObjectSex)Enum.Parse(typeof(TObjectSex), value);
                            break;

                        case "skill_list":
                            template.setNpcSkills(value);
                            break;

                        case "slot_chest":
                            template.slot_chest = value;
                            break;

                        case "slot_rhand":
                            template.slot_rhand = value;
                            break;

                        case "slot_lhand":
                            template.slot_lhand = value;
                            break;

                        case "hit_time_factor":
                            template.hit_time_factor = Convert.ToDouble(value);
                            break;

                        case "hit_time_factor_skill":
                            template.hit_time_factor_skill = Convert.ToDouble(value.Split(' ')[0]);
                            break;

                        case "str":
                            template.Str = Convert.ToInt32(value);
                            break;

                        case "int":
                            template.Int = Convert.ToInt32(value);
                            break;

                        case "dex":
                            template.Dex = Convert.ToInt32(value);
                            break;

                        case "wit":
                            template.Wit = Convert.ToInt32(value);
                            break;

                        case "con":
                            template.Con = Convert.ToInt32(value);
                            break;

                        case "men":
                            template.Men = Convert.ToInt32(value);
                            break;

                        case "org_hp":
                            template.org_hp = Convert.ToDouble(value);
                            break;

                        case "org_hp_regen":
                            template.org_hp_regen = Convert.ToDouble(value);
                            break;

                        case "org_mp":
                            template.org_mp = Convert.ToDouble(value);
                            break;

                        case "org_mp_regen":
                            template.org_mp_regen = Convert.ToDouble(value);
                            break;

                        case "base_attack_type":
                            template.base_attack_type = (TObjectBaseAttackType)Enum.Parse(typeof(TObjectBaseAttackType), value);
                            break;

                        case "base_attack_range":
                            template.base_attack_range = Convert.ToInt32(value);
                            break;

                        case "base_damage_range":
                            //  template.Men = Convert.ToInt32(value);
                            break;

                        case "base_rand_dam":
                            template.base_rand_dam = Convert.ToInt32(value);
                            break;

                        case "base_physical_attack":
                            template.base_physical_attack = Convert.ToDouble(value);
                            break;

                        case "base_critical":
                            template.base_critical = Convert.ToInt32(value);
                            break;

                        case "physical_hit_modify":
                            template.physical_hit_modify = Convert.ToDouble(value);
                            break;

                        case "base_attack_speed":
                            template.base_attack_speed = Convert.ToInt32(value);
                            break;

                        case "base_reuse_delay":
                            template.base_reuse_delay = Convert.ToInt32(value);
                            break;

                        case "base_magic_attack":
                            template.base_magic_attack = Convert.ToDouble(value);
                            break;

                        case "base_defend":
                            template.base_defend = Convert.ToDouble(value);
                            break;

                        case "base_magic_defend":
                            template.base_magic_defend = Convert.ToDouble(value);
                            break;

                        case "base_attribute_attack":
                            // template.physical_hit_modify = Convert.ToDouble(value);
                            break;

                        case "base_attribute_defend":
                            //  template.physical_hit_modify = Convert.ToDouble(value);
                            break;

                        case "physical_avoid_modify":
                            template.physical_avoid_modify = Convert.ToDouble(value);
                            break;

                        case "shield_defense_rate":
                            template.shield_defense_rate = Convert.ToInt32(value);
                            break;

                        case "shield_defense":
                            template.shield_defense = Convert.ToDouble(value);
                            break;

                        case "safe_height":
                            template.safe_height = Convert.ToInt32(value);
                            break;

                        case "soulshot_count":
                            template.soulshot_count = Convert.ToInt32(value);
                            break;

                        case "spiritshot_count":
                            template.spiritshot_count = Convert.ToInt32(value);
                            break;

                        case "clan":
                            template.clan = value;
                            break;

                        case "clan_help_range":
                            template.clan_help_range = Convert.ToInt32(value);
                            break;

                        case "undying":
                            template.undying = Convert.ToInt32(value);
                            break;

                        case "can_be_attacked":
                            template.can_be_attacked = Convert.ToInt32(value);
                            break;

                        case "corpse_time":
                            template.corpse_time = Convert.ToInt32(value);
                            break;

                        case "no_sleep_mode":
                            template.no_sleep_mode = Convert.ToInt32(value);
                            break;

                        case "agro_range":
                            template.agro_range = Convert.ToInt32(value);
                            break;

                        case "passable_door":
                            template.passable_door = Convert.ToInt32(value);
                            break;

                        case "can_move":
                            template.can_move = Convert.ToInt32(value);
                            break;

                        case "flying":
                            template.flying = Convert.ToInt32(value);
                            break;

                        case "has_summoner":
                            template.has_summoner = Convert.ToInt32(value);
                            break;

                        case "targetable":
                            template.targetable = Convert.ToInt32(value);
                            break;

                        case "show_name_tag":
                            template.show_name_tag = Convert.ToInt32(value);
                            break;

                        case "event_flag":
                            template.event_flag = Convert.ToInt32(value);
                            break;

                        case "unsowing":
                            template.unsowing = Convert.ToInt32(value);
                            break;

                        case "private_respawn_log":
                            template.private_respawn_log = Convert.ToInt32(value);
                            break;

                        case "acquire_exp_rate":
                            template.acquire_exp_rate = Convert.ToDouble(value);
                            break;

                        case "acquire_sp":
                            template.acquire_sp = (int)Convert.ToDouble(value);
                            break;

                        case "acquire_rp":
                            template.acquire_rp = (int)Convert.ToDouble(value);
                            break;

                        case "fake_class_id":
                            template.fake_class_id = Convert.ToInt32(value);
                            break;
                        }
                    }

                    _npcs.Add(template.NpcId, template);
                }
            }

            XElement xml       = XElement.Parse(File.ReadAllText(@"scripts\dropdata.xml"));
            XElement ex        = xml.Element("list");
            int      dropitems = 0;

            foreach (var m in ex.Elements())
            {
                if (m.Name == "npc")
                {
                    NpcTemplate template = _npcs[int.Parse(m.Attribute("id").Value)];

                    foreach (var stp in m.Elements())
                    {
                        switch (stp.Name.LocalName)
                        {
                        case "drop":
                        {
                            if (template.DropData == null)
                            {
                                template.DropData = new DropContainer();
                            }

                            foreach (var boxes in stp.Elements())
                            {
                                if (boxes.Name == "box")
                                {
                                    DropBox box = new DropBox();
                                    box.rate = double.Parse(boxes.Attribute("rate").Value);
                                    foreach (var items in boxes.Elements())
                                    {
                                        if (items.Name == "item")
                                        {
                                            DropItem item = new DropItem();
                                            item.id       = int.Parse(items.Attribute("id").Value);
                                            item.min      = long.Parse(items.Attribute("min").Value);
                                            item.max      = long.Parse(items.Attribute("max").Value);
                                            item.rate     = double.Parse(items.Attribute("rate").Value);
                                            item.template = ItemTable.getInstance().getItem(item.id);
                                            box.items.Add(item);
                                            dropitems++;
                                        }
                                    }

                                    template.DropData.multidrop.Add(box);
                                }
                            }
                        }
                        break;

                        case "drop_ex":
                        {
                            if (template.DropData == null)
                            {
                                template.DropData = new DropContainer();
                            }

                            foreach (var boxes in stp.Elements())
                            {
                                if (boxes.Name == "box")
                                {
                                    DropBox box = new DropBox();
                                    box.rate = double.Parse(boxes.Attribute("rate").Value);
                                    foreach (var items in boxes.Elements())
                                    {
                                        if (items.Name == "item")
                                        {
                                            DropItem item = new DropItem();
                                            item.id       = int.Parse(items.Attribute("id").Value);
                                            item.min      = long.Parse(items.Attribute("min").Value);
                                            item.max      = long.Parse(items.Attribute("max").Value);
                                            item.rate     = double.Parse(items.Attribute("rate").Value);
                                            item.template = ItemTable.getInstance().getItem(item.id);
                                            box.items.Add(item);
                                            dropitems++;
                                        }
                                    }

                                    template.DropData.multidrop_ex.Add(box);
                                }
                            }
                        }
                        break;

                        case "spoil":
                        {
                            if (template.DropData == null)
                            {
                                template.DropData = new DropContainer();
                            }

                            foreach (var boxes in stp.Elements())
                            {
                                if (boxes.Name == "item")
                                {
                                    DropItem item = new DropItem();
                                    item.id       = int.Parse(boxes.Attribute("id").Value);
                                    item.min      = long.Parse(boxes.Attribute("min").Value);
                                    item.max      = long.Parse(boxes.Attribute("max").Value);
                                    item.rate     = double.Parse(boxes.Attribute("rate").Value);
                                    item.template = ItemTable.getInstance().getItem(item.id);
                                    template.DropData.spoil.Add(item);
                                    dropitems++;
                                }
                            }
                        }
                        break;

                        case "qdrop":
                        {
                            if (template.DropData == null)
                            {
                                template.DropData = new DropContainer();
                            }

                            foreach (var boxes in stp.Elements())
                            {
                                if (boxes.Name == "item")
                                {
                                    DropItem item = new DropItem();
                                    item.id       = int.Parse(boxes.Attribute("id").Value);
                                    item.min      = long.Parse(boxes.Attribute("min").Value);
                                    item.max      = long.Parse(boxes.Attribute("max").Value);
                                    item.rate     = double.Parse(boxes.Attribute("rate").Value);
                                    item.template = ItemTable.getInstance().getItem(item.id);
                                    template.DropData.qdrop.Add(item);
                                    dropitems++;
                                }
                            }
                        }
                        break;
                        }
                    }
                }
            }

            GC.Collect();
            GC.WaitForPendingFinalizers();
            CLogger.info("NpcTable: loaded #" + _npcs.Count + " NPC, #" + npcVids.Count + " VIDs, " + dropitems + " drop items.");
        }
Пример #4
0
 public recipe_item_entry(int id, long count)
 {
     item       = ItemTable.getInstance().getItem(id);
     this.count = count;
 }