Example #1
0
        private void DisplayItem(ItemDrop drop, int base_x, int base_y, int x, int y, Size item_size, ToolTip droprate_tooltip, int dropbar_height, string prefix = "Drop rate of ")
        {
            Item dropItem = StorageManager.getItem(drop.itemid);
            // the main picture of the item
            PictureBox picture_box = new PictureBox();

            picture_box.Location        = new System.Drawing.Point(base_x + x, base_y + y);
            picture_box.Name            = dropItem.GetName();
            picture_box.Size            = new System.Drawing.Size(item_size.Width, item_size.Height);
            picture_box.TabIndex        = 1;
            picture_box.TabStop         = false;
            picture_box.Image           = drop.max > 1 ? LootDropForm.DrawCountOnItem(dropItem, drop.max) : dropItem.GetImage();
            picture_box.SizeMode        = PictureBoxSizeMode.StretchImage;
            picture_box.BackgroundImage = StyleManager.GetImage("item_background.png");
            picture_box.Click          += openItemBox;
            droprate_tooltip.SetToolTip(picture_box, prefix + dropItem.displayname + " is " + (drop.percentage >= 0 ? Math.Round(drop.percentage, 1).ToString() + "%." : "unknown."));
            this.Controls.Add(picture_box);
            itemControls.Add(picture_box);

            // the 'dropbar' that roughly displays the droprate of the item
            PictureBox dropbar_box = new PictureBox();
            Brush      brush;

            dropbar_box.Location = new System.Drawing.Point(base_x + x, base_y + y + item_size.Height);
            dropbar_box.Name     = "dropbar_image";
            dropbar_box.Size     = new System.Drawing.Size(item_size.Width, dropbar_height);
            dropbar_box.TabIndex = 1;
            dropbar_box.TabStop  = false;
            Image    image = new Bitmap(dropbar_box.Width, dropbar_box.Height);
            Graphics gr    = Graphics.FromImage(image);

            gr.FillRectangle(Brushes.DarkGray, new Rectangle(0, 0, item_size.Width, dropbar_height)); //dropbar base bar
            if (drop.percentage < 1)
            {
                brush = Brushes.DarkRed; // <1% is red
            }
            else if (drop.percentage < 15)
            {
                brush = Brushes.Yellow; //<15% is yellow
            }
            else
            {
                brush = Brushes.ForestGreen; //everything else is green
            }
            gr.FillRectangle(brush, new Rectangle(0, 0, (int)(Math.Ceiling(item_size.Width * drop.percentage / 100) + 1), dropbar_height));
            dropbar_box.Image = image;
            this.Controls.Add(dropbar_box);
            itemControls.Add(dropbar_box);
        }
Example #2
0
        private void DisplayItem(ItemDrop drop, int base_x, int base_y, int x, int y, Size item_size, ToolTip droprate_tooltip, int dropbar_height, string prefix = "Drop rate of ") {

            Item dropItem = MainForm.getItem(drop.itemid);
            // the main picture of the item
            PictureBox picture_box = new PictureBox();
            picture_box.Location = new System.Drawing.Point(base_x + x, base_y + y);
            picture_box.Name = dropItem.GetName();
            picture_box.Size = new System.Drawing.Size(item_size.Width, item_size.Height);
            picture_box.TabIndex = 1;
            picture_box.TabStop = false;
            picture_box.Image = drop.max > 1 ? LootDropForm.DrawCountOnItem(dropItem, drop.max) : dropItem.GetImage();
            picture_box.SizeMode = PictureBoxSizeMode.StretchImage;
            picture_box.BackgroundImage = MainForm.item_background;
            picture_box.Click += openItemBox;
            droprate_tooltip.SetToolTip(picture_box, prefix + dropItem.displayname + " is " + (drop.percentage >= 0 ? Math.Round(drop.percentage, 1).ToString() + "%." : "unknown."));
            this.Controls.Add(picture_box);

            // the 'dropbar' that roughly displays the droprate of the item
            PictureBox dropbar_box = new PictureBox();
            Brush brush;
            dropbar_box.Location = new System.Drawing.Point(base_x + x, base_y + y + item_size.Height);
            dropbar_box.Name = "dropbar_image";
            dropbar_box.Size = new System.Drawing.Size(item_size.Width, dropbar_height);
            dropbar_box.TabIndex = 1;
            dropbar_box.TabStop = false;
            Image image = new Bitmap(dropbar_box.Width, dropbar_box.Height);
            Graphics gr = Graphics.FromImage(image);
            gr.FillRectangle(Brushes.DarkGray, new Rectangle(0, 0, item_size.Width, dropbar_height)); //dropbar base bar
            if (drop.percentage < 1) {
                brush = Brushes.DarkRed; // <1% is red
            } else if (drop.percentage < 15) {
                brush = Brushes.Yellow; //<15% is yellow
            } else {
                brush = Brushes.ForestGreen; //everything else is green
            }
            gr.FillRectangle(brush, new Rectangle(0, 0, (int)(Math.Ceiling(item_size.Width * drop.percentage / 100) + 1), dropbar_height));
            dropbar_box.Image = image;
            this.Controls.Add(dropbar_box);
        }
Example #3
0
        private void CombineItems()
        {
            Size item_size      = new Size(32, 32); //size of item image
            int  dropbar_height = 6;                //height of dropbar
            int  item_spacing   = 6;                //spacing between items
            int  base_x         = 110;
            int  base_y         = this.mainImage.Location.Y;
            int  max_x          = 250;
            int  max_y          = base_y + 134;

            // add a tooltip that displays the actual droprate when you mouseover
            ToolTip droprate_tooltip = new ToolTip();

            droprate_tooltip.AutoPopDelay = 60000;
            droprate_tooltip.InitialDelay = 500;
            droprate_tooltip.ReshowDelay  = 0;
            droprate_tooltip.ShowAlways   = true;
            droprate_tooltip.UseFading    = true;

            int             x = item_spacing, y = item_spacing;
            List <ItemDrop> sorted_items = creature.itemdrops.OrderByDescending(o => o.percentage).ToList();

            foreach (ItemDrop drop in sorted_items)
            {
                if (x > (max_x - item_size.Width - item_spacing))
                {
                    x  = item_spacing;
                    y += item_size.Height + item_spacing;
                }
                DisplayItem(drop, base_x, base_y, x, y, item_size, droprate_tooltip, dropbar_height);
                x += item_size.Width + item_spacing;
            }

            if (creature.skin != null)
            {
                Item       skinItem    = StorageManager.getItem(creature.skin.skinitemid);
                ItemDrop   skinDrop    = new ItemDrop();
                PictureBox picture_box = new PictureBox();
                picture_box.Location        = new System.Drawing.Point(20, this.huntButton.Location.Y + this.huntButton.Size.Height + 10);
                picture_box.Name            = skinItem.GetName();
                picture_box.Size            = new System.Drawing.Size(item_size.Width, item_size.Height);
                picture_box.TabIndex        = 1;
                picture_box.TabStop         = false;
                picture_box.Image           = skinItem.GetImage();
                picture_box.SizeMode        = PictureBoxSizeMode.StretchImage;
                picture_box.BackgroundImage = StyleManager.GetImage("item_background.png");
                picture_box.Click          += openItemBox; droprate_tooltip.SetToolTip(picture_box, "You can skin this creature with the item " + skinItem.displayname + ".");
                this.Controls.Add(picture_box);

                skinDrop.itemid     = creature.skin.dropitemid;
                skinDrop.percentage = creature.skin.percentage;
                skinDrop.min        = 1;
                skinDrop.max        = 1;
                DisplayItem(skinDrop, 20 + item_size.Width + item_spacing, this.huntButton.Location.Y + this.huntButton.Size.Height + 10, 0, 0, item_size, droprate_tooltip, dropbar_height, "Skin rate of ");
                if (y < this.huntButton.Location.Y + this.huntButton.Size.Height)
                {
                    y = this.huntButton.Location.Y + this.huntButton.Size.Height;
                }
            }

            if (this.Height < (y + item_size.Height * 2 + item_spacing))
            {
                this.Height = y + item_size.Height * 2 + item_spacing;
            }
            this.Refresh();
        }
Example #4
0
        private void CombineItems() {
            Size item_size = new Size(32, 32); //size of item image
            int dropbar_height = 6; //height of dropbar
            int item_spacing = 6; //spacing between items
            int base_x = 110;
            int base_y = this.mainImage.Location.Y;
            int max_x = 250;
            int max_y = base_y + 134;

            // add a tooltip that displays the actual droprate when you mouseover
            ToolTip droprate_tooltip = new ToolTip();
            droprate_tooltip.AutoPopDelay = 60000;
            droprate_tooltip.InitialDelay = 500;
            droprate_tooltip.ReshowDelay = 0;
            droprate_tooltip.ShowAlways = true;
            droprate_tooltip.UseFading = true;

            int x = item_spacing, y = item_spacing;
            List<ItemDrop> sorted_items = creature.itemdrops.OrderByDescending(o => o.percentage).ToList();
            foreach (ItemDrop drop in sorted_items) {
                if (x > (max_x - item_size.Width - item_spacing)) {
                    x = item_spacing;
                    y += item_size.Height + item_spacing;
                }
                DisplayItem(drop, base_x, base_y, x, y, item_size, droprate_tooltip, dropbar_height);
                x += item_size.Width + item_spacing;
            }

            if (creature.skin != null) {
                Item skinItem = MainForm.getItem(creature.skin.skinitemid);
                ItemDrop skinDrop = new ItemDrop();
                PictureBox picture_box = new PictureBox();
                picture_box.Location = new System.Drawing.Point(20, this.huntButton.Location.Y + this.huntButton.Size.Height + 10);
                picture_box.Name = skinItem.GetName();
                picture_box.Size = new System.Drawing.Size(item_size.Width, item_size.Height);
                picture_box.TabIndex = 1;
                picture_box.TabStop = false;
                picture_box.Image = skinItem.GetImage();
                picture_box.SizeMode = PictureBoxSizeMode.StretchImage;
                picture_box.BackgroundImage = MainForm.item_background;
                picture_box.Click += openItemBox; droprate_tooltip.SetToolTip(picture_box, "You can skin this creature with the item " + skinItem.displayname + ".");
                this.Controls.Add(picture_box);

                skinDrop.itemid = creature.skin.dropitemid;
                skinDrop.percentage = creature.skin.percentage;
                skinDrop.min = 1;
                skinDrop.max = 1;
                DisplayItem(skinDrop, 20 + item_size.Width + item_spacing, this.huntButton.Location.Y + this.huntButton.Size.Height + 10, 0, 0, item_size, droprate_tooltip, dropbar_height, "Skin rate of ");
                if (y < this.huntButton.Location.Y + this.huntButton.Size.Height) y = this.huntButton.Location.Y + this.huntButton.Size.Height;
            }

            if (this.Height < (y + item_size.Height * 2 + item_spacing)) {
                this.Height = y + item_size.Height * 2 + item_spacing;
            }
            this.Refresh();
        }
Example #5
0
        private static Item createItem(SQLiteDataReader reader)
        {
            SQLiteCommand command;

            if (!reader.Read()) {
                return null;
            }

            Item item = new Item();
            item.permanent = true;
            item.id = reader.GetInt32(0);
            item.displayname = reader.GetString(1);
            item.actual_value = reader.IsDBNull(2) ? DATABASE_NULL : reader.GetInt64(2);
            item.vendor_value = reader.IsDBNull(3) ? DATABASE_NULL : reader.GetInt64(3);
            item.stackable = reader.GetBoolean(4);
            item.capacity = reader.IsDBNull(5) ? DATABASE_NULL : reader.GetFloat(5);
            item.category = reader.IsDBNull(6) ? "Unknown" : reader.GetString(6);
            item.discard = reader.GetBoolean(7);
            item.convert_to_gold = reader.GetBoolean(8);
            item.look_text = reader.IsDBNull(9) ? String.Format("You see a {0}.", item.displayname) : reader.GetString(9);
            item.title = reader.GetString(10);
            item.currency = reader.IsDBNull(11) ? DATABASE_NULL : reader.GetInt32(11);
            item.image = Image.FromStream(reader.GetStream(12));
            if (item.image.RawFormat.Guid == ImageFormat.Gif.Guid) {
                int frames = item.image.GetFrameCount(FrameDimension.Time);
                if (frames == 1) {
                    Bitmap new_bitmap = new Bitmap(item.image);
                    new_bitmap.MakeTransparent();
                    item.image.Dispose();
                    item.image = new_bitmap;
                }
            }

            command = new SQLiteCommand(String.Format("SELECT vendorid, value FROM SellItems WHERE itemid={0}", item.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                ItemSold sellItem = new ItemSold();
                sellItem.itemid = item.id;
                sellItem.npcid = reader.GetInt32(0);
                sellItem.price = reader.GetInt32(1);
                item.sellItems.Add(sellItem);
            }
            command = new SQLiteCommand(String.Format("SELECT vendorid, value FROM BuyItems WHERE itemid={0}", item.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                ItemSold buyItem = new ItemSold();
                buyItem.itemid = item.id;
                buyItem.npcid = reader.GetInt32(0);
                buyItem.price = reader.GetInt32(1);
                item.buyItems.Add(buyItem);
            }
            command = new SQLiteCommand(String.Format("SELECT creatureid, percentage, min, max FROM CreatureDrops WHERE itemid={0}", item.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                ItemDrop itemDrop = new ItemDrop();
                itemDrop.itemid = item.id;
                itemDrop.creatureid = reader.GetInt32(0);
                itemDrop.percentage = reader.IsDBNull(1) ? DATABASE_NULL : reader.GetFloat(1);
                if (itemDrop.percentage > 100) {
                    itemDrop.min = 1;
                    itemDrop.max = (int)(itemDrop.percentage / 100.0 * 2.0);
                    itemDrop.percentage = 100;
                } else {
                    itemDrop.min = Math.Max(reader.GetInt32(2), 1);
                    itemDrop.max = Math.Max(reader.GetInt32(3), itemDrop.min);
                }

                item.itemdrops.Add(itemDrop);
            }
            command = new SQLiteCommand(String.Format("SELECT questid FROM QuestRewards WHERE itemid={0}", item.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                item.rewardedBy.Add(getQuest(reader.GetInt32(0)));
            }
            command = new SQLiteCommand(String.Format("SELECT property, value FROM ItemProperties WHERE itemid={0}", item.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                string property = reader.GetString(0);
                switch(property) {
                    case "Voc":
                        item.vocation = reader.GetString(1);
                        break;
                    case "Level":
                        item.level = reader.GetInt32(1);
                        break;
                    case "Def":
                        item.defensestr = reader["value"].ToString();
                        if (!int.TryParse(item.defensestr, out item.defense)) {
                            item.defense = int.Parse(item.defensestr.Split(' ')[0]);
                        }
                        break;
                    case "Attrib":
                        item.attrib = reader.GetString(1);
                        break;
                    case "Atk":
                        item.attack = reader.GetInt32(1);
                        break;
                    case "Atk+":
                        item.atkmod = reader.GetInt32(1);
                        break;
                    case "Hit+":
                        string str = reader["value"].ToString();
                        int.TryParse(str, out item.hitmod);
                        break;
                    case "Arm":
                        item.armor = reader.GetInt32(1);
                        break;
                    case "Range":
                        item.range = reader.GetInt32(1);
                        break;
                    case "Type":
                        item.type = reader.GetString(1);
                        break;
                }
            }

            return item;
        }
Example #6
0
        private static Creature createCreature(SQLiteDataReader reader)
        {
            SQLiteCommand command;

            if (!reader.Read()) {
                return null;
            }

            Creature cr = new Creature();
            cr.permanent = true;
            cr.id = reader.GetInt32(0);
            cr.displayname = reader["name"].ToString();
            cr.health = reader.IsDBNull(2) ? DATABASE_NULL : reader.GetInt32(2);
            cr.experience = reader.IsDBNull(3) ? DATABASE_NULL : reader.GetInt32(3);
            cr.maxdamage = reader.IsDBNull(4) ? DATABASE_NULL : reader.GetInt32(4);
            cr.summoncost = reader.IsDBNull(5) ? DATABASE_NULL : reader.GetInt32(5);
            cr.illusionable = reader.GetBoolean(6);
            cr.pushable = reader.GetBoolean(7);
            cr.pushes = reader.GetBoolean(8);
            cr.res_phys = reader.IsDBNull(9) ? 100 : reader.GetInt32(9);
            cr.res_holy = reader.IsDBNull(10) ? 100 : reader.GetInt32(10);
            cr.res_death = reader.IsDBNull(11) ? 100 : reader.GetInt32(11);
            cr.res_fire = reader.IsDBNull(12) ? 100 : reader.GetInt32(12);
            cr.res_energy = reader.IsDBNull(13) ? 100 : reader.GetInt32(13);
            cr.res_ice = reader.IsDBNull(14) ? 100 : reader.GetInt32(14);
            cr.res_earth = reader.IsDBNull(15) ? 100 : reader.GetInt32(15);
            cr.res_drown = reader.IsDBNull(16) ? 100 : reader.GetInt32(16);
            cr.res_lifedrain = reader.IsDBNull(17) ? 100 : reader.GetInt32(17);
            cr.paralysable = reader.GetBoolean(18);
            cr.senseinvis = reader.GetBoolean(19);
            cr.abilities = reader.IsDBNull(20) ? DATABASE_STRING_NULL : reader["abilities"].ToString();
            cr.title = reader[21].ToString();
            cr.speed = reader.IsDBNull(22) ? DATABASE_NULL : reader.GetInt32(22);
            cr.armor = reader.IsDBNull(23) ? DATABASE_NULL : reader.GetInt32(23);
            cr.boss = reader.GetInt32(24) > 0;
            if (reader.IsDBNull(25)) {
                return null;
            }
            cr.image = Image.FromStream(reader.GetStream(25));

            command = new SQLiteCommand(String.Format("SELECT skinitemid, knifeitemid, percentage FROM Skins WHERE creatureid={0}", cr.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                Skin skin = new Skin();
                skin.dropitemid = reader.GetInt32(0);
                skin.skinitemid = reader.GetInt32(1);
                skin.percentage = reader.IsDBNull(2) ? DATABASE_NULL : reader.GetFloat(2);
                cr.skin = skin;
            }

            command = new SQLiteCommand(String.Format("SELECT itemid, percentage, min, max FROM CreatureDrops WHERE creatureid={0}", cr.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                ItemDrop itemDrop = new ItemDrop();
                itemDrop.creatureid = cr.id;
                itemDrop.itemid = reader.GetInt32(0);
                itemDrop.percentage = reader.IsDBNull(1) ? DATABASE_NULL : reader.GetFloat(1);
                if (itemDrop.percentage > 100) {
                    itemDrop.min = 1;
                    itemDrop.max = (int)(itemDrop.percentage / 100.0 * 2.0);
                    itemDrop.percentage = 100;
                } else {
                    itemDrop.min = Math.Max(reader.GetInt32(2), 1);
                    itemDrop.max = Math.Max(reader.GetInt32(3), itemDrop.min);
                }
                cr.itemdrops.Add(itemDrop);
            }

            return cr;
        }