コード例 #1
0
        private Attribute SpellVoc(TibiaObject obj)
        {
            SpellTaught spell = npc.spellsTaught.Find(o => o.spellid == (obj as LazyTibiaObject).id);
            string      voc   = (spell.knight ? "Kn+" : "") + (spell.paladin ? "Pa+" : "") + (spell.druid ? "Dr+" : "") + (spell.sorcerer ? "So+" : "");

            if (voc.Length == 3)
            {
                voc = (spell.knight ? "Knight" : "") + (spell.paladin ? "Paladin" : "") + (spell.druid ? "Druid" : "") + (spell.sorcerer ? "Sorcerer" : "");
            }
            else
            {
                voc = voc.Substring(0, voc.Length - 1);
            }
            return(new StringAttribute(voc, 80, Item.GoldColor));
        }
コード例 #2
0
        private static NPC createNPC(SQLiteDataReader reader)
        {
            SQLiteCommand command;

            if (!reader.Read()) {
                return null;
            }

            NPC npc = new NPC();
            npc.permanent = true;
            npc.id = reader.GetInt32(0);
            npc.name = reader["name"].ToString();
            npc.city = reader["city"].ToString();
            if (!reader.IsDBNull(3) && !reader.IsDBNull(4) && !reader.IsDBNull(5)) {
                npc.pos.x = reader.GetInt32(3);
                npc.pos.y = reader.GetInt32(4);
                npc.pos.z = reader.GetInt32(5);
            }
            npc.image = Image.FromStream(reader.GetStream(6));
            npc.job = reader.IsDBNull(7) ? "" : reader.GetString(7);
            if (npc.image.RawFormat.Guid == ImageFormat.Gif.Guid) {
                int frames = npc.image.GetFrameCount(FrameDimension.Time);
                if (frames == 1) {
                    Bitmap new_bitmap = new Bitmap(npc.image);
                    new_bitmap.MakeTransparent();
                    npc.image.Dispose();
                    npc.image = new_bitmap;
                }
            }

            // special case for rashid: change location based on day of the week
            if (npc != null && npc.name == "Rashid") {
                command = new SQLiteCommand(String.Format("SELECT city, x, y, z FROM RashidPositions WHERE day='{0}'", DateTime.Now.DayOfWeek.ToString()), mainForm.conn);
                reader = command.ExecuteReader();
                if (reader.Read()) {
                    npc.city = reader["city"].ToString();
                    npc.pos.x = reader.GetInt32(1);
                    npc.pos.y = reader.GetInt32(2);
                    npc.pos.z = reader.GetInt32(3);
                }
            }
            command = new SQLiteCommand(String.Format("SELECT itemid, value FROM SellItems WHERE vendorid={0}", npc.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                ItemSold sellItem = new ItemSold();
                sellItem.itemid = reader.GetInt32(0);
                sellItem.npcid = npc.id;
                sellItem.price = reader.GetInt32(1);
                npc.sellItems.Add(sellItem);
            }
            command = new SQLiteCommand(String.Format("SELECT itemid, value FROM BuyItems WHERE vendorid={0}", npc.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                ItemSold buyItem = new ItemSold();
                buyItem.itemid = reader.GetInt32(0);
                buyItem.npcid = npc.id;
                buyItem.price = reader.GetInt32(1);
                npc.buyItems.Add(buyItem);
            }
            command = new SQLiteCommand(String.Format("SELECT spellid,knight,druid,paladin,sorcerer FROM SpellNPCs WHERE npcid={0}", npc.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                SpellTaught t = new SpellTaught();
                t.npcid = npc.id;
                t.spellid = reader.GetInt32(0);
                t.knight = reader.GetBoolean(1);
                t.druid = reader.GetBoolean(2);
                t.paladin = reader.GetBoolean(3);
                t.sorcerer = reader.GetBoolean(4);
                npc.spellsTaught.Add(t);
            }

            command = new SQLiteCommand(String.Format("SELECT DISTINCT questid FROM QuestNPCs WHERE npcid={0}", npc.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                Quest q = getQuest(reader.GetInt32(0));
                npc.involvedQuests.Add(q);
            }

            command = new SQLiteCommand(String.Format("SELECT destination,cost,notes FROM NPCDestinations WHERE npcid={0}", npc.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                Transport t = new Transport();
                t.destination = reader.GetString(0);
                t.cost = reader.GetInt32(1);
                t.notes = reader.GetString(2);
                npc.transportOffered.Add(t);
            }
            return npc;
        }
コード例 #3
0
        private static Spell createSpell(SQLiteDataReader reader)
        {
            SQLiteCommand command;

            if (!reader.Read()) {
                return null;
            }

            Spell spell = new Spell();
            spell.permanent = true;
            spell.id = reader.GetInt32(0);
            spell.name = reader["name"].ToString();
            spell.words = reader["words"].ToString();
            spell.element = reader.IsDBNull(3) ? "Unknown" : reader.GetString(3);
            spell.cooldown = reader.IsDBNull(4) ? DATABASE_NULL : reader.GetInt32(4);
            spell.premium = reader.GetBoolean(5);
            spell.promotion = reader.GetBoolean(6);
            spell.levelrequired = reader.GetInt32(7);
            spell.goldcost = reader.GetInt32(8);
            spell.manacost = reader.GetInt32(9);
            spell.knight = reader.GetBoolean(10);
            spell.paladin = reader.GetBoolean(11);
            spell.sorcerer = reader.GetBoolean(12);
            spell.druid = reader.GetBoolean(13);
            spell.image = Image.FromStream(reader.GetStream(14));

            command = new SQLiteCommand(String.Format("SELECT npcid, knight, druid, paladin, sorcerer FROM SpellNPCs WHERE spellid={0}", spell.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                SpellTaught t = new SpellTaught();
                t.npcid = reader.GetInt32(0);
                t.spellid = spell.id;
                t.knight = reader.GetBoolean(1);
                t.druid = reader.GetBoolean(2);
                t.paladin = reader.GetBoolean(3);
                t.sorcerer = reader.GetBoolean(4);
                spell.teachNPCs.Add(t);
            }
            return spell;
        }