Example #1
0
        // sub_5CA74
        internal static bool BuildSpellList(SpellLoc spl_location)
        {
            bool buildSpellList = true;

            gbl.spell_string_list.Clear();

            for (int var_2 = 0; var_2 < gbl.max_spells; var_2++)
            {
                gbl.memorize_spell_id[var_2] = 0;
            }

            switch (spl_location)
            {
                case SpellLoc.memory:
                    foreach (int id in gbl.SelectedPlayer.spellList.LearntList())
                    {
                        if (can_learn_spell(id, gbl.SelectedPlayer))
                        {
                            add_spell_to_learning_list(id);
                        }
                    }
                    break;

                case SpellLoc.memorize:
                    foreach (int id in gbl.SelectedPlayer.spellList.LearningList())
                    {
                        if (can_learn_spell(id, gbl.SelectedPlayer))
                        {
                            add_spell_to_learning_list(id);
                        }
                    }
                    break;

                case SpellLoc.grimoire:
                    foreach (Spells spell in System.Enum.GetValues(typeof(Spells)))
                    {
                        if (gbl.SelectedPlayer.KnowsSpell(spell) &&
                            can_learn_spell((int)spell, gbl.SelectedPlayer))
                        {
                            add_spell_to_learning_list((int)spell);
                        }
                    }
                    break;

                case SpellLoc.scroll:
                    scroll_5C912(false);
                    buildSpellList = false;
                    break;

                case SpellLoc.scrolls:
                    BuildScrollSpellLists(false);
                    buildSpellList = false;
                    break;

                case SpellLoc.scribe:
                    BuildScrollSpellLists(true);
                    buildSpellList = false;
                    break;

                case SpellLoc.choose:
                    foreach (Spells spell in System.Enum.GetValues(typeof(Spells)))
                    {
                        int sp_lvl = gbl.spellCastingTable[(int)spell].spellLevel;
                        SpellClass sp_class = gbl.spellCastingTable[(int)spell].spellClass;

                        if (sp_lvl > 5 || sp_class >= SpellClass.Monster)
                        {
                            //skip this spell
                        }
                        else if (gbl.SelectedPlayer.spellCastCount[(int)sp_class, sp_lvl - 1] > 0 &&
                            can_learn_spell((int)spell, gbl.SelectedPlayer) == true &&
                            gbl.SelectedPlayer.KnowsSpell(spell) == false)
                        {
                            add_spell_to_learning_list((int)spell);
                        }
                    }
                    break;
            }

            if (gbl.spell_string_list.Count > 0)
            {
                if (buildSpellList == true)
                {
                    int idx = 0;
                    int spellLvl = 0;

                    int insert = 0;
                    var inserts = new Queue<KeyValuePair<int, int>>();

                    foreach (var mi in gbl.spell_string_list)
                    {
                        var lastLvl = spellLvl;

                        if (gbl.memorize_spell_id[idx] != 0)
                        {
                            spellLvl = gbl.spellCastingTable[gbl.memorize_spell_id[idx]].spellLevel;
                        }

                        if (spellLvl > lastLvl)
                        {
                            inserts.Enqueue(new KeyValuePair<int, int>(insert, spellLvl));
                            insert++;
                        }

                        insert++;
                        idx++;
                    }

                    foreach (var vp in inserts)
                    {
                        gbl.spell_string_list.Insert(vp.Key, new MenuItem(LevelStrings[vp.Value], true));
                    }
                }
                return true;
            }

            return false;
        }
Example #2
0
        internal static byte spell_menu2(out bool arg_0, ref int index, SpellSource arg_8, SpellLoc spl_location)
        {
            string text;
            byte result;

            switch (spl_location)
            {
                case SpellLoc.memory:

                    text = "in Memory";
                    break;

                case SpellLoc.grimoire:

                    text = "in Grimoire";
                    break;

                case SpellLoc.scroll:
                    text = "on Scroll";
                    break;

                case SpellLoc.scrolls:
                    text = "on Scrolls";
                    break;

                case SpellLoc.choose:
                    text = "to Choose";
                    break;

                case SpellLoc.memorize:
                    text = "to Memorize";
                    break;

                case SpellLoc.scribe:
                    text = "to Scribe";
                    break;

                default:
                    text = string.Empty;
                    break;
            }

            arg_0 = ovr023.BuildSpellList(spl_location);

            if (arg_0 == true)
            {
                if (index < 0 ||
                    arg_8 == SpellSource.Cast)
                {
                    if (gbl.game_state != GameState.Combat)
                    {
                        if (arg_8 == SpellSource.Memorize)
                        {
                            seg037.draw8x8_05();
                        }
                        else
                        {
                            seg037.draw8x8_07();
                        }
                    }
                    else
                    {
                        seg037.DrawFrame_Outer();
                    }
                }

                ovr025.displayPlayerName(true, 1, 1, gbl.SelectedPlayer);

                seg041.displayString("Spells " + text, 0, 10, 1, gbl.SelectedPlayer.name.Length + 4);

                result = ovr023.spell_menu(ref index, arg_8);
            }
            else
            {
                result = 0;
            }

            return result;
        }