Beispiel #1
0
        public static DebuffDB InitialiseDebuffDB()
        {
            DebuffDB debuffDB = new DebuffDB();

            try
            {
                DebuffEffect debuffEffect = new DebuffEffect();

                Assembly     assembly = Assembly.GetExecutingAssembly();
                const string PATH     = "Defiance.Resources.effects.txt";
                using (Stream stream = assembly.GetManifestResourceStream(PATH))
                {
                    using (StreamReader streamReader = new StreamReader(stream))
                    {
                        while (!streamReader.EndOfStream)
                        {
                            try
                            {
                                string text = streamReader.ReadLine();
                                if (text.StartsWith("EFFECT"))
                                {
                                    debuffEffect          = new DebuffEffect();
                                    debuffEffect.EffectId = Convert.ToInt32(text.Replace("EFFECT=", "").Trim());
                                }
                                else if (text.StartsWith("Category"))
                                {
                                    string text2 = text.Replace("Category=", "").Trim();
                                    string a;
                                    if ((a = text2) != null)
                                    {
                                        if (!(a == "Life"))
                                        {
                                            if (a == "Creature")
                                            {
                                                debuffEffect.DebuffCategory = DebuffCategories.Creature;
                                            }
                                        }
                                        else
                                        {
                                            debuffEffect.DebuffCategory = DebuffCategories.Life;
                                        }
                                    }
                                }
                                else if (text.StartsWith("DefaultDebuffDuration"))
                                {
                                    debuffEffect.DefaultDuration = Convert.ToInt32(text.Replace("DefaultDebuffDuration=", "").Trim());
                                }
                                else if (text.StartsWith("DisplayName"))
                                {
                                    debuffEffect.DisplayName = text.Replace("DisplayName=", "").Trim();
                                }
                                else if (text.StartsWith("SpellWords"))
                                {
                                    debuffEffect.SpellWords = text.Replace("SpellWords=", "").Trim();
                                }
                                else if (text.StartsWith("Icon"))
                                {
                                    debuffEffect.Icon = Convert.ToInt32(text.Replace("Icon=", "").Trim());
                                }
                                else if (text.StartsWith("-DEBUFF"))
                                {
                                    DebuffEffectDetails debuffEffectDetails = new DebuffEffectDetails();
                                    text = text.Replace("-DEBUFF|", "");
                                    string[] array = text.Split(new string[]
                                    {
                                        "|"
                                    }, StringSplitOptions.None);
                                    if (array.Length > 0)
                                    {
                                        debuffEffectDetails.DisplayName = array[0];
                                    }
                                    if (array.Length > 1 && array[1].Length > 0)
                                    {
                                        debuffEffectDetails.DefaultDuration = Convert.ToInt32(array[1]);
                                    }
                                    if (array.Length > 2)
                                    {
                                        debuffEffectDetails.SpellWords = array[2];
                                    }
                                    if (array.Length > 4)
                                    {
                                        debuffEffectDetails.Icon = Convert.ToInt32(array[4].Trim());
                                    }
                                    debuffEffect.EffectDetails.Add(debuffEffectDetails);
                                }
                                else if (text.StartsWith("ENDEFFECT"))
                                {
                                    debuffDB.DebuffEffects.Add(debuffEffect);
                                }
                            }
                            catch (Exception ex) { Repo.RecordException(ex); }
                        }
                    }
                }
            }
            catch (Exception ex2) { Repo.RecordException(ex2); }
            return(debuffDB);
        }
Beispiel #2
0
        public void TargetSurface_Draw(HudEmulator Caller, DxTexture Target, Rectangle TargetRegion, HudEmulator.delClearRegion dClearOp)
        {
            try
            {
                if (TargetHud != null)
                {
                    if (lib.MyCore.Actions.CurrentSelection != 0)
                    {
                        WorldObject worldObject = lib.MyCore.WorldFilter[lib.MyCore.Actions.CurrentSelection];
                        if (worldObject != null && worldObject.ObjectClass == ObjectClass.Player)
                        {
                            if (Target != null)
                            {
                                Color color = Color.Transparent;
                                Target.Fill(TargetRegion, color);
                                Target target = TargetCache.GetTarget(worldObject.Id);
                                if (target == null)
                                {
                                    TargetCache.AddOrUpdate(worldObject);
                                    target = TargetCache.GetTarget(worldObject.Id);
                                }
                                int num   = 0;
                                int num2  = 15;
                                int num3  = 285;
                                int num4  = 30;
                                Pen pen   = new Pen(ColorTranslator.FromHtml(CurrentProfile.ColorRed), 8f);
                                Pen pen2  = new Pen(ColorTranslator.FromHtml(CurrentProfile.ColorWhite), 8f);
                                Pen pen3  = new Pen(ColorTranslator.FromHtml(CurrentProfile.ColorGrey), 8f);
                                Pen pen4  = new Pen(ColorTranslator.FromHtml(CurrentProfile.ColorGreen), 8f);
                                Pen pen5  = new Pen(ColorTranslator.FromHtml(CurrentProfile.ColorPurple), 8f);
                                Pen pen6  = new Pen(ColorTranslator.FromHtml(CurrentProfile.ColorBlue), 8f);
                                Pen pen7  = new Pen(ColorTranslator.FromHtml(CurrentProfile.ColorYellow), 8f);
                                Pen pen8  = new Pen(ColorTranslator.FromHtml(CurrentProfile.ColorOrange), 8f);
                                Pen pen10 = new Pen(ColorTranslator.FromHtml(CurrentProfile.ColorOrange), 8f);

                                new Bitmap(50, 50);
                                Bitmap bitmap;
                                if (worldObject.Values(LongValueKey.Monarch) == lib.moncheck)
                                {
                                    pen10 = pen4;
                                }
                                else
                                {
                                    pen10 = pen;
                                }
                                Rectangle rectangle = Utils.DrawText(target.FullName, CurrentProfile.HudFont, pen10, out bitmap);

                                rectangle.Y = 10;
                                rectangle.X = 5;
                                num         = 0;
                                num2       += 10;
                                if (rectangle.Width > num3)
                                {
                                    num3 = rectangle.Width;
                                }
                                num4 += rectangle.Height;
                                Target.DrawImage(bitmap, rectangle, Color.Transparent);
                                rectangle = default(Rectangle);
                                num2     += 10;
                                Bitmap bitmap2 = null;

                                Rectangle rectangle2 = new Rectangle(0, 0, 230, 10);
                                rectangle   = Utils.DrawRectangle(rectangle2, pen, out bitmap2, false, 100, 2);
                                rectangle.Y = 25;
                                rectangle.X = 2;
                                int num5  = num;
                                int num6  = num2;
                                int width = rectangle.Width;
                                num2 += 7;
                                int num7;
                                num7 = target.CurrentHealthPercentage;

                                if (rectangle.Width > num3)
                                {
                                    num3 = rectangle.Width;
                                }
                                num4 += rectangle.Height;

                                Target.DrawImage(bitmap2, rectangle, Color.Transparent);
                                bitmap2     = null;
                                rectangle   = Utils.DrawRectangle(rectangle2, pen, out bitmap2, true, num7, 2);
                                rectangle.X = 2;
                                rectangle.Y = 25;
                                Target.DrawImage(bitmap2, rectangle, Color.Transparent);
                                if (target.MaxHealth > 0)
                                {
                                    string text;
                                    if (!target.HealthInFormat.Contains("-1"))
                                    {
                                        text = target.HealthInFormat;
                                    }
                                    else
                                    {
                                        text = (target.MaxHealth * num7 / 100).ToString() + "/" + target.MaxHealth.ToString();
                                    }
                                    Bitmap bitmap3 = null;
                                    Font   font    = new Font(CurrentProfile.HudFont.Name, 8f, FontStyle.Bold);
                                    rectangle   = Utils.DrawText(text, font, pen2, out bitmap3);
                                    rectangle.X = 0;
                                    rectangle.Y = 22;
                                    rectangle.X = 240;
                                    Target.DrawImage(bitmap3, rectangle, Color.Transparent);
                                    rectangle = default(Rectangle);
                                    num2     += 7;

                                    Bitmap bitmap4 = null;
                                    rectangle2  = new Rectangle(0, 0, 230, 10);
                                    rectangle   = Utils.DrawRectangle(rectangle2, pen7, out bitmap4, false, 100, 2);
                                    rectangle.Y = 37;
                                    rectangle.X = 2;
                                    num5        = num;
                                    num6        = num2;
                                    int width2 = rectangle.Width;
                                    num2 += 7;
                                    if (rectangle.Width > num3)
                                    {
                                        num3 = rectangle.Width;
                                    }
                                    num4 += rectangle.Height;
                                    Target.DrawImage(bitmap4, rectangle, Color.Transparent);
                                    rectangle   = Utils.DrawRectangle(rectangle2, pen7, out bitmap4, true, target.CurrentStaminaPercentage, 2);
                                    rectangle.X = 2;
                                    rectangle.Y = 37;
                                    Target.DrawImage(bitmap4, rectangle, Color.Transparent);
                                    if (!target.StaminaInFormat.Contains("-1"))
                                    {
                                        Bitmap bitmap5 = null;
                                        Font   font2   = new Font(CurrentProfile.HudFont.Name, 8f, FontStyle.Bold);
                                        rectangle   = Utils.DrawText(target.StaminaInFormat, font2, pen2, out bitmap5);
                                        rectangle.X = 0;
                                        rectangle.Y = 34;
                                        rectangle.X = 240;
                                        Target.DrawImage(bitmap5, rectangle, Color.Transparent);
                                    }
                                    rectangle = default(Rectangle);
                                    num2     += 5;

                                    Bitmap bitmap6 = null;
                                    rectangle2  = new Rectangle(0, 0, 230, 10);
                                    rectangle   = Utils.DrawRectangle(rectangle2, pen6, out bitmap6, false, 100, 2);
                                    rectangle.Y = 49;
                                    rectangle.X = 2;
                                    num5        = num;
                                    num6        = num2;
                                    int width3 = rectangle.Width;
                                    num2 += rectangle.Height;
                                    if (rectangle.Width > num3)
                                    {
                                        num3 = rectangle.Width;
                                    }
                                    num4 += rectangle.Height;
                                    Target.DrawImage(bitmap6, rectangle, Color.Transparent);
                                    rectangle   = Utils.DrawRectangle(rectangle2, pen6, out bitmap6, true, target.CurrentManaPercentage, 2);
                                    rectangle.X = 2;
                                    rectangle.Y = 49;
                                    Target.DrawImage(bitmap6, rectangle, Color.Transparent);
                                    if (!target.ManaInFormat.Contains("-1"))
                                    {
                                        Bitmap bitmap7 = null;
                                        Font   font3   = new Font(CurrentProfile.HudFont.Name, 8f, FontStyle.Bold);
                                        rectangle   = Utils.DrawText(target.ManaInFormat, font3, pen2, out bitmap7);
                                        rectangle.X = 0;
                                        rectangle.Y = 46;
                                        rectangle.X = 240;
                                        Target.DrawImage(bitmap7, rectangle, Color.Transparent);
                                    }
                                    int num8 = 0;
                                    int num9 = 0;
                                    num2 += 7;
                                    foreach (Debuff debuff in target.Debuffs)
                                    {
                                        rectangle  = default(Rectangle);
                                        rectangle2 = new Rectangle(0, 0, 22, 22);
                                        DebuffDisplayInfo debuffDisplayInfo = DebuffDB.GetDebuffDisplayInfo(debuff.Name);
                                        Pen pen9 = pen2;

                                        rectangle = new Rectangle(0, 0, 22, 22);

                                        rectangle.Y = 61;
                                        rectangle.X = 5 + num9;
                                        num9       += rectangle.Width + 7;
                                        Target.DrawPortalImage(debuffDisplayInfo.Icon, rectangle);
                                        num8++;
                                    }
                                    if (num9 > num3)
                                    {
                                        num3 = num9;
                                    }
                                }

                                TargetHud.Width  = num3 + (int)((double)0);
                                TargetHud.Height = num4;
                            }
                            else
                            {
                                TargetHud.Visible = false;
                            }
                        }
                    }
                }
            }
            catch { Utility.AddChatText("Error generating Defiance HUD, retrying...", 6); }
        }