private void exportSQLButtonX_Click(object sender, EventArgs e)
        {
            if (lootListViewEx.Items.Count == 0)
            {
                return;
            }

            if (exportSQLFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                StreamWriter writer = new StreamWriter(exportSQLFileDialog.FileName);

                for (int i = 0; i < lootListViewEx.Items.Count; i++)
                {
                    string[] columns = new string[] { "entry", "item", "ChanceOrQuestChance", "mincountOrRef", "maxcount" };
                    string[] values  = new string[] { lootListViewEx.Items[i].SubItems[0].Text, lootListViewEx.Items[i].SubItems[1].Text, lootListViewEx.Items[i].SubItems[2].Text, lootListViewEx.Items[i].SubItems[3].Text, lootListViewEx.Items[i].SubItems[4].Text };

                    writer.WriteLine(mysql.CreateMySQLQuery(Settings.Default.WorldDB, "creature_loot_template", values, columns));


                    string[] updateColumns = new string[] { "lootid", "entry" };
                    string[] updateValues  = new string[] { lootListViewEx.Items[i].SubItems[0].Text, lootListViewEx.Items[i].SubItems[0].Text };

                    writer.WriteLine(mysql.CreateUpdateQuery(Settings.Default.WorldDB, "creature_template", "entry", lootListViewEx.Items[i].SubItems[0].Text, updateValues, updateColumns));

                    writer.WriteLine(String.Empty);
                }

                writer.Close();

                TaskDialog.Show(new TaskDialogInfo("Finished", eTaskDialogIcon.Information2, "Saved", String.Empty, eTaskDialogButton.Ok));
            }
        }
        private void exportSQLButtonX_Click(object sender, EventArgs e)
        {
            if (exportSQLFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                StreamWriter writer = new StreamWriter(exportSQLFileDialog.FileName);

                for (int i = 0; i < vendorListViewEx.Items.Count; i++)
                {
                    string[] columns = new string[] { "entry", "item" };
                    string[] values  = new string[] { vendorIntegerInput.Value.ToString(), vendorListViewEx.Items[i].SubItems[1].Text };

                    writer.WriteLine(mysql.CreateMySQLQuery(Settings.Default.WorldDB, "npc_vendor", values, columns));
                }

                writer.Close();

                TaskDialog.Show(new TaskDialogInfo("Finished", eTaskDialogIcon.Information2, "Saved", String.Empty, eTaskDialogButton.Ok));
            }
        }
        private void wizard_FinishButtonClick(object sender, CancelEventArgs e)
        {
            try
            {
                int unit_class = 0;

                switch (classComboBoxEx.SelectedIndex)
                {
                case 0:
                    unit_class = 1;
                    break;

                case 1:
                    unit_class = 2;
                    break;

                case 2:
                    unit_class = 4;
                    break;

                case 3:
                    unit_class = 8;
                    break;
                }

                Dictionary <string, List <string> > classLevelStats = mysql.ReadAll(Settings.Default.WorldDB, "creature_classlevelstats", new string[] { "level", "class" }, new string[] { minLevelIntegerInput.Value.ToString(), unit_class.ToString() });

                if (!classLevelStats.ContainsKey("basehp2") || !classLevelStats.ContainsKey("basearmor"))
                {
                    TaskDialog.Show(new TaskDialogInfo("Error!", eTaskDialogIcon.Stop, "An error has occured!", String.Empty, eTaskDialogButton.Ok));

                    finished = true;

                    this.Close();

                    return;
                }

                int health = int.Parse(classLevelStats["basehp2"][0]);
                int armor  = int.Parse(classLevelStats["basearmor"][0]);

                float health_mod = 0;

                if (healthIntegerInput.Value != 0 && health != 0)
                {
                    health_mod = float.Parse(healthIntegerInput.Value.ToString()) / health;
                }
                else if (health == 0)
                {
                    health_mod = float.Parse(healthIntegerInput.Value.ToString());
                }

                float armor_mod = 0;

                if (armorIntegerInput.Value != 0 && armor != 0)
                {
                    armor_mod = float.Parse(armorIntegerInput.Value.ToString()) / armor;
                }
                else if (armor == 0)
                {
                    armor_mod = float.Parse(armorIntegerInput.Value.ToString());
                }



                int faction = 0;

                switch (factionComboBoxEx.SelectedIndex)
                {
                case 0:
                    faction = 7;
                    break;

                case 1:
                    faction = 14;
                    break;

                case 2:
                    faction = 35;
                    break;
                }


                int flags = 0;

                if (gossipYesRadioButton.Checked)
                {
                    flags += 1;
                }

                if (vendorYesRadioButton.Checked)
                {
                    flags += 128;
                }

                if (armorerYesRadioButton.Checked)
                {
                    flags += 4096;
                }

                if (innkeeperYesRadioButton.Checked)
                {
                    flags += 65536;
                }

                if (bankerYesRadioButton.Checked)
                {
                    flags += 131072;
                }

                if (auctioneerYesRadioButton.Checked)
                {
                    flags += 2097152;
                }

                if (stableYesRadioButton.Checked)
                {
                    flags += 4194304;
                }

                if (guildBankYesRadioButton.Checked)
                {
                    flags += 8388608;
                }

                if (questGiverYesRadioButton.Checked)
                {
                    flags += 2;
                }

                if (guardYesRadioButton.Checked)
                {
                    flags += 268435456;
                }


                int money = (lootCopperIntegerInput.Value % 100) + (lootSilverIntegerInput.Value * 100) + (lootGoldIntegerInput.Value * 10000);

                int regen = 0;

                if (regenHealthYesRadioButton.Checked)
                {
                    regen = 1;
                }

                string AIName = String.Empty;

                switch (aiNameComboBoxEx.SelectedIndex)
                {
                case 1:
                    AIName = "NullAI";
                    break;

                case 2:
                    AIName = "AggressorAI";
                    break;

                case 3:
                    AIName = "ReactorAI";
                    break;
                }

                double attackTime = TimeSpan.FromSeconds(Convert.ToDouble(speedNumericUpDown.Value)).TotalMilliseconds;


                string npcName    = NameTextBoxX.Text.Replace("'", "\\'");
                string npcSubname = subnameTextBoxX.Text.Replace("'", "\\'");

                string[] columns = new string[] { "entry", "modelid1", "name", "subname", "minlevel", "maxlevel", "exp", "faction_A", "faction_H", "npcflag", "scale", "rank", "mindmg", "maxdmg", "attackpower", "baseattacktime", "rangeattacktime", "unit_class", "family", "minrangedmg", "maxrangedmg", "rangedattackpower", "type", "resistance1", "resistance2", "resistance3", "resistance4", "resistance5", "resistance6", "VehicleId", "mingold", "maxgold", "AIName", "MovementType", "InhabitType", "Health_mod", "Mana_mod", "Armor_mod", "RegenHealth", "ScriptName" };
                string[] values  = new string[] { entryIDIntegerInput.Value.ToString(), displayIDIntegerInput.Value.ToString(), npcName, npcSubname, minLevelIntegerInput.Value.ToString(), maxLevelIntegerInput.Value.ToString(),
                                                  "2", faction.ToString(), faction.ToString(), flags.ToString(), modelSizeNumericUpDown.Value.ToString(), rankComboBoxEx.SelectedIndex.ToString(), minDamageIntegerInput.Value.ToString(), maxDamageIntegerInput.Value.ToString(), attackPowerIntegerInput.Value.ToString(), attackTime.ToString(),
                         attackTime.ToString(), unit_class.ToString(), familyComboItemEx.SelectedIndex.ToString(), minDamageIntegerInput.Value.ToString(), maxDamageIntegerInput.Value.ToString(), attackPowerIntegerInput.Value.ToString(), typeComboBoxEx.SelectedIndex.ToString(), holyIntegerInput.Value.ToString(), fireIntegerInput.Value.ToString(), natureIntegerInput.Value.ToString(), frostIntegerInput.Value.ToString(), shadowIntegerInput.Value.ToString(), arcaneIntegerInput.Value.ToString(), vehicleIDIntegerInput.Value.ToString(), money.ToString(), money.ToString(), AIName, movementTypeComboBoxEx.SelectedIndex.ToString(), (inhabitComboBoxEx.SelectedIndex + 1).ToString(), health_mod.ToString(), manaIntegerInput.Value.ToString(), armor_mod.ToString(), regen.ToString(), scriptNameTextBoxX.Text };


                finished = true;

                if (saveToDBRadioButton.Checked)
                {
                    mysql.ReplaceIntoDatabase(Settings.Default.WorldDB, "creature_template", values, columns);

                    TaskDialog.Show(new TaskDialogInfo("Done", eTaskDialogIcon.Information2, "NPC imported into database", String.Empty, eTaskDialogButton.Ok));

                    this.Close();
                }
                else
                {
                    if (saveSQLFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        string qry = mysql.CreateMySQLQuery(Settings.Default.WorldDB, "creature_template", values, columns);

                        try
                        {
                            StreamWriter writer = new StreamWriter(saveSQLFileDialog.FileName);

                            writer.WriteLine(qry);

                            writer.Flush();

                            writer.Close();

                            TaskDialog.Show(new TaskDialogInfo("Done", eTaskDialogIcon.Information2, "SQL File Saved", String.Empty, eTaskDialogButton.Ok));


                            this.Close();
                        }
                        catch (Exception ex)
                        {
                            TaskDialog.Show(new TaskDialogInfo("Error", eTaskDialogIcon.Stop, "Error!", ex.Message, eTaskDialogButton.Ok));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                TaskDialog.Show(new TaskDialogInfo("Error", eTaskDialogIcon.Stop, "Error!", ex.Message, eTaskDialogButton.Ok));
            }
        }
Beispiel #4
0
        private void wizard_FinishButtonClick(object sender, CancelEventArgs e)
        {
            int type      = itemTypeComboBoxEX.SelectedIndex;
            int bind      = 0;
            int buymoney  = 0;
            int sellmoney = 0;

            switch (itemBindsComboBoxEX.SelectedIndex)
            {
            case 1:
                bind = 1;
                break;

            case 2:
                bind = 3;
                break;

            default:
                bind = 0;
                break;
            }

            buymoney  = (Convert.ToInt32(buyCopperIntegerInput.Value) % 100) + (Convert.ToInt32(buySilverIntegerInput.Value) * 100) + (Convert.ToInt32(buyGoldIntegerInput.Value) * 10000);
            sellmoney = (Convert.ToInt32(sellCopperIntegerInput.Value) % 100) + (Convert.ToInt32(sellSilverIntegerInput.Value) * 100) + (Convert.ToInt32(sellGoldIntegerInput.Value) * 10000);


            List <int> AllowableClasses = new List <int>();
            int        allowableclass   = 0;

            //Allowable Classes

            if (warriorCheckBoxX.Checked)
            {
                AllowableClasses.Add(1);
            }

            if (paladinCheckBoxX.Checked)
            {
                AllowableClasses.Add(2);
            }

            if (hunterCheckBoxX.Checked)
            {
                AllowableClasses.Add(4);
            }

            if (rogueCheckBoxX.Checked)
            {
                AllowableClasses.Add(8);
            }

            if (priestCheckBoxX.Checked)
            {
                AllowableClasses.Add(16);
            }

            if (druidCheckBoxX.Checked)
            {
                AllowableClasses.Add(1024);
            }

            if (shamanCheckBoxX.Checked)
            {
                AllowableClasses.Add(64);
            }

            if (mageCheckBoxX.Checked)
            {
                AllowableClasses.Add(128);
            }

            if (warlockCheckBoxX.Checked)
            {
                AllowableClasses.Add(256);
            }

            if (deathKnightCheckBoxX.Checked)
            {
                AllowableClasses.Add(32);
            }

            foreach (int p in AllowableClasses)
            {
                allowableclass += p;
            }

            if (allowableclass == 0)
            {
                allowableclass = -1;
            }

            List <int> AllowableRaces = new List <int>();
            int        allowablerace  = 0;

            if (humanCheckBoxX.Checked)
            {
                AllowableRaces.Add(1);
            }

            if (orcCheckBoxX.Checked)
            {
                AllowableRaces.Add(2);
            }

            if (dwarfCheckBoxX.Checked)
            {
                AllowableRaces.Add(4);
            }

            if (nightElfCheckBoxX.Checked)
            {
                AllowableRaces.Add(8);
            }

            if (undeadCheckBoxX.Checked)
            {
                AllowableRaces.Add(16);
            }

            if (taurenCheckBoxX.Checked)
            {
                AllowableRaces.Add(32);
            }

            if (gnomeCheckBoxX.Checked)
            {
                AllowableRaces.Add(64);
            }

            if (trollCheckBoxX.Checked)
            {
                AllowableRaces.Add(128);
            }

            if (bloodelfCheckBoxX.Checked)
            {
                AllowableRaces.Add(512);
            }

            if (draeneiCheckBoxX.Checked)
            {
                AllowableRaces.Add(1024);
            }

            foreach (int p in AllowableRaces)
            {
                allowablerace += p;
            }

            if (allowablerace == 0)
            {
                allowablerace = -1;
            }

            int requiredskill = 0;

            switch (skillProfressionComboBoxEX.SelectedIndex)
            {
            case 1:
                requiredskill = 129;
                break;

            case 2:
                requiredskill = 164;
                break;

            case 3:
                requiredskill = 165;
                break;

            case 4:
                requiredskill = 171;
                break;

            case 5:
                requiredskill = 182;
                break;

            case 6:
                requiredskill = 185;
                break;

            case 7:
                requiredskill = 186;
                break;

            case 8:
                requiredskill = 197;
                break;

            case 9:
                requiredskill = 202;
                break;

            case 10:
                requiredskill = 333;
                break;

            case 11:
                requiredskill = 356;
                break;

            case 12:
                requiredskill = 393;
                break;

            case 13:
                requiredskill = 755;
                break;

            case 14:
                requiredskill = 0;
                break;

            case 15:
                requiredskill = 43;
                break;

            case 16:
                requiredskill = 44;
                break;

            case 17:
                requiredskill = 46;
                break;

            case 18:
                requiredskill = 54;
                break;

            case 19:
                requiredskill = 55;
                break;

            case 20:
                requiredskill = 95;
                break;

            case 21:
                requiredskill = 136;
                break;

            case 22:
                requiredskill = 160;
                break;

            case 23:
                requiredskill = 162;
                break;

            case 24:
                requiredskill = 172;
                break;

            case 25:
                requiredskill = 173;
                break;

            case 26:
                requiredskill = 176;
                break;

            case 27:
                requiredskill = 226;
                break;

            case 28:
                requiredskill = 228;
                break;

            case 29:
                requiredskill = 229;
                break;

            case 30:
                requiredskill = 473;
                break;

            case 31:
                requiredskill = 762;
                break;

            default:
                requiredskill = 0;
                break;
            }

            if (mysql != null)
            {
                try
                {
                    string itemName  = itemNameTextBoxX.Text.Replace("'", "\\'");
                    string itemQuote = itemQuoteTextBoxX.Text.Replace("'", "\\'");

                    string[] columns = new string[] { "entry", "class", "subclass", "name", "displayid", "Quality", "BuyPrice", "SellPrice", "AllowableClass", "AllowableRace", "ItemLevel", "RequiredLevel", "RequiredSkill", "RequiredSkillRank", "maxcount", "bonding", "description" };
                    string[] values  = new string[] { entryIDIntegerInput.Value.ToString(), "0", itemTypeComboBoxEX.SelectedIndex.ToString(), itemName, displayIDIntegerInput.Value.ToString(), qualityComboBoxEX.SelectedIndex.ToString(), buymoney.ToString(), sellmoney.ToString(), allowableclass.ToString(), allowablerace.ToString(), itemLevelIntegerInput.Value.ToString(), requiredLevelIntegerInput.Value.ToString(), requiredskill.ToString(), skillLevelIntegerInput.Value.ToString(), maxNumAllowedIntegerInput.Value.ToString(), bind.ToString(), itemQuote };

                    finished = true;

                    if (saveToDBRadioButton.Checked)
                    {
                        mysql.ReplaceIntoDatabase(Settings.Default.WorldDB, "item_template", values, columns);

                        TaskDialog.Show(new TaskDialogInfo("Done", eTaskDialogIcon.Information2, "Item imported into database", String.Empty, eTaskDialogButton.Ok));

                        this.Close();
                    }
                    else
                    {
                        if (saveSQLFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            string qry = mysql.CreateMySQLQuery(Settings.Default.WorldDB, "item_template", values, columns);

                            try
                            {
                                StreamWriter writer = new StreamWriter(saveSQLFileDialog.FileName);

                                writer.WriteLine(qry);

                                writer.Flush();

                                writer.Close();

                                TaskDialog.Show(new TaskDialogInfo("Done", eTaskDialogIcon.Information2, "SQL File Saved", String.Empty, eTaskDialogButton.Ok));


                                this.Close();
                            }
                            catch (Exception ex)
                            {
                                TaskDialog.Show(new TaskDialogInfo("Error", eTaskDialogIcon.Stop, "Error!", ex.Message, eTaskDialogButton.Ok));
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    TaskDialog.Show(new TaskDialogInfo("Error", eTaskDialogIcon.Stop, "Error!", ex.Message, eTaskDialogButton.Ok));
                }
            }
        }