private void UpdateTargetVitals(NetworkMessageEventArgs e) { int guid = e.Message.Value <int>("object"); WorldObject worldObject = lib.MyCore.WorldFilter[guid]; if (worldObject == null) { return; } try { if (guid.Equals(lib.MyCore.Actions.CurrentSelection)) { bool flag = false; if ((e.Message.Value <int>("flags") & 256) > 0) { int currentHealth = e.Message.Value <int>("health"); int maxHealth = e.Message.Value <int>("healthMax"); int currentStamina = e.Message.Value <int>("stamina"); int maxStamina = e.Message.Value <int>("staminaMax"); int currentMana = e.Message.Value <int>("mana"); int maxMana = e.Message.Value <int>("manaMax"); TargetCache.AddOrUpdate(worldObject, currentHealth, maxHealth, currentStamina, maxStamina, currentMana, maxMana); flag = true; } if (TargetSurface != null && flag) { TargetSurface.Invalidate(); } } } catch (Exception ex) { Repo.RecordException(ex); } }
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); } }