These are chat archives for ZaneDubya/UltimaXNA

22nd
Jun 2015
Zane Wagner
@ZaneDubya
Jun 22 2015 02:20
This spellbook gump is such a pain. I don't want to work on it anymore.
Jeff Boulanger
@jeffboulanger
Jun 22 2015 16:19
:(
Cant you have it make itself just with a definition table?
each page is laid out the same isnt it?
Seems like you could make a page layout, then just an array of information for each page
Zane Wagner
@ZaneDubya
Jun 22 2015 18:54
Yes! But part of the problem is that I need to figure out what's on each page before I can lay anything out. So if we're missing spell index 0, then the first page after the index contains spell index 1, and everything else is decremented by one.
I think I'll just plan out what's on each page the first time the client receives the spell book contents... a list of Tuple<int pageNumber, int spellIndex>. How does that sound?
Jeff Boulanger
@jeffboulanger
Jun 22 2015 20:56
seems pretty simple tho, you have a bit flags for spellbook, and when they double click the book, iterate through the complete spellbook table building a seperate list/table of available ones. Then pass it to the spellbook gump for construction
spellbook gump construction can always build itself based on an array
Zane Wagner
@ZaneDubya
Jun 22 2015 21:39
Hm.. Thanks. I'll give it another go this evening.
Jeff Boulanger
@jeffboulanger
Jun 22 2015 22:20
Something like
This message was deleted

64 spells
enum flag = 1 bit per spell (64 bit in length)

table item
spellname
bit (enum)
chapter (1-8)
params reagentTypes[] // not sure you need this, just looking at runuo

Off the top of my head

public class Spellbook 
{
    private static Dictionary<SpellType, SpellInfo[] m_Spells = new SpellInfo[] 
    {
        new SpellInfo("Clumsy", SpellType.Clumsy, 1, Reagent.Bloodmoss, Reagent.Nightshade),
        ...
    };

    private Spells m_Flags;

    public SpellbookGump CreateGump()
    {
        List<SpellInfo> availableSpells = new List<SpellInfo>();

        foreach(SpellType spellType in (SpellType[])Enum.GetValues(typeof(SpellType)))
        {
            SpellInfo info = m_Spells[spell];

            if((info .Type & spellType) == spellType)
            {
                availableSpells.Add(info);
            }
        }

        SpellBookGump gump = new SpellBookGump();

        //First 4 pages is chapters, 2 chapters per gump page.
        for(int i = 0; i < 8; i += 2)
        {
            var leftSpells = availableSpells.Where(s => s.Chapter = i).OrderBy(s => s.Name);
            var rightSpells = availableSpells.Where(s => s.Chapter = i + 1).OrderBy(s => s.Name);

            // CreatePage(IEnumerable<SpellInfo> leftSpells, IEnumeralbe<SpellInfo> rightSpells)
            gump.CreatePage(leftSpells, rightSpells);
        }

        //All the next pages are the spells we have availabe, 2 per gump page
        int count = availableSpells.Count;

        for(int i = 0; i < count ; i += 2)
        {
            SpellInfo leftSpell = availableSpells[i];
            SpellInfo rightSpell = null;

            if(i + 1 < count)
            {
                rightSpell = availableSpells[i+1];
            }

            // CreatePage(SpellInfo left, SpellInfo right)
            gump.CreatePage(leftSpell, rightSpell);
        }
    }
}
Jeff Boulanger
@jeffboulanger
Jun 22 2015 22:38
For all i know its a bit more than that, but this should give you an idea of what i mean. Im not sure if the server sends mroe info, like what reagents to use, or whatever