public void Run()
        {
            System.Collections.ArrayList tradeScrollList = new System.Collections.ArrayList();

            for (int ip = 0; ip < Globals.iprp_spells2da.RowCount; ip++)
            {
                //DebugWindow.PrintDebugMessage("Looking at iprp_spells.2da row: " + ip);
                string tdaSpellId = Globals.iprp_spells2da["SpellIndex"][ip];
                string tdaCasterLevel = Globals.iprp_spells2da["CasterLvl"][ip];
                string icon = Globals.iprp_spells2da["Icon"][ip];
                bool formatOK = true;
                int spellId = -1;
                int casterLevel = -1;
                try
                {
                    spellId = Convert.ToInt32(tdaSpellId);
                    casterLevel = Convert.ToInt32(tdaCasterLevel);
                    DebugWindow.PrintDebugMessage("Creating consumables for spell id " + spellId + ", caster level " + casterLevel + " and scroll icon " + icon + ".");
                }
                catch
                {
                    DebugWindow.PrintDebugMessage("2da format error for iprp_spells.2da line " + ip + ", spell id " + tdaSpellId + ", caster level " + tdaCasterLevel + ".");
                    formatOK = false;
                }

                if (formatOK && !ipHash.Contains(tdaSpellId.ToString() + "_" + tdaCasterLevel.ToString()))
                {

                    NWN2Toolset.NWN2.Rules.CNWSpell spell = Globals.spells.GetSpell(spellId);
                    ipHash.Add(tdaSpellId.ToString() + "_" + tdaCasterLevel.ToString());

                    if (spell != null && spell.IsValid() == 1)
                    {
                        int targets = spell.GetSpellTargetType();
                        int wizardLevel = spell.GetSpellWizardLevel();
                        int clericLevel = spell.GetSpellClericLevel();
                        int druidLevel = spell.GetSpellDruidLevel();
                        int rangerLevel = spell.GetSpellRangerLevel();
                        int paladinLevel = spell.GetSpellPaladinLevel();
                        int bardLevel = spell.GetSpellBardLevel();

                        // Find the lowest spell level.
                        int lowestSpellLevel = wizardLevel;
                        if (lowestSpellLevel > clericLevel)
                            lowestSpellLevel = clericLevel;
                        if (lowestSpellLevel > druidLevel)
                            lowestSpellLevel = druidLevel;

                        float costLevel = lowestSpellLevel;
                        if (lowestSpellLevel == 0)
                            costLevel = 0.5F;

                        if ((lowestSpellLevel < 255))
                        {
                            if ((targets & 2) != 0 && lowestSpellLevel <= 3 && spell.GetSpellHostile() != 1 && !nonpotion(spellId))
                            {
                                // Can target a creature, ie can be a potion.
                                Potion potion = new Potion(ip, spellId, lowestSpellLevel, casterLevel, spell);
                                Globals.AddBlueprint(potion.blueprint);
                                potionStore.addToPotionItems(potion.blueprint);
                            }

                            if (lowestSpellLevel <= 4)
                            {
                                // Can be a wand.
                                Wand wand = new Wand(ip, spellId, lowestSpellLevel, casterLevel, spell);
                                addClassRestrictions(wand.blueprint, bardLevel, clericLevel, druidLevel, paladinLevel, rangerLevel, wizardLevel);
                                Globals.AddBlueprint(wand.blueprint);
                                wandStore.addToPotionItems(wand.blueprint);
                            }

                            int lowestDivineLevel = clericLevel;
                            if (druidLevel < clericLevel)
                            {
                                lowestDivineLevel = druidLevel;
                            }
                            if (lowestDivineLevel == 255)
                            {
                                lowestDivineLevel = rangerLevel;
                                if (lowestDivineLevel > paladinLevel)
                                    lowestDivineLevel = paladinLevel;
                            }
                            if (lowestDivineLevel < 255)
                            {
                                // Can be a divine scroll.
                                Scroll scroll = new DivineScroll(ip, spellId, lowestSpellLevel, casterLevel, spell, icon);
                                addClassRestrictions(scroll.blueprint, 255, clericLevel, druidLevel, paladinLevel, rangerLevel, 255);
                                Globals.AddBlueprint(scroll.blueprint);
                                scrollStore.addToPotionItems(scroll.blueprint);
                            }

                            int lowestArcaneLevel = wizardLevel;
                            if (wizardLevel == 255)
                            {
                                lowestArcaneLevel = bardLevel;
                            }

                            if (wizardLevel < 255 && !tradeScrollList.Contains(spellId))
                            {
                                // Can be a trade scroll.
                                TradeScroll tradescroll = new TradeScroll(spellId, lowestSpellLevel, spell);
                                Globals.AddBlueprint(tradescroll.blueprint);
                                tradeScrollList.Add(spellId);
                            }

                            if (lowestArcaneLevel < 255)
                            {
                                // Can be an arcane scroll.
                                Scroll scroll = new ArcaneScroll(ip, spellId, lowestSpellLevel, casterLevel, spell, icon);
                                addClassRestrictions(scroll.blueprint, bardLevel, 255, 255, 255, 255, wizardLevel);
                                Globals.AddBlueprint(scroll.blueprint);
                                scrollStore.addToPotionItems(scroll.blueprint);
                            }
                        }
                    }
                }
            }
            DebugWindow.PrintDebugMessage("Items in blueprint collection: " + Globals.items.Count);

            NotfyIconsNotFoundFor("Potions", Potion.iconsMissing);
            NotfyIconsNotFoundFor("Wand", Wand.iconsMissing);
            NotfyIconsNotFoundFor("Scroll", Scroll.iconsMissing);

            ipHash = new HashSet<String>();
        }