예제 #1
0
        private void Application_Load(object sender, EventArgs e)
        {
            //Prepare GUI
            powerTypeCombo.Items.Add(new ComboItem("Mana", (int)PowerType.MANA));
            powerTypeCombo.Items.Add(new ComboItem("Rage", (int)PowerType.RAGE));
            powerTypeCombo.Items.Add(new ComboItem("Energy", (int)PowerType.ENERGY));
            powerTypeCombo.SelectedIndex = 0;

            //Prepare spellHeader
            spellHeader.DBCmagic        = DBCReader.DBCFmtSig;
            spellHeader.RecordsCount    = (uint)spellReader.RecordsCount;
            spellHeader.FieldsCount     = (uint)spellReader.FieldsCount;
            spellHeader.RecordSize      = (uint)spellReader.RecordSize;
            spellHeader.StringTableSize = (uint)spellReader.StringTableSize;

            //Load individual spell structures
            for (int i = 0; i < spellHeader.RecordsCount; i++)
            {
                GCHandle handle = GCHandle.Alloc(spellReader.GetRowAsByteArray(i), GCHandleType.Pinned);
                var      size   = Marshal.SizeOf(typeof(Spell));
                Spell    spell  = (Spell)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(Spell));
                spellDict.Add(spell.Entry, spell);
                handle.Free();
            }

            //Prepare skillLineHeader
            skillLineHeader.DBCmagic        = DBCReader.DBCFmtSig;
            skillLineHeader.RecordsCount    = (uint)skillLineReader.RecordsCount;
            skillLineHeader.FieldsCount     = (uint)skillLineReader.FieldsCount;
            skillLineHeader.RecordSize      = (uint)skillLineReader.RecordSize;
            skillLineHeader.StringTableSize = (uint)skillLineReader.StringTableSize;

            //Load individual skill line ability structures
            for (int i = 0; i < skillLineHeader.RecordsCount; i++)
            {
                GCHandle  handle    = GCHandle.Alloc(skillLineReader.GetRowAsByteArray(i), GCHandleType.Pinned);
                var       size      = Marshal.SizeOf(typeof(SkillLine));
                SkillLine skillLine = (SkillLine)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(SkillLine));
                skillLineDict.Add(skillLine.ID, skillLine);
                handle.Free();
            }

            skillLineAbilityHeader.DBCmagic        = DBCReader.DBCFmtSig;
            skillLineAbilityHeader.RecordsCount    = (uint)skillLineAbilityReader.RecordsCount;
            skillLineAbilityHeader.FieldsCount     = (uint)skillLineAbilityReader.FieldsCount;
            skillLineAbilityHeader.RecordSize      = (uint)skillLineAbilityReader.RecordSize;
            skillLineAbilityHeader.StringTableSize = (uint)skillLineAbilityReader.StringTableSize;

            //Load individual skill line ability structures
            for (int i = 0; i < skillLineAbilityHeader.RecordsCount; i++)
            {
                GCHandle         handle           = GCHandle.Alloc(skillLineAbilityReader.GetRowAsByteArray(i), GCHandleType.Pinned);
                var              size             = Marshal.SizeOf(typeof(SkillLineAbility));
                SkillLineAbility skillLineAbility = (SkillLineAbility)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(SkillLineAbility));
                skillLineAbilityDict.Add(skillLineAbility.ID, skillLineAbility);
                handle.Free();
            }
        }
예제 #2
0
        private void loadSpellsButton_Click(object sender, EventArgs e)
        {
            SkillLineItem   skillLineItem = (SkillLineItem)skillLineList.SelectedItem;
            MySqlConnection con           = new MySqlConnection();
            string          conString     = "SERVER=127.0.0.1;PORT=3306;DATABASE=world70;UID=root;PASSWORD=ascent;";

            con.ConnectionString = conString;
            con.Open();

            foreach (var skillLineID in skillLineItem.skillLines)
            {
                foreach (var pair in skillLineAbilityDict)
                {
                    SkillLineAbility skillLineAbility = pair.Value;
                    if (skillLineID != skillLineAbility.skillLine)
                    {
                        continue;
                    }
                    if (skillLineAbility.skillLine != skillLineID)
                    {
                        continue;
                    }

                    /* Spells which we should modify */
                    if (!spellDict.Keys.Contains(skillLineAbility.spell))
                    {
                        continue;
                    }
                    Spell spell = spellDict[skillLineAbility.spell];

                    //Filtering out obsolete spells
                    //if (spell.StartRecoveryCategory == 0 || spell.StartRecoveryTime == 0
                    //  || spell.baseLevel == 0) continue;

                    if (spell.baseLevel == 0)
                    {
                        continue;
                    }

                    try
                    {
                        string query = $"INSERT INTO custom_spell_system (spellID, spellName, spellLevel)VALUES ({spell.Entry},\"{spellReader.StringTable[(int)spell.SpellName_0]}\", {spell.spellLevel});";
                        //MessageBox.Show(query);
                        MySqlCommand    cmd    = new MySqlCommand(query, con);
                        MySqlDataReader reader = cmd.ExecuteReader();
                        reader.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }

                    combinedSpellList.Items.Add($"{spell.Entry}, {spellReader.StringTable[(int)spell.SpellName_0]}, {spellReader.StringTable[(int)spell.Description_0]}");
                }
            }
        }
예제 #3
0
        //20 rage = 200 powercost (manaCost in DB files)
        //20 energy = 20 powercost (manaCost in DB files)
        private void handleManaLine()
        {
            SkillLineItem skillLineItem = (SkillLineItem)skillLineList.SelectedItem;

            foreach (var skillLineID in skillLineItem.skillLines)
            {
                foreach (var pair in skillLineAbilityDict)
                {
                    SkillLineAbility skillLineAbility = pair.Value;
                    if (skillLineID != skillLineAbility.skillLine)
                    {
                        continue;
                    }
                    if (skillLineAbility.skillLine != skillLineID)
                    {
                        continue;
                    }

                    /* Spells which we should modify */
                    if (!spellDict.Keys.Contains(skillLineAbility.spell))
                    {
                        continue;
                    }
                    Spell spell = spellDict[skillLineAbility.spell];
                    //if (spell.Entry != 116) continue;

                    //So we don't edit spells which have already been converted or use the energy resource
                    if (spell.powerType != (uint)PowerType.MANA)
                    {
                        continue;
                    }
                    spell.powerType = (uint)PowerType.ENERGY;

                    //Let's say a frostbolt costs 11 mana pct, now it costs 33 energy, if it's above 75 it will become 75.
                    double baseEnergyCost = Convert.ToDouble(spell.ManaCostPercentage);
                    baseEnergyCost *= 1.5;
                    if (baseEnergyCost > 40)
                    {
                        baseEnergyCost = 40;
                    }

                    spell.manaCost           = Convert.ToUInt32(baseEnergyCost); //manaCost is Power Cost in spell editor, 20 energy =
                    spell.ManaCostPercentage = 0;

                    spellDict[skillLineAbility.spell] = spell;
                }
            }
        }